From fa352cb9c7709ea525cc180042055decee85ef36 Mon Sep 17 00:00:00 2001 From: JKamue Date: Tue, 13 Aug 2024 10:25:37 +0200 Subject: [PATCH] ci(Clockodo.QuickActions): Beim Start automatisch nach updates suchen und installieren --- .../coIT.Clockodo.QuickActions.Installer.aip | 53 +++++-------------- src/coIT.Clockodo.QuickActions/Program.cs | 42 +++++++++++++-- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/src/coIT.Clockodo.QuickActions.Installer/coIT.Clockodo.QuickActions.Installer.aip b/src/coIT.Clockodo.QuickActions.Installer/coIT.Clockodo.QuickActions.Installer.aip index 5d26d31..b5d501c 100644 --- a/src/coIT.Clockodo.QuickActions.Installer/coIT.Clockodo.QuickActions.Installer.aip +++ b/src/coIT.Clockodo.QuickActions.Installer/coIT.Clockodo.QuickActions.Installer.aip @@ -90,7 +90,6 @@ - @@ -103,22 +102,14 @@ - - - - - - - + - - - + @@ -136,15 +127,15 @@ - - - - - - - - - + + + + + + + + + @@ -152,15 +143,8 @@ - - - - - - - @@ -196,9 +180,9 @@ - + - + @@ -206,18 +190,9 @@ - + - - - - - - - - - diff --git a/src/coIT.Clockodo.QuickActions/Program.cs b/src/coIT.Clockodo.QuickActions/Program.cs index 0c3ecfc..3830865 100644 --- a/src/coIT.Clockodo.QuickActions/Program.cs +++ b/src/coIT.Clockodo.QuickActions/Program.cs @@ -1,4 +1,6 @@ -namespace coIT.Clockodo.QuickActions +using System.Diagnostics; + +namespace coIT.Clockodo.QuickActions { internal static class Program { @@ -8,10 +10,44 @@ internal static class Program [STAThread] static void Main() { + var updatesWurdenGefundenUndWerdenDurchgeführt = UpdaterAktualisiertAnwendung(); + // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new FormMain()); + if (!updatesWurdenGefundenUndWerdenDurchgeführt) + { + ApplicationConfiguration.Initialize(); + Application.Run(new FormMain()); + } + } + + public static bool UpdaterAktualisiertAnwendung() + { + var updaterPfad = ErwarteterPfadFürUpdater(); + if (File.Exists(updaterPfad)) + { + + Process process = Process.Start(updaterPfad); + process.WaitForExit(); + var code = process.ExitCode; + process.Close(); + + // Updater exit code 0 bedeutet, dass Updates gefunden wurden + // https://www.advancedinstaller.com/user-guide/updater.html#section370 + var updateGefundenExitCode = 0; + return code == updateGefundenExitCode; + } + return false; + } + + public static string ErwarteterPfadFürUpdater() + { +#if DEBUG + var appdataOrdner = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + return Path.Combine(appdataOrdner, "co-IT.eu GmbH", "Clockodo QuickActions", "updater.exe"); +#else + return Path.Combine(Application.StartupPath, "..", "updater.exe"); +#endif } } }