在生产服务器上,我每3个小时就有一封电子邮件。
但是它将每3小时向客户发送n次电子邮件。 (即每次4至5次)
在本地运行正常。
我有Azure Server。升级到最新版本后,将出现此问题。才能正常工作。
版本:3.0.7
public static class JobSchedulerService
{
public static async System.Threading.Tasks.Task StopAsync()
{
var scheduler = await StdSchedulerFactory.GetDefaultScheduler();
await scheduler.UnscheduleJob(new TriggerKey("HourlyBookingAlert", "HourlyBookingAlertGroup"));
await scheduler.DeleteJob(new JobKey("HourlyBookingAlertJob", "HourlyBookingAlertJobGroup"));
await scheduler.Clear();
await scheduler.UnscheduleJob(new TriggerKey("BookingAlert", "BookingAlertGroup"));
await scheduler.DeleteJob(new JobKey("BookingAlertJobs", "BookingAlertJobGroups"));
await scheduler.Clear();
}
public static async System.Threading.Tasks.Task StartAsync()
{
await StopAsync();
if (true)
{
var scheduler =await StdSchedulerFactory.GetDefaultScheduler();
await scheduler.Start();
var job =
JobBuilder.Create<EmailJob>()
.WithIdentity("HourlyBookingAlertJob", "HourlyBookingAlertJobGroup")
.Build();
var trigger = TriggerBuilder.Create().WithIdentity("HourlyBookingAlert", "HourlyBookingAlertGroup")
.WithDailyTimeIntervalSchedule
(s =>
s.WithIntervalInMinutes(
Convert.ToInt16(
SettingStorage.AdminSettings.AppSettings[RcomAdminSetting.AppSettingTypes.HourlyBookingCheckRequiredbyEveryMinute]))
.OnEveryDay().InTimeZone(TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"))
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(0, 5))
)
.Build();
await scheduler.ScheduleJob(job, trigger);
//await Task.Delay(TimeSpan.FromSeconds(60));
// await scheduler.Shutdown();
}
if (true)
{
var scheduler2 = await StdSchedulerFactory.GetDefaultScheduler();
await scheduler2.Start();
var bookingAlertjob =
JobBuilder.Create<BookingAlert>()
.WithIdentity("BookingAlertJobs", "BookingAlertJobGroups")
.Build();
var bookingAlertTrigger = TriggerBuilder.Create().WithIdentity("BookingAlert", "BookingAlertGroup")
.WithDailyTimeIntervalSchedule
(s =>
s.WithIntervalInMinutes(
Convert.ToInt16(
SettingStorage.AdminSettings.AppSettings[RcomAdminSetting.AppSettingTypes.BookingStatusAlertRequiredbyEveryMinute]))
.OnEveryDay().InTimeZone(TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"))
.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(0, 5)).WithRepeatCount(0)
)
.Build();
await scheduler2.ScheduleJob(bookingAlertjob, bookingAlertTrigger);
//await Task.Delay(TimeSpan.FromSeconds(60));
//await scheduler2.Shutdown();
}
}
}