Further improvements for update handling. IO-408
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.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.4.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
//Setting Squirrel Aware Version.
|
||||
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]
|
||||
@@ -160,7 +160,7 @@ namespace BodyshopPartner.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Browse for QB File.
|
||||
/// Looks up a localized string similar to Browse for QuickBooks File.
|
||||
/// </summary>
|
||||
public static string Label_BrowseForQb {
|
||||
get {
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
<value>Auto-start Monitors</value>
|
||||
</data>
|
||||
<data name="Label_BrowseForQb" xml:space="preserve">
|
||||
<value>Browse for QB File</value>
|
||||
<value>Browse for QuickBooks File</value>
|
||||
</data>
|
||||
<data name="Label_FilePath" xml:space="preserve">
|
||||
<value>File Path</value>
|
||||
|
||||
7
BodyshopUploader/Releases/RELEASES
Normal file
7
BodyshopUploader/Releases/RELEASES
Normal file
@@ -0,0 +1,7 @@
|
||||
CC5A9E1708874E6ACB29A5622DFD9C5772230727 ImEXOnlinePartner-1.0.0-full.nupkg 4937580
|
||||
7C5340F2B41ECAAA84BEE8ACD790135A64485D29 ImEXOnlinePartner-1.0.1-delta.nupkg 36746
|
||||
DCD839653F086BCA57F1D32A5235FFD63656E828 ImEXOnlinePartner-1.0.1-full.nupkg 4936984
|
||||
AF4689DFA19C7EAC5E1F03DFCF298A05B550198B ImEXOnlinePartner-1.0.2-delta.nupkg 30212
|
||||
F2D64AFC971565D6A6AB3C69D39918BA651D2BB3 ImEXOnlinePartner-1.0.2-full.nupkg 4938834
|
||||
B28BABEA8C23215EE92CD691B8F69CEEC40D04C8 ImEXOnlinePartner-1.0.3-delta.nupkg 30700
|
||||
CA43E2BC60A8A67126609C5682AA3D39D68D2400 ImEXOnlinePartner-1.0.3-full.nupkg 4935967
|
||||
@@ -63,12 +63,20 @@ namespace BodyshopPartner.Utils
|
||||
{
|
||||
logger.Fatal("Unable to set exception for http port", Ex.ToString());
|
||||
}
|
||||
|
||||
Utils.UpdateHandler.ToggleStartWithWindows(true);
|
||||
mgr.CreateShortcutForThisExe();
|
||||
},
|
||||
onAppUpdate: v => mgr.CreateShortcutForThisExe(),
|
||||
onAppUpdate: v => {
|
||||
mgr.CreateShortcutForThisExe();
|
||||
Utils.UpdateHandler.ToggleStartWithWindows(Properties.Settings.Default.StartWithWindows);
|
||||
},
|
||||
onAppUninstall: v => mgr.RemoveShortcutForThisExe(),
|
||||
onFirstRun: () => { logger.Info("We've run for the first time."); });
|
||||
onFirstRun: () =>
|
||||
{
|
||||
logger.Info("We've run for the first time.");
|
||||
|
||||
Utils.UpdateHandler.ToggleStartWithWindows(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace BodyshopPartner.ViewModels
|
||||
async p =>
|
||||
{
|
||||
await InstallUpdates();
|
||||
UpdateAvailable = false;
|
||||
|
||||
});
|
||||
}
|
||||
return _installUpdatesCommand;
|
||||
@@ -203,7 +203,7 @@ namespace BodyshopPartner.ViewModels
|
||||
p => true,
|
||||
p =>
|
||||
{
|
||||
ToggleStartWithWindows((bool)(p));
|
||||
Utils.UpdateHandler.ToggleStartWithWindows((bool)(p));
|
||||
});
|
||||
}
|
||||
return _startWithWindowsCommand;
|
||||
|
||||
@@ -97,12 +97,13 @@ namespace BodyshopPartner.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task InstallUpdates()
|
||||
{
|
||||
logger.Debug("Updates are available! Installing.");
|
||||
try
|
||||
{
|
||||
await Utils.UpdateHandler.ApplyUpdates(UpdateProgress, UpdateProgress);
|
||||
await Utils.UpdateHandler.ApplyUpdates((val) => UpdateProgress = val, (val) => UpdateProgress = val);
|
||||
|
||||
}
|
||||
catch (Exception Ex)
|
||||
@@ -198,22 +199,6 @@ namespace BodyshopPartner.ViewModels
|
||||
App.Current.Shutdown();
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task LoadBodyshopData()
|
||||
{
|
||||
|
||||
@@ -149,12 +149,13 @@
|
||||
Margin="8"
|
||||
Content="{x:Static p:Resources.Label_BrowseForQb}" />
|
||||
<Separator />
|
||||
<Button DockPanel.Dock="Top"
|
||||
<!--<Button DockPanel.Dock="Top"
|
||||
Margin="8"
|
||||
Command="{Binding TestCommand}"
|
||||
Content="DEVELOPER TEST" />
|
||||
Content="DEVELOPER TEST" />-->
|
||||
<Label DockPanel.Dock="Top"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Center"
|
||||
Content="{Binding AppVersion}" />
|
||||
<StackPanel Visibility="{Binding UpdateAvailable, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user