diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-25 17:52:49 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-25 17:52:49 +0200 |
| commit | 9277bbd2fa070c69b83904f8fe5628fab2b947b8 (patch) | |
| tree | 3099f9ce92f04c28517eb13938e913a1e376b3fe /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | |
| parent | f779e2b6f0bb1dedc7644c64651b59e31ce62c00 (diff) | |
| download | Tango-9277bbd2fa070c69b83904f8fe5628fab2b947b8.tar.gz Tango-9277bbd2fa070c69b83904f8fe5628fab2b947b8.zip | |
Working on job export import to storage.
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 } } |
