Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ea3cbcce8 | ||
|
|
84ef070eb6 | ||
|
|
448a6ddb57 | ||
|
|
a95c19fe68 |
+1
-1
@@ -1 +1 @@
|
|||||||
1.0.41
|
1.0.45
|
||||||
|
|||||||
@@ -123,25 +123,38 @@ 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)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
issue.DeleteWorklogAsync(workLog, token: cancellationToken);
|
issue.DeleteWorklogAsync(workLog, token: cancellationToken);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.Error($"Не могу удалить Worklog по задаче {taskTimeItem.Branch}: {ex.Message}.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
hasTodayWorklog = false;
|
hasTodayWorklog = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -155,13 +168,19 @@ 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)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
workLogToAdd = issue.AddWorklogAsync(workLogToAdd, token: cancellationToken).Result;
|
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ using System.Runtime.InteropServices;
|
|||||||
//
|
//
|
||||||
// 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.41")]
|
[assembly: AssemblyVersion("1.0.45")]
|
||||||
[assembly: AssemblyFileVersion("1.0.41")]
|
[assembly: AssemblyFileVersion("1.0.45")]
|
||||||
[assembly: AssemblyInformationalVersion("1.0.41")]
|
[assembly: AssemblyInformationalVersion("1.0.45")]
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ namespace JiraTimeBot.UI
|
|||||||
if (txtDummyMode.Checked)
|
if (txtDummyMode.Checked)
|
||||||
{
|
{
|
||||||
_log.Info("Выключаем режим Тестового прогона");
|
_log.Info("Выключаем режим Тестового прогона");
|
||||||
|
txtDummyMode.Checked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var tokenSource = GetTokenSource())
|
using (var tokenSource = GetTokenSource())
|
||||||
|
|||||||
Reference in New Issue
Block a user