using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Newtonsoft.Json; using Repository.Station; using Service.Cloud.Client; using Service.Cloud.Common; using Service.Cloud.Msg.Cloud.Resp; using System.Drawing; namespace Service.Cloud.Handler; [Scope("InstancePerDependency")] public class FaultReportResHandler : IBaseHandler { private static readonly ILog Log = LogManager.GetLogger(typeof(FaultReportResHandler)); public EquipAlarmRecordRepository equipAlarmRecordRepository { get; set; } EquipAlarmProcessRecordRepository equipAlarmProcessRecordRepository { get; set; } public void Handle(string t) { FaultReportRes? resp = JsonConvert.DeserializeObject(t); if (resp != null) { if (CloudClientMgr.CloudClient != null) { CloudClientMgr.CloudClient.RealTimeFault.SetResp(resp); string? reqFc = CloudClientMgr.CloudClient.RealTimeFault.Req?.fc; int? reqFg = CloudClientMgr.CloudClient.RealTimeFault.Req?.fg; Log.Info($"receive FaultReportRes fc={reqFc} {JsonConvert.SerializeObject(resp)}"); if (!string.IsNullOrWhiteSpace(reqFc) && resp.re == 0) { if (reqFg == 1) { equipAlarmRecordRepository.Update(it => it.UploadStatus == 1, it => it.ErrorCode == reqFc); } else { equipAlarmProcessRecordRepository.Update(it => it.UploadStatus == 1, it => it.ErrorCode == reqFc); } } } } } public bool CanHandle(string cmd) { return CloudConst.faultReportRes == cmd; } }