From eed57807589a6de896c27e988e2d0e8d1358faa4 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 23 Oct 2018 15:41:42 +0300 Subject: Added storage api proto files. --- .../ViewModels/MainViewVM.cs | 62 +++++++++++++--------- 1 file changed, 36 insertions(+), 26 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 49a8ca807..9b625a6ee 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -445,6 +445,11 @@ namespace Tango.MachineStudio.UI.ViewModels } } + x.SelectedMachine.EnableDiagnostics = x.EnableDiagnostics; + x.SelectedMachine.EnableEmbeddedDebugging = x.EnableDiagnostics; + x.SelectedMachine.EnableEventsNotification = x.EnableDiagnostics; + x.SelectedMachine.UseKeepAlive = x.EnableKeepAlive; + if (x.SelectedMachine.RequiresAuthentication) { _notificationProvider.ShowModalDialog(async (login) => @@ -453,11 +458,6 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - if (x.SelectedMachine.EnableDiagnostics) - { - x.SelectedMachine.EnableEmbeddedDebugging = true; - } - await x.SelectedMachine.As().Connect(new PMR.Integration.ExternalBridgeLoginRequest() { AppID = "Machine Studio", @@ -479,6 +479,11 @@ namespace Tango.MachineStudio.UI.ViewModels PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber)); + if (x.UploadHardwareConfiguration) + { + UploadHardwareConfiguration(); + } + } catch (ResponseErrorException ex) { @@ -507,11 +512,6 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - if (x.SelectedMachine.EnableDiagnostics) - { - x.SelectedMachine.EnableEmbeddedDebugging = true; - } - await x.SelectedMachine.Connect(); x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber; ApplicationManager.SetConnectedMachine(x.SelectedMachine); @@ -520,6 +520,11 @@ namespace Tango.MachineStudio.UI.ViewModels _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber)); _settings.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber; _settings.Save(); + + if (x.UploadHardwareConfiguration) + { + UploadHardwareConfiguration(); + } } catch (Exception ex) { @@ -560,22 +565,7 @@ namespace Tango.MachineStudio.UI.ViewModels { using (NotificationProvider.PushTaskItem("Uploading hardware configuration...")) { - try - { - using (ObservablesContext db = ObservablesContext.CreateDefault()) - { - var config = db.Adapter.GetConfiguration(s => s.Guid == ApplicationManager.Machine.ConfigurationGuid); - var hw = db.Adapter.GetHardwareVersionByMachine(ApplicationManager.Machine.Guid); - - await ApplicationManager.ConnectedMachine.UploadHardwareConfiguration(hw, config); - } - NotificationProvider.ShowInfo("Hardware configuration uploaded successfully."); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error uploading hardware configuration."); - NotificationProvider.ShowError("Error uploading hardware configuration." + Environment.NewLine + ex.Message); - } + UploadHardwareConfiguration(); } } } @@ -623,6 +613,26 @@ namespace Tango.MachineStudio.UI.ViewModels InvalidateRelayCommands(); } + private async void UploadHardwareConfiguration() + { + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var config = db.Adapter.GetConfiguration(s => s.Guid == ApplicationManager.Machine.ConfigurationGuid); + var hw = db.Adapter.GetHardwareVersionByMachine(ApplicationManager.Machine.Guid); + + await ApplicationManager.ConnectedMachine.UploadHardwareConfiguration(hw, config); + } + NotificationProvider.ShowInfo("Hardware configuration uploaded successfully."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error uploading hardware configuration."); + NotificationProvider.ShowError("Error uploading hardware configuration." + Environment.NewLine + ex.Message); + } + } + /// /// Navigates to the home screen. /// -- cgit v1.3.1