I am new to quartz.net. I want to build a simple window based application which scheduled the task. Suppose I have 4 task ans it start and end time Example
Breakfast ; 8:00;8:30
Lunch;13:00;13:30
dinner;19:30;20:00
Now I want when I click on button at 8:00 AM a message box should appear with a text "breakfast started!!!" at 8:30 AM again a message box should appear with a text as "Breakfast end!!!" and so on.
I had gone through tutorial. But confuse how to proceed. Can any one help me out?
EDIT
Is it possible to use one job and one triggers for this?
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
for (int i = 0; i < listBox1.Items.Count; i++)
{
string[] strArr = Regex.Split(listBox1.Items[i].ToString(), @";", RegexOptions.Multiline);
// define the job and tie it to our HelloJob class
IJobDetail jobStart = JobBuilder.Create<HelloJob>()
.WithIdentity("job" + i, "group1") // name "myJob", group "group1"
.StoreDurably()
.UsingJobData("jobSays", strArr[0].ToUpper().Trim() + " " + "starts")
.Build();
string[] ArrStart = strArr[1].Trim().Split(':');
ITrigger triggerstart = TriggerBuilder.Create()
.WithIdentity("trigger" + i, "group1")
.WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(Convert.ToInt32(ArrStart[0]), Convert.ToInt32(ArrStart[1])))
// .WithSimpleSchedule(x => x.WithMisfireHandlingInstructionIgnoreMisfires()
.ForJob(jobStart)
.Build();
// .WithSchedule(CronScheduleBuilder.CronSchedule("0 4 06 1/1 * ? *"))
// Tell quartz to schedule the job using our trigger
scheduler.ScheduleJob(jobStart, triggerstart);
scheduler.Start();
string[] Arrend = strArr[2].Trim().Split(':');
IJobDetail jobend = JobBuilder.Create<HelloJob>()
.WithIdentity("job1" + i, "group1")
.StoreDurably()
.UsingJobData("jobSays", strArr[0].ToUpper().Trim() + " " + "end")
.Build();
ITrigger triggerend = TriggerBuilder.Create()
.WithIdentity("trigger1" + i, "group1")
.WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(Convert.ToInt32(Arrend[0]), Convert.ToInt32(Arrend[1])))
// .WithSimpleSchedule(x => x.WithMisfireHandlingInstructionIgnoreMisfires()
.ForJob(jobend)
.Build();
scheduler.ScheduleJob(jobend, triggerend);
scheduler.Start();
}
}
catch (SchedulerException se)
{
Console.WriteLine("Scheduler Exception : " + se);
}
}
public class HelloJob : IJob
{
public void Execute(IJobExecutionContext context)
{
JobKey key = context.JobDetail.Key;
JobDataMap dataMap = context.JobDetail.JobDataMap;
string jobSays = dataMap.GetString("jobSays");
MessageBox.Show(jobSays);
}
}