From 6b819ada41db5b1ebe7f44c6fc00c91a6ad4fe0c Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 26 Feb 2021 07:22:29 -0800 Subject: [PATCH] Restore taskbar --- BodyshopUploader/Utils/UpdateHandler.cs | 19 ++++++++++++++++++- BodyshopUploader/ViewModels/MainViewModel.cs | 17 ++++++++++++++++- BodyshopUploader/Views/Main.xaml | 5 +++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/BodyshopUploader/Utils/UpdateHandler.cs b/BodyshopUploader/Utils/UpdateHandler.cs index 54a7902..2f30ad7 100644 --- a/BodyshopUploader/Utils/UpdateHandler.cs +++ b/BodyshopUploader/Utils/UpdateHandler.cs @@ -95,7 +95,8 @@ namespace BodyshopPartner.Utils logger.Debug("Install Progress " + _.ToString()); InstallProgress(_); }); - UpdateManager.RestartApp(System.Reflection.Assembly.GetEntryAssembly().Location); + logger.Debug("Attempting to restart application. " + System.Reflection.Assembly.GetEntryAssembly().Location); + UpdateManager.RestartApp(); } catch (Exception Ex) { @@ -106,6 +107,22 @@ namespace BodyshopPartner.Utils } + public static void test() + { + using (var updateManager = new UpdateManager(UpdatePath)) + { + try + { + UpdateManager.RestartApp(); + } + catch (Exception Ex) + { + logger.Error("Error updating Partner App. " + Ex.ToString()); + } + + } + } + public static void BackupSettings() { string settingsFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath; diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs index bb6bc63..f992b18 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.cs @@ -88,13 +88,28 @@ namespace BodyshopPartner.ViewModels private async Task updateCheck() { + +#if (!DEBUG) logger.Debug("Checking if updates are available."); UpdateAvailable = await Utils.UpdateHandler.AreUpdatesAvailable(); if (UpdateAvailable) { - string msg = "An update to ImEX Online Partner is Available"; + string msg = "An update to ImEX Online Partner is Available. It will be automatically downloaded and applied."; Utils.Notifications.notifier.ShowInformation(msg); + logger.Debug("Updates are available! Installing."); + try + { + await Utils.UpdateHandler.ApplyUpdates((val) => UpdateProgress = val, (val) => UpdateProgress = val); + + } + catch (Exception Ex) + { + logger.Error("Error while updating." + Ex.ToString()); + + } } +#endif + } diff --git a/BodyshopUploader/Views/Main.xaml b/BodyshopUploader/Views/Main.xaml index f913dc5..a35c743 100644 --- a/BodyshopUploader/Views/Main.xaml +++ b/BodyshopUploader/Views/Main.xaml @@ -8,6 +8,7 @@ xmlns:properties="clr-namespace:BodyshopPartner.Properties" xmlns:util="clr-namespace:BodyshopPartner.Utils" xmlns:vm="clr-namespace:BodyshopPartner.ViewModels" + xmlns:tb="http://www.hardcodet.net/taskbar" mc:Ignorable="d" Title="{x:Static p:Resources.Title_Main}" Height="600" @@ -53,7 +54,7 @@ IsIndeterminate="{Binding IndeterminateLoading}" Height="8" /> - +