diff --git a/JiraTimeBotForm/Program.cs b/JiraTimeBotForm/Program.cs index 2c15114..d0c24d7 100644 --- a/JiraTimeBotForm/Program.cs +++ b/JiraTimeBotForm/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Windows.Forms; namespace JiraTimeBotForm @@ -11,9 +12,33 @@ namespace JiraTimeBotForm [STAThread] static void Main() { + if (PriorProcess() != null) + { + + MessageBox.Show("Another instance of the app is already running."); + return; + } + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); } + + public static Process PriorProcess() + // Returns a System.Diagnostics.Process pointing to + // a pre-existing process with the same name as the + // current one, if any; or null if the current process + // is unique. + { + Process curr = Process.GetCurrentProcess(); + Process[] procs = Process.GetProcessesByName(curr.ProcessName); + foreach (Process p in procs) + { + if ((p.Id != curr.Id) && + (p.MainModule.FileName == curr.MainModule.FileName)) + return p; + } + return null; + } } } diff --git a/JiraTimeBotForm/TaskTime/TaskTimeDiscoverer.cs b/JiraTimeBotForm/TaskTime/TaskTimeDiscoverer.cs index 22addb0..5333f07 100644 --- a/JiraTimeBotForm/TaskTime/TaskTimeDiscoverer.cs +++ b/JiraTimeBotForm/TaskTime/TaskTimeDiscoverer.cs @@ -34,13 +34,18 @@ namespace JiraTimeBotForm.TaskTime } var repo = new Repository(repoDirectory); - var log = repo.Log(new LogCommand {Date = date, Users = { settings.MercurialAuthorEmail }}); + var log = repo.Log(new LogCommand {Date = date, Users = { settings.MercurialAuthorEmail } }); foreach (var changeset in log) { if (!changeset.Branch.Contains("-")) { continue; } + //Пропускаем Close коммиты + if (changeset.CommitMessage.StartsWith($"Close {changeset.Branch} branch")) + { + continue; + } workTasks.Add(changeset.Branch); _log.Trace($" - Найден changeset: {changeset.Timestamp} - {changeset.Branch} - {changeset.AuthorEmailAddress}"); diff --git a/JiraTimeBotForm/frmMain.Designer.cs b/JiraTimeBotForm/frmMain.Designer.cs index c6fb20c..a574d4b 100644 --- a/JiraTimeBotForm/frmMain.Designer.cs +++ b/JiraTimeBotForm/frmMain.Designer.cs @@ -145,6 +145,7 @@ namespace JiraTimeBotForm this.txtLog.Location = new System.Drawing.Point(218, 16); this.txtLog.Multiline = true; this.txtLog.Name = "txtLog"; + this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.txtLog.Size = new System.Drawing.Size(510, 264); this.txtLog.TabIndex = 11; //