Added update handler.
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
<description>ImEX Online Partner</description>
|
<description>ImEX Online Partner</description>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
<file src="*.*" target="lib\net45\" exclude="*.pdb;*.nupkg;*.vshost.*"/>
|
<file src="*.*" target="lib\net45\" exclude="*.pdb;*.nupkg;*.vshost.*"/>
|
||||||
|
<file src="**\*.*" target="lib\net45\" exclude="*.pdb;*.nupkg;*.vshost.*"/>
|
||||||
</files>
|
</files>
|
||||||
</package>
|
</package>
|
||||||
@@ -14,7 +14,7 @@ namespace BodyshopPartner.Utils
|
|||||||
{
|
{
|
||||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public const string UpdatePath = @"https://update.partner.imex.online";
|
public const string UpdatePath = @"http://partner.imex.online/";
|
||||||
|
|
||||||
public static async Task<bool> AreUpdatesAvailable()
|
public static async Task<bool> AreUpdatesAvailable()
|
||||||
{
|
{
|
||||||
@@ -55,6 +55,7 @@ namespace BodyshopPartner.Utils
|
|||||||
{
|
{
|
||||||
var updateInfo = await updateManager.CheckForUpdate();
|
var updateInfo = await updateManager.CheckForUpdate();
|
||||||
var releases = updateInfo.ReleasesToApply;
|
var releases = updateInfo.ReleasesToApply;
|
||||||
|
logger.Debug("Applying releases", releases.ToString());
|
||||||
await updateManager.DownloadReleases(releases, _ => { DownloadProgress = _; });
|
await updateManager.DownloadReleases(releases, _ => { DownloadProgress = _; });
|
||||||
await updateManager.ApplyReleases(updateInfo, _ => { InstallProgress = _; });
|
await updateManager.ApplyReleases(updateInfo, _ => { InstallProgress = _; });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,15 +83,24 @@ namespace BodyshopPartner.ViewModels
|
|||||||
_callingThread.ReportProgress(80);
|
_callingThread.ReportProgress(80);
|
||||||
logger.Debug("VM Init Complete");
|
logger.Debug("VM Init Complete");
|
||||||
Task.Run(() => Utils.HTTPServer.InitHttpServer(AddHttpStatus));
|
Task.Run(() => Utils.HTTPServer.InitHttpServer(AddHttpStatus));
|
||||||
|
Task.Run(() => updateCheck());
|
||||||
_callingThread.ReportProgress(100);
|
_callingThread.ReportProgress(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task updateCheck()
|
||||||
|
{
|
||||||
|
logger.Debug("Checking if updates are available.");
|
||||||
|
if (await Utils.UpdateHandler.AreUpdatesAvailable())
|
||||||
|
{
|
||||||
|
logger.Debug("Updates are available! Installing.");
|
||||||
|
await Utils.UpdateHandler.ApplyUpdates(Progress, Progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async void _updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
private async void _updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
if (await Utils.UpdateHandler.AreUpdatesAvailable())
|
await updateCheck();
|
||||||
{
|
|
||||||
await Utils.UpdateHandler.ApplyUpdates(Progress, Progress);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MonitoringPathsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
private void MonitoringPathsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||||
@@ -206,7 +215,7 @@ namespace BodyshopPartner.ViewModels
|
|||||||
IndeterminateLoading = true;
|
IndeterminateLoading = true;
|
||||||
foreach (var s in ShopData)
|
foreach (var s in ShopData)
|
||||||
{
|
{
|
||||||
if (s.Id == ActiveShop.Id) s.AssociationActive = true;
|
if (s.Id == ActiveShop?.Id) s.AssociationActive = true;
|
||||||
else s.AssociationActive = false;
|
else s.AssociationActive = false;
|
||||||
var r = new GraphQLRequest
|
var r = new GraphQLRequest
|
||||||
{
|
{
|
||||||
@@ -228,10 +237,10 @@ namespace BodyshopPartner.ViewModels
|
|||||||
};
|
};
|
||||||
await Utils.GraphQL.ExecuteQuery(r);
|
await Utils.GraphQL.ExecuteQuery(r);
|
||||||
}
|
}
|
||||||
Properties.Settings.Default.LastSelectedShop = ActiveShop.Id;
|
Properties.Settings.Default.LastSelectedShop = ActiveShop?.Id;
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
Utils.AppMetaData.ActiveShopId = ActiveShop.Id;
|
Utils.AppMetaData.ActiveShopId = ActiveShop?.Id;
|
||||||
Utils.AppMetaData.ShopRegion = ActiveShop.RegionConfig;
|
Utils.AppMetaData.ShopRegion = ActiveShop?.RegionConfig;
|
||||||
IndeterminateLoading = false;
|
IndeterminateLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BodyshopPartner.Utils.Growls;
|
using BodyshopPartner.Utils.Growls;
|
||||||
using BodyshopPartner.Models;
|
using BodyshopPartner.Models;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace BodyshopPartner.ViewModels
|
namespace BodyshopPartner.ViewModels
|
||||||
{
|
{
|
||||||
@@ -55,5 +56,12 @@ namespace BodyshopPartner.ViewModels
|
|||||||
get { return _httpServerLog; }
|
get { return _httpServerLog; }
|
||||||
set { SetProperty(ref _httpServerLog, value); }
|
set { SetProperty(ref _httpServerLog, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string _appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||||
|
public string AppVersion
|
||||||
|
{
|
||||||
|
get { return _appVersion; }
|
||||||
|
set { SetProperty(ref _appVersion, value); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
xmlns:vm="clr-namespace:BodyshopPartner.ViewModels"
|
xmlns:vm="clr-namespace:BodyshopPartner.ViewModels"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="{x:Static p:Resources.Title_Main}"
|
Title="{x:Static p:Resources.Title_Main}"
|
||||||
Height="450"
|
Height="489.819"
|
||||||
Width="800"
|
Width="800"
|
||||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||||
TextElement.FontWeight="Regular"
|
TextElement.FontWeight="Regular"
|
||||||
@@ -149,6 +149,9 @@
|
|||||||
Command="{Binding TestCommand}"
|
Command="{Binding TestCommand}"
|
||||||
Background="Tomato"
|
Background="Tomato"
|
||||||
Content="_TEST COMMAND" />
|
Content="_TEST COMMAND" />
|
||||||
|
<Label DockPanel.Dock="Top"
|
||||||
|
Margin="8"
|
||||||
|
Content="{Binding AppVersion}" />
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -216,10 +219,12 @@
|
|||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
<DockPanel Grid.Row="1"
|
<DockPanel Grid.Row="1"
|
||||||
Height="Auto">
|
Height="Auto">
|
||||||
<TextBox DockPanel.Dock="Top" Text="{Binding Source={x:Static properties:Settings.Default},
|
<TextBox DockPanel.Dock="Top"
|
||||||
|
Text="{Binding Source={x:Static properties:Settings.Default},
|
||||||
Path=QuickBooksFilePath}"
|
Path=QuickBooksFilePath}"
|
||||||
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_QbFilePath}" TextChanged="TextBox_TextChanged"/>
|
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_QbFilePath}"
|
||||||
|
TextChanged="TextBox_TextChanged" />
|
||||||
<TextBox Height="Auto"
|
<TextBox Height="Auto"
|
||||||
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_InteractionLog}"
|
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_InteractionLog}"
|
||||||
Text="{Binding HttpServerLog}"
|
Text="{Binding HttpServerLog}"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<description>ImEX Online Partner</description>
|
<description>ImEX Online Partner</description>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
<file src="*.*" target="lib\net45\" exclude="*.pdb;*.nupkg;*.vshost.*"/>
|
<file src="*.*" target="lib\net45\" exclude="*.pdb;*.nupkg;*.vshost.*"/>
|
||||||
|
<file src="**\*.*" target="lib\net45\" exclude="*.pdb;*.nupkg;*.vshost.*"/>
|
||||||
</files>
|
</files>
|
||||||
</package>
|
</package>
|
||||||
Reference in New Issue
Block a user