您好,登錄后才能下訂單哦!
- public class ManInfo
- {
- static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(InfoBLL));
- public static void Start()
- {
- ISchedulerFactory _schedFactory = new StdSchedulerFactory();
- logger.Info("開始執行程序");
- try
- {
- //計劃任務
- 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("開始更改信息狀態");
- Import();
- logger.Info("開始修復更改出現的信息");
- 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>定時更新狀態</name>
- <group>定時更新</group>
- <description>定時更新產品的狀態類型</description>
- <job-type>MyInfo.InfoBLL,MyInfo</job-type>
- </job-detail>
- <trigger>
- <cron>
- <name>定時更新狀態</name>
- <group>定時更新</group>
- <job-name>定時更新</job-name>
- <job-group>定時更新</job-group>
- <cron-expression> 0 * 15 * * ? </cron-expression>
- </cron>
- </trigger>
- </job>
- </quartz>
配置文件說明見下一篇!O(∩_∩)O~
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。