From 2fbcef8f52705335e602e7c41f511b5ebc627c38 Mon Sep 17 00:00:00 2001 From: Danil Kislov Date: Wed, 26 Jun 2019 08:45:35 +0300 Subject: [PATCH] =?UTF-8?q?Msgbox=20=D0=BF=D1=80=D0=BE=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .semver.txt | 2 +- src/JiraTimeBot/Properties/AssemblyInfo.cs | 62 +++++++++++----------- src/JiraTimeBot/UI/frmMain.cs | 8 +++ src/JiraTimeBot/Update/IUpdater.cs | 1 + src/JiraTimeBot/Update/Updater.cs | 15 +++++- 5 files changed, 55 insertions(+), 33 deletions(-) diff --git a/.semver.txt b/.semver.txt index 3e9c4a6..73b4678 100644 --- a/.semver.txt +++ b/.semver.txt @@ -1 +1 @@ -1.0.50 +1.0.51 diff --git a/src/JiraTimeBot/Properties/AssemblyInfo.cs b/src/JiraTimeBot/Properties/AssemblyInfo.cs index e328dc5..3ac595f 100644 --- a/src/JiraTimeBot/Properties/AssemblyInfo.cs +++ b/src/JiraTimeBot/Properties/AssemblyInfo.cs @@ -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.50")] -[assembly: AssemblyFileVersion("1.0.50")] -[assembly: AssemblyInformationalVersion("1.0.50")] +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.51")] +[assembly: AssemblyFileVersion("1.0.51")] +[assembly: AssemblyInformationalVersion("1.0.51")] diff --git a/src/JiraTimeBot/UI/frmMain.cs b/src/JiraTimeBot/UI/frmMain.cs index f741e9b..77a40c5 100644 --- a/src/JiraTimeBot/UI/frmMain.cs +++ b/src/JiraTimeBot/UI/frmMain.cs @@ -222,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) diff --git a/src/JiraTimeBot/Update/IUpdater.cs b/src/JiraTimeBot/Update/IUpdater.cs index 014e8fa..38e5e09 100644 --- a/src/JiraTimeBot/Update/IUpdater.cs +++ b/src/JiraTimeBot/Update/IUpdater.cs @@ -5,5 +5,6 @@ namespace JiraTimeBot.Update internal interface IUpdater { bool UpdateToNewVersion(bool firstTime); + void SelfRestart(); } } diff --git a/src/JiraTimeBot/Update/Updater.cs b/src/JiraTimeBot/Update/Updater.cs index c2c3516..e5476cd 100644 --- a/src/JiraTimeBot/Update/Updater.cs +++ b/src/JiraTimeBot/Update/Updater.cs @@ -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) {