/// <summary> /// /// </summary> public Rule Validate(QueryProvider qp) { if (null == DateTimeMathParser.ToDuration(Frequency, TimeUnit.Second)) { AlertValidationException.ThrowBadParseFrequency(); } if (!string.IsNullOrEmpty(For) && !DateTimeMathParser.ToDuration(For, TimeUnit.Second).HasValue) { AlertValidationException.ThrowBadParseFor(); } if (null == Conditions || 0 == Conditions.Length) { AlertValidationException.ThrowNoCondtitions(); } if (!Enum.IsDefined(typeof(NoDataOptions), NoDataOption)) { AlertValidationException.ThrowBadParseNoDataOption(); } if (!Enum.IsDefined(typeof(ErrorOptions), ErrorOption)) { AlertValidationException.ThrowBadParseErrorOption(); } Conditions .ToList() .ForEach(c => c.Validate(qp)); return(this); }
/// <summary> /// /// </summary> /// <param name="r"></param> public void Update(Alerts.Rule r) { Name = r.Name; Frequency = ( int )DateTimeMathParser.ToDuration(r.Frequency); Settings = JsonConvert.SerializeObject(r, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented }); }