public static ICalendar GetCalendar(this SnapshotRule rule) { if (rule.HasCalendar() == false) { return(null); } // Modify here to handle several calendar if necessary in the future // Beware of calling GetExcludingDayRange if no exclusion range enabled rule.GetExcludingDayRange(out DateTime from, out DateTime to); return(new DailyCalendar(from, to)); }
public static ITrigger GetTrigger(this SnapshotRule rule) { TriggerBuilder builder = TriggerBuilder.Create() .WithIdentity(rule.ToString(), "SnapshotJob") .WithCronSchedule(rule.GeneratedCron) .StartAt(rule.PeriodStart) .UsingJobData("RuleId", rule.Id) .WithDescription(rule.ToString()); if (rule.PeriodEndEnabled) { builder = builder.EndAt(rule.PeriodEnd); } if (rule.HasCalendar()) { builder = builder.ModifiedByCalendar(rule.GetCalendarName()); } return(builder.Build()); }