Ejemplo n.º 1
0
        private void NotifyUpDown(Endpoint endpoint, EndpointStatus status)
        {
            if (status.InProgressResults == null || !status.InProgressResults.Any())
            {
                return;
            }

            if (status.InProgressResults.Last().Success)
            {
                if (status.IsUp == false || status.IsUp == null)
                {
                    // Endpoint has just come up
                    _notifier.NotifyUp(endpoint, status.DownAsOf);
                }
                // If old status is true, don't notify that it's up
            }
            else
            {
                if (status.IsUp == null || status.IsUp == true)
                {
                    // Endpoint has just gone down
                    _notifier.NotifyDown(endpoint, status.DownAsOf ?? status.InProgressResults.Last().Start, status.InProgressResults.Last().Error);
                }
                else if (status.LastFinishedResults?.Last().Error?.ToString() != status.InProgressResults.Last().Error?.ToString())
                {
                    // Endpoint is down, but with a different error
                    _notifier.NotifyDown(endpoint, status.DownAsOf ?? status.InProgressResults.Last().Start, status.InProgressResults.Last().Error);
                }
            }
        }