/// <summary> /// Gets the output message. /// </summary> /// <param name="result">if set to <c>true</c> health check was successful; otherwise <c>failed</c>.</param> /// <param name="hc">The hc.</param> /// <returns>The Formatted Message</returns> private HealthCheckMessage GetOutputMessage(bool result, IHealthCheck hc) { //Green Condition if (result && _failureTracking.ContainsKey(hc.Id)) { var dt = _failureTracking[hc.Id]; _failureTracking.Remove(hc.Id); return new HealthCheckMessage { Type = HealthCheckMessageType.CheckSucceeded, Message = hc.GetSuccessMessage(dt), SendMail = true }; } //Red Condition - New if (!result && !_failureTracking.ContainsKey(hc.Id)) { _failureTracking.Add(hc.Id, DateTime.Now); return new HealthCheckMessage { Type = HealthCheckMessageType.CheckFailed, Message = hc.GetFailureMessage(), SendMail = true }; } //Red Condition - Repeated Issue if (!result && _failureTracking.ContainsKey(hc.Id)) { var dt = _failureTracking[hc.Id]; if (dt.AddMilliseconds(HeartBeatSettings.SettingsManager.RenotifyAfter) < DateTime.Now) { //If the time it was logged at + the renotify after value < that now... alert again & bump the notification. _failureTracking[hc.Id] = DateTime.Now; return new HealthCheckMessage { Type = HealthCheckMessageType.CheckFailed, Message = hc.GetFailureMessage(), SendMail = true }; } } //Status Unchanged since last time - just log to file return new HealthCheckMessage { Type = result ? HealthCheckMessageType.CheckSucceeded : HealthCheckMessageType.CheckFailed, Message = result ? hc.GetSuccessMessage() : hc.GetFailureMessage(), SendMail = false }; }