Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c1e396502 | ||
|
|
7933ca244c | ||
|
|
f63b441691 | ||
|
|
f06f5b885a | ||
|
|
18450ff78e | ||
|
|
2fbcef8f52 | ||
|
|
359c7a23bf | ||
|
|
5211a94121 | ||
|
|
b82ad07460 | ||
|
|
2a74eba1d4 | ||
|
|
90be770027 | ||
|
|
63b74263bd | ||
|
|
8c38726588 | ||
|
|
3ea3cbcce8 | ||
|
|
84ef070eb6 | ||
|
|
448a6ddb57 | ||
|
|
a95c19fe68 | ||
|
|
e0c610399e |
+1
-1
@@ -1 +1 @@
|
||||
1.0.40
|
||||
1.0.55
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
- JQL (Режим Jira) - можно задать свой JQL для поиска задач. Возможные замены: %USER% - Логин Jira, %DATE% дата на которую формируем список. Значнеие по умолчанию: status changed by '%USER%' during ("%DATE%","%DATE%")
|
||||
- Задача "учёта времени" - задача, куда будет списываться по 30 минут в день на "затраты на учет времени". Должна содержать знак '-'.
|
||||
- Время запуска - время автоматического запуска бота. Если была установлена галочка "тестовый прогон" - она будет снята.
|
||||
- Минут в рабочем дне - количество распределяемых минут (оыбчно 8 * 60).
|
||||
- Рандомных минут - если > 0, то будет прибавлено рандомное количество минут к рабочему времени (но кратное значению округления).
|
||||
- Добавлять описание (Режим Mercurial) - добавлять ли в описание CommitMessage, если не установлено - добавляются стандартные фразы программистов (типа "написание кода").
|
||||
|
||||
- Автозагрузка - загружать ли программу при старте ОС.
|
||||
# Скачать
|
||||
Скачать актуальную версию можно тут: https://github.com/monster1025/JiraTimeBot/releases/latest
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace JiraTimeBot.Configuration
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
public int MinuterPerWorkDay = 8 * 60;
|
||||
public int RountToMinutes { get; set; }
|
||||
public int MinuterPerWorkDay { get; set; }
|
||||
public int RoundToMinutes { get; set; }
|
||||
|
||||
public string JiraUrl = "https://myteam.aeroclub.ru";
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace JiraTimeBot.Configuration
|
||||
public WorkType WorkType { get; set; }
|
||||
public string JiraQuery { get; set; }
|
||||
public string TimeControlTask { get; set; }
|
||||
public int RandomWorkMinutes { get; set; }
|
||||
|
||||
public static Settings LoadAndCheck(Action settingsSource, Action<string> errorMessageReporter)
|
||||
{
|
||||
@@ -60,7 +61,7 @@ namespace JiraTimeBot.Configuration
|
||||
var errors = new List<string>();
|
||||
message = null;
|
||||
|
||||
if (settings.RountToMinutes == default(int))
|
||||
if (settings.RoundToMinutes == default(int))
|
||||
{
|
||||
errors.Add("Укажите округление времени, например, 10 (минут)");
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ namespace JiraTimeBot.JiraIntegration
|
||||
|
||||
try
|
||||
{
|
||||
List<Issue> affectedIssues =
|
||||
jira.Issues.GetIssuesFromJqlAsync(jql, 100, 0, cancellationToken).Result.ToList();
|
||||
List<Issue> affectedIssues = jira.Issues.GetIssuesFromJqlAsync(jql, 100, 0, cancellationToken).Result.ToList();
|
||||
return affectedIssues;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -123,24 +122,37 @@ namespace JiraTimeBot.JiraIntegration
|
||||
var userWorklogs = workLogs.Where(w =>
|
||||
w.StartDate.GetValueOrDefault().Date == date && w.Author.Equals(settings.JiraUserName,
|
||||
StringComparison.InvariantCultureIgnoreCase)).ToList();
|
||||
var comment = _descriptionSource.GetDescription(taskTimeItem, addCommentsToWorklog, settings);
|
||||
|
||||
foreach (var workLog in userWorklogs)
|
||||
{
|
||||
var timeSpent = TimeSpan.FromSeconds(workLog.TimeSpentInSeconds);
|
||||
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)
|
||||
{
|
||||
_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}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.Trace($"Описание отличается, удаляю worklog: {taskTimeItem.Branch} {workLog.Author} {workLog.CreateDate}: {workLog.TimeSpent}");
|
||||
}
|
||||
if (!dummy)
|
||||
{
|
||||
issue.DeleteWorklogAsync(workLog, token: cancellationToken);
|
||||
try
|
||||
{
|
||||
issue.DeleteWorklogAsync(workLog, WorklogStrategy.RetainRemainingEstimate, token: cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error($"Не могу удалить Worklog по задаче {taskTimeItem.Branch}: {ex.Message}.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
hasTodayWorklog = false;
|
||||
}
|
||||
@@ -155,12 +167,18 @@ namespace JiraTimeBot.JiraIntegration
|
||||
{
|
||||
var timeSpentJira = $"{taskTimeItem.Time.TotalMinutes}m";
|
||||
|
||||
var comment = _descriptionSource.GetDescription(taskTimeItem, addCommentsToWorklog, settings);
|
||||
|
||||
Worklog workLogToAdd = new Worklog(timeSpentJira, date.Value, comment);
|
||||
if (!dummy)
|
||||
{
|
||||
workLogToAdd = issue.AddWorklogAsync(workLogToAdd, token: cancellationToken).Result;
|
||||
try
|
||||
{
|
||||
workLogToAdd = issue.AddWorklogAsync(workLogToAdd, WorklogStrategy.RetainRemainingEstimate, token: cancellationToken).Result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error($"Не могу добавить Worklog по задаче {taskTimeItem.Branch}: {ex.Message} ({ex.InnerException?.Message}).");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
_log.Trace($"Добавили Worklog для {taskTimeItem.Branch}: {workLogToAdd.Author} {workLogToAdd.CreateDate}: {workLogToAdd.TimeSpent}");
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ namespace JiraTimeBot
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_log.Warn($"{realDate:dd.MM.yyyy} вы не сделали ничего полезного =) Использую предыдущий день.");
|
||||
daysDiff--;
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace JiraTimeBot.Mercurial.Modifiers
|
||||
}
|
||||
|
||||
//Пропускаем Close и Merge коммиты
|
||||
if (commitMessage.StartsWith($"Close {branch} ", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
commitMessage.StartsWith($"Merge with ", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (commitMessage.StartsWith($"Close {branch}", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
commitMessage.StartsWith($"Merge with", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("JiraTimeBot")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("JiraTimeBot")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
// 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
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")]
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.40")]
|
||||
[assembly: AssemblyFileVersion("1.0.40")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.40")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("JiraTimeBot")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("JiraTimeBot")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
// 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
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")]
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.55")]
|
||||
[assembly: AssemblyFileVersion("1.0.55")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.55")]
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace JiraTimeBot.TaskTime
|
||||
|
||||
public List<TaskTimeItem> CalculateTaskTime(List<MercurialCommitItem> commits, Settings settings, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
int minutesPerWorkDay = settings.MinuterPerWorkDay;
|
||||
int remainMinutes = settings.MinuterPerWorkDay;
|
||||
int minutesPerWorkDay = settings.MinuterPerWorkDay + GetRandomMinutes(settings);
|
||||
int workHours = (settings.MinuterPerWorkDay / 60);
|
||||
int totalCommitsCount = commits.Count;
|
||||
|
||||
if (!commits.Any())
|
||||
@@ -30,11 +30,11 @@ namespace JiraTimeBot.TaskTime
|
||||
}
|
||||
|
||||
//если кол-во коммитов более чем кол-во интервалов - то уменьшим интервал вдвое.
|
||||
while (totalCommitsCount > (8 * (60.0 / settings.RountToMinutes)))
|
||||
while (totalCommitsCount > (workHours * (60.0 / settings.RoundToMinutes)))
|
||||
{
|
||||
settings.RountToMinutes = (int)RoundTo((decimal)(settings.RountToMinutes / 2.0), 5);
|
||||
_log.Info($"Слишком много задач - уменьшаю интервал до {settings.RountToMinutes}.");
|
||||
if (settings.RountToMinutes == 5)
|
||||
settings.RoundToMinutes = (int)RoundTo((decimal)(settings.RoundToMinutes / 2.0), 5);
|
||||
_log.Info($"Слишком много задач - уменьшаю интервал до {settings.RoundToMinutes}.");
|
||||
if (settings.RoundToMinutes == 5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -55,6 +55,7 @@ namespace JiraTimeBot.TaskTime
|
||||
});
|
||||
}
|
||||
|
||||
int remainMinutes = minutesPerWorkDay;
|
||||
//Нам нужно раскидать 480 минут в день.
|
||||
foreach (var taskGroup in commits.GroupBy(f => f.Branch).OrderByDescending(f=>f.Count()))
|
||||
{
|
||||
@@ -64,7 +65,7 @@ namespace JiraTimeBot.TaskTime
|
||||
}
|
||||
|
||||
int currentTaskCommits = taskGroup.Count();
|
||||
int currentTaskTime = (int)RoundTo(minutesPerWorkDay / totalCommitsCount * currentTaskCommits, settings.RountToMinutes);
|
||||
int currentTaskTime = (int)RoundTo(minutesPerWorkDay / totalCommitsCount * currentTaskCommits, settings.RoundToMinutes, false);
|
||||
remainMinutes = remainMinutes - currentTaskTime;
|
||||
|
||||
var orderedTasks = taskGroup.OrderBy(f => f.Time).ToArray();
|
||||
@@ -98,7 +99,7 @@ namespace JiraTimeBot.TaskTime
|
||||
_log.Trace($"Погрешность распределения времени: {remainMinutes}. Добавляю к первой задаче.");
|
||||
}
|
||||
|
||||
if (workTimeItems.First().Time.TotalMinutes > Math.Abs(remainMinutes) && remainMinutes < 0)
|
||||
if ((workTimeItems.First().Time.TotalMinutes > Math.Abs(remainMinutes) && remainMinutes < 0) || remainMinutes > 0)
|
||||
{
|
||||
//если переборщили или не достаточно добавили до 8 часов - скореектируем остаток в первой задаче (она самая трудозатратная).
|
||||
workTimeItems.First().Time += TimeSpan.FromMinutes(remainMinutes);
|
||||
@@ -109,6 +110,14 @@ namespace JiraTimeBot.TaskTime
|
||||
return workTimeItems;
|
||||
}
|
||||
|
||||
private int GetRandomMinutes(Settings settings)
|
||||
{
|
||||
var rand = new Random();
|
||||
int randomIntervals = settings.RandomWorkMinutes / settings.RoundToMinutes;
|
||||
int randomMinutes = rand.Next(0, randomIntervals + 1) * settings.RoundToMinutes;
|
||||
return randomMinutes;
|
||||
}
|
||||
|
||||
private void PrintTotal(List<TaskTimeItem> workTimeItems)
|
||||
{
|
||||
var totalTime = TimeSpan.Zero;
|
||||
|
||||
Generated
+18
-13
@@ -34,6 +34,7 @@
|
||||
this.tmrStart = new System.Windows.Forms.Timer(this.components);
|
||||
this.tmrUpdate = new System.Windows.Forms.Timer(this.components);
|
||||
this.tlpControls = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.txtLog = new System.Windows.Forms.TextBox();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.btnMeeting = new System.Windows.Forms.Button();
|
||||
@@ -43,7 +44,6 @@
|
||||
this.btnDoForDate = new System.Windows.Forms.Button();
|
||||
this.dteForDay = new System.Windows.Forms.DateTimePicker();
|
||||
this.btnSettings = new System.Windows.Forms.Button();
|
||||
this.txtLog = new System.Windows.Forms.TextBox();
|
||||
this.tlpControls.SuspendLayout();
|
||||
this.panel2.SuspendLayout();
|
||||
this.pnlTopControls.SuspendLayout();
|
||||
@@ -82,6 +82,18 @@
|
||||
this.tlpControls.Size = new System.Drawing.Size(759, 416);
|
||||
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
|
||||
//
|
||||
this.panel2.Controls.Add(this.btnCancel);
|
||||
@@ -103,6 +115,7 @@
|
||||
this.btnCancel.TabIndex = 19;
|
||||
this.btnCancel.Text = "Отменить операцию";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// btnMeeting
|
||||
//
|
||||
@@ -112,6 +125,7 @@
|
||||
this.btnMeeting.TabIndex = 18;
|
||||
this.btnMeeting.Text = "Митинг";
|
||||
this.btnMeeting.UseVisualStyleBackColor = true;
|
||||
this.btnMeeting.Click += new System.EventHandler(this.btnMeeting_Click);
|
||||
//
|
||||
// txtDummyMode
|
||||
//
|
||||
@@ -131,6 +145,7 @@
|
||||
this.btnStart.TabIndex = 16;
|
||||
this.btnStart.Text = "Проставить время";
|
||||
this.btnStart.UseVisualStyleBackColor = true;
|
||||
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
|
||||
//
|
||||
// pnlTopControls
|
||||
//
|
||||
@@ -151,6 +166,7 @@
|
||||
this.btnDoForDate.TabIndex = 25;
|
||||
this.btnDoForDate.Text = "Проставить на дату";
|
||||
this.btnDoForDate.UseVisualStyleBackColor = true;
|
||||
this.btnDoForDate.Click += new System.EventHandler(this.btnDoForDate_Click);
|
||||
//
|
||||
// dteForDay
|
||||
//
|
||||
@@ -171,18 +187,7 @@
|
||||
this.btnSettings.TabIndex = 23;
|
||||
this.btnSettings.Text = "Настройки";
|
||||
this.btnSettings.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// 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;
|
||||
this.btnSettings.Click += new System.EventHandler(this.btnSettings_Click);
|
||||
//
|
||||
// frmMain
|
||||
//
|
||||
|
||||
@@ -172,6 +172,7 @@ namespace JiraTimeBot.UI
|
||||
if (txtDummyMode.Checked)
|
||||
{
|
||||
_log.Info("Выключаем режим Тестового прогона");
|
||||
txtDummyMode.Checked = false;
|
||||
}
|
||||
|
||||
using (var tokenSource = GetTokenSource())
|
||||
@@ -221,6 +222,14 @@ namespace JiraTimeBot.UI
|
||||
{
|
||||
//если обновились - отключаем до рестарта
|
||||
tmrUpdate.Enabled = false;
|
||||
var result = MessageBox.Show($"Приложение обновлено до новой версии. Перезапустить сейчас?",
|
||||
"Обновление",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Warning);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
updater.SelfRestart();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
+50
-4
@@ -49,6 +49,10 @@
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.txtTimeControlTask = new System.Windows.Forms.TextBox();
|
||||
this.chkAutostart = new System.Windows.Forms.CheckBox();
|
||||
this.lblWorkDay = new System.Windows.Forms.Label();
|
||||
this.txtWorkDayDuration = new System.Windows.Forms.TextBox();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.txtRandomMinutes = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label5
|
||||
@@ -76,6 +80,7 @@
|
||||
this.label4.Size = new System.Drawing.Size(76, 13);
|
||||
this.label4.TabIndex = 26;
|
||||
this.label4.Text = "Путь до репо:";
|
||||
this.label4.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// txtRepoPath
|
||||
//
|
||||
@@ -92,6 +97,7 @@
|
||||
this.label2.Size = new System.Drawing.Size(82, 13);
|
||||
this.label2.TabIndex = 24;
|
||||
this.label2.Text = "Mercurial name:";
|
||||
this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// txtMercurialEmail
|
||||
//
|
||||
@@ -153,7 +159,7 @@
|
||||
// chkAddComments
|
||||
//
|
||||
this.chkAddComments.AutoSize = true;
|
||||
this.chkAddComments.Location = new System.Drawing.Point(65, 277);
|
||||
this.chkAddComments.Location = new System.Drawing.Point(65, 336);
|
||||
this.chkAddComments.Name = "chkAddComments";
|
||||
this.chkAddComments.Size = new System.Drawing.Size(133, 17);
|
||||
this.chkAddComments.TabIndex = 31;
|
||||
@@ -162,7 +168,7 @@
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
this.btnSave.Location = new System.Drawing.Point(86, 300);
|
||||
this.btnSave.Location = new System.Drawing.Point(86, 359);
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnSave.TabIndex = 32;
|
||||
@@ -227,18 +233,54 @@
|
||||
// chkAutostart
|
||||
//
|
||||
this.chkAutostart.AutoSize = true;
|
||||
this.chkAutostart.Location = new System.Drawing.Point(65, 254);
|
||||
this.chkAutostart.Location = new System.Drawing.Point(65, 313);
|
||||
this.chkAutostart.Name = "chkAutostart";
|
||||
this.chkAutostart.Size = new System.Drawing.Size(96, 17);
|
||||
this.chkAutostart.TabIndex = 40;
|
||||
this.chkAutostart.Text = "Автозагрузка";
|
||||
this.chkAutostart.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblWorkDay
|
||||
//
|
||||
this.lblWorkDay.AutoSize = true;
|
||||
this.lblWorkDay.Location = new System.Drawing.Point(15, 258);
|
||||
this.lblWorkDay.Name = "lblWorkDay";
|
||||
this.lblWorkDay.Size = new System.Drawing.Size(117, 13);
|
||||
this.lblWorkDay.TabIndex = 42;
|
||||
this.lblWorkDay.Text = "Минут в рабочем дне:";
|
||||
//
|
||||
// txtWorkDayDuration
|
||||
//
|
||||
this.txtWorkDayDuration.Location = new System.Drawing.Point(133, 254);
|
||||
this.txtWorkDayDuration.Name = "txtWorkDayDuration";
|
||||
this.txtWorkDayDuration.Size = new System.Drawing.Size(99, 20);
|
||||
this.txtWorkDayDuration.TabIndex = 41;
|
||||
//
|
||||
// label9
|
||||
//
|
||||
this.label9.AutoSize = true;
|
||||
this.label9.Location = new System.Drawing.Point(30, 284);
|
||||
this.label9.Name = "label9";
|
||||
this.label9.Size = new System.Drawing.Size(101, 13);
|
||||
this.label9.TabIndex = 44;
|
||||
this.label9.Text = "Рандомных минут:";
|
||||
//
|
||||
// txtRandomMinutes
|
||||
//
|
||||
this.txtRandomMinutes.Location = new System.Drawing.Point(133, 280);
|
||||
this.txtRandomMinutes.Name = "txtRandomMinutes";
|
||||
this.txtRandomMinutes.Size = new System.Drawing.Size(99, 20);
|
||||
this.txtRandomMinutes.TabIndex = 43;
|
||||
//
|
||||
// frmSettings
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(243, 334);
|
||||
this.ClientSize = new System.Drawing.Size(243, 391);
|
||||
this.Controls.Add(this.label9);
|
||||
this.Controls.Add(this.txtRandomMinutes);
|
||||
this.Controls.Add(this.lblWorkDay);
|
||||
this.Controls.Add(this.txtWorkDayDuration);
|
||||
this.Controls.Add(this.chkAutostart);
|
||||
this.Controls.Add(this.label8);
|
||||
this.Controls.Add(this.txtTimeControlTask);
|
||||
@@ -294,5 +336,9 @@
|
||||
private System.Windows.Forms.Label label8;
|
||||
private System.Windows.Forms.TextBox txtTimeControlTask;
|
||||
private System.Windows.Forms.CheckBox chkAutostart;
|
||||
private System.Windows.Forms.Label lblWorkDay;
|
||||
private System.Windows.Forms.TextBox txtWorkDayDuration;
|
||||
private System.Windows.Forms.Label label9;
|
||||
private System.Windows.Forms.TextBox txtRandomMinutes;
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,12 @@ namespace JiraTimeBot.UI
|
||||
txtRepoPath.Text = settings.RepositoryPath;
|
||||
actTime.Text = settings.ActivationTime.ToString("hh\\:mm\\:ss");
|
||||
chkAddComments.Checked = settings.AddCommentsToWorklog;
|
||||
txtRoundTo.Text = settings.RountToMinutes.ToString();
|
||||
txtRoundTo.Text = settings.RoundToMinutes.ToString();
|
||||
cboWorkType.SelectedIndex = (int) settings.WorkType;
|
||||
txtTimeControlTask.Text = settings.TimeControlTask;
|
||||
txtJQL.Text = settings.JiraQuery;
|
||||
txtWorkDayDuration.Text = settings.MinuterPerWorkDay.ToString();
|
||||
txtRandomMinutes.Text = settings.RandomWorkMinutes.ToString();
|
||||
|
||||
cboWorkType_SelectedIndexChanged(null, null);
|
||||
}
|
||||
@@ -48,6 +50,14 @@ namespace JiraTimeBot.UI
|
||||
{
|
||||
roundTo = 15;
|
||||
}
|
||||
if (!int.TryParse(txtWorkDayDuration.Text, out var minuterPerWorkDay))
|
||||
{
|
||||
minuterPerWorkDay = 8 * 60;
|
||||
}
|
||||
if (!int.TryParse(txtRandomMinutes.Text, out var randomWorkMinutes))
|
||||
{
|
||||
randomWorkMinutes = 0;
|
||||
}
|
||||
|
||||
var settings = new Settings
|
||||
{
|
||||
@@ -57,10 +67,12 @@ namespace JiraTimeBot.UI
|
||||
ActivationTime = TimeSpan.Parse(actTime.Text),
|
||||
RepositoryPath = txtRepoPath.Text,
|
||||
AddCommentsToWorklog = chkAddComments.Checked,
|
||||
RountToMinutes = roundTo,
|
||||
RoundToMinutes = roundTo,
|
||||
WorkType = (WorkType) cboWorkType.SelectedIndex,
|
||||
JiraQuery = txtJQL.Text,
|
||||
TimeControlTask = txtTimeControlTask.Text,
|
||||
MinuterPerWorkDay = minuterPerWorkDay,
|
||||
RandomWorkMinutes = randomWorkMinutes
|
||||
};
|
||||
|
||||
//LockUnlock(false);
|
||||
|
||||
@@ -5,5 +5,6 @@ namespace JiraTimeBot.Update
|
||||
internal interface IUpdater
|
||||
{
|
||||
bool UpdateToNewVersion(bool firstTime);
|
||||
void SelfRestart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
@@ -124,7 +125,19 @@ namespace JiraTimeBot.Update
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SelfRestart()
|
||||
{
|
||||
var name = Application.ExecutablePath;
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo {
|
||||
Arguments = "/C choice /C Y /N /D Y /T 1 & \"" + name + "\"",
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
CreateNoWindow = true,
|
||||
FileName = "cmd.exe"
|
||||
};
|
||||
Process.Start(startInfo);
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
|
||||
private bool DownloadFile(string url, string to)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user