Improved updated handler & allow qb file selection when file locked.
This commit is contained in:
@@ -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")]
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user