using EasyQuartz;
public void ConfigureServices(IServiceCollection services)
{
//Add Service
services.AddEasyQuartzService();
}
[TriggerCron("0/1 * * * * ? *")]
public class Test1Job : IJob
{
public Task Execute(IJobExecutionContext context)
{
Console.WriteLine($"{DateTime.Now}我是 Test1Job");
return Task.CompletedTask;
}
}
public class Test2Job : EasyQuartzJob, IJob
{
private readonly IConfiguration _configuration;
public Test2Job(IConfiguration configuration)
{
_configuration = configuration;
}
public override string Cron => _configuration["Test2JobCron"];
public Task Execute(IJobExecutionContext context)
{
Console.WriteLine($"{DateTime.Now}我是 Test2Job");
return Task.CompletedTask;
}
}
using EasyQuartz;
builder.Services.AddEasyQuartz(e =>
{
e.UseMySql(m => { m.ConnectionString = "server=XXX;user=root;database='XXX';port=3306;password=XXX;SslMode=None"; });
e.UseDashboard();
});