You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB
C#

1 year ago
using Admin.Core.IService.ISys;
using Admin.Core.IService;
using Admin.Core.Service;
using Quartz;
using System;
using System.Threading.Tasks;
/// <summary>
/// 这里要注意下,命名空间和程序集是一样的,不然反射不到
/// </summary>
namespace Admin.Core.Tasks
{
public class Job_TestTask_Quartz : JobBase, IJob
{
private readonly ISysTasksQzService _tasksQzService;
public Job_TestTask_Quartz(ISysTasksQzService tasksQzService, ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService)
{
_tasksQzService = tasksQzService;
_SysTasksQzService = SysTasksQzService;
_sysJobLogService = sysJobLogService;
}
public async Task Execute(IJobExecutionContext context)
{
await ExecuteJob(context, async () => await Run(context));
}
public async Task Run(IJobExecutionContext context)
{
var r = await _tasksQzService.QueryAsync(d => d.IsStart == true);
foreach (var item in r)
{
Console.WriteLine($"[{DateTime.Now}] 任务1 [{item.Name}]");
}
Console.WriteLine($"[{DateTime.Now}] 任务1 [{Guid.NewGuid()}]");
// return Task.CompletedTask;
}
}
}