aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-15 16:12:43 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-15 16:12:43 +0200
commitffe61a7cf745230b1436dbedf1610af72a618a0c (patch)
tree6002737dd72c2e7237637aad3b3b23358ba8eb8e /Software/Visual_Studio/MachineStudio
parentd6f46df0e9ccd08276912bcdcded246de0bc4447 (diff)
downloadTango-ffe61a7cf745230b1436dbedf1610af72a618a0c.tar.gz
Tango-ffe61a7cf745230b1436dbedf1610af72a618a0c.zip
Working on machine events.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs153
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/IEventLogger.cs3
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj3
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config1
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs12
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs1
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs3
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs6
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs7
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs18
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml2
15 files changed, 171 insertions, 42 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
index b2dded955..4a16be957 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
@@ -54,7 +54,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
private IAuthenticationProvider _authentication;
private ObservablesContext _machineDbContext;
private ObservablesContext _activeJobDbContext;
- private LogManager LogManager = LogManager.Default;
private SpeechSynthesizer _speech;
private SoundPlayer _soundPlayer;
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs
index fbc2e2d49..2621f622a 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs
@@ -33,7 +33,6 @@ namespace Tango.MachineStudio.Synchronization.ViewModels
private INotificationProvider _notification;
private bool _isWorking;
private MainViewVM _mainView;
- private LogManager LogManager = LogManager.Default;
#region Constructors
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs
index 0fa1ce149..57b3af1a8 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs
@@ -40,7 +40,6 @@ namespace Tango.MachineStudio.Synchronization.ViewModels
private RemoteDB _remoteDB;
private LocalDB _localDB;
private MainViewVM _mainView;
- private LogManager LogManager = LogManager.Default;
#region Constructors
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs
index c22ce335c..ff4badffe 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs
@@ -1,4 +1,5 @@
-using System;
+using Google.Protobuf;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
@@ -8,21 +9,32 @@ using System.Threading.Tasks;
using Tango.BL;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
+using Tango.Core;
+using Tango.Integration.Services;
using Tango.Logging;
using Tango.MachineStudio.Common.Authentication;
+using Tango.MachineStudio.Common.Diagnostics;
using Tango.MachineStudio.Common.StudioApplication;
using Tango.PMR.Diagnostics;
+using Tango.Integration.Operation;
namespace Tango.MachineStudio.Common.EventLogging
{
- public class DefaultEventLogger : IEventLogger
+ /// <summary>
+ /// Represents the default database events logger.
+ /// </summary>
+ /// <seealso cref="IEventLogger" />
+ public class DefaultEventLogger : ExtendedObject, IEventLogger
{
private ObservablesContext _db;
private Thread _logThread;
private ConcurrentQueue<MachinesEvent> _events;
private IStudioApplicationManager _application;
private IAuthenticationProvider _authentication;
- private Dictionary<EventTypes, String> _eventTypesGuids;
+ private Dictionary<EventTypes, BL.Entities.EventType> _eventTypesGuids;
+ private String _hostName;
+
+ #region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="DefaultEventLogger"/> class.
@@ -31,12 +43,14 @@ namespace Tango.MachineStudio.Common.EventLogging
/// <param name="authenticationProvider">The authentication provider.</param>
public DefaultEventLogger(IStudioApplicationManager applicationManager, IAuthenticationProvider authenticationProvider)
{
+ _hostName = Environment.MachineName;
+
_events = new ConcurrentQueue<MachinesEvent>();
_db = ObservablesContext.CreateDefault();
_db.Configuration.LazyLoadingEnabled = false;
- _eventTypesGuids = new Dictionary<EventTypes, string>();
+ _eventTypesGuids = new Dictionary<EventTypes, BL.Entities.EventType>();
_db.ActionTypes.ToList();
_db.EventTypesCategories.ToList();
@@ -45,7 +59,7 @@ namespace Tango.MachineStudio.Common.EventLogging
foreach (var type in _db.EventTypes)
{
- _eventTypesGuids.Add((EventTypes)type.Code, type.Guid);
+ _eventTypesGuids.Add((EventTypes)type.Code, type);
}
_application = applicationManager;
@@ -53,14 +67,93 @@ namespace Tango.MachineStudio.Common.EventLogging
_logThread = new Thread(LogThreadMethod);
_logThread.IsBackground = true;
_logThread.Start();
+
+ _application.ConnectedMachineChanged += _application_ConnectedMachineChanged;
+ }
+
+ #endregion
+
+ #region Event Handlers
+
+ /// <summary>
+ /// Handle the application manager connected machine changed event.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="machine">The machine.</param>
+ private void _application_ConnectedMachineChanged(object sender, IExternalBridgeClient machine)
+ {
+ if (machine != null)
+ {
+ if (machine.MachineEventsStateProvider != null)
+ {
+ machine.MachineEventsStateProvider.NewEvents -= MachineEventsStateProvider_NewEvents;
+ machine.MachineEventsStateProvider.NewEvents += MachineEventsStateProvider_NewEvents;
+ }
+
+ machine.RequestSent -= Machine_RequestSent;
+ machine.RequestFailed -= Machine_RequestFailed;
+ machine.ResponseReceived -= Machine_ResponseReceived;
+
+ machine.RequestSent += Machine_RequestSent;
+ machine.RequestFailed += Machine_RequestFailed;
+ machine.ResponseReceived += Machine_ResponseReceived;
+ }
+ }
+
+ /// <summary>
+ /// Handles the RequestSent event of the connected machine.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="message">The message.</param>
+ private void Machine_RequestSent(object sender, IMessage message)
+ {
+ Log(EventTypes.RequestSent, String.Format("Sending request '{0}'...{1}{2}", message.GetType().Name, Environment.NewLine, message.ToJsonString()));
}
/// <summary>
+ /// Handles the RequestFailed event of the connected machine.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="RequestFailedEventArgs"/> instance containing the event data.</param>
+ private void Machine_RequestFailed(object sender, RequestFailedEventArgs e)
+ {
+ Log(EventTypes.RequestFailed, String.Format("Request failed '{0}'...{1}{2}{1}{3}", e.Message.GetType().Name, Environment.NewLine, e.Message.ToJsonString(), e.Exception.ToString()));
+ }
+
+ /// <summary>
+ /// Handles the ResponseReceived event of the connected machine.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="message">The message.</param>
+ private void Machine_ResponseReceived(object sender, IMessage message)
+ {
+ Log(EventTypes.ResponseReceived, String.Format("Response received '{0}'...{1}{2}", message.GetType().Name, Environment.NewLine, message.ToJsonString()));
+ }
+
+ /// <summary>
+ /// Handles the connected machine events state provider NewEvents event.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="events">The events.</param>
+ private void MachineEventsStateProvider_NewEvents(object sender, IEnumerable<Event> events)
+ {
+ foreach (var ev in events)
+ {
+ Log(ev);
+ }
+ }
+
+ #endregion
+
+ #region Logging
+
+ /// <summary>
/// Logs the specified machine event.
/// </summary>
/// <param name="machineEvent">The machine event.</param>
public void Log(MachinesEvent machineEvent)
{
+ LogManager.Log("Logging event " + machineEvent.EventType.Name + " - " + machineEvent.Description);
_events.Enqueue(machineEvent);
}
@@ -72,11 +165,12 @@ namespace Tango.MachineStudio.Common.EventLogging
public void Log(EventTypes eventType, string message)
{
MachinesEvent machineEvent = new MachinesEvent();
- machineEvent.MachineGuid = _application.ConnectedMachine.Guid;
+ machineEvent.MachineGuid = _application.ConnectedMachine != null ? _application.ConnectedMachine.Guid : null;
machineEvent.DateTime = DateTime.UtcNow;
machineEvent.Description = message;
- machineEvent.EventTypeGuid = _eventTypesGuids[eventType];
- machineEvent.UserGuid = _authentication.CurrentUser.Guid;
+ machineEvent.EventType = _eventTypesGuids[eventType];
+ machineEvent.UserGuid = _authentication.CurrentUser != null ? _authentication.CurrentUser.Guid : null;
+ machineEvent.HostName = _hostName;
Log(machineEvent);
}
@@ -96,7 +190,7 @@ namespace Tango.MachineStudio.Common.EventLogging
/// <param name="exception">The exception.</param>
public void Log(Exception exception)
{
- Log(EventTypes.ApplicationException, exception.Message);
+ Log(EventTypes.ApplicationException, exception.ToString());
}
/// <summary>
@@ -108,37 +202,42 @@ namespace Tango.MachineStudio.Common.EventLogging
Log(EventTypes.ApplicationInformation, message);
}
+ /// <summary>
+ /// Logging thread loop.
+ /// </summary>
private void LogThreadMethod()
{
- try
+ while (true)
{
- while (true)
+ bool _saveChanges = false;
+
+ while (_events.Count > 0)
{
- bool _saveChanges = false;
+ MachinesEvent ev = null;
- while (_events.Count > 0)
+ if (_events.TryDequeue(out ev))
{
- MachinesEvent ev = null;
-
- if (_events.TryDequeue(out ev))
- {
- _db.MachinesEvents.Add(ev);
- _saveChanges = true;
- }
+ _db.MachinesEvents.Add(ev);
+ _saveChanges = true;
}
+ }
- if (_saveChanges)
+ if (_saveChanges)
+ {
+ try
{
_db.SaveChanges();
}
-
- Thread.Sleep(5000);
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error saving machine event to database.");
+ }
}
- }
- catch (Exception ex)
- {
- LogManager.Default.Log(ex, "Error saving machine event to database.");
+
+ Thread.Sleep(5000);
}
}
+
+ #endregion
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/IEventLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/IEventLogger.cs
index 645bd4a95..bafdca914 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/IEventLogger.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/IEventLogger.cs
@@ -9,6 +9,9 @@ using Tango.PMR.Diagnostics;
namespace Tango.MachineStudio.Common.EventLogging
{
+ /// <summary>
+ /// Represents a database events logger.
+ /// </summary>
public interface IEventLogger
{
/// <summary>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
index 7c28cb4c8..15ab97a27 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
@@ -46,6 +46,9 @@
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
+ <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath>
+ </Reference>
<Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath>
</Reference>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config
index cf0df03c8..8cd12859b 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config
@@ -2,6 +2,7 @@
<packages>
<package id="CommonServiceLocator" version="1.3" targetFramework="net46" />
<package id="EntityFramework" version="6.0.0" targetFramework="net46" />
+ <package id="Google.Protobuf" version="3.4.1" targetFramework="net46" />
<package id="MahApps.Metro" version="1.5.0" targetFramework="net46" />
<package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" />
<package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net46" />
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<IEventLogger>();
+ 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;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultStudioModuleLoader"/> 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<Window> _openedWindows;
- private LogManager LogManager = LogManager.Default;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultStudioApplicationManager" /> 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<ExternalBridgeScanner>();
SimpleIoc.Default.Unregister<IVideoCaptureProvider>();
SimpleIoc.Default.Unregister<IDiagnosticsFrameProvider>();
+ SimpleIoc.Default.Unregister<IEventLogger>();
SimpleIoc.Default.Register<INotificationProvider, DefaultNotificationProvider>();
SimpleIoc.Default.Register<IAuthenticationProvider, DefaultAuthenticationProvider>();
@@ -66,6 +68,7 @@ namespace Tango.MachineStudio.UI
SimpleIoc.Default.Register<ExternalBridgeScanner, ExternalBridgeScanner>();
SimpleIoc.Default.Register<IVideoCaptureProvider, DefaultVideoCaptureProvider>();
SimpleIoc.Default.Register<IDiagnosticsFrameProvider, DefaultDiagnosticsFrameProvider>();
+ SimpleIoc.Default.Register<IEventLogger, DefaultEventLogger>();
SimpleIoc.Default.Register<MainViewVM>();
SimpleIoc.Default.Register<LoadingViewVM>();
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
/// <param name="navigationManager">The navigation manager.</param>
/// <param name="studioModuleLoader">The studio module loader.</param>
/// <param name="notificationProvider">The notification provider.</param>
- 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
/// <param name="authenticationProvider">The authentication provider.</param>
/// <param name="navigationManager">The navigation manager.</param>
/// <param name="notificationProvider">The notification provider.</param>
- 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<String>(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;
/// <summary>
/// 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 @@
</Grid>
<Grid Grid.Row="1" Margin="0 10 0 0">
- <TextBox Style="{x:Null}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderBrush="#515151" IsReadOnly="True" AcceptsReturn="True" Foreground="#FF5C5C" Padding="2" TextWrapping="Wrap" Text="{Binding Exception}"></TextBox>
+ <TextBox Style="{x:Null}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderBrush="#515151" IsReadOnly="True" AcceptsReturn="True" Foreground="#202020" Padding="2" TextWrapping="Wrap" Text="{Binding Exception}"></TextBox>
</Grid>
</Grid>