public async Task <AlertGroup> Edit(AlertGroup model) { var updateResult = await _alertGroupRepository.Update(model); if (updateResult) { return(await _alertGroupRepository.Read(model.Id)); } return(model); }
private async Task <IList <AlertValue> > AlertValuesForAlertGroup(AlertGroup group) { var alertValues = new List <AlertValue>(); foreach (var alert in group.Alerts) { var values = await _alertValueService.AlertValuesForAlert(alert.Id); alertValues.AddRange(values); } return(alertValues.Where(av => !av.AlertGroupValueId.HasValue).OrderBy(e => e.TimespanStart).ToList()); }
public static bool CanAlert(string groupname, int resetInterval) { if (String.IsNullOrEmpty(groupname) || resetInterval == 0) return true; var ag = AlertGroups.FirstOrDefault(p => p.Name == groupname); if (ag == null) { ag = new AlertGroup(groupname); AlertGroups.Add(ag); return true; } if ((Now - ag.LastReset).TotalSeconds >= resetInterval) { ag.LastReset = Now; return true; } ag.LastReset = Now; return false; }
public static bool CanAlert(string groupname, int resetInterval) { if (string.IsNullOrEmpty(groupname) || resetInterval == 0) { return(true); } var ag = AlertGroups.FirstOrDefault(p => p.Name == groupname); if (ag == null) { ag = new AlertGroup(groupname); AlertGroups.Add(ag); return(true); } if ((Now - ag.LastReset).TotalSeconds >= resetInterval) { ag.LastReset = Now; return(true); } ag.LastReset = Now; return(false); }
public async Task <AlertGroup> Create(AlertGroup model) { var createdId = await _alertGroupRepository.Create(model); return(await _alertGroupRepository.Read(createdId)); }