diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs | 61 |
1 files changed, 8 insertions, 53 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs index ee96a77a5..f9674e409 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs @@ -16,10 +16,6 @@ using Tango.Integration.Operation; using Tango.PPC.Common.Application; using Tango.PPC.Common.Authentication; using Tango.PPC.Common.Connection; -using Tango.Transport; -using Tango.PPC.Common.ExternalBridge; -using Tango.PPC.Shared.Events; -using Tango.Core.DI; namespace Tango.PPC.Common.EventLogging { @@ -39,7 +35,6 @@ namespace Tango.PPC.Common.EventLogging private bool _isInitialized; private List<MachinesEvent> _pendingEvents; private List<MachinesEvent> _currentEvents; - private Machine _machine; #region Events @@ -55,21 +50,6 @@ namespace Tango.PPC.Common.EventLogging #endregion - private IPPCExternalBridgeService _externalBridge; - [TangoInject(Mode = TangoInjectMode.WhenAvailable)] - public IPPCExternalBridgeService ExternalBridgeService - { - get { return _externalBridge; } - set - { - if (_externalBridge != value) - { - _externalBridge = value; - _externalBridge.RegisterRequestHandler(this); - } - } - } - #region Constructors /// <summary> @@ -104,6 +84,7 @@ namespace Tango.PPC.Common.EventLogging _machineProvider.MachineOperator.PrintingAborted += MachineOperator_PrintingAborted; _machineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; _machineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed; + } #endregion @@ -118,28 +99,18 @@ namespace Tango.PPC.Common.EventLogging { _db = ObservablesContext.CreateDefault(); - _machine = _db.Machines.FirstOrDefault(); - _db.EventTypes.ToList(); foreach (var type in _db.EventTypes) { - try - { - _eventTypesGuids.Add((EventTypes)type.Code, type); - } - catch (Exception ex) - { - LogManager.Log(ex, $"Error initializing event type '{type.Name}'."); - } + _eventTypesGuids.Add((EventTypes)type.Code, type); } _isInitialized = true; } - catch (Exception ex) + catch { _isInitialized = false; - LogManager.Log(ex, "Error initializing event types."); } } } @@ -279,7 +250,7 @@ namespace Tango.PPC.Common.EventLogging machineEvent.HostName = _hostName; machineEvent.EventType = _eventTypesGuids[machineEvent.Type]; - if (_machine == null) + if (_machineProvider.MachineOperator == null || _authentication.CurrentUser == null) { _pendingEvents.Add(machineEvent); } @@ -297,14 +268,14 @@ namespace Tango.PPC.Common.EventLogging } LogManager.Log("Logging event " + machineEvent.EventType.Name); - machineEvent.MachineGuid = _machine.Guid; - machineEvent.UserGuid = null; - machineEvent.User = null; + machineEvent.MachineGuid = _machineProvider.Machine.Guid; + machineEvent.UserGuid = _authentication.CurrentUser.Guid; + machineEvent.User = _authentication.CurrentUser; _events.Enqueue(machineEvent); if (!_currentEvents.Exists(x => x.Type == machineEvent.Type)) { - if (machineEvent.Group != EventTypeGroups.Application && machineEvent.Group != EventTypeGroups.Transport && machineEvent.Group != EventTypeGroups.Jobs) + if (machineEvent.Group != EventTypeGroups.Application && machineEvent.Group != EventTypeGroups.Transport) { _currentEvents.Add(machineEvent); } @@ -414,21 +385,5 @@ namespace Tango.PPC.Common.EventLogging } #endregion - - #region External Bridge Handler - - [ExternalBridgeRequestHandlerMethod(typeof(PushEmulatedEventRequest), RequestHandlerLoggingMode.LogRequestNameAndContent)] - public async Task OnStartPerformanceUpdatesRequest(PushEmulatedEventRequest request, String token, ExternalBridgeReceiver receiver) - { - _machineProvider.MachineOperator.PushEmulatedEvent(request.Event, request.Timeout); - await receiver.SendGenericResponse(new PushEmulatedEventResponse(), token); - } - - public void OnReceiverDisconnected(ExternalBridgeReceiver receiver) - { - - } - - #endregion } } |
