C # using Quartz.net timing issues

Source: Internet
Author: User

You need to complete the scheduled query data for the job. So after the understanding, I completed a demo.

The required DLLs are downloaded at that address

Http://pan.baidu.com/s/1sjNQLXV

First introduce quartz this dll ...

In Quartz.net there is a configuration file called Quartz.properties, which allows you to modify the framework runtime environment. The default is to use the Quartz.properties file inside the Quartz.dll. Of course you can configure it in the application configuration file.

PS: Of course. Because I am a limited level. The words above are copied from others. I didn't take care of that. configuration file, in order to save trouble, modified the configuration file.

<configSections> <section name="Quartz"Type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,culture=neutral, publickeytoken= b77a5c561934e089"/> <sectiongroup name="Common"> <section name="Logging"Type="Common.Logging.ConfigurationSectionHandler, common.logging"/> </sectionGroup> </configSections> <common> <logging> <factoryadapter t Ype="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, common.logging"> <arg key="Showlogname"Value="true"/> <arg key="Showdatatime"Value="true"/> <arg key=" Level"Value="INFO"/> <arg key="DateTimeFormat"Value="HH:mm:ss:fff"/> </factoryAdapter> </logging> </common> <quartz> <add key="Quartz.scheduler.instanceName"Value="Exampledefaultquartzscheduler"/> <add key="Quartz.threadPool.type"Value="Quartz.Simpl.SimpleThreadPool, Quartz"/> <add key="Quartz.threadPool.threadCount"Value="Ten"/> <add key="quartz.threadPool.threadPriority"Value="2"/> <add key="Quartz.jobStore.misfireThreshold"Value="60000"/> <add key="Quartz.jobStore.type"Value="Quartz.Simpl.RAMJobStore, Quartz"/> </quartz>

Of course. This is required to introduce the common.logging and C5 of these two DLLs:

Specifically the role of these two DLLs I do not understand. When I understand it, re-edit it.

After the configuration file configuration is complete:

Write a class that inherits Quartz.ijob

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Diagnostics;usingSystem.Runtime.InteropServices;usingcommon.logging;usingQuartz;namespacewebdemo{ Public classQuartz:Quartz.IJob {Private StaticILog _log = Logmanager.getlogger (typeof(quartz));  Public voidExecute (Quartz.ijobexecutioncontext context) {Test (); }        /// <summary>        ///Open the DOS interface/// </summary>        Private voidTest () {System.Diagnostics.Process P=NewProcess (); p.StartInfo.FileName="Cmd.exe"; P.startinfo.useshellexecute=false; P.startinfo.redirectstandardinput=true; P.startinfo.redirectstandardoutput=true; P.startinfo.createnowindow=false;            P.start (); //this line of command-shutdown commands//p.standardinput.writeline ("shutdown-s-T 0"); //P.standardinput.writeline ("exit");P.close (); }       }}

Then I call the class in the Application_Start method of the global class

voidApplication_Start (Objectsender, EventArgs e) {            //Code that runs on application startupquartz.ischedulerfactory SF=NewQuartz.Impl.StdSchedulerFactory (); Sched=SF.            Getscheduler (); Quartz.jobkey Jobkey=NewQuartz.jobkey ("Myjob","MyGroup"); Quartz.ijobdetail Job= quartz.jobbuilder.create<webdemo.quartz>(). Withidentity (Jobkey).            Build (); //more complex ApplicationsQuartz.Spi.IOperableTrigger trigger =NewQuartz.Impl.Triggers.CronTriggerImpl ("Trigname","group1","0. * WED"); Sched.            Schedulejob (Job, trigger); Sched.        Start (); }
"0 31 10?" * WED "This means that every Wednesday morning, 10 points, 31 minutes, 0 seconds will be automatically executed. The DOS window will open automatically.
But the premise is. The program must be running. Not closed: Otherwise it doesn't make any sense ...
void Application_End (object  sender, EventArgs e)        {            //  Code that runs on Application shutdown            //    code to run when application is closed            ifnull)            {                sched. Shutdown (true);            }                  }

For the specific timing of the format can be consulted:

http://blog.csdn.net/weinierbian/article/details/6237337

You can also study here:

Http://www.cnblogs.com/shanyou/archive/2007/08/25/quartznettutorial.html

C # using quartz.net timing issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.