Added update handler.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
<description>ImEX Online Partner</description>
|
||||
</metadata>
|
||||
<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>
|
||||
</package>
|
||||
@@ -14,7 +14,7 @@ namespace BodyshopPartner.Utils
|
||||
{
|
||||
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()
|
||||
{
|
||||
@@ -55,6 +55,7 @@ namespace BodyshopPartner.Utils
|
||||
{
|
||||
var updateInfo = await updateManager.CheckForUpdate();
|
||||
var releases = updateInfo.ReleasesToApply;
|
||||
logger.Debug("Applying releases", releases.ToString());
|
||||
await updateManager.DownloadReleases(releases, _ => { DownloadProgress = _; });
|
||||
await updateManager.ApplyReleases(updateInfo, _ => { InstallProgress = _; });
|
||||
}
|
||||
|
||||
@@ -83,15 +83,24 @@ namespace BodyshopPartner.ViewModels
|
||||
_callingThread.ReportProgress(80);
|
||||
logger.Debug("VM Init Complete");
|
||||
Task.Run(() => Utils.HTTPServer.InitHttpServer(AddHttpStatus));
|
||||
Task.Run(() => updateCheck());
|
||||
_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)
|
||||
{
|
||||
if (await Utils.UpdateHandler.AreUpdatesAvailable())
|
||||
{
|
||||
await Utils.UpdateHandler.ApplyUpdates(Progress, Progress);
|
||||
}
|
||||
await updateCheck();
|
||||
}
|
||||
|
||||
private void MonitoringPathsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
@@ -206,7 +215,7 @@ namespace BodyshopPartner.ViewModels
|
||||
IndeterminateLoading = true;
|
||||
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;
|
||||
var r = new GraphQLRequest
|
||||
{
|
||||
@@ -228,10 +237,10 @@ namespace BodyshopPartner.ViewModels
|
||||
};
|
||||
await Utils.GraphQL.ExecuteQuery(r);
|
||||
}
|
||||
Properties.Settings.Default.LastSelectedShop = ActiveShop.Id;
|
||||
Properties.Settings.Default.LastSelectedShop = ActiveShop?.Id;
|
||||
Properties.Settings.Default.Save();
|
||||
Utils.AppMetaData.ActiveShopId = ActiveShop.Id;
|
||||
Utils.AppMetaData.ShopRegion = ActiveShop.RegionConfig;
|
||||
Utils.AppMetaData.ActiveShopId = ActiveShop?.Id;
|
||||
Utils.AppMetaData.ShopRegion = ActiveShop?.RegionConfig;
|
||||
IndeterminateLoading = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BodyshopPartner.Utils.Growls;
|
||||
using BodyshopPartner.Models;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BodyshopPartner.ViewModels
|
||||
{
|
||||
@@ -55,5 +56,12 @@ namespace BodyshopPartner.ViewModels
|
||||
get { return _httpServerLog; }
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
Title="{x:Static p:Resources.Title_Main}"
|
||||
Height="450"
|
||||
Height="489.819"
|
||||
Width="800"
|
||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||
TextElement.FontWeight="Regular"
|
||||
@@ -108,7 +108,7 @@
|
||||
</tb:TaskbarIcon>
|
||||
|
||||
<StackPanel DockPanel.Dock="Right">
|
||||
|
||||
|
||||
<ComboBox ItemsSource="{Binding ShopData}"
|
||||
Margin="8"
|
||||
SelectedItem="{Binding ActiveShop}"
|
||||
@@ -135,7 +135,7 @@
|
||||
<Button Command="{Binding StopFolderMonitorsCommand, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="8"
|
||||
Content="{x:Static p:Resources.Label_StopAllMonitors}" />
|
||||
|
||||
|
||||
<Button Command="{Binding StopFolderMonitorsCommand, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="8"
|
||||
Content="{x:Static p:Resources.Label_StopAllMonitors}" />
|
||||
@@ -149,6 +149,9 @@
|
||||
Command="{Binding TestCommand}"
|
||||
Background="Tomato"
|
||||
Content="_TEST COMMAND" />
|
||||
<Label DockPanel.Dock="Top"
|
||||
Margin="8"
|
||||
Content="{Binding AppVersion}" />
|
||||
|
||||
</StackPanel>
|
||||
<Grid>
|
||||
@@ -216,10 +219,12 @@
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<DockPanel Grid.Row="1"
|
||||
Height="Auto">
|
||||
<TextBox DockPanel.Dock="Top" Text="{Binding Source={x:Static properties:Settings.Default},
|
||||
Height="Auto">
|
||||
<TextBox DockPanel.Dock="Top"
|
||||
Text="{Binding Source={x:Static properties:Settings.Default},
|
||||
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"
|
||||
materialDesign:HintAssist.Hint="{x:Static p:Resources.Label_InteractionLog}"
|
||||
Text="{Binding HttpServerLog}"
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<description>ImEX Online Partner</description>
|
||||
</metadata>
|
||||
<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>
|
||||
</package>
|
||||
Reference in New Issue
Block a user