private EventLine[] GetAnalyticsEventList(DateTime periodStart, DateTime periodEnd) { AlarmClientManager _alarmClientManager = new AlarmClientManager(); int eventCount = (int)(_startCache + _endCache) / 500; try { IAlarmClient alarmClient = _alarmClientManager.GetAlarmClient(EnvironmentManager.Instance.MasterSite.ServerId); EventLine[] events = alarmClient.GetEventLines(0, eventCount, new VideoOS.Platform.Proxy.Alarm.EventFilter() { Conditions = new Condition[] { new Condition() { Operator = Operator.NotEquals, Target = Target.Type, Value = "System Event" }, new Condition() { Operator = Operator.LessThan, Target = Target.Timestamp, Value = periodEnd }, new Condition() { Operator = Operator.GreaterThan, Target = Target.Timestamp, Value = periodStart } } }); return(events); } catch (Exception ex) { // this will happen if for instance the Event Server cannot be contacted. Showing error each time is quite intrusive, so let's just log. EnvironmentManager.Instance.Log(true, nameof(OverlayGraphOnEventBackgroundPlugin), "Exception thrown: " + ex.Message); return(new EventLine[] { }); } }
public MainForm() { InitializeComponent(); _viewMode = ViewMode.Alarm; MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId); _messageCommunication = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId); _alarmClientManager = new AlarmClientManager(); rbAlarms.Tag = ViewMode.Alarm; rbAnalytics.Tag = ViewMode.Analytics; rbEvents.Tag = ViewMode.Event; rbLPR.Tag = ViewMode.LPR; rbAccess.Tag = ViewMode.Access; setGrid(); }
private void CreatePlaybackDictionary(ImageViewerAddOn imageViewerAddOn, DateTime videoTime) { CachedOverlayObjects coo; if (!_dicAddOnOverlayObjectsPlayback.TryGetValue(imageViewerAddOn, out coo) || coo.StartTime > videoTime || coo.EndTime < videoTime) { DateTime startDatetime = videoTime.AddMilliseconds(-_startCache); DateTime endDatetime = videoTime.AddMilliseconds(_endCache); if (endDatetime > DateTime.Now) { endDatetime = DateTime.Now; } EventLine[] analyticsEventLines = GetAnalyticsEventList(startDatetime, endDatetime); if (analyticsEventLines.Length == 0) { return; } CachedOverlayObjects overlayObjectList = new CachedOverlayObjects(); overlayObjectList.OverlayObjectList = new List <OverlayObject>(); overlayObjectList.StartTime = startDatetime; overlayObjectList.EndTime = endDatetime; AlarmClientManager _alarmClientManager = new AlarmClientManager(); IAlarmClient alarmClient = _alarmClientManager.GetAlarmClient(EnvironmentManager.Instance.MasterSite.ServerId); foreach (EventLine ev in analyticsEventLines) { BaseEvent baseevent = alarmClient.GetEvent(ev.Id); overlayObjectList.OverlayObjectList.Add(new OverlayObject(baseevent, ev.Timestamp)); } if (_dicAddOnOverlayObjectsPlayback.ContainsKey(imageViewerAddOn)) { _dicAddOnOverlayObjectsPlayback.Remove(imageViewerAddOn); } _dicAddOnOverlayObjectsPlayback.Add(imageViewerAddOn, overlayObjectList); } }