2025-11-13 15:31:08 +08:00

67 lines
2.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Infrastructure;
using Infrastructure.Attribute;
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 DOAN.Model.MES.dev;
using DOAN.Model.System;
using DOAN.Service.MES.andon.IService;
namespace DOAN.Tasks.TaskScheduler
{
/// <summary>
/// 超过一个小时就发送邮箱
/// </summary>
[AppService(ServiceType = typeof(Job_Email_send), ServiceLifetime = LifeTime.Scoped)]
public class Job_Email_send : JobBase, IJob
{
private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private readonly IAndonInteractionService _andonInteractionService;
public Job_Email_send(IAndonInteractionService andonInteractionService)
{
_andonInteractionService= andonInteractionService;
}
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<SysTasks>().FirstAsync(f => f.ID == trigger.JobName);
if (info == null)
{
throw new CustomException($"任务{trigger?.JobName}_邮件发送定时调度请求执行失败任务不存在");
}
//string[] result = _andonInteractionService.MonitoringMails();
// string[] result = _andonInteractionService.MonitoringMails();
_andonInteractionService.WatchPushAndon();
//if (result!=null&&result.Length > 0)
//{
// foreach (string s in result)
// {
// logger.Info($"任务【{info.Name}】_邮件发送定时调度请求执行结果={s}\n");
// }
//}
//else
//{
// logger.Info($"任务【{info.Name}】_邮件发送定时调度请求执行结果 没有数据\n");
//}
}
}
}