StowayNet.Extensions.Quartz发布
v 0.1.0
StowayNet.Extensions.Quartz是为了简化Quartz在.net core项目中的调用而写的开源项目,并且对Quartz进行了改进,让其支持依赖注入。
Github地址:https://github.com/stoway/StowayNet.Extensions.Quartz
入门
NuGet
你可以运行以下命令在你的项目中安装 StowayNet.Extensions.Quartz
.
PM> Install-Package StowayNet.Extensions.Quartz
配置
首先配置 StowayNet.Extensions.Quartz
到 Startup.cs 文件中,如下:
......
using StowayNet;
......
public void ConfigureServices(IServiceCollection services)
{
......
services.AddStowayNet();
......
}
示例
class TestJob : StowayNet.Extensions.Quartz.IQuartzJob
{
private readonly ILogger<TestJob> _logger;
public string ServiceName => nameof(TestJob);
public string QuartzCronExpression => "*/2 * * * * ?";
public TestJob(ILogger<TestJob> logger)
{
_logger = logger;
}
public Task Execute(IJobExecutionContext context)
{
_logger.LogDebug($"{nameof(TestJob)} start, {DateTime.Now:G}");
return Task.CompletedTask;
}
}