using Infrastructure; using Infrastructure.Attribute; using Microsoft.Extensions.DependencyInjection; using Quartz; using Quartz.Impl.Triggers; using Quartz.Impl; using SqlSugar.IOC; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ZR.Model.System; namespace ZR.Tasks.TaskScheduler { /// /// 设备管理 调度每日的巡检和点检 /// [AppService(ServiceType = typeof(Job_Device_Execute), ServiceLifetime = LifeTime.Scoped)] public class Job_Device_Execute : JobBase, IJob { private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); public async Task Execute(IJobExecutionContext context) { await ExecuteJob(context, async () => await Run(context)); } public async Task Run(IJobExecutionContext context) { AbstractTrigger trigger = (context as JobExecutionContextImpl).Trigger as AbstractTrigger; //var info = await tasksQzService.CopyNew().GetByIdAsync(trigger.JobName); var info = await DbScoped.SugarScope.CopyNew().Queryable().FirstAsync(f => f.ID == trigger.JobName); if (info == null) { throw new CustomException($"任务{trigger?.JobName}设备管理调度请求执行失败,任务不存在"); } string result; } } }