From 69c55f54ee7217f16419049a311ce437d3c19157 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 13 Feb 2019 20:02:59 +0200 Subject: Fixed issue with PPC WIFI connection profiles. Implemented OS restart after first setup. Prevented PPC updater crashes without restarting PPC. Implemented restarting system view on PPC. --- .../Connectivity/DefaultConnectivityProvider.cs | 11 +++++- .../PPCApplication/DefaultPPCApplicationManager.cs | 19 +++++++++ .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 8 ++++ .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 9 +++++ .../ViewModels/RestartingSystemViewVM.cs | 45 ++++++++++++++++++++++ .../PPC/Tango.PPC.UI/Views/MachineSetupView.xaml | 2 +- .../PPC/Tango.PPC.UI/Views/MainView.xaml | 1 + .../Tango.PPC.UI/Views/RestartingSystemView.xaml | 27 +++++++++++++ .../Views/RestartingSystemView.xaml.cs | 28 ++++++++++++++ .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- 10 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingSystemViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs index a05e66f10..5fc7f00df 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs @@ -224,7 +224,14 @@ namespace Tango.PPC.UI.Connectivity if (vm.DialogResult) { - result = await network.Connect(auth); + result = await network.Connect(auth, true); + + if (!result) + { + await _notification.ShowError("Could not connect to the specified network. Please check your password."); + await network.Forget(); + } + await RefreshAvailableWiFiNetworks(); } else @@ -234,7 +241,7 @@ namespace Tango.PPC.UI.Connectivity } else { - result = await network.Connect(auth); + result = await network.Connect(auth, false); await RefreshAvailableWiFiNetworks(); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 2929908cc..39ce8cd30 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -45,6 +45,11 @@ namespace Tango.PPC.UI.PPCApplication private IPPCModuleLoader _moduleLoader; private INotificationProvider _notificationProvider; + /// + /// Occurs when a system restart is required. + /// + public event EventHandler SystemRestartRequired; + /// /// Occurs when the application has started. /// @@ -141,6 +146,7 @@ namespace Tango.PPC.UI.PPCApplication PPCSettings settings = null; bool initialized = false; + bool isAfterSetup = false; await Task.Factory.StartNew(() => { @@ -163,8 +169,21 @@ namespace Tango.PPC.UI.PPCApplication if (App.StartupArgs.Contains("-update_ok")) { LogManager.Log("Application started with '-update_ok' startup arguments. The application has been successfully updated."); + + if (settings.ApplicationState == ApplicationStates.PreSetup) + { + isAfterSetup = true; + LogManager.Log("System restart is required."); + } + settings.ApplicationState = ApplicationStates.Ready; settings.Save(); + + if (isAfterSetup) + { + SystemRestartRequired?.Invoke(this, new EventArgs()); + return; + } } if (settings.ApplicationState == ApplicationStates.Ready) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 17598c085..f40bfa7de 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -144,6 +144,7 @@ + @@ -174,6 +175,9 @@ NoPermissionsView.xaml + + RestartingSystemView.xaml + Designer MSBuild:Compile @@ -242,6 +246,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 444fd70b9..4eb5475f0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -102,6 +102,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); TangoIOC.Default.GetInstance().ContentRendered += (_, __) => @@ -191,5 +192,13 @@ namespace Tango.PPC.UI return TangoIOC.Default.GetInstance(); } } + + public static RestartingSystemViewVM RestartingSystemViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingSystemViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingSystemViewVM.cs new file mode 100644 index 000000000..b1cb57fce --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/RestartingSystemViewVM.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; +using Tango.PPC.Common.Application; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.OS; + +namespace Tango.PPC.UI.ViewModels +{ + public class RestartingSystemViewVM : PPCViewModel + { + private IOperationSystemManager _os; + private INavigationManager _navigationManager; + + public RestartingSystemViewVM(IPPCApplicationManager applicationManager, IOperationSystemManager operationSystemManager, INavigationManager navigationManager) + { + _navigationManager = navigationManager; + _os = operationSystemManager; + applicationManager.SystemRestartRequired += ApplicationManager_SystemRestartRequired; + } + + private void ApplicationManager_SystemRestartRequired(object sender, EventArgs e) + { + InvokeUI(() => + { + _navigationManager.NavigateTo(NavigationView.RestartingSystemView); + }); + } + + public async override void OnNavigatedTo() + { + base.OnNavigatedTo(); + await Task.Delay(2000); + _os.Restart(); + } + + public override void OnApplicationStarted() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index 30b99dbbf..9437caac9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -65,7 +65,7 @@ Checking internet connection, please wait... - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index 6d1bde59d..c6e3fa6ea 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -89,6 +89,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml new file mode 100644 index 000000000..996b1788d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml @@ -0,0 +1,27 @@ + + + + + + + + Setup completed. + + + + Restarting the system for the last time... + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml.cs new file mode 100644 index 000000000..1b426192e --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.Views +{ + /// + /// Interaction logic for RestartingSystemView.xaml + /// + public partial class RestartingSystemView : UserControl + { + public RestartingSystemView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + -- cgit v1.3.1