diff options
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.cs | 48 |
1 files changed, 47 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 451cd07a1..f582d0bb0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.Core.Helpers; +using Tango.Explorer; using Tango.PPC.Common; using Tango.PPC.Common.MachineUpdate; using Tango.PPC.UI.ViewsContracts; @@ -17,7 +18,6 @@ namespace Tango.PPC.UI.ViewModels { public enum MachineUpdateView { - UpdateCheckView, UpdateCheckErrorView, UpdateAvailableView, @@ -26,6 +26,8 @@ namespace Tango.PPC.UI.ViewModels UpdateDbProgressView, UpdateCompletedView, UpdateFailedView, + UpdateFromPackageView, + UpdateFailedFromPackageView, } private MachineUpdateResult _update_result; @@ -209,6 +211,11 @@ namespace Tango.PPC.UI.ViewModels #endregion + #region Override Methods + + /// <summary> + /// Called when the application has been started. + /// </summary> public override void OnApplicationStarted() { @@ -222,5 +229,44 @@ namespace Tango.PPC.UI.ViewModels { return View.NavigateTo(view); } + + /// <summary> + /// Called when the application is ready and all modules views are loaded. + /// </summary> + public override void OnApplicationReady() + { + base.OnApplicationReady(); + + StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Update.Extension, HandleSoftwareUpdatePackageLoaded); + } + + #endregion + + #region Handle USB Update + + private async void HandleSoftwareUpdatePackageLoaded(ExplorerFileItem fileItem) + { + if (await NotificationProvider.ShowQuestion("Do you with to install the selected software package?")) + { + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.MachineUpdateView); + await NavigateTo(MachineUpdateView.UpdateFromPackageView); + + LogManager.Log("Starting machine update from package..."); + + try + { + _update_result = await MachineUpdateManager.Update(fileItem.Path); + LogManager.Log("Machine update from package completed."); + await NavigateTo(MachineUpdateView.UpdateCompletedView); + } + catch (Exception ex) + { + LogManager.Log(ex, "Machine update from package failed."); + await NavigateTo(MachineUpdateView.UpdateFailedFromPackageView); + } + } + } + + #endregion } } |
