Objective:
The front-end time shares the quartz.net. Have to the source, actually posted code has been written very clearly, there may be no class library operation instructions, so today wrote a description of the operation, I hope to be helpful.
First post the address of the Quartz.net class library:
Quartz.net plug-in class library encapsulation
Objective: to facilitate the creation, deletion, pause and continuation of task scheduling, and to improve the maintainability and extensibility of the task in the system.
Use process:
1. References : all DLLs under the \SVN\REF\THIRDPARTY\QUARTZ\NET40 folder .
2. Configure The Web. config, as
3. Call the class library method at the point of use:
3.1 Get task schedule execution time interval and start execution time (these values can be directly assigned in code)
3.2 Creating a task
New Qjob ("STANDARDSD", "Jobid", "Poll fee", "Shandong University"). Handle (Dorepay). Start (StartTime, times, 0);
Note: STANDARDSD: System code (SYSCODE)
Jobid: Task ID (Jobid)
Poll Payment: Task Name
Shandong University: Task group name (group)
Dorepay: Task Scheduler trigger action. (action)
StartTime: Task start time (startTime)
Times: Task interval (internaltimes)
0: Maximum number of executions (0 means unlimited) (maxtimes)
4. Pausing and continuing a task without stopping the server
Modify the task persistence file, the default address is ~/files/jobs/
When state is working indicates that the task is performing normally
When State is pending/empty indicates that the task is performing normally ( Note case, write wrong, press working Execution )
Attention:
( 1 ) system Coding and Tasks The ID combination must be unique.
(2) Start the execution time preferably in the system operation infrequent time period (in the service platform and Shandong University I use 3:ten)
(3) When creating a task schedule, if the current time is greater than the start time, the task is executed one time before it is created. So I want to start the time when creating the task do not use datetime.now. With a specified time or with DateTime.Now.AddMinutes (1)
(4) based on the description of (3), the start time if specified as 2016-06-06 3:10, when the server is down after this time, restart the system, whether or not after 3:10, the system will be executed once
Invocation Description:
Invoke description |
Object initialization |
New qjob (String syscode, string id, String name = "", String group = "") |
Parameter description |
Syscode: system code Id:jobid Name: task names Group: Task Group |
Other Notes |
Syscode+jobid: Uniqueness of the markers ' tasks Name,group: Can be empty but recommended to write on to make it easier to work with task persistence files StartTime: Start time defaults to DateTime.Now.AddMinutes (1) Maxtimes: The maximum number of executions defaults to 0 Internaltimes: Time interval defaults to 1 hours |
Persistent file Storage address assignment |
JobFactory.Instance.SetPath (String path) |
Parameter description |
The file path must end with @ "\" and not be assigned the default address of ~\file\jobs\ |
Task Trigger action |
Handle (Action handler) and Handle (action<iqjob> handler) |
Parameter description |
The two parameters do not have a callback parameter (iqjob), a parameter |
Create a task (1) |
Start (DateTime starttime, int internaltimes, int maxtimes) |
Parameter description |
Starttime: Start time Internaltimes: Task Execution interval Maxtimes: Maximum number of executions |
Create a task (2) |
Start () |
Parameter description |
Execute the Create Job Task Scheduler directly |
Remove a task |
Iqjob.remove () |
Description |
Delete According to Iqjob (Syscoed and Jobid determine their uniqueness) |
Pausing a task |
Iqjob.pause () |
Description |
Pause based on Iqjob (Syscoed and Jobid determine their uniqueness) |
Continue task |
Iqjob.resume () |
Description |
Resume according to Iqjob (Syscoed and Jobid determine their uniqueness) |
Modify a task trigger action |
JobFactory.Instance.Trigger (string system_code, action action) JobFactory.Instance.Trigger (String system_code, action<iqjob> Action) |
Parameter description |
System_code: System code Action: Trigger action |
Persistent operations |
JobFactory.Instance.Initialize (); |
Description |
Gets the persisted file, deserializes it, and then creates the object for task scheduling. |
The cases are as follows:
(1)NewQjob ("Syscode","Jobid","name","Group"). Handle (Job_handler). Start (DateTime.Now.AddSeconds ( -),2,Ten); (2)NewQjob ("Syscode","Jobid","name","Group"). Handle (Job_detail_handler). Start (); (3)NewQjob ("Syscode","Jobid","name","Group"). Remove (); (4)NewQjob ("Syscode","Jobid"). Remove (); (5)NewQjob ("Syscode","Jobid","name","Group"). Pause (); (6)NewQjob ("Syscode","Jobid"). Pause (); (7)NewQjob ("Syscode","Jobid","name","Group"). Resume (); (8)NewQjob ("Syscode","Jobid"). Resume ();
View Code
Quartz.net Custom class Library Interface usage documentation