Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98f4985f06 | ||
|
|
4e5ccaf658 | ||
|
|
fab2b22bce | ||
|
|
7c86cefa53 | ||
|
|
fce2939cce | ||
|
|
0121d8d139 | ||
|
|
2d8214e64f | ||
|
|
02bee8abbd | ||
|
|
0f00ba3f0e | ||
|
|
71d02f7efe |
+1
-1
@@ -1 +1 @@
|
||||
1.0.17
|
||||
1.0.20
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# JiraTimeBot [](https://travis-ci.org/monster1025/JiraTimeBot)
|
||||
Приложение для автоматического добавления Jira Worklog'ов исходя из количества коммитов в ветку.
|
||||
|
||||
# Предположения
|
||||
# Ограничения
|
||||
- Предполагается что все Ваши репозитории находятся в одной папке (к которой вы указываете путь в настройках).
|
||||
- Предполагается что ветки в JIRA имеют название эквивалентное имени бранча в Mercurial.
|
||||
|
||||
# Скачать
|
||||
Скачать актуальную версию можно тут: https://github.com/monster1025/JiraTimeBot/releases/latest
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ call tools\SetVersion.cmd %VERSION%
|
||||
git add .
|
||||
git commit -m "%~1"
|
||||
|
||||
git tag -m "Version v%VERSION%" -a v%VERSION%
|
||||
git tag -m "Version v%VERSION%: %~1" -a v%VERSION%
|
||||
git push origin v%VERSION%
|
||||
|
||||
git push
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace JiraTimeBotForm.Configuration
|
||||
namespace JiraTimeBot.Configuration
|
||||
{
|
||||
public class PasswordEncryptionClass
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace JiraTimeBotForm.Configuration
|
||||
namespace JiraTimeBot.Configuration
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
using System.Windows.Forms;
|
||||
using Autofac;
|
||||
using Autofac.Extras.AggregateService;
|
||||
using JiraTimeBotForm.JiraIntegration;
|
||||
using JiraTimeBotForm.JiraIntegration.Comments;
|
||||
using JiraTimeBotForm.Mercurial;
|
||||
using JiraTimeBotForm.Mercurial.Modifiers;
|
||||
using JiraTimeBotForm.TasksProcessors;
|
||||
using JiraTimeBotForm.TaskTime;
|
||||
using JiraTimeBotForm.UI;
|
||||
using JiraTimeBotForm.UI.Tray;
|
||||
using JiraTimeBot.JiraIntegration;
|
||||
using JiraTimeBot.JiraIntegration.Comments;
|
||||
using JiraTimeBot.Mercurial;
|
||||
using JiraTimeBot.Mercurial.Modifiers;
|
||||
using JiraTimeBot.TasksProcessors;
|
||||
using JiraTimeBot.TaskTime;
|
||||
using JiraTimeBot.UI.Tray;
|
||||
|
||||
namespace JiraTimeBotForm.DI
|
||||
namespace JiraTimeBot.DI
|
||||
{
|
||||
public class Bootstrapper
|
||||
{
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using JiraTimeBotForm.TaskTime.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.TaskTime.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.JiraIntegration.Comments
|
||||
namespace JiraTimeBot.JiraIntegration.Comments
|
||||
{
|
||||
public interface IJiraDescriptionSource
|
||||
{
|
||||
string GetDescription(TaskTimeItem item, bool addCommentsToWorklog);
|
||||
string GetDescription(TaskTimeItem item, bool addCommentsToWorklog, Settings settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JiraTimeBotForm.TaskTime.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.TaskTime.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.JiraIntegration.Comments
|
||||
namespace JiraTimeBot.JiraIntegration.Comments
|
||||
{
|
||||
public class JiraDescriptionSource : IJiraDescriptionSource
|
||||
{
|
||||
@@ -13,14 +14,19 @@ namespace JiraTimeBotForm.JiraIntegration.Comments
|
||||
"кодинг", "написание кода и тестов"
|
||||
};
|
||||
|
||||
public string GetDescription(TaskTimeItem taskTimeItem, bool addCommentsToWorklog)
|
||||
public string GetDescription(TaskTimeItem taskTimeItem, bool addCommentsToWorklog, Settings settings)
|
||||
{
|
||||
if (addCommentsToWorklog)
|
||||
{
|
||||
return taskTimeItem.Description;
|
||||
}
|
||||
|
||||
return _dummyComments.OrderBy(f => Guid.NewGuid()).FirstOrDefault();
|
||||
if (settings.WorkType == WorkType.Mercurial)
|
||||
{
|
||||
return _dummyComments.OrderBy(f => Guid.NewGuid()).FirstOrDefault();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Atlassian.Jira;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.JiraIntegration.Comments;
|
||||
using JiraTimeBotForm.TaskTime.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.JiraIntegration.Comments;
|
||||
using JiraTimeBot.TaskTime.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.JiraIntegration
|
||||
namespace JiraTimeBot.JiraIntegration
|
||||
{
|
||||
public class JiraApi
|
||||
{
|
||||
@@ -119,7 +119,7 @@ namespace JiraTimeBotForm.JiraIntegration
|
||||
{
|
||||
var timeSpentJira = $"{taskTimeItem.Time.TotalMinutes}m";
|
||||
|
||||
var comment = _descriptionSource.GetDescription(taskTimeItem, addCommentsToWorklog);
|
||||
var comment = _descriptionSource.GetDescription(taskTimeItem, addCommentsToWorklog, settings);
|
||||
|
||||
Worklog workLogToAdd = new Worklog(timeSpentJira, date.Value, comment);
|
||||
if (!dummy)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.Mercurial;
|
||||
using JiraTimeBotForm.Mercurial.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.Mercurial;
|
||||
using JiraTimeBot.Mercurial.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.JiraIntegration
|
||||
namespace JiraTimeBot.JiraIntegration
|
||||
{
|
||||
public class JiraCommitEmulator : IMercurialLog
|
||||
{
|
||||
|
||||
@@ -3,14 +3,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.Mercurial;
|
||||
using JiraTimeBotForm.Mercurial.Objects;
|
||||
using JiraTimeBotForm.TasksProcessors;
|
||||
using JiraTimeBotForm.TaskTime;
|
||||
using JiraTimeBotForm.TaskTime.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.Mercurial;
|
||||
using JiraTimeBot.Mercurial.Objects;
|
||||
using JiraTimeBot.TasksProcessors;
|
||||
using JiraTimeBot.TaskTime;
|
||||
using JiraTimeBot.TaskTime.Objects;
|
||||
|
||||
namespace JiraTimeBotForm
|
||||
namespace JiraTimeBot
|
||||
{
|
||||
class Job
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JiraTimeBotForm
|
||||
namespace JiraTimeBot
|
||||
{
|
||||
public class Logger : ILog
|
||||
{
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JiraTimeBotForm.JiraIntegration;
|
||||
using JiraTimeBot.JiraIntegration;
|
||||
|
||||
namespace JiraTimeBotForm.Mercurial
|
||||
namespace JiraTimeBot.Mercurial
|
||||
{
|
||||
public interface IAllMercurialProviders
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.Mercurial.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.Mercurial.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.Mercurial
|
||||
namespace JiraTimeBot.Mercurial
|
||||
{
|
||||
public interface IMercurialLog
|
||||
{
|
||||
|
||||
@@ -4,12 +4,12 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.Mercurial.Modifiers;
|
||||
using JiraTimeBotForm.Mercurial.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.Mercurial.Modifiers;
|
||||
using JiraTimeBot.Mercurial.Objects;
|
||||
using Mercurial;
|
||||
|
||||
namespace JiraTimeBotForm.Mercurial
|
||||
namespace JiraTimeBot.Mercurial
|
||||
{
|
||||
public class MercurialLog: IMercurialLog
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace JiraTimeBotForm.Mercurial.Modifiers
|
||||
namespace JiraTimeBot.Mercurial.Modifiers
|
||||
{
|
||||
public class CommitSkipper : ICommitSkipper
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace JiraTimeBotForm.Mercurial.Modifiers
|
||||
namespace JiraTimeBot.Mercurial.Modifiers
|
||||
{
|
||||
public interface ICommitSkipper
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace JiraTimeBotForm.Mercurial.Modifiers
|
||||
namespace JiraTimeBot.Mercurial.Modifiers
|
||||
{
|
||||
public interface ITechnicalInfoSkipper
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Text;
|
||||
|
||||
namespace JiraTimeBotForm.Mercurial.Modifiers
|
||||
namespace JiraTimeBot.Mercurial.Modifiers
|
||||
{
|
||||
public class TechnicalInfoSkipper : ITechnicalInfoSkipper
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace JiraTimeBotForm.Mercurial.Objects
|
||||
namespace JiraTimeBot.Mercurial.Objects
|
||||
{
|
||||
public class MercurialCommitItem
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using JiraTimeBotForm.UI;
|
||||
using JiraTimeBot.UI;
|
||||
|
||||
namespace JiraTimeBotForm
|
||||
namespace JiraTimeBot
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
|
||||
@@ -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.17")]
|
||||
[assembly: AssemblyFileVersion("1.0.17")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.17")]
|
||||
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.20")]
|
||||
[assembly: AssemblyFileVersion("1.0.20")]
|
||||
[assembly: AssemblyInformationalVersion("1.0.20")]
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.Mercurial;
|
||||
using JiraTimeBotForm.Mercurial.Objects;
|
||||
using JiraTimeBotForm.TaskTime.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.Mercurial.Objects;
|
||||
using JiraTimeBot.TaskTime.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.TaskTime
|
||||
namespace JiraTimeBot.TaskTime
|
||||
{
|
||||
public interface ITaskTimeCalculator
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace JiraTimeBotForm.TaskTime.Objects
|
||||
namespace JiraTimeBot.TaskTime.Objects
|
||||
{
|
||||
public class TaskTimeItem
|
||||
{
|
||||
|
||||
@@ -3,12 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.Mercurial;
|
||||
using JiraTimeBotForm.Mercurial.Objects;
|
||||
using JiraTimeBotForm.TaskTime.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.Mercurial.Objects;
|
||||
using JiraTimeBot.TaskTime.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.TaskTime
|
||||
namespace JiraTimeBot.TaskTime
|
||||
{
|
||||
public class TaskTimeByCommitsCalculator: ITaskTimeCalculator
|
||||
{
|
||||
@@ -24,6 +23,17 @@ namespace JiraTimeBotForm.TaskTime
|
||||
int remainMinutes = settings.MinuterPerWorkDay;
|
||||
int totalCommitsCount = commits.Count;
|
||||
|
||||
//если кол-во коммитов более чем кол-во интервалов - то уменьшим интервал вдвое.
|
||||
while (totalCommitsCount > (8 * (60.0 / settings.RountToMinutes)))
|
||||
{
|
||||
settings.RountToMinutes = (int)RoundTo((decimal)(settings.RountToMinutes / 2.0), 5);
|
||||
_log.Info($"Слишком много задачь - уменьшаю интервал до {settings.RountToMinutes}.");
|
||||
if (settings.RountToMinutes == 5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
List<TaskTimeItem> workTimeItems = new List<TaskTimeItem>();
|
||||
|
||||
//Нам нужно раскидать 480 минут в день.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace JiraTimeBotForm.TasksProcessors
|
||||
namespace JiraTimeBot.TasksProcessors
|
||||
{
|
||||
public interface IAllTasksProcessors
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.TaskTime.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.TaskTime.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.TasksProcessors
|
||||
namespace JiraTimeBot.TasksProcessors
|
||||
{
|
||||
interface ITasksProcessor
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.JiraIntegration;
|
||||
using JiraTimeBotForm.TaskTime.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.JiraIntegration;
|
||||
using JiraTimeBot.TaskTime.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.TasksProcessors
|
||||
namespace JiraTimeBot.TasksProcessors
|
||||
{
|
||||
public class MeetingProcessor : ITasksProcessor
|
||||
{
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.JiraIntegration;
|
||||
using JiraTimeBotForm.TaskTime;
|
||||
using JiraTimeBotForm.TaskTime.Objects;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.JiraIntegration;
|
||||
using JiraTimeBot.TaskTime.Objects;
|
||||
|
||||
namespace JiraTimeBotForm.TasksProcessors
|
||||
namespace JiraTimeBot.TasksProcessors
|
||||
{
|
||||
public class WorkLogTasksProcessor : ITasksProcessor
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JiraTimeBotForm.UI.Tray
|
||||
namespace JiraTimeBot.UI.Tray
|
||||
{
|
||||
public interface ITrayMenu
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JiraTimeBotForm.UI.Tray
|
||||
namespace JiraTimeBot.UI.Tray
|
||||
{
|
||||
public static class RestoreFromTray {
|
||||
[DllImport( "user32.dll" )]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JiraTimeBotForm.UI.Tray
|
||||
namespace JiraTimeBot.UI.Tray
|
||||
{
|
||||
public class TrayMenu: ITrayMenu
|
||||
{
|
||||
|
||||
Generated
+2
-2
@@ -1,4 +1,4 @@
|
||||
namespace JiraTimeBotForm.UI
|
||||
namespace JiraTimeBot.UI
|
||||
{
|
||||
partial class frmMain
|
||||
{
|
||||
@@ -114,7 +114,7 @@
|
||||
//
|
||||
// tmrUpdate
|
||||
//
|
||||
this.tmrUpdate.Interval = 10000;
|
||||
this.tmrUpdate.Interval = 1000;
|
||||
this.tmrUpdate.Tick += new System.EventHandler(this.tmrUpdate_Tick);
|
||||
//
|
||||
// frmMain
|
||||
|
||||
@@ -6,16 +6,16 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Autofac;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.DI;
|
||||
using JiraTimeBotForm.TasksProcessors;
|
||||
using JiraTimeBotForm.UI.Tray;
|
||||
using JiraTimeBotForm.Update;
|
||||
using JiraTimeBot.Configuration;
|
||||
using JiraTimeBot.DI;
|
||||
using JiraTimeBot.TasksProcessors;
|
||||
using JiraTimeBot.UI.Tray;
|
||||
using JiraTimeBot.Update;
|
||||
|
||||
// This is the code for your desktop app.
|
||||
// Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
|
||||
|
||||
namespace JiraTimeBotForm.UI
|
||||
namespace JiraTimeBot.UI
|
||||
{
|
||||
public partial class frmMain : Form
|
||||
{
|
||||
@@ -96,7 +96,15 @@ namespace JiraTimeBotForm.UI
|
||||
|
||||
PrintStartMessage();
|
||||
tmrStart.Enabled = true;
|
||||
tmrUpdate.Enabled = true;
|
||||
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
_log.Trace("Приложение запущено в режиме отладки. Отключаю обновление.");
|
||||
}
|
||||
else
|
||||
{
|
||||
tmrUpdate.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void PrintStartMessage()
|
||||
@@ -210,19 +218,23 @@ namespace JiraTimeBotForm.UI
|
||||
var downloadUrl = checker.GetDownloadUrl(release);
|
||||
_log.Info($"Доступна новая версия: {gitVersion} {downloadUrl}");
|
||||
|
||||
var success = checker.DownloadFile(downloadUrl);
|
||||
var success = checker.DownloadFile(downloadUrl, "update.zip");
|
||||
if (!success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var result = InstallUpdate(gitVersion);
|
||||
var result = InstallUpdate(gitVersion, "update.zip");
|
||||
if (result)
|
||||
{
|
||||
//если обновились - отключаем до рестарта
|
||||
tmrUpdate.Enabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.Info($"Вы используете последнюю версию.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -231,7 +243,7 @@ namespace JiraTimeBotForm.UI
|
||||
}
|
||||
}
|
||||
|
||||
private bool InstallUpdate(Version gitVersion)
|
||||
private bool InstallUpdate(Version gitVersion, string updateFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -244,7 +256,7 @@ namespace JiraTimeBotForm.UI
|
||||
Directory.CreateDirectory(bkpDir);
|
||||
}
|
||||
|
||||
using (ZipArchive archive = ZipFile.OpenRead(Path.Combine(appFile.DirectoryName, "update.zip")))
|
||||
using (ZipArchive archive = ZipFile.OpenRead(Path.Combine(appFile.DirectoryName, updateFile)))
|
||||
{
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace JiraTimeBotForm.UI
|
||||
namespace JiraTimeBot.UI
|
||||
{
|
||||
partial class frmSettings
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBot.Configuration;
|
||||
|
||||
namespace JiraTimeBotForm.UI
|
||||
namespace JiraTimeBot.UI
|
||||
{
|
||||
public partial class frmSettings : Form
|
||||
{
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace JiraTimeBotForm.Update
|
||||
namespace JiraTimeBot.Update
|
||||
{
|
||||
public partial class GitHubReleaseResponse
|
||||
{
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace JiraTimeBotForm.Update
|
||||
namespace JiraTimeBot.Update
|
||||
{
|
||||
class UpdateChecker
|
||||
{
|
||||
@@ -38,7 +35,7 @@ namespace JiraTimeBotForm.Update
|
||||
return release;
|
||||
}
|
||||
|
||||
public bool DownloadFile(string url)
|
||||
public bool DownloadFile(string url, string to)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -47,7 +44,7 @@ namespace JiraTimeBotForm.Update
|
||||
{
|
||||
client.Headers.Add("User-Agent",
|
||||
"Mozilla/5.0 (X11; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0");
|
||||
client.DownloadFile(url, "update.zip");
|
||||
client.DownloadFile(url, to);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user