public void Handle(CheckNotification notification) { if (square == notification.Square) { InCheck = true; } }
public CheckNotification AddCheckNotification(bool isHealthy) { using (var checkContext = new CheckContext(Options)) { var check = new Check { Name = CheckName }; var checkNotification = new CheckNotification { Check = check, CheckResult = new CheckResult { Check = check, CheckBatch = new CheckBatch(), Type = isHealthy ? CheckResultType.Success : CheckResultType.Failure }, IsHealthy = isHealthy, Version = 1 }; checkContext.CheckNotifications.Add(checkNotification); checkContext.SaveChanges(); return(checkNotification); } }
public DataTable ValidateNotification(CheckNotification obj) { using (SqlCommand sqlCommand = new SqlCommand()) { sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = Procedures.Notification_Validate; sqlCommand.Parameters.AddWithValue("@NotificationId", obj.NotificationId); sqlCommand.Parameters.AddWithValue("@NotificationNumber", obj.NotificationNumber); sqlCommand.Parameters.AddWithValue("@DateOfNotification", obj.DateOfNotification); sqlCommand.Parameters.AddWithValue("@DocFinalDateOfComments", obj.FinalDateOfComment); return(DAL.GetDataTable(ConfigurationHelper.connectionString, sqlCommand)); } }
private async Task SendAsync(Check check, CheckNotification notification, CancellationToken token) { string text; if (notification.IsHealthy) { text = $"The check '{check.Name}' has been HEALTHY since {notification.CheckResult.Time.ToLocalTime()}."; } else { text = $"The check '{check.Name}' has been FAILING since {notification.CheckResult.Time.ToLocalTime()}."; } await _sender.SendNotificationAsync(text, token); }
public void PropertyValueChange_CallsBoth() { _changedProperty = new NotificationData(); _changingProperty = new NotificationData(); //setup CheckNotification not = new CheckNotification(); not.PropertyChanged += new PropertyChangedEventHandler(ChangedName); not.PropertyChanging += new PropertyChangingEventHandler(ChangingName); //act not.Name = "Test"; //assert Assert.That(_changingProperty.PropertyName, new EqualConstraint("Name")); Assert.That(_changedProperty.PropertyName, new EqualConstraint("Name")); Assert.That(_changingProperty.PropertyValue, new EqualConstraint(null)); Assert.That(_changedProperty.PropertyValue, new EqualConstraint("Test")); Assert.That(_changingProperty.TimeOfCall, new LessThanConstraint(_changedProperty.TimeOfCall), "First changing must be called, afterwards changed"); }
public async Task Run(Check check, CheckNotification notification, CheckResult result, CheckerSettings settings, ICheckLogger logger) { _check = check; _notification = notification; _result = result; _settings = settings; _logger = logger; logger.Info($"Running {GetType().Name}"); var message = $"Check {_check.Name} completed in {_result.TimeMS}ms with result status: {_result.Status.Name.ToString()} (Type: {_result.Status.Type.Name})"; var failed = result.Status.Type.Identifier == nameof(ResultTypeEnum.Failed); if (notification.Sent != null && !failed) { logger.Info("Notification sent and no longer failing, resetting"); await SendNotification(NotificationType.Fixed, message); notification.Sent = null; } else if (notification.Sent == null && failed) { var sent = false; if (!sent) { sent = await CheckCount(message); } if (!sent) { sent = await CheckMinutes(message); } if (sent) { notification.Sent = DateTime.UtcNow; } } else if (notification.Sent != null) { logger.Info($"Notification already sent at {notification.Sent}"); } }
public void PropertyValueMatchesPrev_NoCall() { _changedProperty = new NotificationData(); _changingProperty = new NotificationData(); //setup CheckNotification not = new CheckNotification(); not.Name = "Test"; not.PropertyChanging += new PropertyChangingEventHandler(ChangingName); not.PropertyChanged += new PropertyChangedEventHandler(ChangedName); //act not.Name = "Test"; //assert Assert.That(_changingProperty.PropertyName, new EqualConstraint(null)); Assert.That(_changedProperty.PropertyName, new EqualConstraint(null)); Assert.That(_changingProperty.PropertyValue, new EqualConstraint(null)); Assert.That(_changedProperty.PropertyValue, new EqualConstraint(null)); Assert.That(_changedProperty.TimeOfCall, new EqualConstraint(0)); Assert.That(_changingProperty.TimeOfCall, new EqualConstraint(0)); }