aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-13 16:12:45 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-13 16:12:45 +0300
commit998cc8d4d91a7f85389cd0918f127257576c2c13 (patch)
tree368ecd76f09b8ff1c4156a554b799cd231c42119 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs
parent4490b0a76d4188cb285d62b106e208803ceaa133 (diff)
downloadTango-998cc8d4d91a7f85389cd0918f127257576c2c13.tar.gz
Tango-998cc8d4d91a7f85389cd0918f127257576c2c13.zip
Logs and comments for PPC.UI !
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs81
1 files changed, 80 insertions, 1 deletions
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
{
+ /// <summary>
+ /// Represents the machine setup view ViewModel.
+ /// </summary>
+ /// <seealso cref="Tango.PPC.Common.PPCViewModel{Tango.PPC.UI.ViewsContracts.IMachineSetupView}" />
public class MachineSetupViewVM : PPCViewModel<IMachineSetupView>
{
+ /// <summary>
+ /// Represents the various machine setup view states.
+ /// </summary>
public enum MachineSetupStates
{
None,
@@ -31,9 +38,17 @@ namespace Tango.PPC.UI.ViewModels
private MachineSetupResult _setup_result;
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets the machine setup manager.
+ /// </summary>
public IMachineSetupManager MachineSetupManager { get; set; }
private String _serialNumber;
+ /// <summary>
+ /// Gets or sets the serial number.
+ /// </summary>
public String SerialNumber
{
get { return _serialNumber; }
@@ -41,6 +56,9 @@ namespace Tango.PPC.UI.ViewModels
}
private String _hostAddress;
+ /// <summary>
+ /// Gets or sets the host address.
+ /// </summary>
public String HostAddress
{
get { return _hostAddress; }
@@ -48,6 +66,9 @@ namespace Tango.PPC.UI.ViewModels
}
private String _log;
+ /// <summary>
+ /// Gets or sets the log.
+ /// </summary>
public String Log
{
get { return _log; }
@@ -55,16 +76,38 @@ namespace Tango.PPC.UI.ViewModels
}
private MachineSetupStates _state;
+ /// <summary>
+ /// Gets or sets the state.
+ /// </summary>
public MachineSetupStates State
{
get { return _state; }
set { _state = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
+ #endregion
+
+ #region Commands
+
+ /// <summary>
+ /// Gets or sets the start command.
+ /// </summary>
public RelayCommand StartCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the complete command.
+ /// </summary>
public RelayCommand CompleteCommand { get; set; }
+ #endregion
+
+ #region Constructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MachineSetupViewVM"/> class.
+ /// </summary>
+ /// <param name="applicationManager">The application manager.</param>
+ /// <param name="machineSetupManager">The machine setup manager.</param>
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
+
+ /// <summary>
+ /// Handles the SetupRequired event of the ApplicationManager.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void ApplicationManager_SetupRequired(object sender, EventArgs e)
{
+ LogManager.Log("SetupRequired event received. Navigating to MachineSetupView...");
NavigationManager.NavigateTo(NavigationView.MachineSetupView);
}
+ #endregion
+
+ #region Private Methods
+
+ /// <summary>
+ /// Appends the log.
+ /// </summary>
+ /// <param name="msg">The MSG.</param>
private void AppendLog(String msg)
{
if (msg != null && !msg.Contains("SQL Examiner"))
@@ -96,8 +157,13 @@ namespace Tango.PPC.UI.ViewModels
}
}
+ /// <summary>
+ /// Starts the setup.
+ /// </summary>
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);
}
}
+ /// <summary>
+ /// Completes the setup.
+ /// </summary>
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
}
}