diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-27 15:31:21 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-27 15:31:21 +0200 |
| commit | e0167674d812f90896b982fa236dc2634eb79bcb (patch) | |
| tree | 99be93e441c7fe09a199a7390f1b24c41eb95860 /Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging | |
| parent | e2f911073fbf4ca14a2cd9e1c04592888ad9de1a (diff) | |
| download | Tango-e0167674d812f90896b982fa236dc2634eb79bcb.tar.gz Tango-e0167674d812f90896b982fa236dc2634eb79bcb.zip | |
Working on PPC Events module.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs | 24 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/IEventLogger.cs | 9 |
2 files changed, 27 insertions, 6 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 0ebcdeb22..5162bc532 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs @@ -34,13 +34,19 @@ namespace Tango.PPC.Common.EventLogging private String _hostName; private bool _isInitialized; private List<MachinesEvent> _pendingEvents; + private List<MachinesEvent> _currentEvents; #region Events /// <summary> - /// Occurs when a new machine event has been logged. + /// Occurs when a new machine event has been received. /// </summary> - public event EventHandler<MachinesEvent> NewLog; + public event EventHandler<MachinesEvent> EventReceived; + + /// <summary> + /// Occurs when a machine event has been resolved. + /// </summary> + public event EventHandler<MachinesEvent> EventResolved; #endregion @@ -57,6 +63,7 @@ namespace Tango.PPC.Common.EventLogging _events = new ConcurrentQueue<MachinesEvent>(); _pendingEvents = new List<MachinesEvent>(); + _currentEvents = new List<MachinesEvent>(); _eventTypesGuids = new Dictionary<EventTypes, BL.Entities.EventType>(); @@ -181,7 +188,15 @@ namespace Tango.PPC.Common.EventLogging { foreach (var ev in events) { - Log(String.Format("Event '{0}' resolved.", ev.EventType.Name)); + //Log(String.Format("Event '{0}' resolved.", ev.EventType.Name)); + + var existing = _currentEvents.SingleOrDefault(x => x.Type == ev.Type); + + if (existing != null) + { + _currentEvents.Remove(existing); + EventResolved?.Invoke(this, existing); + } } } @@ -220,7 +235,8 @@ namespace Tango.PPC.Common.EventLogging machineEvent.UserGuid = _authentication.CurrentUser.Guid; machineEvent.User = _authentication.CurrentUser; _events.Enqueue(machineEvent); - NewLog?.Invoke(this, machineEvent); + _currentEvents.Add(machineEvent); + EventReceived?.Invoke(this, machineEvent); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/IEventLogger.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/IEventLogger.cs index f7eadac1e..10560e034 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/IEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/IEventLogger.cs @@ -15,9 +15,14 @@ namespace Tango.PPC.Common.EventLogging public interface IEventLogger { /// <summary> - /// Occurs when a new machine event has been logged. + /// Occurs when a new machine event has been received. /// </summary> - event EventHandler<MachinesEvent> NewLog; + event EventHandler<MachinesEvent> EventReceived; + + /// <summary> + /// Occurs when a machine event has been resolved. + /// </summary> + event EventHandler<MachinesEvent> EventResolved; /// <summary> /// Logs the specified machine event. |
