I have used Quartz.net for scheduling some task. The problem is that it's working only while debugging in the local.
The code is not working on my local server and production as well.
Please don't mark it as duplicate because none of the solution mentioned in other questions solved my issue.
public class JobScheduler
{
public static ISchedulerFactory schedFact;
public static IScheduler sched;
public static void Start()
{
schedFact = new StdSchedulerFactory();
// get a scheduler
sched = schedFact.GetScheduler();
sched.Start();
IJobDetail job = JobBuilder.Create<RemovePlanJob>().Build();
int hours = Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["schedulerHours"].ToString());
int minute = Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["schedulerMinutes"].ToString());
ITrigger trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule
(s =>
s.WithIntervalInHours(24)
.OnEveryDay()
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(hours, minute))
)
.Build();
sched.ScheduleJob(job, trigger);
}
}
public class RemovePlanJob : IJob
{
public void Execute(IJobExecutionContext context)
{
//execute code
}
}
Any Help would be great!!
I got it working by adding timezone in TriggerBuilder.