Używam Quartz.NET i Crona jako wyzwalcza z harmonogramem.
Wszystko mi działa w wersji devloperskiej zadanie się ładnie odpala natomiast nie działa na serwerze w wersji produkcyjnej
Scheduler class: 'Quartz.Core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'Quartz.Simpl.DefaultThreadPool' - with 10 threads.
Using job-store 'Quartz.Simpl.RAMJobStore' - which does not support persistence. and is not clustered.
2021-09-07 08:51:30.5236||INFO|Quartz.Impl.StdSchedulerFactory|Quartz scheduler 'QuartzScheduler' initialized
2021-09-07 08:51:30.5236||INFO|Quartz.Impl.StdSchedulerFactory|Quartz scheduler version: 3.3.3.0
2021-09-07 08:51:30.5617||INFO|Quartz.ContainerConfigurationProcessor|Adding 1 jobs, 1 triggers.
2021-09-07 08:51:30.5617||INFO|Quartz.ContainerConfigurationProcessor|Adding job: DEFAULT.SendEmailQualityControlJob
2021-09-07 08:51:30.5617||DEBUG|Quartz.ContainerConfigurationProcessor|Scheduling job: DEFAULT.SendEmailQualityControlJob with trigger: DEFAULT.SendEmailQualityControlJob-trigger
2021-09-07 08:51:30.5874||DEBUG|Quartz.ContainerConfigurationProcessor|Rescheduling job: DEFAULT.SendEmailQualityControlJob with updated trigger: DEFAULT.SendEmailQualityControlJob-trigger
2021-09-07 08:51:30.5874||INFO|Quartz.Core.QuartzScheduler|Scheduler QuartzScheduler_$_NON_CLUSTERED started.
2021-09-07 08:51:30.9056||INFO|Microsoft.Hosting.Lifetime|Application started. Press Ctrl+C to shut down.
2021-09-07 08:51:30.9056||INFO|Microsoft.Hosting.Lifetime|Hosting environment: Production
2021-09-07 08:51:30.9196||INFO|Microsoft.Hosting.Lifetime|Content root path: C:\IISPATCH\TLC
2021-09-07 08:51:44.2154||INFO|AppForSellers.Areas.Identity.Pages.Account.LoginModel|Użytkownik .
2021-09-07 09:12:10.8593||INFO|Microsoft.Hosting.Lifetime|Application is shutting down...
2021-09-07 09:12:10.8746||INFO|Quartz.Core.QuartzScheduler|Scheduler QuartzScheduler_$_NON_CLUSTERED shutting down.
2021-09-07 09:12:10.8746||INFO|Quartz.Core.QuartzScheduler|Scheduler QuartzScheduler_$_NON_CLUSTERED paused.
2021-09-07 09:12:10.8937||INFO|Quartz.Core.QuartzScheduler|Scheduler QuartzScheduler_$_NON_CLUSTERED Shutdown complete.
c#
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.AddQuartz(q =>
{
// q.UseMicrosoftDependencyInjectionScopedJobFactory();
// // Register the job, loading the schedule from configuration
// q.AddJobAndTrigger<SendEmailQualityControlJob>(hostContext.Configuration);
//});
//services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
q.UseMicrosoftDependencyInjectionJobFactory();
// Create a "key" for the job
var jobKey = new JobKey("SendEmailQualityControlJob");
// Register the job with the DI container
q.AddJob<SendEmailQualityControlJob>(opts => opts.WithIdentity(jobKey));
// Create a trigger for the job
q.AddTrigger(opts => opts
.ForJob(jobKey) // link to the SendEmailQualityControlJob
.WithIdentity("SendEmailQualityControlJob-trigger") // give the trigger a unique name
.WithCronSchedule("00 50 08 ? * TUE *"));
//cronExpression: "00 08 12 ? * MON,TUE,WED,THU,FRI *"));
});
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
}).ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
}).UseNLog();
Swój przykład oparłem o bardzo dobry artykuł
https://andrewlock.net/using-quartz-net-with-asp-net-core-and-worker-services/
Potrzebuję pomocy żeby odpalić rozsyłkę maili na serwerze za pomocą harmonogramu z Quartz.NET.