feat: 添加sample示例
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Quartz;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.BackgroundWorkers.Quartz;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Uow;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Rbac.Application.Jobs
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时任务
|
||||
/// </summary>
|
||||
public class TestJob : QuartzBackgroundWorkerBase
|
||||
{
|
||||
private ISqlSugarRepository<UserEntity> _repository;
|
||||
public TestJob(ISqlSugarRepository<UserEntity> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
JobDetail = JobBuilder.Create<TestJob>().WithIdentity(nameof(TestJob)).Build();
|
||||
Trigger = TriggerBuilder.Create().WithIdentity(nameof(TestJob)).StartNow()
|
||||
.WithSimpleSchedule(x => x
|
||||
.WithIntervalInSeconds(1000 * 60)
|
||||
.RepeatForever())
|
||||
.Build();
|
||||
}
|
||||
public override async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
//定时任务,非常简单
|
||||
Console.WriteLine("你好,世界");
|
||||
// var eneities= await _repository.GetListAsync();
|
||||
//var entities= await _sqlSugarClient.Queryable<UserEntity>().ToListAsync();
|
||||
//await Console.Out.WriteLineAsync(entities.Count().ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user