From 83340c3ef5509df76f68b814977549b7ed8ab94a Mon Sep 17 00:00:00 2001 From: Danil Kislov Date: Tue, 5 Mar 2019 16:26:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=20=D1=83=D1=87=D0=B8=D1=82=D1=8B?= =?UTF-8?q?=D0=B2=D0=B0=D0=B5=D0=BC=20=D0=B7=D0=B0=D0=BA=D1=80=D1=8B=D1=82?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B2=D0=B5=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JiraTimeBotForm/Program.cs | 25 +++++++++++++++++++ .../TaskTime/TaskTimeDiscoverer.cs | 7 +++++- JiraTimeBotForm/frmMain.Designer.cs | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) 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; //