Compare commits

...
4 Commits
4 changed files with 75 additions and 51 deletions
+1 -1
View File
@@ -1 +1 @@
1.0.40 1.0.44
+25 -6
View File
@@ -123,24 +123,37 @@ namespace JiraTimeBot.JiraIntegration
var userWorklogs = workLogs.Where(w => var userWorklogs = workLogs.Where(w =>
w.StartDate.GetValueOrDefault().Date == date && w.Author.Equals(settings.JiraUserName, w.StartDate.GetValueOrDefault().Date == date && w.Author.Equals(settings.JiraUserName,
StringComparison.InvariantCultureIgnoreCase)).ToList(); StringComparison.InvariantCultureIgnoreCase)).ToList();
var comment = _descriptionSource.GetDescription(taskTimeItem, addCommentsToWorklog, settings);
foreach (var workLog in userWorklogs) foreach (var workLog in userWorklogs)
{ {
var timeSpent = TimeSpan.FromSeconds(workLog.TimeSpentInSeconds); var timeSpent = TimeSpan.FromSeconds(workLog.TimeSpentInSeconds);
var timeDiff = Math.Abs((timeSpent - taskTimeItem.Time).TotalMinutes); var timeDiff = Math.Abs((timeSpent - taskTimeItem.Time).TotalMinutes);
if (timeDiff > 1 || userWorklogs.Count > 1) if (timeDiff > 1 || userWorklogs.Count > 1 || userWorklogs.First().Comment != comment)
{ {
if (timeDiff > 1) if (timeDiff > 1)
{ {
_log.Trace($"Время отличается на {timeDiff} минут, удаляю worklog: {taskTimeItem.Branch} {workLog.Author} {workLog.CreateDate}: {workLog.TimeSpent}"); _log.Trace($"Время отличается на {timeDiff} минут, удаляю worklog: {taskTimeItem.Branch} {workLog.Author} {workLog.CreateDate}: {workLog.TimeSpent}");
} }
else else if (userWorklogs.Count > 1)
{ {
_log.Trace($"Найдено более одного ворклога на задачу, удаляю worklog: {taskTimeItem.Branch} {workLog.Author} {workLog.CreateDate}: {workLog.TimeSpent}"); _log.Trace($"Найдено более одного ворклога на задачу, удаляю worklog: {taskTimeItem.Branch} {workLog.Author} {workLog.CreateDate}: {workLog.TimeSpent}");
} }
else
{
_log.Trace($"Описание отличается, удаляю worklog: {taskTimeItem.Branch} {workLog.Author} {workLog.CreateDate}: {workLog.TimeSpent}");
}
if (!dummy) if (!dummy)
{ {
issue.DeleteWorklogAsync(workLog, token: cancellationToken); try
{
issue.DeleteWorklogAsync(workLog, token: cancellationToken);
}
catch (Exception ex)
{
_log.Error($"Не могу удалить Worklog по задаче {taskTimeItem.Branch}: {ex.Message}.");
continue;
}
} }
hasTodayWorklog = false; hasTodayWorklog = false;
} }
@@ -155,12 +168,18 @@ namespace JiraTimeBot.JiraIntegration
{ {
var timeSpentJira = $"{taskTimeItem.Time.TotalMinutes}m"; var timeSpentJira = $"{taskTimeItem.Time.TotalMinutes}m";
var comment = _descriptionSource.GetDescription(taskTimeItem, addCommentsToWorklog, settings);
Worklog workLogToAdd = new Worklog(timeSpentJira, date.Value, comment); Worklog workLogToAdd = new Worklog(timeSpentJira, date.Value, comment);
if (!dummy) if (!dummy)
{ {
workLogToAdd = issue.AddWorklogAsync(workLogToAdd, token: cancellationToken).Result; try
{
workLogToAdd = issue.AddWorklogAsync(workLogToAdd, token: cancellationToken).Result;
}
catch (Exception ex)
{
_log.Error($"Не могу добавить Worklog по задаче {taskTimeItem.Branch}: {ex.Message}.");
continue;
}
} }
_log.Trace($"Добавили Worklog для {taskTimeItem.Branch}: {workLogToAdd.Author} {workLogToAdd.CreateDate}: {workLogToAdd.TimeSpent}"); _log.Trace($"Добавили Worklog для {taskTimeItem.Branch}: {workLogToAdd.Author} {workLogToAdd.CreateDate}: {workLogToAdd.TimeSpent}");
} }
+31 -31
View File
@@ -1,31 +1,31 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("JiraTimeBot")] [assembly: AssemblyTitle("JiraTimeBot")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JiraTimeBot")] [assembly: AssemblyProduct("JiraTimeBot")]
[assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")] [assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")]
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.40")] [assembly: AssemblyVersion("1.0.44")]
[assembly: AssemblyFileVersion("1.0.40")] [assembly: AssemblyFileVersion("1.0.44")]
[assembly: AssemblyInformationalVersion("1.0.40")] [assembly: AssemblyInformationalVersion("1.0.44")]
+18 -13
View File
@@ -34,6 +34,7 @@
this.tmrStart = new System.Windows.Forms.Timer(this.components); this.tmrStart = new System.Windows.Forms.Timer(this.components);
this.tmrUpdate = new System.Windows.Forms.Timer(this.components); this.tmrUpdate = new System.Windows.Forms.Timer(this.components);
this.tlpControls = new System.Windows.Forms.TableLayoutPanel(); this.tlpControls = new System.Windows.Forms.TableLayoutPanel();
this.txtLog = new System.Windows.Forms.TextBox();
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button();
this.btnMeeting = new System.Windows.Forms.Button(); this.btnMeeting = new System.Windows.Forms.Button();
@@ -43,7 +44,6 @@
this.btnDoForDate = new System.Windows.Forms.Button(); this.btnDoForDate = new System.Windows.Forms.Button();
this.dteForDay = new System.Windows.Forms.DateTimePicker(); this.dteForDay = new System.Windows.Forms.DateTimePicker();
this.btnSettings = new System.Windows.Forms.Button(); this.btnSettings = new System.Windows.Forms.Button();
this.txtLog = new System.Windows.Forms.TextBox();
this.tlpControls.SuspendLayout(); this.tlpControls.SuspendLayout();
this.panel2.SuspendLayout(); this.panel2.SuspendLayout();
this.pnlTopControls.SuspendLayout(); this.pnlTopControls.SuspendLayout();
@@ -82,6 +82,18 @@
this.tlpControls.Size = new System.Drawing.Size(759, 416); this.tlpControls.Size = new System.Drawing.Size(759, 416);
this.tlpControls.TabIndex = 19; this.tlpControls.TabIndex = 19;
// //
// txtLog
//
this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtLog.Location = new System.Drawing.Point(153, 3);
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.ReadOnly = true;
this.tlpControls.SetRowSpan(this.txtLog, 2);
this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtLog.Size = new System.Drawing.Size(603, 410);
this.txtLog.TabIndex = 27;
//
// panel2 // panel2
// //
this.panel2.Controls.Add(this.btnCancel); this.panel2.Controls.Add(this.btnCancel);
@@ -103,6 +115,7 @@
this.btnCancel.TabIndex = 19; this.btnCancel.TabIndex = 19;
this.btnCancel.Text = "Отменить операцию"; this.btnCancel.Text = "Отменить операцию";
this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
// //
// btnMeeting // btnMeeting
// //
@@ -112,6 +125,7 @@
this.btnMeeting.TabIndex = 18; this.btnMeeting.TabIndex = 18;
this.btnMeeting.Text = "Митинг"; this.btnMeeting.Text = "Митинг";
this.btnMeeting.UseVisualStyleBackColor = true; this.btnMeeting.UseVisualStyleBackColor = true;
this.btnMeeting.Click += new System.EventHandler(this.btnMeeting_Click);
// //
// txtDummyMode // txtDummyMode
// //
@@ -131,6 +145,7 @@
this.btnStart.TabIndex = 16; this.btnStart.TabIndex = 16;
this.btnStart.Text = "Проставить время"; this.btnStart.Text = "Проставить время";
this.btnStart.UseVisualStyleBackColor = true; this.btnStart.UseVisualStyleBackColor = true;
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
// //
// pnlTopControls // pnlTopControls
// //
@@ -151,6 +166,7 @@
this.btnDoForDate.TabIndex = 25; this.btnDoForDate.TabIndex = 25;
this.btnDoForDate.Text = "Проставить на дату"; this.btnDoForDate.Text = "Проставить на дату";
this.btnDoForDate.UseVisualStyleBackColor = true; this.btnDoForDate.UseVisualStyleBackColor = true;
this.btnDoForDate.Click += new System.EventHandler(this.btnDoForDate_Click);
// //
// dteForDay // dteForDay
// //
@@ -171,18 +187,7 @@
this.btnSettings.TabIndex = 23; this.btnSettings.TabIndex = 23;
this.btnSettings.Text = "Настройки"; this.btnSettings.Text = "Настройки";
this.btnSettings.UseVisualStyleBackColor = true; this.btnSettings.UseVisualStyleBackColor = true;
// this.btnSettings.Click += new System.EventHandler(this.btnSettings_Click);
// txtLog
//
this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtLog.Location = new System.Drawing.Point(153, 3);
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.ReadOnly = true;
this.tlpControls.SetRowSpan(this.txtLog, 2);
this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtLog.Size = new System.Drawing.Size(603, 410);
this.txtLog.TabIndex = 27;
// //
// frmMain // frmMain
// //