public void CheckAlert(Server server, Alert alert) { var chart = _chartDataGenerator.GenerateChart(server.Name); var dataSet = chart.DataSets.FirstOrDefault(x => x.Label == alert.Dataset); if (alert.Thresholds == null || !alert.Thresholds.Any() || dataSet?.Points == null || !dataSet.Points.Any()) { return; } ChechIfDataHasBeenReceived(server, alert, dataSet); var thresholds = alert.Thresholds.OrderByDescending(x => x.Level); foreach (var alertThreshold in thresholds) { var dataPoints = dataSet.Points.OrderByDescending(x => x.Label).Take(alertThreshold.DurationInMin); if (dataPoints.All(x => double.Parse(x.Value.ToString()) >= alertThreshold.Threshold)) { _notifierService.Notify( _notificationBuilder .Where(x => x.AlertLevel = alertThreshold.Level) .Where(x => x.Message = GenerateMessage(server, alert, alertThreshold)).Build()); break; } } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { GroupCreateDTO groupCreate = new GroupCreateDTO(); groupCreate.ObjectGuid = Guid.NewGuid().ToString().Replace("-", ""); groupCreate.SamAccountName = "Group SamAccountName 11111"; groupCreate.DisplayName = "Group DisplayName 1212121212"; groupCreate.Name = "Group Name 12121212"; groupCreate.Description = "Group Description 12121212"; groupCreate.DistinguishedName = "Group DistinguishedName asakdalk"; groupCreate.GroupScope = GroupScopeEnum.DOMAIN.ToString(); groupCreate.GroupType = GroupTypeEnum.DISTRIBUTION.ToString(); groupCreate.LastAdChangeMillis = DateTimeOffset.Now.ToUnixTimeMilliseconds(); SyncEventDTO body = new SyncEventDTO(); body.ActiveDirectoryId = "5c11b84a4e9b467d84356761448a997e"; body.Type = "GROUP_CREATE"; body.Message = groupCreate; Console.WriteLine("ExecuteAsync ... "); BrokerHeader header = new BrokerHeader(); header.Tenant = "12345"; header.User = "******"; BrokerMessage message = new BrokerMessage(header, body); await _notifierService.Notify(message); }
public async Task <string> GetQuoteAsync() { try { var request = new HttpRequestMessage() { RequestUri = new Uri(new Uri(ServerAddress), QuoteEndpoint), Method = HttpMethod.Get, }; var response = await _httpClient.SendAsync(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var quoteString = await response.Content.ReadAsStringAsync(); return(quoteString); } else { return(DefaultQuote); } } catch (Exception e) { _notifier.Notify("Network error"); return(null); } }
protected void Notify(INotifierService service, NotifierData data) { try { service.Notify(data); } catch (Exception ex) { _exceptionLogger.Log(ex); } }
protected void Notify(INotifierService service, NotifierData data) { try { service.Notify(data); } catch (Exception ex) { _logger.Error <NotificationsService>(ex); } }
public async Task <IActionResult> Post([FromBody] MessageRequest content) { await _customerService.Notify(content?.Message); return(CreateResponseOnPost()); }