Taken from –
1) Download Quartz latest from http://sourceforge.net/projects/quartznet/files/quartznet/
2) Unzip it.
3) Copy over files from unzipped location (\server\bin\4.0\*.*) to Program files(x86)\Quartz.Net (Need to
create directory)
4) Install the Quartz service by the running the
following –
Quartz.Server.exe
–install
5) After this, it ll be listed in services.msc
6) (optional but
useful) Enable logging in Quartz by
adding/modifying few lines in Quartz.Server.exe.config
<common>
<logging>
<factoryAdapter
type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,
Common.Logging.Log4net">
<arg
key="configType" value="INLINE" />
<arg key="configFile"
value="Trace/application.log.txt"/>
<arg key="level" value="ALL" />
</factoryAdapter>
</logging>
</common>
<appSettings>
<add
key="log4net.Internal.Debug" value="false"/>
</appSettings>
<log4net>
<appender
name="ConsoleAppender"
type="log4net.Appender.ConsoleAppender">
<layout
type="log4net.Layout.PatternLayout">
<conversionPattern
value="%d [%t] %-5p %l - %m%n" />
</layout>
</appender>
<appender
name="EventLogAppender"
type="log4net.Appender.EventLogAppender">
<layout
type="log4net.Layout.PatternLayout">
<conversionPattern
value="%d [%t] %-5p %l - %m%n" />
</layout>
</appender>
<appender name="GeneralLog"
type="log4net.Appender.RollingFileAppender">
<file
value="Trace/application.log.txt"/>
<appendToFile
value="true"/>
<maximumFileSize
value="1024KB"/>
<rollingStyle
value="Size"/>
<layout
type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{HH:mm:ss} [%t] %-5p %c -
%m%n"/>
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref
ref="ConsoleAppender" />
<appender-ref ref="EventLogAppender" />
<appender-ref
ref="GeneralLog"/>
</root>
</log4net>
</configuration>
7) Create a class library, add Quartz nuget pkg and create a simple job my
implementing IJob.
namespace
QuartzMultipleJobsDemo
{
public class OddJob : IJob
{
private static readonly ILog Log =
LogManager.GetLogger(typeof(OddJob));
//Empty ctor is mandatory.
public OddJob()
{
}
public void
Execute(IJobExecutionContext context)
{
Log.DebugFormat("{0}****{0}Job {1} fired @ {2} next scheduled for
{3}{0}***{0}",
Environment.NewLine,
context.JobDetail.Key,
context.FireTimeUtc.Value.ToString("r"),
context.NextFireTimeUtc.Value.ToString("r"));
}
}
}
8) Build and copy the DLL to c:\Program
files(x86)\Quartz.NET (created in Point 3)
9) Modify quartz_jobs.xml to add the job and trigger. The
job name is specified using namespacename.classname, assemblyname. (sample
below)
<job>
<name>EvenJob</name>
<group>QuartzJobLib</group>
<description>EnhancementProj -
EvenJob</description>
<job-type>QuartzMultipleJobsDemo.EvenJob,
QuartzMultipleJobsDemo</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<job>
<name>OddJob</name>
<group>QuartzJobLib</group>
<description>EnhancementProj -
OddJob</description>
<job-type>QuartzMultipleJobsDemo.OddJob,
QuartzMultipleJobsDemo</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<trigger>
<simple>
<name>sampleSimpleTriggerEven</name>
<group>sampleSimpleGroup</group>
<description>Simple trigger to
simply fire sample job</description>
<job-name>EvenJob</job-name>
<job-group>QuartzJobLib</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<repeat-count>50</repeat-count>
<repeat-interval>1000</repeat-interval>
</simple>
</trigger>
<trigger>
<simple>
<name>sampleSimpleTriggerOdd</name>
<group>sampleSimpleGroup</group>
<description>Simple trigger to
simply fire sample job</description>
<job-name>OddJob</job-name>
<job-group>QuartzJobLib</job-group>
<misfire-instruction>SmartPolicy</misfire-instruction>
<repeat-count>50</repeat-count>
<repeat-interval>3000</repeat-interval>
</simple>
</trigger>