2024-11-15 16:45:01 +08:00
|
|
|
|
using Hangfire;
|
|
|
|
|
|
using Volo.Abp.BackgroundWorkers.Hangfire;
|
2024-01-09 16:59:20 +08:00
|
|
|
|
using Yi.Framework.Rbac.Domain.Entities;
|
|
|
|
|
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
2023-12-22 18:11:14 +08:00
|
|
|
|
|
2025-02-23 01:31:30 +08:00
|
|
|
|
namespace Yi.Abp.Web.Jobs
|
2023-12-22 18:11:14 +08:00
|
|
|
|
{
|
2024-01-09 16:59:20 +08:00
|
|
|
|
/// <summary>
|
2025-02-23 01:31:30 +08:00
|
|
|
|
/// 定时任务Test,Job可单独拆成一个Host单独允许
|
2024-01-09 16:59:20 +08:00
|
|
|
|
/// </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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|