aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
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
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')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs82
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs92
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs1
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs54
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs81
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs3
6 files changed, 281 insertions, 32 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
index a5a8d9ac3..3b672411d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
@@ -13,12 +13,21 @@ using Tango.PPC.Common.Navigation;
namespace Tango.PPC.UI.ViewModels
{
+ /// <summary>
+ /// Represents the external bridge view ViewModel.
+ /// </summary>
+ /// <seealso cref="Tango.PPC.Common.PPCViewModel" />
[TangoCreateWhenRegistered]
public class ExternalBridgeViewVM : PPCViewModel
{
private bool _disconnecting;
+ #region Properties
+
private ExternalBridgeClientConnectedEventArgs _connection;
+ /// <summary>
+ /// Gets or sets the last client connection event arguments.
+ /// </summary>
public ExternalBridgeClientConnectedEventArgs Connection
{
get { return _connection; }
@@ -26,26 +35,58 @@ namespace Tango.PPC.UI.ViewModels
}
private User _user;
+ /// <summary>
+ /// Gets or sets the user connected user.
+ /// </summary>
public User User
{
get { return _user; }
- set { _user = value; RaisePropertyChangedAuto(); }
+ set { _user = value; RaisePropertyChangedAuto(); }
}
+ #endregion
+
+ #region Commands
+
+ /// <summary>
+ /// Gets or sets the close session command.
+ /// </summary>
public RelayCommand CloseSessionCommand { get; set; }
+ #endregion
+
+ #region Constructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ExternalBridgeViewVM"/> class.
+ /// </summary>
public ExternalBridgeViewVM()
{
- CloseSessionCommand = new RelayCommand(CloseSession,() => !_disconnecting);
+ CloseSessionCommand = new RelayCommand(CloseSession, () => !_disconnecting);
}
+ #endregion
+
+ #region Private Methods
+
+ /// <summary>
+ /// Closes the current session.
+ /// </summary>
private void CloseSession()
{
+ LogManager.Log("Disconnecting current external bridge session.");
_disconnecting = true;
InvalidateRelayCommands();
ExternalBridgeService.DisconnectSession();
}
+ #endregion
+
+ #region Override Methods
+
+ /// <summary>
+ /// Called when the navigation system has navigated to this VM view.
+ /// </summary>
public override void OnNavigatedTo()
{
base.OnNavigatedTo();
@@ -54,22 +95,43 @@ namespace Tango.PPC.UI.ViewModels
InvalidateRelayCommands();
}
+ /// <summary>
+ /// Called when the application has been started.
+ /// </summary>
public override void OnApplicationStarted()
{
- ExternalBridgeService.ConnectionRequest += ExternalBridgeService_ClientConnected;
+ ExternalBridgeService.ConnectionRequest += ExternalBridgeService_ConnectionRequest;
ExternalBridgeService.ClientDisconnected += ExternalBridgeService_ClientDisconnected;
}
+ #endregion
+
+ #region Event Handlers
+
+ /// <summary>
+ /// Handles the <see cref="ExternalBridgeService.ClientDisconnected"/> event.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void ExternalBridgeService_ClientDisconnected(object sender, EventArgs e)
{
+ LogManager.Log("External bridge client disconnected. Navigating to home module...");
+
InvokeUI(() =>
{
NavigationManager.NavigateTo(NavigationView.HomeModule);
});
}
- private void ExternalBridgeService_ClientConnected(object sender, ExternalBridgeClientConnectedEventArgs e)
+ /// <summary>
+ /// Handles the <see cref="ExternalBridgeService.ConnectionRequest"/> event.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="e">The <see cref="ExternalBridgeClientConnectedEventArgs"/> instance containing the event data.</param>
+ private void ExternalBridgeService_ConnectionRequest(object sender, ExternalBridgeClientConnectedEventArgs e)
{
+ LogManager.Log($"External bridge connection request received.\n{e.ToJsonString()}");
+
if (e.Request.Password == MachineProvider.Machine.ExternalBridgePassword)
{
e.Confirmed = true;
@@ -78,11 +140,23 @@ namespace Tango.PPC.UI.ViewModels
User = Adapter.Users.SingleOrDefault(x => x.Guid == e.Request.UserGuid);
+ if (User != null)
+ {
+ LogManager.Log($"External bridge connection user has been identified as {User.Contact.FullName}");
+ }
+
+ LogManager.Log("Navigating to external bridge view...");
InvokeUI(() =>
{
NavigationManager.NavigateTo(NavigationView.ExternalBridgeView, false);
});
}
+ else
+ {
+ LogManager.Log("Connection password did not match the machine external bridge password.");
+ }
}
+
+ #endregion
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
index 268f42ce9..3bcacc989 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
@@ -28,6 +28,8 @@ namespace Tango.PPC.UI.ViewModels
[TangoInject]
public IPPCModuleLoader ModuleLoader { get; set; }
+ #region Properties
+
private bool _isMenuOpened;
/// <summary>
/// Gets or sets a value indicating whether the side menu is opened.
@@ -48,6 +50,10 @@ namespace Tango.PPC.UI.ViewModels
set { _isNotificationsOpened = value; RaisePropertyChangedAuto(); }
}
+ #endregion
+
+ #region Commands
+
/// <summary>
/// Gets or sets the module navigation command.
/// </summary>
@@ -78,6 +84,10 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
public RelayCommand SignOutCommand { get; set; }
+ #endregion
+
+ #region Constructors
+
/// <summary>
/// Initializes a new instance of the <see cref="LayoutViewVM"/> class.
/// </summary>
@@ -92,8 +102,17 @@ namespace Tango.PPC.UI.ViewModels
SignOutCommand = new RelayCommand(SignOut);
}
+ #endregion
+
+ #region Private Methods
+
+ /// <summary>
+ /// Stops the printing.
+ /// </summary>
private void StopPrinting()
{
+ LogManager.Log("Stop printing layout command pressed!");
+
if (_jobHandler != null)
{
_jobHandler.Cancel();
@@ -107,10 +126,12 @@ namespace Tango.PPC.UI.ViewModels
{
if (NavigationManager.CanNavigateBack)
{
+ LogManager.Log("Back command pressed.");
NavigationManager.NavigateBack();
}
else
{
+ LogManager.Log("Menu command pressed.");
IsMenuOpened = true;
}
}
@@ -121,6 +142,7 @@ namespace Tango.PPC.UI.ViewModels
/// <param name="moduleName">Name of the module.</param>
private void NavigateToModule(string moduleName)
{
+ LogManager.Log("Navigate to module command pressed.");
IsMenuOpened = false;
NavigationManager.NavigateTo(moduleName);
}
@@ -130,33 +152,48 @@ namespace Tango.PPC.UI.ViewModels
/// </summary>
private void NavigateHome()
{
+ LogManager.Log("Navigate home command pressed.");
IsMenuOpened = false;
NavigationManager.NavigateTo(NavigationView.HomeModule);
}
/// <summary>
- /// Called when the application has been started.
+ /// Represents an event that is raised when the sign-out operation is complete.
/// </summary>
- public override void OnApplicationStarted()
+ private void SignOut()
{
- base.OnApplicationStarted();
- ModuleLoader.ModulesLoaded += ModuleLoader_ModulesLoaded;
- MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted;
+ LogManager.Log("SignOut command pressed.");
+ AuthenticationProvider.LogOut();
+ IsMenuOpened = false;
}
- private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e)
+ /// <summary>
+ /// Opens the first notification or display all.
+ /// </summary>
+ private void OpenFirstNotificationOrDisplayAll()
{
- _jobHandler = e.JobHandler;
+ if (NotificationProvider.NotificationItems.Count == 1)
+ {
+ //Open first
+ }
+ else
+ {
+ IsNotificationsOpened = true;
+ }
}
+ #endregion
+
+ #region Override Methods
+
/// <summary>
- /// Handles the ModulesLoaded event of the ModuleLoader.
+ /// Called when the application has been started.
/// </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 ModuleLoader_ModulesLoaded(object sender, EventArgs e)
+ public override void OnApplicationStarted()
{
- View.ApplyModules(ModuleLoader.UserModules);
+ base.OnApplicationStarted();
+ ModuleLoader.ModulesLoaded += ModuleLoader_ModulesLoaded;
+ MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted;
}
/// <summary>
@@ -167,28 +204,31 @@ namespace Tango.PPC.UI.ViewModels
}
+ #endregion
+
+ #region Event Handlers
+
/// <summary>
- /// Represents an event that is raised when the sign-out operation is complete.
+ /// Handles the PrintingStarted event of the MachineOperator.
/// </summary>
- private void SignOut()
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="PrintingEventArgs"/> instance containing the event data.</param>
+ private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e)
{
- AuthenticationProvider.LogOut();
- IsMenuOpened = false;
+ _jobHandler = e.JobHandler;
}
/// <summary>
- /// Opens the first notification or display all.
+ /// Handles the ModulesLoaded event of the ModuleLoader.
/// </summary>
- private void OpenFirstNotificationOrDisplayAll()
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
+ private void ModuleLoader_ModulesLoaded(object sender, EventArgs e)
{
- if (NotificationProvider.NotificationItems.Count == 1)
- {
- //Open first
- }
- else
- {
- IsNotificationsOpened = true;
- }
+ LogManager.Log("Modules loaded. Applying modules to main navigation control...");
+ View.ApplyModules(ModuleLoader.UserModules);
}
+
+ #endregion
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
index 77767d588..852997f87 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
@@ -61,6 +61,7 @@ namespace Tango.PPC.UI.ViewModels
public override void OnApplicationStarted()
{
IsLoading = false;
+ LogManager.Log("Application started. Navigating to LoginView...");
NavigationManager.NavigateTo(NavigationView.LoginView);
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs
index 022efd9b8..812f10121 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs
@@ -9,14 +9,25 @@ using Tango.PPC.Common.Navigation;
using SimpleValidator.Extensions;
using System.ComponentModel.DataAnnotations;
using Tango.SharedUI.Helpers;
+using Tango.PPC.Common.Authentication;
+using Tango.BL.Entities;
namespace Tango.PPC.UI.ViewModels
{
+ /// <summary>
+ /// Represents the PPC login view ViewModel.
+ /// </summary>
+ /// <seealso cref="Tango.PPC.Common.PPCViewModel" />
public class LoginViewVM : PPCViewModel
{
public RelayCommand LoginCommand { get; set; }
+ #region Properties
+
private String _email;
+ /// <summary>
+ /// Gets or sets the email.
+ /// </summary>
[Required(ErrorMessage = "Email is required")]
[EmailAddress(ErrorMessage = "Please enter a valid email address")]
public String Email
@@ -26,6 +37,9 @@ namespace Tango.PPC.UI.ViewModels
}
private String _password;
+ /// <summary>
+ /// Gets or sets the password.
+ /// </summary>
[Required(ErrorMessage = "Password is required")]
public String Password
{
@@ -43,7 +57,13 @@ namespace Tango.PPC.UI.ViewModels
set { _isLoading = value; RaisePropertyChangedAuto(); }
}
+ #endregion
+
+ #region Constructors
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LoginViewVM"/> class.
+ /// </summary>
public LoginViewVM()
{
LoginCommand = new RelayCommand(Login);
@@ -52,12 +72,28 @@ namespace Tango.PPC.UI.ViewModels
Password = "1234";
}
+ #endregion
+
+ #region Override Methods
+
+ /// <summary>
+ /// Called when the application has been started.
+ /// </summary>
public override void OnApplicationStarted()
{
AuthenticationProvider.CurrentUserChanged += AuthenticationProvider_CurrentUserChanged;
}
- private void AuthenticationProvider_CurrentUserChanged(object sender, BL.Entities.User user)
+ #endregion
+
+ #region Event Handlers
+
+ /// <summary>
+ /// Handles the <see cref="IAuthenticationProvider.CurrentUserChanged"/> event.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="user">The user.</param>
+ private void AuthenticationProvider_CurrentUserChanged(object sender, User user)
{
if (user == null)
{
@@ -65,8 +101,17 @@ namespace Tango.PPC.UI.ViewModels
}
}
+ #endregion
+
+ #region Private Methods
+
+ /// <summary>
+ /// Login to the application using the user name and password.
+ /// </summary>
private void Login()
{
+ LogManager.Log("Login command pressed.");
+
if (Validate())
{
IsLoading = true;
@@ -83,10 +128,17 @@ namespace Tango.PPC.UI.ViewModels
ApplicationManager.ModulesInitialized += async (_, __) =>
{
await Task.Delay(500);
+ LogManager.Log("Modules initialized. Navigating to home module...");
await NavigationManager.NavigateTo(NavigationView.HomeModule);
IsLoading = false;
};
}
+ else
+ {
+ LogManager.Log("Invalid user credentials.");
+ }
}
+
+ #endregion
}
}
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
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
index 67d885685..e207c30b3 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
@@ -22,6 +22,9 @@ namespace Tango.PPC.UI.ViewModels
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
public class MainViewVM : PPCViewModel
{
+ /// <summary>
+ /// Called when the application has been started.
+ /// </summary>
public override void OnApplicationStarted()
{
}