using Autofac.Core; using HslCommunication; using HslCommunication.Core; using HslCommunication.WebSocket; using Microsoft.Extensions.Hosting; using Microsoft.VisualBasic.FileIO; using Newtonsoft.Json; using Quartz; using SixLabors.ImageSharp.PixelFormats; using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Communicator; using WIDESEAWCS_Core.Helper; using WIDESEAWCS_ISystemServices; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.DeviceBase; using WIDESEAWCS_QuartzJob.StackerCrane.Enum; using WIDESEAWCS_Tasks.OHT; namespace WIDESEAWCS_Tasks { [DisallowConcurrentExecution] public class SSGOneJob : JobBase, IJob { public static bool W_ZXJ_Heat = true; public static bool W_TC_Heat = true; WebSocketServer _webSocketServer; private readonly Idt_ErrormsginfoService _ErrormsginfoService; public SSGOneJob(WebSocketServer webSocketServer,Idt_ErrormsginfoService errormsginfoService) { _webSocketServer = webSocketServer; _ErrormsginfoService = errormsginfoService; } public Task Execute(IJobExecutionContext context) { bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value); if (flag && value != null) { try { OtherDevice device = (OtherDevice)value; //状态数据发送给前端 string ohtData = JsonConvert.SerializeObject(device.Communicator.IsConnected); _webSocketServer.PublishAllClientPayload(ohtData); } catch (Exception ex) { //状态数据发送给前端 _webSocketServer.PublishAllClientPayload("false"); _ErrormsginfoService.UpdateErrorMsg(ex.Message, 1); } } return Task.CompletedTask; } } }