Exemplo n.º 1
0
        public long RecordEvent(MonitoringEventsDto dto)
        {
            var entity = new MonitoringEvents();
            entity.InjectFrom(dto);

            if (entity.EventEnd != DateTime.MinValue)
            {
                Logger.Trace("Removing existing Event record");

                var all = Repo.GetAll();
                Logger.Trace("We have all events count: {0}", all.Count());

                var startNotification = all.FirstOrDefault(x => x.EventStart == entity.EventStart);
                if (startNotification != null)
                {
                    Logger.Trace("We have found the old event to delete id: {0}", startNotification.Id);

                   Repo.Delete(startNotification);
                }
            }

            Logger.Trace("Inserting new event: Name: {0} | Type: {1}", entity.EventName, entity.EventType);
            return Repo.Insert(entity);
        }
Exemplo n.º 2
0
        public void SaveEvent()
        {
            var dto = new MonitoringEventsDto
            {
                EventName = ConvertEvent(AlertType),
                EventEnd = EndEventTime,
                EventStart = StartEventTime,
                EventType = EndEventTime == DateTime.MinValue ? EventTypeDto.Start : EventTypeDto.End
            };

            var result = EventService.RecordEvent(dto);
            Logger.Trace("Saved event to DB result {0}", result);
        }