From ffe61a7cf745230b1436dbedf1610af72a618a0c Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 15 Mar 2018 16:12:43 +0200 Subject: Working on machine events. --- .../MachineStudio/Tango.MachineStudio.UI/App.xaml.cs | 12 ++++++++++++ .../Modules/DefaultStudioModuleLoader.cs | 1 - .../DefaultStudioApplicationManager.cs | 1 - .../Tango.MachineStudio.UI/ViewModelLocator.cs | 3 +++ .../Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs | 6 +++++- .../Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs | 7 ++++++- .../Tango.MachineStudio.UI/ViewModels/MainViewVM.cs | 18 +++++++++++------- .../Windows/ExceptionWindow.xaml | 2 +- 8 files changed, 38 insertions(+), 12 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs index a7596e16c..f94a6c9d9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs @@ -12,6 +12,8 @@ using Tango.BL.Entities; using Tango.Logging; using Tango.MachineStudio.UI.Windows; using Tango.Settings; +using Microsoft.Practices.ServiceLocation; +using Tango.MachineStudio.Common.EventLogging; namespace Tango.MachineStudio.UI { @@ -67,6 +69,16 @@ namespace Tango.MachineStudio.UI } catch { } + try + { + var eventLogger = ServiceLocator.Current.GetInstance(); + if (eventLogger != null) + { + eventLogger.Log(e.Exception); + } + } + catch { } + Application.Current.Dispatcher.Invoke(() => { ExceptionWindow exWin = new ExceptionWindow(e.Exception); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs index 16526cee6..121d429ec 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs @@ -29,7 +29,6 @@ namespace Tango.MachineStudio.UI.Modules private IAuthenticationProvider _authenticationProvider; private bool _loaded; public event EventHandler ModulesLoaded; - private LogManager LogManager = LogManager.Default; /// /// Initializes a new instance of the class. diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index f48ddb0e2..b4b1c5153 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -31,7 +31,6 @@ namespace Tango.MachineStudio.UI.StudioApplication private INavigationManager _navigationManager; private IStudioModuleLoader _moduleLoader; private List _openedWindows; - private LogManager LogManager = LogManager.Default; /// /// Initializes a new instance of the class. diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 675022276..571122eb5 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -6,6 +6,7 @@ using Tango.Integration.Services; using Tango.Logging; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Diagnostics; +using Tango.MachineStudio.Common.EventLogging; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; @@ -57,6 +58,7 @@ namespace Tango.MachineStudio.UI SimpleIoc.Default.Unregister(); SimpleIoc.Default.Unregister(); SimpleIoc.Default.Unregister(); + SimpleIoc.Default.Unregister(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); @@ -66,6 +68,7 @@ namespace Tango.MachineStudio.UI SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 9ee8471ec..54b83a5cc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -13,6 +13,7 @@ using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; using Tango.SharedUI; using Tango.BL; +using Tango.MachineStudio.Common.EventLogging; namespace Tango.MachineStudio.UI.ViewModels { @@ -25,6 +26,7 @@ namespace Tango.MachineStudio.UI.ViewModels private INotificationProvider _notificationProvider; private INavigationManager _navigationManager; private IStudioModuleLoader _studioModuleLoader; + private IEventLogger _eventLogger; private LogManager logManager = LogManager.Default; public IStudioApplicationManager ApplicationManager { get; set; } @@ -42,8 +44,9 @@ namespace Tango.MachineStudio.UI.ViewModels /// The navigation manager. /// The studio module loader. /// The notification provider. - public LoadingViewVM(IStudioApplicationManager applicationManager, INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider) + public LoadingViewVM(IStudioApplicationManager applicationManager, INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider, IEventLogger eventLogger) { + _eventLogger = eventLogger; ApplicationManager = applicationManager; _navigationManager = navigationManager; _studioModuleLoader = studioModuleLoader; @@ -67,6 +70,7 @@ namespace Tango.MachineStudio.UI.ViewModels { _studioModuleLoader.LoadModules(); _navigationManager.NavigateTo(NavigationView.LoginView); + _eventLogger.Log("Application started successfully"); IsLoading = false; }); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index c5936eea8..7fefe4a41 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Tango.Core.Commands; using Tango.Core.Cryptography; using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.EventLogging; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; using Tango.Settings; @@ -25,6 +26,7 @@ namespace Tango.MachineStudio.UI.ViewModels private IAuthenticationProvider _authenticationProvider; private INavigationManager _navigationManager; private INotificationProvider _notificationProvider; + private IEventLogger _eventLogger; private Rfc2898Cryptographer cryptographer; private String _email; @@ -60,11 +62,12 @@ namespace Tango.MachineStudio.UI.ViewModels /// The authentication provider. /// The navigation manager. /// The notification provider. - public LoginViewVM(IAuthenticationProvider authenticationProvider, INavigationManager navigationManager, INotificationProvider notificationProvider) + public LoginViewVM(IAuthenticationProvider authenticationProvider, INavigationManager navigationManager, INotificationProvider notificationProvider, IEventLogger eventLogger) { _notificationProvider = notificationProvider; _navigationManager = navigationManager; _authenticationProvider = authenticationProvider; + _eventLogger = eventLogger; LoginCommand = new RelayCommand(Login); cryptographer = new Rfc2898Cryptographer(); @@ -89,6 +92,8 @@ namespace Tango.MachineStudio.UI.ViewModels SettingsManager.Default.MachineStudio.LastLoginPassword = RememberMe ? cryptographer.Encrypt(password) : null; SettingsManager.SaveDefaultSettings(); + + _eventLogger.Log("User logged in"); } catch { 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 84c4e2dd3..ba94cd860 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -16,6 +16,7 @@ using Tango.Integration.Services; using Tango.Logging; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.EventLogging; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; @@ -43,7 +44,7 @@ namespace Tango.MachineStudio.UI.ViewModels private INavigationManager _navigation; private bool _isDisconnecting; private Thread _updateCheckThread; - private LogManager logManager = LogManager.Default; + private IEventLogger _eventLogger; /// /// Gets or sets the current loaded module. @@ -201,8 +202,10 @@ namespace Tango.MachineStudio.UI.ViewModels IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider, IStudioApplicationManager applicationManager, - INavigationManager navigationManager) : base(view) + INavigationManager navigationManager, + IEventLogger eventLogger) : base(view) { + _eventLogger = eventLogger; _navigation = navigationManager; AuthenticationProvider = authenticationProvider; StudioModuleLoader = studioModuleLoader; @@ -250,7 +253,7 @@ namespace Tango.MachineStudio.UI.ViewModels } catch (Exception ex) { - logManager.Log(ex, "Error in version update periodic check..."); + LogManager.Log(ex, "Error in version update periodic check..."); } Thread.Sleep(TimeSpan.FromMinutes(4)); @@ -320,11 +323,12 @@ namespace Tango.MachineStudio.UI.ViewModels else { ApplicationManager.ConnectedMachine = x.SelectedMachine; + _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP",x.SelectedMachine.SerialNumber)); } } catch (Exception ex) { - logManager.Log(ex); + LogManager.Log(ex); _notificationProvider.ShowError(ex.Message); } @@ -345,13 +349,13 @@ namespace Tango.MachineStudio.UI.ViewModels await x.SelectedMachine.Connect(); x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber; ApplicationManager.ConnectedMachine = x.SelectedMachine; - + _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber)); SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber; SettingsManager.SaveDefaultSettings(); } catch (Exception ex) { - logManager.Log(ex); + LogManager.Log(ex); _notificationProvider.ShowError(ex.Message); } @@ -447,7 +451,7 @@ namespace Tango.MachineStudio.UI.ViewModels } catch (Exception ex) { - logManager.Log(ex, "Error popping out module " + module.Name); + LogManager.Log(ex, "Error popping out module " + module.Name); _notificationProvider.ShowError("Error popping out module " + module.Name); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml index c08a08842..892e4944f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml @@ -43,7 +43,7 @@ - + -- cgit v1.3.1