/// <summary> /// Create a CronScheduleBuilder with a cron-expression that sets the /// schedule to fire one per week on the given day at the given time /// (hour and minute). /// </summary> /// <remarks> /// </remarks> /// <param name="dayOfWeek">the day of the week to fire</param> /// <param name="hour">the hour of day to fire</param> /// <param name="minute">the minute of the given hour to fire</param> /// <returns>the new CronScheduleBuilder</returns> /// <seealso cref="CronExpression" /> public static CronScheduleBuilder WeeklyOnDayAndHourAndMinute(DayOfWeek dayOfWeek, int hour, int minute) { DateBuilder.ValidateHour(hour); DateBuilder.ValidateMinute(minute); string cronExpression = $"0 {minute} {hour} ? * {(int) dayOfWeek + 1}"; return(CronScheduleNoParseException(cronExpression)); }
/// <summary> /// Create a CronScheduleBuilder with a cron-expression that sets the /// schedule to fire every day at the given time (hour and minute). /// </summary> /// <remarks> /// </remarks> /// <param name="hour">the hour of day to fire</param> /// <param name="minute">the minute of the given hour to fire</param> /// <returns>the new CronScheduleBuilder</returns> /// <seealso cref="CronExpression" /> public static CronScheduleBuilder DailyAtHourAndMinute(int hour, int minute) { DateBuilder.ValidateHour(hour); DateBuilder.ValidateMinute(minute); string cronExpression = $"0 {minute} {hour} ? * *"; return(CronScheduleNoParseException(cronExpression)); }
/// <summary> /// Create a CronScheduleBuilder with a cron-expression that sets the /// schedule to fire every day at the given time (hour and minute). /// </summary> /// <remarks> /// </remarks> /// <param name="hour">the hour of day to fire</param> /// <param name="minute">the minute of the given hour to fire</param> /// <returns>the new CronScheduleBuilder</returns> /// <seealso cref="CronExpression" /> public static CronScheduleBuilder DailyAtHourAndMinute(int hour, int minute) { DateBuilder.ValidateHour(hour); DateBuilder.ValidateMinute(minute); string cronExpression = String.Format("0 {0} {1} ? * *", minute, hour); return(new CronScheduleBuilder(cronExpression)); }
/// <summary> /// Create a CronScheduleBuilder with a cron-expression that sets the /// schedule to fire one per week on the given day at the given time /// (hour and minute). /// </summary> /// <remarks> /// </remarks> /// <param name="dayOfWeek">the day of the week to fire</param> /// <param name="hour">the hour of day to fire</param> /// <param name="minute">the minute of the given hour to fire</param> /// <returns>the new CronScheduleBuilder</returns> /// <seealso cref="CronExpression" /> public static CronScheduleBuilder WeeklyOnDayAndHourAndMinute(DayOfWeek dayOfWeek, int hour, int minute) { DateBuilder.ValidateHour(hour); DateBuilder.ValidateMinute(minute); string cronExpression = string.Format("0 {0} {1} ? * {2}", minute, hour, ((int)dayOfWeek) + 1); return(CronScheduleNoParseException(cronExpression)); }
/// <summary> /// Create a CronScheduleBuilder with a cron-expression that sets the /// schedule to fire one per month on the given day of month at the given /// time (hour and minute). /// </summary> /// <remarks> /// </remarks> /// <param name="dayOfMonth">the day of the month to fire</param> /// <param name="hour">the hour of day to fire</param> /// <param name="minute">the minute of the given hour to fire</param> /// <returns>the new CronScheduleBuilder</returns> /// <seealso cref="CronExpression" /> public static CronScheduleBuilder MonthlyOnDayAndHourAndMinute(int dayOfMonth, int hour, int minute) { DateBuilder.ValidateDayOfMonth(dayOfMonth); DateBuilder.ValidateHour(hour); DateBuilder.ValidateMinute(minute); string cronExpression = $"0 {minute} {hour} {dayOfMonth} * ?"; return(CronScheduleNoParseException(cronExpression)); }
/// <summary> /// Create a CronScheduleBuilder with a cron-expression that sets the /// schedule to fire one per month on the given day of month at the given /// time (hour and minute). /// </summary> /// <remarks> /// </remarks> /// <param name="dayOfMonth">the day of the month to fire</param> /// <param name="hour">the hour of day to fire</param> /// <param name="minute">the minute of the given hour to fire</param> /// <returns>the new CronScheduleBuilder</returns> /// <seealso cref="CronExpression" /> public static CronScheduleBuilder MonthlyOnDayAndHourAndMinute(int dayOfMonth, int hour, int minute) { DateBuilder.ValidateDayOfMonth(dayOfMonth); DateBuilder.ValidateHour(hour); DateBuilder.ValidateMinute(minute); string cronExpression = String.Format("0 {0} {1} {2} * ?", minute, hour, dayOfMonth); return(new CronScheduleBuilder(cronExpression)); }
/// <summary> /// Create a CronScheduleBuilder with a cron-expression that sets the /// schedule to fire at the given day at the given time (hour and minute) on the given days of the week. /// </summary> /// <param name="hour">the hour of day to fire</param> /// <param name="minute">the minute of the given hour to fire</param> /// <param name="daysOfWeek">the days of the week to fire</param> /// <returns>the new CronScheduleBuilder</returns> /// <seealso cref="CronExpression" /> public static CronScheduleBuilder AtHourAndMinuteOnGivenDaysOfWeek(int hour, int minute, params DayOfWeek[] daysOfWeek) { if (daysOfWeek == null || daysOfWeek.Length == 0) { throw new ArgumentException("You must specify at least one day of week."); } DateBuilder.ValidateHour(hour); DateBuilder.ValidateMinute(minute); string cronExpression = $"0 {minute} {hour} ? * {(int) daysOfWeek[0] + 1}"; for (int i = 1; i < daysOfWeek.Length; i++) { cronExpression = cronExpression + "," + ((int)daysOfWeek[i] + 1); } return(CronScheduleNoParseException(cronExpression)); }