資源簡介
Quartz.net做為任務調度核心,利用Log4Net做為日志輸出,C#完成WINDOWS服務在后臺定時執行任務;

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Diagnostics;
using?System.ServiceProcess;
using?System.Text;
using?Quartz;
using?Quartz.Impl;
using?Quartz.xml;
using?System.Collections;
namespace?pa_pip_service
{
????partial?class?Main?:?Servicebase
????{
????????private?ISchedulerFactory?schedulerFactory;
????????private?JobSchedulingDataProcessor?processor;
????????private?static?log4net.ILog?logger?=?log4net.LogManager.GetLogger(typeof(Main));
????????public?Main()
????????{
????????????InitializeComponent();
????????????schedulerFactory?=?new?StdSchedulerFactory();
????????????processor?=?new?JobSchedulingDataProcessor(true?true);
????????}
????????protected?override?void?onstart(string[]?args)
????????{
????????????//?TODO:?在此處添加代碼以啟動服務。
????????????try
????????????{
????????????????IScheduler?scheduler?=?schedulerFactory.GetScheduler();//獲取一個調度接口
????????????????string?fileName?=?AppDomain.CurrentDomain.baseDirectory?+?“JobConfiguration.xml“;
????????????????processor.ProcessFile(fileName?null);
????????????????processor.ScheduleJobs(new?Hashtable()?scheduler?false);
????????????????scheduler.Start();//啟動調度
????????????????logger.Info(“service?started?ok“);
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????logger.Error(“service?started?fail“?ex);
????????????}
????????}
????????protected?override?void?onstop()
????????{
????????????//?TODO:?在此處添加代碼以執行停止服務所需的關閉操作。
????????????try
????????????{
????????????????IScheduler?scheduler?=?schedulerFactory.GetScheduler();
????????????????scheduler.Shutdown(true);
????????????????logger.Info(“service?stopped?ok“);
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????logger.Error(“service?stopped?fail“?ex);
????????????}
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????28672??2009-07-24?16:44??C#定時調度任務服務\測試\Debug\Common.Logging.dll
?????文件????????106??2014-02-05?21:47??C#定時調度任務服務\測試\Debug\Install.bat
?????文件??????28672??2005-09-23?07:28??C#定時調度任務服務\測試\Debug\InstallUtil.exe
?????文件????????775??2014-02-05?21:37??C#定時調度任務服務\測試\Debug\JobConfiguration.xm
?????文件????????664??2014-02-05?20:22??C#定時調度任務服務\測試\Debug\Log4Net.config
?????文件?????303104??2013-11-18?05:51??C#定時調度任務服務\測試\Debug\log4net.dll
?????文件????????834??2014-02-05?21:56??C#定時調度任務服務\測試\Debug\logs\log.txt
?????文件???????7168??2014-02-05?21:46??C#定時調度任務服務\測試\Debug\pa_pip_service.exe
?????文件??????11608??2014-02-05?21:46??C#定時調度任務服務\測試\Debug\pa_pip_service.vshost.exe
?????文件???????5632??2014-02-05?21:38??C#定時調度任務服務\測試\Debug\pa_pip_service_library.dll
?????文件?????438272??2010-08-22?20:53??C#定時調度任務服務\測試\Debug\Quartz.dll
?????文件?????????44??2014-02-05?21:47??C#定時調度任務服務\測試\Debug\UnInstall.bat
?????文件??????28672??2009-07-24?16:44??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\app.publish\Application?Files\pa_pip_service_1_0_0_0\Common.Logging.dll.deploy
?????文件????????775??2014-02-05?21:37??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\app.publish\Application?Files\pa_pip_service_1_0_0_0\JobConfiguration.xm
?????文件?????303104??2013-11-18?05:51??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\app.publish\Application?Files\pa_pip_service_1_0_0_0\log4net.dll.deploy
?????文件???????6656??2014-02-05?21:59??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\app.publish\Application?Files\pa_pip_service_1_0_0_0\pa_pip_service.exe.deploy
?????文件???????9769??2014-02-05?21:59??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\app.publish\Application?Files\pa_pip_service_1_0_0_0\pa_pip_service.exe.manifest
?????文件???????5632??2014-02-05?21:38??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\app.publish\Application?Files\pa_pip_service_1_0_0_0\pa_pip_service_library.dll.deploy
?????文件?????438272??2010-08-22?20:53??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\app.publish\Application?Files\pa_pip_service_1_0_0_0\Quartz.dll.deploy
?????文件???????5470??2014-02-05?21:59??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\app.publish\pa_pip_service.application
?????文件?????495104??2014-02-05?21:59??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\app.publish\setup.exe
?????文件??????28672??2009-07-24?16:44??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\Common.Logging.dll
?????文件?????303104??2013-11-18?05:51??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\log4net.dll
?????文件????1452231??2013-11-18?05:51??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\log4net.xm
?????文件???????1652??2014-02-05?22:01??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\pa_pip_service.application
?????文件???????6656??2014-02-05?22:01??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\pa_pip_service.exe
?????文件???????6028??2014-02-05?22:01??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\pa_pip_service.exe.manifest
?????文件??????24064??2014-02-05?22:01??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\pa_pip_service.pdb
?????文件??????11608??2014-02-05?21:46??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\pa_pip_service.vshost.exe
?????文件???????5632??2014-02-05?21:38??C#定時調度任務服務\源碼\pa_pip_service\pa_pip_service\bin\Debug\pa_pip_service_library.dll
............此處省略97個文件信息
- 上一篇:帶條碼打印的固定資產管理系統源碼Asp.NET
- 下一篇:高拍儀編程
評論
共有 條評論