/// <summary> /// 异常通知 /// </summary> /// <param name="errorObject"></param> /// <param name="Level">层级</param> /// <param name="EventFlow">事件流程</param> /// <param name="Subject">主题</param> /// <param name="Content">内容</param> /// <param name="FinishedMode">最后完成模式,通知已通知人员</param> public async Task SendErrorMessageAsync(ErrorObject errorObject, int Level, EventHandleFlowEnum EventFlow, string Subject, string Content, bool FinishedMode = false) { List <person> persons; List <string> infoList = new List <string>(); persons = GetMsgedPersonList(errorObject, Level, EventFlow, FinishedMode); //获取需要通知的人员列表 bool res = await PostMessageToLuyuan(errorObject, EventFlow, persons); //对外发送信息 if (errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.All || errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.WeChat || errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.WeChat_Broadcast || errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.WeChat_Email) { //微信通知 foreach (person p in persons) { infoList.Add(p.user_name); } WeChatHelper.SendWeChatMessage(infoList, Content); } if (errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.All || errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.Email || errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.Email_Broadcast || errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.WeChat_Email) { infoList = new List <string>(); //邮件通知 foreach (person p in persons) { infoList.Add(p.user_email); } MailHelper.SendMail(infoList, Subject, Content); } if (errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.All || errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.Broadcast || errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.Email_Broadcast || errorObject.eConfig.trigger_message_type == (int)ErrorMsgType.WeChat_Broadcast) { //语音通知 //speechSynth.Speak(Content); if (SpeechTag != null) { if (ScadaAPIConfig.EnableScadaApi) { ScadaAPIHelper.WriteValueAsync(SpeechTag.tag_code, Content); } else { //MqttManager.MqttHelper.WriteValueToWA(SpeechTag.tag_code, Content, true);//输出语音播报文本信息 } } } }
/// <summary> /// 灯颜色输出写值 /// </summary> /// <param name="device_id"></param> /// <param name="ColorValue"></param> /// <param name="tagAreaAttributeEnum"></param> public bool WriteLightColorAsync(int device_id, int ColorValue, TagAreaAttributeEnum tagAreaAttributeEnum, int Value) { bool bit = false; if (tagAreaAttributeEnum == TagAreaAttributeEnum.machine_info) { MachineTagInfo tagInfo = GetLightTowerOutTag <MachineTagInfo>(device_id, ColorValue, tagAreaAttributeEnum); if (tagInfo != null) { if (ScadaAPIConfig.EnableScadaApi) { bit = ScadaAPIHelper.WriteValueAsync(tagInfo.tag_code, Value); if (bit == false) { bit = ScadaAPIHelper.WriteValueAsync(tagInfo.tag_code, Value);//失败再次写入 } } else { //MqttManager.MqttHelper.WriteValueToWA(tagInfo.tag_code, Value);//写值 } } } else if (tagAreaAttributeEnum == TagAreaAttributeEnum.station_info) { try { StationTagInfo tagInfo = GetLightTowerOutTag <StationTagInfo>(device_id, ColorValue, tagAreaAttributeEnum); if (tagInfo != null) { if (ScadaAPIConfig.EnableScadaApi) { bit = ScadaAPIHelper.WriteValueAsync(tagInfo.tag_code, Value); if (bit == false) { bit = ScadaAPIHelper.WriteValueAsync(tagInfo.tag_code, Value);//失败再次写入 } } else { //MqttManager.MqttHelper.WriteValueToWA(tagInfo.tag_code, Value);//写值 } } } catch (Exception ex) { Console.WriteLine(ex.Message); bit = false; } } return(bit); }