public static void CreateLockFile(bool clearIfExist = false)
{
if (Empresas.Configuracoes == null || Empresas.Configuracoes.Count == 0) return;
if (clearIfExist) ClearLockFiles(false);
IEnumerable<string> diretorios = (from d in Empresas.Configuracoes
select d.PastaBase);
foreach (string dir in diretorios)
{
if (!string.IsNullOrEmpty(dir) && Directory.Exists(dir))
{
string file = String.Format("{0}\\{1}-{2}.lock", dir, Propriedade.NomeAplicacao, Environment.MachineName);
FileInfo fi = new FileInfo(file);
using (StreamWriter sw = new StreamWriter(file, false)
{
AutoFlush = true
})
{
sw.WriteLine("Iniciado em: {0:dd/MM/yyyy hh:mm:ss}", DateTime.Now);
sw.WriteLine("Estação: {0}", Environment.MachineName);
sw.WriteLine("IP: {0}", Functions.GetIPAddress());
sw.Flush();
sw.Close();
}
}
}
}