67 lines
2.3 KiB
C#
Raw Normal View History

2024-06-21 14:10:17 +08:00
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;
2024-07-01 16:04:10 +08:00
using DOAN.Model.MES.dev;
using DOAN.Model.System;
using DOAN.Service.MES.andon.IService;
2024-06-21 14:10:17 +08:00
2024-07-01 16:04:10 +08:00
namespace DOAN.Tasks.TaskScheduler
2024-06-21 14:10:17 +08:00
{
/// <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}_邮件发送定时调度请求执行失败任务不存在");
}
2025-11-13 15:30:44 +08:00
//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");
// }
2024-06-21 14:10:17 +08:00
2025-11-13 15:30:44 +08:00
//}
//else
//{
// logger.Info($"任务【{info.Name}】_邮件发送定时调度请求执行结果 没有数据\n");
//}
2024-06-21 14:10:17 +08:00
}
}
}