public MonthOnLastDayOfMonthUnit(Schedule schedule, int duration)
 {
     Schedule = schedule;
     Duration = duration;
     Schedule.CalculateNextRun = x =>
         {
             var nextRun = x.Date.LastDayOfMonth();
             return (x > nextRun) ? x.Date.FirstDayOfMonth().AddMonths(Duration).LastDayOfMonth() : x.Date.LastDayOfMonth();
         };
 }
 public YearOnLastDayOfYearUnit(Schedule schedule, int duration)
 {
     Schedule = schedule;
     Duration = duration;
     Schedule.CalculateNextRun = x =>
         {
             var nextRun = x.Date.FirstDayOfYear().AddMonths(11).LastDayOfMonth();
             return (x > nextRun) ? x.Date.FirstDayOfYear().AddYears(Duration).AddMonths(11).LastDayOfMonth() : nextRun;
         };
 }
 public YearOnDayOfYearUnit(Schedule schedule, int duration, int dayOfYear)
 {
     Schedule = schedule;
     Duration = duration;
     DayOfYear = dayOfYear;
     Schedule.CalculateNextRun = x =>
         {
             var nextRun = x.Date.FirstDayOfYear().AddDays(DayOfYear - 1);
             return (x > nextRun) ? x.Date.FirstDayOfYear().AddYears(Duration).AddDays(DayOfYear - 1) : nextRun;
         };
 }
 public MonthOnDayOfMonthUnit(Schedule schedule, int duration, int dayOfMonth)
 {
     Schedule = schedule;
     Duration = duration;
     DayOfMonth = dayOfMonth;
     Schedule.CalculateNextRun = x =>
         {
             var nextRun = x.Date.FirstDayOfMonth().AddDays(DayOfMonth - 1);
             return (x > nextRun) ? x.Date.FirstDayOfMonth().AddMonths(Duration).AddDays(DayOfMonth - 1) : nextRun;
         };
 }
Example #5
0
 public WeekUnit(Schedule schedule, int duration)
 {
     Schedule = schedule;
     Duration = duration;
     if (Duration < 0)
         Duration = 0;
     Schedule.CalculateNextRun = x =>
         {
             var nextRun = x.Date.AddDays(Duration*7);
             return (x > nextRun) ? nextRun.AddDays(Math.Max(Duration, 1)*7) : nextRun;
         };
 }
 public MonthOnDayOfWeekUnit(Schedule schedule, int duration, Week week, DayOfWeek dayOfWeek)
 {
     Schedule = schedule;
     Duration = duration;
     Week = week;
     DayOfWeek = dayOfWeek;
     if (Week == Week.Last)
         Schedule.CalculateNextRun = x =>
             {
                 var nextRun = x.Date.FirstDayOfMonth().LastWeekdayOfMonth(DayOfWeek);
                 return (x > nextRun) ? x.Date.FirstDayOfMonth().AddMonths(Duration).LastWeekdayOfMonth(DayOfWeek) : nextRun;
             };
     else
         Schedule.CalculateNextRun = x =>
             {
                 var nextRun = x.Date.FirstDayOfMonth().AddWeeks((int)Week).NextDayOfWeek(DayOfWeek);
                 return (x > nextRun)
                            ? x.Date.FirstDayOfMonth().AddMonths(Duration).AddWeeks((int)Week).NextDayOfWeek(DayOfWeek)
                            : nextRun;
             };
 }
 public WeeklyDayOfWeekUnit(Schedule schedule, int duration, DayOfWeek day)
 {
     Schedule = schedule;
     Duration = duration;
     Day = day;
     if (Duration > 0)
     {
         Schedule.CalculateNextRun = x =>
             {
                 var nextRun = x.Date.AddDays(Duration * 7).NextDayOfWeek(day);
                 return (x > nextRun) ? nextRun.AddDays(Duration * 7) : nextRun;
             };
     }
     else
     {
         Schedule.CalculateNextRun = x =>
             {
                 var nextRun = x.Date.NextDayOfWeek(day, false);
                 return (x > nextRun) ? nextRun.AddDays(7) : nextRun;
             };
     }
 }
Example #8
0
 public MonthUnit(Schedule schedule, int duration)
 {
     Schedule = schedule;
     Duration = duration;
     Schedule.CalculateNextRun = x => x.Date.AddMonths(Duration);
 }