Open source Job scheduling framework-quartz.net-Practical use 2

Source: Internet
Author: User

Correct an error code for the first article.

The following is the error code, which does not know if the Jobid is already present in the system

// instantiates a job key object that is used to obtain a job object or to determine whether a job exists.  New  Jobkey (identity); // the same job has been added through the Job Ke object, if not null Ijobdetail job = Scheduler. Getjobdetail (Jobkey); // checks whether the job exists in the schedule, exists, and deletes the job if the parameters change.  if (scheduler. Checkexists (Jobkey) && job. jobdatamap["cron"]. ToString () ! = Cron) {    Scheduler. Deletejob (Jobkey);}

The correct way to get Jobkey and Ijobdetail objects is as follows

This method uses the job's groupname group name for matching lookups, first returning all of the group's Jobkey and then iterating through the lookup.

What the? You didn't set groupname?

GroupName is default if GroupName is not set

Of course, you can also use groupmatcher<jobkey> to match other methods such as

Anygroup ();
Groupcontains (string compareTo);
Groupstartswith (string compareTo);
Groupendswith (string compareTo);
Groupequals (string compareTo);

//you first need to find the Iset collection of Jobkey based on the group name. groupmatcher<jobkey> Matcher = groupmatcher<jobkey>. Groupequals (groupName);//Note: This is not the iset<t> in System.Collection. quartz.collection.iset<jobkey> keys =Scheduler. Getjobkeys (matcher);//using enumeration objects to loop through lookupsvarEn =keys. GetEnumerator (); while(en. MoveNext ()) {stringrowID = en. Current.Name.Replace ("Reporttime",""); if(dt. Select ("id= '"+ rowID +"'"). Length = =0) {Loghelper.addlog ("Timing Module","detects that the schedule configuration information does not already exist and will delete the scheduled calculation task. ",""); Scheduler. Deletejob (en.    Current); }}

Open source Job scheduling framework-quartz.net-Practical use 2

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.