Base squirrel config.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\squirrel.windows.1.9.1\build\squirrel.windows.props" Condition="Exists('..\packages\squirrel.windows.1.9.1\build\squirrel.windows.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -55,6 +56,15 @@
|
||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DeltaCompressionDotNet, Version=1.1.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet.MsDelta, Version=1.1.0.0, Culture=neutral, PublicKeyToken=46b2138a390abf55, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.MsDelta.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.1.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DotNetDBF, Version=6.0.0.3, Culture=neutral, PublicKeyToken=9c071727b589770e, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DotNetDBF.6.0.0.3\lib\net35\DotNetDBF.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -81,15 +91,39 @@
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.6.8\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\squirrel.windows.1.9.1\lib\Net45\NuGet.Squirrel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Ookii.Dialogs.Wpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0c15020868fd6249, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Ookii.Dialogs.1.0\lib\net35\Ookii.Dialogs.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpCompress, Version=0.17.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpCompress.0.17.1\lib\net45\SharpCompress.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Squirrel, Version=1.9.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\squirrel.windows.1.9.1\lib\Net45\Squirrel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.AppContext, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll</HintPath>
|
||||
@@ -287,6 +321,7 @@
|
||||
<Compile Include="Utils\RelayCommand.cs" />
|
||||
<Compile Include="Utils\TrayIcon.cs" />
|
||||
<Compile Include="Utils\UiConverters.cs" />
|
||||
<Compile Include="Utils\UpdateHandler.cs" />
|
||||
<Compile Include="ViewModels\LoginViewModel.commands.cs" />
|
||||
<Compile Include="ViewModels\LoginViewModel.cs" />
|
||||
<Compile Include="ViewModels\MainViewModel.commands.cs" />
|
||||
@@ -380,6 +415,9 @@
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\squirrel.windows.1.9.1\build\squirrel.windows.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\squirrel.windows.1.9.1\build\squirrel.windows.props'))" />
|
||||
<Error Condition="!Exists('..\packages\squirrel.windows.1.9.1\build\squirrel.windows.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\squirrel.windows.1.9.1\build\squirrel.windows.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
|
||||
<Import Project="..\packages\squirrel.windows.1.9.1\build\squirrel.windows.targets" Condition="Exists('..\packages\squirrel.windows.1.9.1\build\squirrel.windows.targets')" />
|
||||
</Project>
|
||||
112
BodyshopUploader/Utils/UpdateHandler.cs
Normal file
112
BodyshopUploader/Utils/UpdateHandler.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using Squirrel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BodyshopUploader.Utils
|
||||
{
|
||||
public static class UpdateHandler
|
||||
{
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public const string UpdatePath = @"https://bodyshop.snapt.ca";
|
||||
|
||||
public static async Task<bool> AreUpdatesAvailable()
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Debug("Checking if updates are available.");
|
||||
using (var updateManager = new UpdateManager(UpdatePath))
|
||||
{
|
||||
var updateInfo = await updateManager.CheckForUpdate();
|
||||
if (updateInfo == null || !updateInfo.ReleasesToApply.Any())
|
||||
{
|
||||
logger.Debug("No releases to apply.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
logger.Error(Ex, "Unable to retrieve updates. ");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static async Task ApplyUpdates(int DownloadProgress, int InstallProgress)
|
||||
{
|
||||
try
|
||||
{
|
||||
BackupSettings();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, "Unable to backup settings.");
|
||||
}
|
||||
|
||||
using (var updateManager = new UpdateManager(UpdatePath))
|
||||
{
|
||||
var updateInfo = await updateManager.CheckForUpdate();
|
||||
var releases = updateInfo.ReleasesToApply;
|
||||
await updateManager.DownloadReleases(releases, _ => { DownloadProgress = _; });
|
||||
await updateManager.ApplyReleases(updateInfo, _ => { InstallProgress = _; });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void BackupSettings()
|
||||
{
|
||||
string settingsFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;
|
||||
string destination = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\..\\last.config";
|
||||
logger.Trace("Backup settings from: {0} to: {1}", settingsFile, destination);
|
||||
File.Copy(settingsFile, destination, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restore our settings backup if any.
|
||||
/// Used to persist settings across updates.
|
||||
/// </summary>
|
||||
public static void RestoreSettings()
|
||||
{
|
||||
//Restore settings after application update
|
||||
string destFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;
|
||||
string sourceFile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\..\\last.config";
|
||||
// Check if we have settings that we need to restore
|
||||
if (!File.Exists(sourceFile))
|
||||
{
|
||||
// Nothing we need to do
|
||||
return;
|
||||
}
|
||||
// Create directory as needed
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destFile));
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
// Copy our backup file in place
|
||||
try
|
||||
{
|
||||
logger.Trace("Restore settings from: {0} to: {1}", sourceFile, destFile);
|
||||
File.Copy(sourceFile, destFile, true);
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
// Delete backup files
|
||||
try
|
||||
{
|
||||
File.Delete(sourceFile);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,11 @@ namespace BodyshopUploader.ViewModels
|
||||
|
||||
_callingThread.ReportProgress(30);
|
||||
|
||||
_updateCheckTimer.Elapsed += _updateTimer_Elapsed;
|
||||
_updateCheckTimer.AutoReset = true;
|
||||
_updateCheckTimer.Start();
|
||||
|
||||
_callingThread.ReportProgress(50);
|
||||
//Cannot use await.
|
||||
LoadBodyshopData().Wait(); ;
|
||||
|
||||
@@ -74,6 +79,13 @@ namespace BodyshopUploader.ViewModels
|
||||
_callingThread.ReportProgress(100);
|
||||
}
|
||||
|
||||
private async void _updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if(await Utils.UpdateHandler.AreUpdatesAvailable())
|
||||
{
|
||||
await Utils.UpdateHandler.ApplyUpdates(Progress, Progress);
|
||||
}
|
||||
}
|
||||
|
||||
private void MonitoringPathsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace BodyshopUploader.ViewModels
|
||||
public partial class MainViewModel : BaseViewModel
|
||||
{
|
||||
public GrowlNotification Growler;
|
||||
private System.Timers.Timer _updateCheckTimer = new System.Timers.Timer(60 * 1000);
|
||||
|
||||
private ObservableCollection<Monitor> _monitoringPaths = new ObservableCollection<Monitor>();
|
||||
public ObservableCollection<Monitor> MonitoringPaths
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace BodyshopUploader.Views
|
||||
{
|
||||
public Login()
|
||||
{
|
||||
Utils.UpdateHandler.RestoreSettings();
|
||||
Properties.Settings.Default.Reload();
|
||||
|
||||
InitializeComponent();
|
||||
Utils.ApplicationExceptionHandler.InitExceptionHandlers();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net472" />
|
||||
<package id="DotNetDBF" version="6.0.0.3" targetFramework="net472" />
|
||||
<package id="FirebaseAuthentication.net" version="3.4.0" targetFramework="net472" />
|
||||
<package id="GraphQL.Client" version="1.0.3" targetFramework="net472" />
|
||||
@@ -10,12 +11,16 @@
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net472" />
|
||||
<package id="Microsoft.NETCore.Platforms" version="3.1.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net472" />
|
||||
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net472" />
|
||||
<package id="NETStandard.Library" version="2.0.3" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
|
||||
<package id="NLog" version="4.6.8" targetFramework="net472" />
|
||||
<package id="NLog.Config" version="4.6.8" targetFramework="net472" />
|
||||
<package id="NLog.Schema" version="4.6.8" targetFramework="net472" />
|
||||
<package id="Ookii.Dialogs" version="1.0" targetFramework="net472" />
|
||||
<package id="SharpCompress" version="0.17.1" targetFramework="net472" />
|
||||
<package id="Splat" version="1.6.2" targetFramework="net472" />
|
||||
<package id="squirrel.windows" version="1.9.1" targetFramework="net472" />
|
||||
<package id="System.AppContext" version="4.3.0" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
|
||||
|
||||
Reference in New Issue
Block a user