Quartz.net 调度程序在调试时在本地工作,但不在生产中

Quartz.net Scheduler is working on local while debugging but not on production

我已经使用 Quartz.net 来安排一些任务。问题是它只在本地调试时有效。

该代码在我的本地服务器和生产环境中也不起作用。

请不要将其标记为重复,因为其他问题中提到的 none 解决方案解决了我的问题。

 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
    }
}

任何帮助都会很棒!!

我通过在 TriggerBuilder 中添加时区使其工作。

 ITrigger trigger = TriggerBuilder.Create()
                            .WithDailyTimeIntervalSchedule
                              (s =>
                                 s.WithIntervalInHours(24)
                                .OnEveryDay()
                                .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(hours, minute))
                                .InTimeZone(TimeZoneInfo.Local)
                              )
                            .Build();