37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using LangGuan.Command.Extension;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
using Microsoft.Extensions.Hosting;
|
||
using Quartz;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace LangGuan.Services.Job
|
||
{
|
||
public class MyJob : IJob
|
||
{
|
||
public const string PlanId = "";
|
||
public const string PlanName = "";
|
||
private PlanService _planService;
|
||
public MyJob(PlanService planService)
|
||
{
|
||
_planService = planService;
|
||
}
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
/// <returns></returns>
|
||
public async Task Execute(IJobExecutionContext context)
|
||
{
|
||
JobDataMap datamap = context.JobDetail.JobDataMap;
|
||
string id = datamap.GetString("PlanId");
|
||
string PlanName = datamap.GetString("PlanName");
|
||
Console.WriteLine($"定时任务当前时间:{DateTime.Now},计划名称 :{PlanName}传参:{id}--");
|
||
await _planService.exec(id);
|
||
|
||
}
|
||
}
|
||
}
|