Component to facilitate the use of Quartz.NET, and eliminating the complex JobFactory configuration.
SimplifySchedulerJob supports .NET 6.0/7.0/8.0 and .NET Standard 2.0.
- Microsoft.Extensions.Configuration.Binder 2.2.0
- Microsoft.Extensions.DependencyInjection.Abstractions 8.0.2
- Quartz.AspNetCore 3.13.1
With .NET CLI
dotnet add package Simplify.Scheduler.JobOr with Nuget CLI
NuGet\Install-Package Simplify.Scheduler.JobAdd the configuration to your project's appSettings.json file.
{
"MyJobService": {
"Cron": "0 0/1 * * * ?"
}
}Create a class that represents the configuration of the appSettings.json and inherit the JobOptions class.
public class MyLogger : JobOptions
{
}In the service interface, inherit the IJobService interface and pass the type of the class that represents the configuration of the appSettings.json.
[JobService(typeof(MyLogger))]
public interface IMyJobService : IJobService
{
}In the service, implement the ExecuteJobAsync method with the routine you want to execute.
public class MyJobService : IMyJobService
{
...
public async Task ExecuteJobAsync()
{
// YOUR CODE
}
...
}In dependency injection, register the created service and add the SimplifySchedulerJob dependencies.
...
// REGISTER YOUR SERVICE
services.AddTransient(typeof(IMyJobService), typeof(MyJobService));
// REGISTER SIMPLIFYSCHEDULERJOB DEPENDENCIES
services.AddSimplifySchedulerJob(builder.Configuration, assembly);
...Start SimplifySchedulerJob before starting the application.
...
app.UseSimplifySchedulerJob(assembly);
app.Run();
...See LICENSE for details.
