示例#1
0
        private static string CreateTimeOfMonthValue(TimeSpan runTime, TimeOfMonthToRun timeOfMonthToRun, int dayToRun, int amountOfMonthsToRunAfter)
        {
            CronGenerationValueValidator.ValidateMonthsToRunAfter(amountOfMonthsToRunAfter);

            if (timeOfMonthToRun != TimeOfMonthToRun.Last)
            {
                var day = ParseDayOfWeek(dayToRun);
                var timeOfMonuthToRunIntValue = (int)timeOfMonthToRun;
                return($"{ParseCronTimeSpan(runTime)} ? 1/{amountOfMonthsToRunAfter} {day}#{timeOfMonuthToRunIntValue} *");
            }
            else
            {
                var day = dayToRun + 1;
                return($"{ParseCronTimeSpan(runTime)} ? 1/{amountOfMonthsToRunAfter} {day}L *");
            }
        }
示例#2
0
 /// <summary>
 /// Generate a cron expression that runs at a set time of the month every x months
 /// Example : A cron that will run run at 13:00 on the second Friday every 3 months
 /// </summary>
 /// <param name="runTime">Time that the cron will run</param>
 /// <param name="timeOfMonthToRun">Period of the month the cron will run (Frst, Second, Thrid, Fourth, or Last)</param>
 /// <param name="dayToRun">Day that the cron will run (0 - 6)</param>
 /// <param name="amountOfMonthsToRunAfter">Time between months that the cron will run on (1-12)</param>
 /// <returns>Cron experssion</returns>
 public static string GenerateSetDayMonthlyCronExpression(TimeSpan runTime, TimeOfMonthToRun timeOfMonthToRun, int dayToRun, int amountOfMonthsToRunAfter)
 {
     return(CreateTimeOfMonthValue(runTime, timeOfMonthToRun, dayToRun, amountOfMonthsToRunAfter));
 }