Hi,
I have a trouble with my ASp.net application, I have tested several solutions but I don't see any issue on it. Thanks by advance for your advice.
I have installed and running Quartz.Net as a Windows Service. Quartz.Net is in the same folder as my API in order to execute jobs in it.
Below my global.asax Application_Start
public static ISchedulerFactory schedFact;
public static IScheduler scheduler;
protected void Application_Start()
{
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "ServerScheduler";
properties["quartz.scheduler.proxy"] = "true";
properties["quartz.threadPool.threadCount"] = "10";
properties["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler";
schedFact = new StdSchedulerFactory(properties);
scheduler = schedFact.GetScheduler();
scheduler.Start();
MyAPI.Services.ScheduleTasks.JobScheduler.StartGenerateContract();
}Here the class where my jobs are scrippted:
public class ScheduleTasks
{
public static Dictionary<string, string> report;
public class JobScheduler
{
public static void StartGenerateContract()
{
try
{
MailService.SendMail("StartGenerateContract", "Scheduletask",
new Exception(DateTime.Now.ToString()));
IJobDetail job_generate = JobBuilder.Create<GenerateAndSendContract>()
.WithIdentity("generateContractJob", "group1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger_contracts", "group1")
.ForJob("generateContractJob", "group1")
.StartNow()
.WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(01, 00))
.Build();
MyAPI.MvcApplication.scheduler.ScheduleJob(job_generate, trigger);
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}
}
}Then my job that is in the same file and class ScheduleTasks
public class GenerateAndSendContract : IJob
{
public void Execute(IJobExecutionContext context)
{
try
{
MailService.SendMail("GenerateAndSendContract", "Scheduletask");
//my working code...
}
catch (Exception e)
{
MailService.SendErrorMail("GenerateAndSendContract", "ScheduleTasks", e);
}
}
}My scheduleTask is perfectly executed because I receive the first email (StartGenerateContract), with the good interval. But the job is not executed cause the code in the class generateandsendcontract is not fired (no break point, no mail GenerateAndSendContract send).
Anything wrong in my code? Thank you for your help.