Subject: First hand on Implementation of Quartz.Net
In my
post you can see that Quarz.Net is really
powerful scheduling jobs system. This tutorial shows you how to develop a
schedule a job using quartz. I have
created the simple CSharp example of execute the job which is basically sending
the email. Just follow this steps are you are done.
1.
Download
Quartz.Net
Download the Quartz
library from official website.
Instructions
You need to add
necessary references. It is available under the bin folder.
·
Quartz.dll
·
Common.Logging
I have created
sample application using Visual Studio 2012. I’ve set the target framework as
.Net Framework 4.
2.
Quartz Job
File Name: SendEmail.cs
This class file is
responsible for what need to be done. I have created class “SendMail” which is
responsible for sending email. You can see SendEmail class has implemented IJob
interface.
3. Quartz Trigger
It is necessary to define the timings to
execute the jobs. I have created a simple job which is sending email. It will
execute at every midnight at 12.30. You will found the cron trigger example
from their official site. See this page for more examples. (http://quartznet.sourceforge.net/tutorial/lesson_6.html)
If you have any confusing cron just let me know. I am there for you. J
4.
Start Scheduler
Now it’s time to start the wheel. Let’s
turn it on. This piece of code is responsible for start the scheduler to these
kind bulky jobs.
5. Full Example
You can see the
full source code of file. Just place the code like these and all the things
done.
Ahhh,
this is very small thing to write. Now Hit the F5 button and get relaxed. J
Happy
Coding.