您好,登錄后才能下訂單哦!
- public class ManInfo
- {
- static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(InfoBLL));
- public static void Start()
- {
- ISchedulerFactory _schedFactory = new StdSchedulerFactory();
- logger.Info("開始執(zhí)行程序");
- try
- {
- //計(jì)劃任務(wù)
- IScheduler sched = _schedFactory.GetScheduler();
- JobSchedulingDataProcessor processor = new JobSchedulingDataProcessor(true, true);
- Stream s = new FileStream(AppDomain.CurrentDomain.BaseDirectory + (@"macher-setting.xml"), FileMode.Open);
- processor.ProcessStream(s, null);
- processor.ScheduleJobs(new Hashtable(), sched, false);
- sched.Start();
- }
- catch (Exception ex)
- {
- logger.Error("Application_Start:" + ex);
- }
- }
- }
記得要引用QuartZ.dll
- public class InfoBLL : IJob
- {
- static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(InfoBLL));
- void IJob.Execute(JobExecutionContext context)
- {
- logger.Info("開始更改信息狀態(tài)");
- Import();
- logger.Info("開始修復(fù)更改出現(xiàn)的信息");
- repair();
- // System.Threading.WaitCallback waitCallback = new WaitCallback(BindWLT);
- //ThreadPool.QueueUserWorkItem(waitCallback, arr);
- //ThreadPool.QueueUserWorkItem(waitCallback, arr1);
- }
- }
記得一定要繼承接口!
最重要的要配置:
- <?xml version="1.0" encoding="utf-8" ?>
- <quartz xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" overwrite-existing-jobs="true">
- <job>
- <job-detail>
- <name>定時(shí)更新狀態(tài)</name>
- <group>定時(shí)更新</group>
- <description>定時(shí)更新產(chǎn)品的狀態(tài)類型</description>
- <job-type>MyInfo.InfoBLL,MyInfo</job-type>
- </job-detail>
- <trigger>
- <cron>
- <name>定時(shí)更新狀態(tài)</name>
- <group>定時(shí)更新</group>
- <job-name>定時(shí)更新</job-name>
- <job-group>定時(shí)更新</job-group>
- <cron-expression> 0 * 15 * * ? </cron-expression>
- </cron>
- </trigger>
- </job>
- </quartz>
配置文件說明見下一篇!O(∩_∩)O~
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。