c# - How to setup Quartz.NET for scheduling Emails -
c# - How to setup Quartz.NET for scheduling Emails -
there 2 solutions quartz.server.2008.sln , quartz.2008.sln in downloaded quartz.net library. have setup recurring job. there table in database schedules defined (like first fri of month, each 5 in month, each sunday 12 am...etc). have method executed on schedule. how can utilize quartz.net schedule database , set method execute? proper steps?
i think can create windows service running in background. can read schedulefromdatabase varaible database , pass quartz.
this little illustration console app:
static void main(string[] args) { ischedulerfactory schedfact = new stdschedulerfactory(); ischeduler sched = schedfact.getscheduler(); sched.start(); jobdetail jobdetail = new jobdetail("myjob", null, typeof(hellojob)); //read string database string schedulefromdatabase="0 11 16 ? * fri,sun"; crontrigger trigger = new crontrigger("trigger1", null, "myjob", null,schedulefromdatabase ); trigger.starttimeutc = datetime.utcnow; trigger.name = "mytrigger"; sched.schedulejob(jobdetail, trigger); } public class hellojob:ijob { public void execute(jobexecutioncontext context) { console.writeline(datetime.now.tostring()); //call here method! } } this can useful:
quartz.net server documentation
c# asp.net scheduled-tasks scheduling quartz.net
Comments
Post a Comment