Further improvements for update handling. IO-408
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Squirrel;
|
||||
using Microsoft.Win32;
|
||||
using Squirrel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
@@ -13,6 +14,25 @@ namespace BodyshopPartner.Utils
|
||||
{
|
||||
public static class UpdateHandler
|
||||
{
|
||||
|
||||
public static void ToggleStartWithWindows(bool shouldStart)
|
||||
{
|
||||
|
||||
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
|
||||
if (shouldStart)
|
||||
{
|
||||
// Add the value in the registry so that the application runs at startup
|
||||
rkApp.SetValue(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove the value from the registry so that the application doesn't start
|
||||
rkApp.DeleteValue(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public const string UpdatePath = @"http://partner.imex.online/";
|
||||
@@ -22,6 +42,7 @@ namespace BodyshopPartner.Utils
|
||||
try
|
||||
{
|
||||
logger.Debug("Checking if updates are available.");
|
||||
|
||||
using (var updateManager = new UpdateManager(UpdatePath))
|
||||
{
|
||||
var updateInfo = await updateManager.CheckForUpdate();
|
||||
@@ -44,7 +65,9 @@ namespace BodyshopPartner.Utils
|
||||
|
||||
}
|
||||
|
||||
public static async Task ApplyUpdates(int DownloadProgress, int InstallProgress)
|
||||
public delegate void DownloadProgress(int value);
|
||||
public delegate void InstallProgress(int value);
|
||||
public static async Task ApplyUpdates(DownloadProgress DownloadProgress, InstallProgress InstallProgress)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -65,13 +88,14 @@ namespace BodyshopPartner.Utils
|
||||
await updateManager.DownloadReleases(releases, _ =>
|
||||
{
|
||||
logger.Debug("Download Release Progress " + _.ToString());
|
||||
DownloadProgress = _;
|
||||
DownloadProgress(_);
|
||||
});
|
||||
await updateManager.ApplyReleases(updateInfo, _ =>
|
||||
{
|
||||
logger.Debug("Install Progress " + _.ToString());
|
||||
InstallProgress = _;
|
||||
InstallProgress(_);
|
||||
});
|
||||
UpdateManager.RestartApp(System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user