aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-12-15 16:52:30 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-12-15 16:52:30 +0200
commit66be0fdd579050375421ad54dc25cf35bac0845c (patch)
tree429ebbf390862a2cc1dcad40aecb96a1399c7ab0 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parent97513f619e9778e8409831db04b29b0dcf53f1b9 (diff)
downloadTango-66be0fdd579050375421ad54dc25cf35bac0845c.tar.gz
Tango-66be0fdd579050375421ad54dc25cf35bac0845c.zip
Implemented several fallbacks to PPC update failure !
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs34
1 files changed, 33 insertions, 1 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 613c70809..5fe153ee9 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs
@@ -17,8 +17,11 @@ using Tango.Explorer;
using Tango.Integration.ExternalBridge;
using Tango.PMR.FirmwareUpgrade;
using Tango.PPC.Common;
+using Tango.PPC.Common.Application;
using Tango.PPC.Common.ExternalBridge;
using Tango.PPC.Common.MachineUpdate;
+using Tango.PPC.Common.Navigation;
+using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.Publish;
using Tango.PPC.Common.Web;
using Tango.PPC.Shared.RemoteUpgrade;
@@ -121,7 +124,7 @@ namespace Tango.PPC.UI.ViewModels
#region Constructors
- public MachineUpdateViewVM(IMachineUpdateManager machineUpdateManager, IPPCExternalBridgeService externalBridge)
+ public MachineUpdateViewVM(IMachineUpdateManager machineUpdateManager, IPPCExternalBridgeService externalBridge, IPPCApplicationManager applicationManager, INavigationManager navigationManager, INotificationProvider notificationProvider)
{
MachineUpdateManager = machineUpdateManager;
externalBridge.RegisterRequestHandler(this);
@@ -142,6 +145,11 @@ namespace Tango.PPC.UI.ViewModels
});
machineUpdateManager.UpdateAvailable += MachineUpdateManager_UpdateAvailable;
+
+ NavigationManager = navigationManager;
+ NotificationProvider = notificationProvider;
+ ApplicationManager = applicationManager;
+ ApplicationManager.UpdaterFailed += ApplicationManager_UpdaterFailed;
}
#endregion
@@ -565,6 +573,30 @@ namespace Tango.PPC.UI.ViewModels
#endregion
+ #region Updater Failed
+
+ private void ApplicationManager_UpdaterFailed(object sender, EventArgs e)
+ {
+ InvokeUI(async () =>
+ {
+ try
+ {
+ await NavigationManager.NavigateTo(NavigationView.MachineUpdateView);
+ await NavigateTo(MachineUpdateView.UpdateProgressView);
+ await MachineUpdateManager.RestoreLastDatabaseBackup();
+ await Task.Delay(5000);
+ ApplicationManager.Restart();
+ }
+ catch (Exception ex)
+ {
+ await NotificationProvider.ShowError($"Could not restore the application to its previous state.\n{ex.FlattenMessage()}");
+ ApplicationManager.Restart();
+ }
+ });
+ }
+
+ #endregion
+
#region External Bridge Handler
[ExternalBridgeRequestHandlerMethod(typeof(StartRemoteApplicationUpgradeRequest), RequestHandlerLoggingMode.LogRequestName)]