Beispiel #1
0
        public async Task <AlertTypeDto> PutAlertType(int id, AlertTypeDto model)
        {
            var url    = CRMApiUri + "/AlertType/" + id;
            var result = await PutRequestToApi(url, model);

            return(result);
        }
Beispiel #2
0
        public async Task <BaseEntity> SaveAndReturnEntityAsync(AlertTypeDto entityDto)
        {
            var entity = _mapper.Map <AlertType>(entityDto);
            var result = await _repository.SaveAndReturnEntityAsync(entity);

            return(result);
        }
Beispiel #3
0
        public async Task <AlertTypeDto> PostAlertType(AlertTypeDto model)
        {
            var url    = CRMApiUri + "/AlertType";
            var result = await PostRequestToApi(url, model);

            return(result);
        }
Beispiel #4
0
        public async Task <IActionResult> Post([FromBody] AlertTypeDto alertType)
        {
            if (alertType.Id != 0)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Identity insert is not permitted."));
            }

            return(await SaveAndReturnEntityAsync(async() => await _AlertTypeService.SaveAndReturnEntityAsync(alertType)));
        }
Beispiel #5
0
        public async Task <IActionResult> Put(int id, [FromBody] AlertTypeDto alertType)
        {
            if (id == 0 || alertType.Id == 0)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Id needs to be greater than 0."));
            }

            return(await SaveAndReturnEntityAsync(async() => await _AlertTypeService.SaveAndReturnEntityAsync(alertType)));
        }
Beispiel #6
0
 public AlertIntervals(AlertSettingsDto service, AlertTypeDto alertType)
 {
     var item = service.AlertRules.FirstOrDefault(x => x.AlertType == alertType);
     if (item != null)
     {
         var notificationTime = item.ThresholdTime;
         CriticalNotification = TimeSpan.FromSeconds(notificationTime);
     }
 }
Beispiel #7
0
 public AlertThreshold(AlertSettingsDto service, AlertTypeDto alertType)
 {
     var item = service.AlertRules.FirstOrDefault(x => x.AlertType == alertType);
     if (item != null)
     {
         var critical = item.Percentage;
         CriticalLoad = critical;
     }
 }
Beispiel #8
0
 public Notifier(TimeSpan interval, IEventService eventService, ISmtpClient client, IFile file, ILogger logger, AlertTypeDto type)
 {
     Interval     = interval;
     EventService = eventService;
     SmtpClient   = client;
     File         = file;
     Logger       = logger;
     Sendy        = new EmailSender(file, logger, client);
     AlertType    = type;
 }
Beispiel #9
0
        public AlertIntervals(AlertSettingsDto service, AlertTypeDto alertType)
        {
            var item = service.AlertRules.FirstOrDefault(x => x.AlertType == alertType);

            if (item != null)
            {
                var notificationTime = item.ThresholdTime;
                CriticalNotification = TimeSpan.FromSeconds(notificationTime);
            }
        }
Beispiel #10
0
 public Notifier(TimeSpan interval, IEventService eventService, ISmtpClient client, IFile file, ILogger logger, AlertTypeDto type)
 {
     Interval = interval;
     EventService = eventService;
     SmtpClient = client;
     File = file;
     Logger = logger;
     Sendy = new EmailSender(file, logger, client);
     AlertType = type;
 }
Beispiel #11
0
        public AlertThreshold(AlertSettingsDto service, AlertTypeDto alertType)
        {
            var item = service.AlertRules.FirstOrDefault(x => x.AlertType == alertType);

            if (item != null)
            {
                var critical = item.Percentage;
                CriticalLoad = critical;
            }
        }
Beispiel #12
0
        private string ConvertEvent(AlertTypeDto type)
        {
            switch (type)
            {
            case AlertTypeDto.Cpu:
                return(EventName.CpuEvent);

            case AlertTypeDto.Network:
                return(EventName.NetworkEvent);

            case AlertTypeDto.Hdd:
                return(EventName.HddSpaceEvent);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Beispiel #13
0
        public IActionResult Save(AlertTypeDto model)
        {
            UpdateAuditInformation(model);
            if (!ModelState.IsValid)
            {
                GetStateSettings(ViewState.Write);
                return(PartialView("Edit", model));
            }
            model = model.Id > 0
                ? _lookupFacadeApiClient.PutAlertType(model.Id, model).Result
                : _lookupFacadeApiClient.PostAlertType(model).Result;

            if (!string.IsNullOrWhiteSpace(model.ErrorMessage))
            {
                return(PartialView("Edit", model));
            }
            return(Json(new { message = model.SuccessMessage }));
        }
Beispiel #14
0
        public async Task <int> SaveAsync(AlertTypeDto entityDto)
        {
            var result = await SaveAndReturnEntityAsync(entityDto);

            return(result.Id);
        }
Beispiel #15
0
 private string ConvertEvent(AlertTypeDto type)
 {
     switch (type)
     {
         case AlertTypeDto.Cpu:
             return EventName.CpuEvent;
         case AlertTypeDto.Network:
             return EventName.NetworkEvent;
         case AlertTypeDto.Hdd:
             return EventName.HddSpaceEvent;
         default:
             throw new ArgumentOutOfRangeException(nameof(type), type, null);
     }
 }
Beispiel #16
0
 public ConfigurationReader(ISettingsService<AlertSettingsDto> settings, AlertTypeDto alertType)
 {
     Settings = settings;
     AlertType = alertType;
 }
Beispiel #17
0
 public async Task <AlertTypeDto> PutAlertType(int id, AlertTypeDto model)
 {
     return(await _alertTypeApiClient.PutAlertType(id, model));
 }
Beispiel #18
0
 public async Task <AlertTypeDto> PostAlertType(AlertTypeDto model)
 {
     return(await _alertTypeApiClient.PostAlertType(model));
 }
Beispiel #19
0
 public ConfigurationReader(ISettingsService <AlertSettingsDto> settings, AlertTypeDto alertType)
 {
     Settings  = settings;
     AlertType = alertType;
 }