diff --git a/BodyshopUploader/Properties/AssemblyInfo.cs b/BodyshopUploader/Properties/AssemblyInfo.cs index 5870c91..a7e5348 100644 --- a/BodyshopUploader/Properties/AssemblyInfo.cs +++ b/BodyshopUploader/Properties/AssemblyInfo.cs @@ -51,7 +51,7 @@ using System.Windows; // 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.*")] -[assembly: AssemblyVersion("1.0.18.0")] +[assembly: AssemblyVersion("1.0.12.0")] [assembly: AssemblyFileVersion("1.0.0.0")] //Setting Squirrel Aware Version. [assembly: AssemblyMetadata("SquirrelAwareVersion", "1")] \ No newline at end of file diff --git a/BodyshopUploader/Utils/UpdateHandler.cs b/BodyshopUploader/Utils/UpdateHandler.cs index 2f30ad7..d90bcba 100644 --- a/BodyshopUploader/Utils/UpdateHandler.cs +++ b/BodyshopUploader/Utils/UpdateHandler.cs @@ -67,6 +67,47 @@ namespace BodyshopPartner.Utils public delegate void DownloadProgress(int value); public delegate void InstallProgress(int value); + + public static async Task UpdateAppEasy(InstallProgress InstallProgress) + { + try + { + BackupSettings(); + } + catch (Exception ex) + { + logger.Warn(ex, "Unable to backup settings."); + } + + try + { + using (var updateManager = new UpdateManager(UpdatePath)) + { + + await updateManager.UpdateApp(_ => + { + logger.Debug("Install Progress " + _.ToString()); + InstallProgress(_); + }); + await UpdateManager.RestartAppWhenExited(); + logger.Debug("Ready to restart app with updated version."); + + App.Current.Dispatcher.Invoke(() => + { + App.Current.Shutdown(); + }); + + + } + } + catch (Exception Ex) + { + logger.Error(Ex); + } + + } + + public static async Task ApplyUpdates(DownloadProgress DownloadProgress, InstallProgress InstallProgress) { try diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs index cc2e1b8..8fe033b 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.cs @@ -90,26 +90,28 @@ namespace BodyshopPartner.ViewModels private async Task updateCheck() { -#if (!DEBUG) +//#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. 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); + await Utils.UpdateHandler.UpdateAppEasy((val) => UpdateProgress = val); - } - catch (Exception Ex) - { - logger.Error("Error while updating." + Ex.ToString()); + //UpdateAvailable = await Utils.UpdateHandler.AreUpdatesAvailable(); + //if (UpdateAvailable) + //{ + // 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); - } - } -#endif + // } + // catch (Exception Ex) + // { + // logger.Error("Error while updating." + Ex.ToString()); + + // } + //} +//#endif } @@ -201,6 +203,7 @@ namespace BodyshopPartner.ViewModels { OpenFileDialog openFileDialog = new OpenFileDialog(); + openFileDialog.ValidateNames = false; openFileDialog.Multiselect = false; openFileDialog.Filter = "QuickBooks files (*.qbw)|*.qbw|All files (*.*)|*.*"; openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);