where should I locatemy Quartz Code in asp.net -
i have asp.net website , want task once day. task is: sending email users 2 days before expiration of registration. used quartz.net version 1.0. have wrote sample code opens window in each second. don't know should locate code in asp.net project?! in simple page. want independent pages.
public class dumbjob : ijob { public dumbjob() { } public void execute(jobexecutioncontext context) { console.writeline("dumbjob executing."); system.windows.forms.messagebox.show("nice"); } } protected void page_load(object sender, eventargs e) { if (!ispostback) { // construct scheduler factory ischedulerfactory schedfact = new stdschedulerfactory(); // scheduler ischeduler sched = schedfact.getscheduler(); sched.start(); // construct job info jobdetail jobdetail = new jobdetail("myjob", null, typeof(dumbjob)); // fire every hour trigger trigger = triggerutils.makesecondlytrigger();//.makehourlytrigger(); // start on next hour trigger.starttimeutc = triggerutils.getevenseconddate(datetime.utcnow); trigger.name = "mytrigger"; sched.schedulejob(jobdetail, trigger); } }
there various ways can that...but it's better o build sort of console applications case.
frankly simplest of windows schedule task trigger every day , launch exe program (that you'd write using console dotnet) check soon-to-expire users , send email when found... if don't want have user + email code in various places (and centralize in dotnet web app), i'd create soap/rest end point in .net webapp called thin client, scheduled "windows schedule task"
quartz give more flexibility when comes scheduling , doing more enterprise things job clustering / job high availability / job monitoring example... that'd still .net console app start quartz scheduler, create trigger, , run forever...(possibly wrapped windows "wrapper" service more control)
Comments
Post a Comment