Skip to content

fabiorbarbosa/Simplify.Scheduler.Job

Repository files navigation

SimplifySchedulerJob

SimplifySchedulerJob logo

Component to facilitate the use of Quartz.NET, and eliminating the complex JobFactory configuration.

Compatibility

SimplifySchedulerJob supports .NET 6.0/7.0/8.0 and .NET Standard 2.0.

Dependencies

  • Microsoft.Extensions.Configuration.Binder 2.2.0
  • Microsoft.Extensions.DependencyInjection.Abstractions 8.0.2
  • Quartz.AspNetCore 3.13.1

Installation

With .NET CLI

  dotnet add package Simplify.Scheduler.Job

Or with Nuget CLI

  NuGet\Install-Package Simplify.Scheduler.Job

Usage/Examples

Add 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();
...

License

See LICENSE for details.

About

Component to facilitate the use of Quartz.NET, and eliminating the complex JobFactory configuration.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages