Quartz.Net Cron Expression for Monthly, Weekly, and Daily

I am new to quartz.net and a cron expression, and I need to create a quartz.net scheduler in a C # dotnet application, which should run in Monthly, Weekly, and Daily based on the values ​​it receives from the database.

A table that contains planning details.

Id EffectiveDate  StartTime  Frequency  
 1  2012-04-22      20:55      Daily       
 2  2012-04-22      10:12      Weekly     
 3  2012-04-22      17:00      Daily   
 4  2012-04-23      02:15      Monthly   
 5  2012-04-26      18:30      Daily        
 6  2012-04-27      11:45      Weekly

Please help me solve this problem.

+3
source share
1 answer

@ user1301587, I hope you found the way forward, but I noticed that your question is still quite high on Google, so I will continue and add some psuedo code on how I will do this:

  • ( )
  • CronScheduleBuilder :

    string cronExpression = string.Format( "{0} {1} {2} {3} {4} {5}",                           ,                          minutePart,                          hourPart,                          dayOfMonthPart,                          monthPart,                          dayOfWeekPart                          );

    IScheduleBuilder scheduleBuilder = CronScheduleBuilder
                    .CronSchedule(cronExpression)
                    .InTimeZone(TimeZoneInfo.Utc);
    

. cron 0 26 6 * *? 6:26 , , Quartz , UTC,

, :

ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create()
                .WithIdentity("TestTrigger")
                .WithSchedule(scheduleBuilder)
                .Build();

, Quart.Net

+3

All Articles