aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs78
1 files changed, 67 insertions, 11 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
index 84e65e516..2bdeffadf 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
@@ -23,11 +23,13 @@ namespace Tango.PPC.UI.ViewModels
UpdateAvailableView,
UpToDateView,
UpdateProgressView,
+ UpdateDbProgressView,
UpdateCompletedView,
UpdateFailedView,
}
private MachineUpdateResult _update_result;
+ private DbCompareResult _db_compare_result;
#region Properties
@@ -46,6 +48,16 @@ namespace Tango.PPC.UI.ViewModels
set { _latestVersion = value; RaisePropertyChangedAuto(); }
}
+ private bool _isDbUpdate;
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is database update.
+ /// </summary>
+ public bool IsDbUpdate
+ {
+ get { return _isDbUpdate; }
+ set { _isDbUpdate = value; RaisePropertyChangedAuto(); }
+ }
+
#endregion
#region Commands
@@ -70,6 +82,11 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
public RelayCommand CloseCommand { get; set; }
+ /// <summary>
+ /// Gets or sets to application command.
+ /// </summary>
+ public RelayCommand ToApplicationCommand { get; set; }
+
#endregion
#region Constructors
@@ -86,6 +103,12 @@ namespace Tango.PPC.UI.ViewModels
NavigationManager.NavigateTo(Common.Navigation.NavigationView.HomeModule);
NavigateTo(MachineUpdateView.UpdateCheckView);
});
+
+ ToApplicationCommand = new RelayCommand(() =>
+ {
+ NavigationManager.NavigateTo(Common.Navigation.NavigationView.HomeModule);
+ NavigateTo(MachineUpdateView.UpdateCheckView);
+ });
}
#endregion
@@ -98,6 +121,8 @@ namespace Tango.PPC.UI.ViewModels
try
{
+ IsDbUpdate = false;
+
var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber, "http://localhost:51581/");
if (response.IsUpdateAvailable)
@@ -107,7 +132,17 @@ namespace Tango.PPC.UI.ViewModels
}
else
{
- await NavigateTo(MachineUpdateView.UpToDateView);
+ _db_compare_result = await MachineUpdateManager.UpdateDBCheck(MachineProvider.Machine.SerialNumber, "http://localhost:51581/");
+
+ if (_db_compare_result.RequiresUpdate)
+ {
+ IsDbUpdate = true;
+ await NavigateTo(MachineUpdateView.UpdateAvailableView);
+ }
+ else
+ {
+ await NavigateTo(MachineUpdateView.UpToDateView);
+ }
}
}
catch (Exception ex)
@@ -119,20 +154,41 @@ namespace Tango.PPC.UI.ViewModels
private async void Update()
{
- await NavigateTo(MachineUpdateView.UpdateProgressView);
+ if (!IsDbUpdate)
+ {
+ await NavigateTo(MachineUpdateView.UpdateProgressView);
- LogManager.Log("Starting machine update...");
+ LogManager.Log("Starting machine update...");
- try
- {
- _update_result = await MachineUpdateManager.Update(MachineProvider.Machine.SerialNumber, "http://localhost:51581/");
- LogManager.Log("Machine update completed.");
- await NavigateTo(MachineUpdateView.UpdateCompletedView);
+ try
+ {
+ _update_result = await MachineUpdateManager.Update(MachineProvider.Machine.SerialNumber, "http://localhost:51581/");
+ LogManager.Log("Machine update completed.");
+ await NavigateTo(MachineUpdateView.UpdateCompletedView);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Machine update failed.");
+ await NavigateTo(MachineUpdateView.UpdateFailedView);
+ }
}
- catch (Exception ex)
+ else
{
- LogManager.Log(ex, "Machine update failed.");
- await NavigateTo(MachineUpdateView.UpdateFailedView);
+ await NavigateTo(MachineUpdateView.UpdateDbProgressView);
+
+ LogManager.Log("Starting database update...");
+
+ try
+ {
+ await MachineUpdateManager.UpdateDB(_db_compare_result);
+ LogManager.Log("Database update completed.");
+ await NavigateTo(MachineUpdateView.UpToDateView);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Database update failed.");
+ await NavigateTo(MachineUpdateView.UpdateFailedView);
+ }
}
}