From 998cc8d4d91a7f85389cd0918f127257576c2c13 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 13 Aug 2018 16:12:45 +0300 Subject: Logs and comments for PPC.UI ! --- .../Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs | 81 +++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs index 2877d52b3..a81db331c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -19,8 +19,15 @@ using Tango.SQLExaminer; namespace Tango.PPC.UI.ViewModels { + /// + /// Represents the machine setup view ViewModel. + /// + /// public class MachineSetupViewVM : PPCViewModel { + /// + /// Represents the various machine setup view states. + /// public enum MachineSetupStates { None, @@ -31,9 +38,17 @@ namespace Tango.PPC.UI.ViewModels private MachineSetupResult _setup_result; + #region Properties + + /// + /// Gets or sets the machine setup manager. + /// public IMachineSetupManager MachineSetupManager { get; set; } private String _serialNumber; + /// + /// Gets or sets the serial number. + /// public String SerialNumber { get { return _serialNumber; } @@ -41,6 +56,9 @@ namespace Tango.PPC.UI.ViewModels } private String _hostAddress; + /// + /// Gets or sets the host address. + /// public String HostAddress { get { return _hostAddress; } @@ -48,6 +66,9 @@ namespace Tango.PPC.UI.ViewModels } private String _log; + /// + /// Gets or sets the log. + /// public String Log { get { return _log; } @@ -55,16 +76,38 @@ namespace Tango.PPC.UI.ViewModels } private MachineSetupStates _state; + /// + /// Gets or sets the state. + /// public MachineSetupStates State { get { return _state; } set { _state = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + #endregion + + #region Commands + + /// + /// Gets or sets the start command. + /// public RelayCommand StartCommand { get; set; } + /// + /// Gets or sets the complete command. + /// public RelayCommand CompleteCommand { get; set; } + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The application manager. + /// The machine setup manager. public MachineSetupViewVM(IPPCApplicationManager applicationManager, IMachineSetupManager machineSetupManager) { MachineSetupManager = machineSetupManager; @@ -80,11 +123,29 @@ namespace Tango.PPC.UI.ViewModels applicationManager.SetupRequired += ApplicationManager_SetupRequired; } + #endregion + + #region Event Handlers + + /// + /// Handles the SetupRequired event of the ApplicationManager. + /// + /// The source of the event. + /// The instance containing the event data. private void ApplicationManager_SetupRequired(object sender, EventArgs e) { + LogManager.Log("SetupRequired event received. Navigating to MachineSetupView..."); NavigationManager.NavigateTo(NavigationView.MachineSetupView); } + #endregion + + #region Private Methods + + /// + /// Appends the log. + /// + /// The MSG. private void AppendLog(String msg) { if (msg != null && !msg.Contains("SQL Examiner")) @@ -96,8 +157,13 @@ namespace Tango.PPC.UI.ViewModels } } + /// + /// Starts the setup. + /// private async void StartSetup() { + LogManager.Log("Starting machine setup..."); + State = MachineSetupStates.Working; try @@ -106,18 +172,31 @@ namespace Tango.PPC.UI.ViewModels Settings.ApplicationState = ApplicationStates.SemiSetup; Settings.Save(); State = MachineSetupStates.Completed; + + LogManager.Log("Machine setup completed."); } catch (Exception ex) { + LogManager.Log(ex, "Machine setup failed."); State = MachineSetupStates.Failed; await NotificationProvider.ShowInfo(ex.Message); } } + /// + /// Completes the setup. + /// private void CompleteSetup() { - Process.Start(AssemblyHelper.GetCurrentAssemblyFolder() + "\\Tango.PPC.Updater.exe", _setup_result.UpdatePackagePath); + String updater_exe = AssemblyHelper.GetCurrentAssemblyFolder() + "\\Tango.PPC.Updater.exe"; + + LogManager.Log("Completing machine setup..."); + LogManager.Log($"Executing '{updater_exe}' with arguments '{_setup_result.UpdatePackagePath}'..."); + Process.Start(updater_exe, _setup_result.UpdatePackagePath); + LogManager.Log("Terminating application process!"); Environment.Exit(0); } + + #endregion } } -- cgit v1.3.1