/// <summary> /// GetChecklistState /// </summary> /// <param name="ruleId">ruleId</param> /// <param name="frequency">frequency</param> /// <param name="lastService">lastService</param> /// <param name="nextDue">nextDue</param> /// <param name="companyId">companyId</param> /// <returns>State</returns> private string GetChecklistState(int ruleId, string frequency, DateTime? lastService, DateTime? nextDue, int companyId) { string state = "Healthy"; if (nextDue.HasValue) { if ((DateTime)nextDue < DateTime.Now) { state = "Expired"; } else { RuleGateway ruleGateway = new RuleGateway(); ruleGateway.LoadAllByRuleId(ruleId, companyId); int? alarmDays = ruleGateway.GetAlarmDays(ruleId); if (alarmDays.HasValue) { TimeSpan diference; int daysBeforeNextDue = 0; diference = (DateTime)nextDue - DateTime.Now; daysBeforeNextDue = diference.Days; if (daysBeforeNextDue <= (int)alarmDays) { state = "Warning"; } } } } return state; }