Files
Yi.Admin/Yi.Abp.Net8/src/Yi.Abp.Application/Jobs/TestJob.cs

32 lines
950 B
C#
Raw Normal View History

2024-11-15 16:45:01 +08:00
using Hangfire;
2024-01-09 16:59:20 +08:00
using SqlSugar;
2024-11-15 16:45:01 +08:00
using Volo.Abp.BackgroundWorkers.Hangfire;
2024-01-09 16:59:20 +08:00
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.SqlSugarCore.Abstractions;
2023-12-22 18:11:14 +08:00
2024-01-11 18:51:53 +08:00
namespace Yi.Abp.Application.Jobs
2023-12-22 18:11:14 +08:00
{
2024-01-09 16:59:20 +08:00
/// <summary>
/// 定时任务
/// </summary>
2024-11-15 16:45:01 +08:00
public class TestJob : HangfireBackgroundWorkerBase
2023-12-22 18:11:14 +08:00
{
2024-05-22 14:35:08 +08:00
private ISqlSugarRepository<UserAggregateRoot> _repository;
public TestJob(ISqlSugarRepository<UserAggregateRoot> repository)
2023-12-22 18:11:14 +08:00
{
2024-01-09 16:59:20 +08:00
_repository = repository;
2024-11-15 16:45:01 +08:00
RecurringJobId = "测试";
//每天一次
CronExpression = Cron.Daily();
2023-12-22 18:11:14 +08:00
}
2024-11-15 16:45:01 +08:00
public override Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
2023-12-22 18:11:14 +08:00
{
//定时任务,非常简单
2024-01-09 16:59:20 +08:00
Console.WriteLine("你好,世界");
2024-11-15 16:45:01 +08:00
return Task.CompletedTask;
2023-12-22 18:11:14 +08:00
}
}
}