Пример #1
0
        public static ServerEvent GetServerEvent(ServerEventDto srvEventDto1, ServerEventDto srvEventDto2, long alertThreshold)
        {
            long duration = Math.Abs(srvEventDto1.Timestamp - srvEventDto2.Timestamp);
            bool alert    = duration > alertThreshold;

            return(string.IsNullOrEmpty(srvEventDto1.Type)
                ? ServerEventFactory.createBaseServerEvent(srvEventDto1, srvEventDto2, duration, alert)
                : ServerEventFactory.createAppServerEvent(srvEventDto1, srvEventDto2, duration, alert));
        }
Пример #2
0
 private static ServerEvent createBaseServerEvent(ServerEventDto srvEventDto1, ServerEventDto srvEventDto2, long duration, bool alert)
 {
     return(new ServerEvent
     {
         Id = srvEventDto1.Id,
         Duration = duration,
         Alert = alert
     });
 }
Пример #3
0
 private static ServerEvent createAppServerEvent(ServerEventDto srvEventDto1, ServerEventDto srvEventDto2, long duration, bool alert)
 {
     return(new AppServerEvent
     {
         Id = srvEventDto1.Id,
         Duration = duration,
         Alert = alert,
         Type = srvEventDto1.Type,
         Host = srvEventDto1.Host
     });
 }
Пример #4
0
        private bool tryGetPairedEvent(ServerEventDto eventDto, out ServerEventDto pairedEvent)
        {
            if (_tempSavedEvents.TryRemove(eventDto.Id, out pairedEvent))
            {
                return(true);
            }

            if (!_tempSavedEvents.TryAdd(eventDto.Id, eventDto))
            {
                if (_tempSavedEvents.TryRemove(eventDto.Id, out pairedEvent))
                {
                    return(true);
                }
            }

            return(false);
        }