Исправление ошибок

This commit is contained in:
Danil Kislov
2019-03-02 01:11:34 +03:00
parent ff3a78eb3f
commit 947bb8f638
6 changed files with 34 additions and 14 deletions
+10 -3
View File
@@ -20,7 +20,7 @@ namespace JiraTimeBotForm.JiraIntegration
_jira = Jira.CreateRestClient(_settings.JiraUrl, _settings.JiraUserName, _settings.JiraPassword);
}
public void SetTodayWorklog(List<TaskTimeItem> taskTimeItems, DateTime? date = null)
public void SetTodayWorklog(List<TaskTimeItem> taskTimeItems, DateTime? date = null, bool dummy = false)
{
if (date == null)
{
@@ -48,7 +48,10 @@ namespace JiraTimeBotForm.JiraIntegration
if (timeDiff > 1)
{
_log.Trace($"Время отличается на {timeDiff} минут, удаляю worklog: {taskTimeItem.Branch} {workLog.Author} {workLog.CreateDate}: {workLog.TimeSpent}");
if (!dummy)
{
issue.DeleteWorklogAsync(workLog, WorklogStrategy.RetainRemainingEstimate);
}
hasTodayWorklog = false;
}
else
@@ -62,8 +65,12 @@ namespace JiraTimeBotForm.JiraIntegration
if (!hasTodayWorklog)
{
var timeSpentJira = $"{taskTimeItem.Time.TotalMinutes}m";
var addedWorklog = issue.AddWorklogAsync(new Worklog(timeSpentJira, date.Value)).Result;
_log.Trace($"Добавили Worklog для {taskTimeItem.Branch}: {addedWorklog.Author} {addedWorklog.CreateDate}: {addedWorklog.TimeSpent}");
var workLogToAdd = new Worklog(timeSpentJira, date.Value);
if (!dummy)
{
workLogToAdd = issue.AddWorklogAsync(workLogToAdd).Result;
}
_log.Trace($"Добавили Worklog для {taskTimeItem.Branch}: {workLogToAdd.Author} {workLogToAdd.CreateDate}: {workLogToAdd.TimeSpent}");
}
}
}
+7 -7
View File
@@ -32,7 +32,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Google-Noto-Emoji-Smileys-10103-robot-face.ico</ApplicationIcon>
<ApplicationIcon>app.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Atlassian.Jira, Version=10.4.0.0, Culture=neutral, processorArchitecture=MSIL">
@@ -74,11 +74,11 @@
<Compile Include="Extensions\Extensions.cs" />
<Compile Include="Logger.cs" />
<Compile Include="Configuration\Settings.cs" />
<Compile Include="Form1.cs">
<Compile Include="frmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
<Compile Include="frmMain.Designer.cs">
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="JiraIntegration\JiraApi.cs" />
<Compile Include="Passwords\EncryptionClass.cs" />
@@ -87,8 +87,8 @@
<Compile Include="TaskTime\ITaskTimeDiscoverer.cs" />
<Compile Include="TaskTime\TaskTimeDiscoverer.cs" />
<Compile Include="TaskTime\TaskTimeItem.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
<EmbeddedResource Include="frmMain.resx">
<DependentUpon>frmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
@@ -114,7 +114,7 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Google-Noto-Emoji-Smileys-10103-robot-face.ico" />
<Content Include="app.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 170 KiB

@@ -45,6 +45,7 @@ namespace JiraTimeBotForm
this.btnStart = new System.Windows.Forms.Button();
this.ntfyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.tmrStart = new System.Windows.Forms.Timer(this.components);
this.txtDummyMode = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// actTime
@@ -168,11 +169,22 @@ namespace JiraTimeBotForm
this.tmrStart.Interval = 1000;
this.tmrStart.Tick += new System.EventHandler(this.tmrStart_Tick);
//
// txtDummyMode
//
this.txtDummyMode.AutoSize = true;
this.txtDummyMode.Location = new System.Drawing.Point(48, 234);
this.txtDummyMode.Name = "txtDummyMode";
this.txtDummyMode.Size = new System.Drawing.Size(114, 17);
this.txtDummyMode.TabIndex = 13;
this.txtDummyMode.Text = "Òåñòîâûé ïðîãîí";
this.txtDummyMode.UseVisualStyleBackColor = true;
//
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(740, 292);
this.Controls.Add(this.txtDummyMode);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.txtLog);
this.Controls.Add(this.label4);
@@ -215,6 +227,7 @@ namespace JiraTimeBotForm
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.NotifyIcon ntfyIcon;
private System.Windows.Forms.Timer tmrStart;
private System.Windows.Forms.CheckBox txtDummyMode;
}
}
@@ -163,9 +163,9 @@ namespace JiraTimeBotForm
var taskTimes = taskDiscoverer.GetTaskTimes(settings, date);
if (!taskTimes.Any())
{
_log.Warn($"{date} вы не сделали ничего полезного =) Использую предыдущий день.");
_log.Warn($"{date:dd.MM.yyyy} вы не сделали ничего полезного =) Использую предыдущий день.");
daysDiff--;
if (daysDiff < 7)
if (daysDiff < -7)
{
_log.Error("Íå íàøëè íè îäíîãî êîììèòà çà ïðåäûäóùèå 7 äíåé. Âîçìîæíî âû â îòïóñêå? Âûõîæó.");
return;
@@ -180,7 +180,7 @@ namespace JiraTimeBotForm
_log.Trace($"- {taskTime.Branch} (êîììèòîâ {taskTime.Commits}): {taskTime.Time}");
}
jira.SetTodayWorklog(taskTimes);
jira.SetTodayWorklog(taskTimes, dummy: txtDummyMode.Checked);
_log.Info("Ãîòîâî.");
return;
}