public MessageBoxEx(NotifyTypeEnum type, string msg) : this() { switch (type) { case NotifyTypeEnum.Tooltip: break; case NotifyTypeEnum.Error: //this.BorderBrush = Brushes.Red; //this.CaptionForeground = Brushes.Red; break; case NotifyTypeEnum.Warning: //this.BorderBrush = new SolidColorBrush(Color.FromRgb(202, 81, 0)); //this.CaptionForeground = new SolidColorBrush(Color.FromRgb(202, 81, 0)); break; case NotifyTypeEnum.Question: this.btn_cancel.Visibility = Visibility.Visible; break; default: break; } txt_msg.Text = msg; }
/// <summary> /// 消息通知 /// </summary> /// <summary> /// /// </summary> /// <param name="content">内容</param> /// <param name="msgEnum">消息类型</param> /// <param name="groupType">群类别</param> /// <param name="notifyType">群类别</param> /// <param name="msgType">消息内容类型</param> /// <param name="atMobiles">通知人手机</param> /// <param name="isAtAll">是否@所有人</param> public static void NotifyChat(NotifyTypeEnum notifyType, NotifyMsgEnum msgEnum, string content, NotifyMsgTypeEnum msgType, string[] atMobiles = null, bool isAtAll = false) { #if !DEBUG var localIp = "?"; var host = Dns.GetHostEntry(Dns.GetHostName()); foreach (var ip in host.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { localIp = ip.ToString(); } } if (localIp == "192.168.1.184") { return; } #else //notifyType = NotifyTypeEnum.Test; #endif var groups = Configs.Where(x => x.IsChat && x.Type == notifyType); foreach (var group in groups) { switch (group.Platform) { case NotifyPlatformEnum.DingTalk: RobotNotifyDingTalkChat(group, msgEnum, content, msgType, atMobiles, isAtAll); break; case NotifyPlatformEnum.WorkWeiXin: RobotNotifyWeiXinChat(group, msgEnum, content, msgType, atMobiles, isAtAll); break; default: break; } } }
private static bool Show(NotifyTypeEnum type, string msg, Window owner = null) { var result = true; //此处不能用BeginInvoke异步执行 Application.Current.Dispatcher.Invoke(new Action(() => { var winMsg = new MessageBoxEx(type, msg); winMsg.Title = type.GetDescription(); winMsg.Owner = owner ?? ControlUtils.GetTopWindow(); winMsg.ShowDialog(); result = winMsg.DialogResultEx; })); return(result); }
/// <summary> /// Display notification /// </summary> /// <param name="type">Notification type</param> /// <param name="message">Message</param> /// <param name="persistForTheNextRequest">A value indicating whether a message should be persisted for the next request</param> protected virtual void AddNotification(NotifyTypeEnum type, string message, bool persistForTheNextRequest) { string dataKey = string.Format("cargo.notifications.{0}", type); if (persistForTheNextRequest) { if (TempData[dataKey] == null) { TempData[dataKey] = new List <string>(); } ((List <string>)TempData[dataKey]).Add(message); } else { if (ViewData[dataKey] == null) { ViewData[dataKey] = new List <string>(); } ((List <string>)ViewData[dataKey]).Add(message); } }
private void Connection_Mysql() { while (myWorkState) { TimeSpan timeSpan = DateTime.Now.Subtract(ConnectionTime); if (timeSpan.TotalMilliseconds > 5000) { CaseSettings = Ewatch_MySqlMethod.CaseLoad(); #region AI上下限 var Alarmdata = Ewatch_MySqlMethod.AiConfig_Compare_Load(); foreach (var item in Alarmdata) { var caseSetting = CaseSettings.Where(g => g.CaseNo == item.CaseNo).ToList()[0]; var value = Ewatch_MySqlMethod.Ai64web(item); if (value != null) { var nowdata = Ewatch_MySqlMethod.Alarm_Procedure(item, value); var Adata = AiConfigs.Where(g => g.PK == item.PK).ToList(); if (Adata.Count > 0) { if (item.CompareType != Adata[0].CompareType) { NotifyTypeEnum notifyTypeEnum = (NotifyTypeEnum)caseSetting.NotifyTypeEnum; switch (notifyTypeEnum) { case NotifyTypeEnum.None: break; case NotifyTypeEnum.Line: { switch (item.CompareType) { case 0: //上限 { LineNotifyClass lineNotifyClass = new LineNotifyClass(); lineNotifyClass.LineNotifyFunction(caseSetting.NotifyToken, $"\r案場名稱: {caseSetting.TitleName}\r點位名稱: {item.AiName}\r超過上限值: {item.AiMax}\r目前數值為 {nowdata}"); } break; case 1: //正常 { LineNotifyClass lineNotifyClass = new LineNotifyClass(); lineNotifyClass.LineNotifyFunction(caseSetting.NotifyToken, $"\r案場名稱: {caseSetting.TitleName}\r點位名稱: {item.AiName}\r上限值: {item.AiMax}\r下限值: {item.AiMin}\r恢復正常,目前數值為 {nowdata}"); } break; case 2: //下限 { LineNotifyClass lineNotifyClass = new LineNotifyClass(); lineNotifyClass.LineNotifyFunction(caseSetting.NotifyToken, $"\r案場名稱: {caseSetting.TitleName}\r點位名稱: {item.AiName}\r低於下限值: {item.AiMin}\r目前數值為 {nowdata}"); } break; } } break; case NotifyTypeEnum.Telegram: { switch (item.CompareType) { case 0: //上限 { TelegramBotClass telegramBotClass = new TelegramBotClass(caseSetting.NotifyApi) { Chat_ID = caseSetting.NotifyToken }; telegramBotClass.Send_Message_Group($"\r案場名稱: {caseSetting.TitleName}\r點位名稱: {item.AiName}\r超過上限值: {item.AiMax}\r目前數值為 {nowdata}"); } break; case 1: //正常 { TelegramBotClass telegramBotClass = new TelegramBotClass(caseSetting.NotifyApi) { Chat_ID = caseSetting.NotifyToken }; telegramBotClass.Send_Message_Group($"\r案場名稱: {caseSetting.TitleName}\r點位名稱: {item.AiName}\r上限值: {item.AiMax}\r下限值: {item.AiMin}\r恢復正常,目前數值為 {nowdata}"); } break; case 2: //下限 { TelegramBotClass telegramBotClass = new TelegramBotClass(caseSetting.NotifyApi) { Chat_ID = caseSetting.NotifyToken }; telegramBotClass.Send_Message_Group($"\r案場名稱: {caseSetting.TitleName}\r點位名稱: {item.AiName}\r低於下限值: {item.AiMin}\r目前數值為 {nowdata}"); } break; } } break; } } } } } #endregion AiConfigs = Alarmdata; ConnectionTime = DateTime.Now; } else { Thread.Sleep(80); } } }
protected void Connection_Mysql() { while (myWorkState) { TimeSpan timeSpan = DateTime.Now.Subtract(ConnectionTime); if (timeSpan.TotalMilliseconds > 1000) //每一秒查詢動作 { var casevalue = MySqlMethod.CaseLoad(); foreach (var caseitem in casevalue) { if (caseitem.NotifyTypeEnum != 0)// 檢查是否使用發報功能 0 =不使用 { var aivalue = MySqlMethod.AiLoad(caseitem); foreach (var aiitem in aivalue) { if (aiitem.NotifyFlag) //AI點位需要發報 { if (MySqlMethod.AI64Load(aiitem)) //檢查即時數值是否超過時間 { var TimeValue = MySqlMethod.Ai_Time(aiitem); //檢查發報數值是否達到 if (TimeValue == null || TimeValue >= aiitem.TimeoutSpan) { NotifyTypeEnum notifyTypeEnum = (NotifyTypeEnum)caseitem.NotifyTypeEnum; switch (notifyTypeEnum) { case NotifyTypeEnum.None: break; case NotifyTypeEnum.Line: { LineNotifyClass lineNotifyClass = new LineNotifyClass(); lineNotifyClass.LineNotifyFunction(caseitem.NotifyToken, $"設備名稱:{aiitem.AiName} \r最後上傳時間 : {MySqlMethod.AI_LastTime(aiitem)}\r上傳逾時請檢查"); } break; case NotifyTypeEnum.Telegram: { TelegramBotClass telegramBotClass = new TelegramBotClass(caseitem.NotifyApi) { Chat_ID = caseitem.NotifyToken }; telegramBotClass.Send_Message_Group($"設備名稱:{aiitem.AiName} \r最後上傳時間 : {MySqlMethod.AI_LastTime(aiitem)}\r上傳逾時請檢查"); } break; } MySqlMethod.UpdataAi_Time(aiitem, true); } } else { MySqlMethod.UpdataAi_Time(aiitem, false); } } } var electricvalue = MySqlMethod.ElectricLoad(caseitem); foreach (var electricitem in electricvalue) { if (electricitem.NotifyFlag)//電表點位需要發報 { if (MySqlMethod.ElectricMeterLoad(electricitem)) { var TimeValue = MySqlMethod.ElectricMeter_Time(electricitem); if (TimeValue == null || TimeValue >= electricitem.TimeoutSpan) { NotifyTypeEnum notifyTypeEnum = (NotifyTypeEnum)caseitem.NotifyTypeEnum; switch (notifyTypeEnum) { case NotifyTypeEnum.None: break; case NotifyTypeEnum.Line: { LineNotifyClass lineNotifyClass = new LineNotifyClass(); lineNotifyClass.LineNotifyFunction(caseitem.NotifyToken, $"設備名稱:{electricitem.ElectricName} \r最後上傳時間 : {MySqlMethod.ElectricMeter_LastTime(electricitem)}\r上傳逾時請檢查"); } break; case NotifyTypeEnum.Telegram: { TelegramBotClass telegramBotClass = new TelegramBotClass(caseitem.NotifyApi) { Chat_ID = caseitem.NotifyToken }; telegramBotClass.Send_Message_Group($"設備名稱:{electricitem.ElectricName} \r最後上傳時間 : {MySqlMethod.ElectricMeter_LastTime(electricitem)}\r上傳逾時請檢查"); } break; } MySqlMethod.UpdataElectricMeter_Time(electricitem, true); } } else { MySqlMethod.UpdataElectricMeter_Time(electricitem, false); } } } } } ConnectionTime = DateTime.Now; } else { Thread.Sleep(80); } } }
private void Connection_Mysql() { while (myWorkState) { TimeSpan timeSpan = DateTime.Now.Subtract(ConnectionTime); if (timeSpan.TotalMilliseconds > 5000) { var NewCaseSettings = ChungHsin_MySqlMethod.CaseLoad(); var NewReceiveSettings = ChungHsin_MySqlMethod.ReceiveLoad(); var NewDeviceConfigs = ChungHsin_MySqlMethod.DevicesLoad(); foreach (var Caseitem in NewCaseSettings) { #region 接收 var ReceiveValue = ChungHsin_MySqlMethod.ReceiveLoad(Caseitem); foreach (var Receiveitem in ReceiveValue) { if (Receiveitem.NotifyFlag) { if (ChungHsin_MySqlMethod.AI64Load(Receiveitem)) { var TimeValue = ChungHsin_MySqlMethod.Receive_Time(Receiveitem); if (TimeValue == null || TimeValue >= Receiveitem.HTimeoutSpan) { if (NewReceiveSettings.SingleOrDefault(g => g.PK == Receiveitem.PK) != null) { NewReceiveSettings.Single(g => g.PK == Receiveitem.PK).ConnectionFlag = "斷線"; NotifyTypeEnum notifyTypeEnum = (NotifyTypeEnum)Caseitem.NotifyTypeEnum; switch (notifyTypeEnum) { case NotifyTypeEnum.None: break; case NotifyTypeEnum.Line: { LineNotifyClass lineNotifyClass = new LineNotifyClass(); lineNotifyClass.LineNotifyFunction(Caseitem.NotifyToken, $"設備名稱:{Receiveitem.ReceiveName} \r最後上傳時間 : {ChungHsin_MySqlMethod.AI_LastTime(Receiveitem)}\r上傳逾時請檢查"); } break; case NotifyTypeEnum.Telegram: { TelegramBotClass telegramBotClass = new TelegramBotClass(Caseitem.NotifyApi) { Chat_ID = Caseitem.NotifyToken }; telegramBotClass.Send_Message_Group($"設備名稱:{Receiveitem.ReceiveName} \r最後上傳時間 : {ChungHsin_MySqlMethod.AI_LastTime(Receiveitem)}\r上傳逾時請檢查"); } break; } ChungHsin_MySqlMethod.UpdataReceive_Time(Receiveitem, true); } } else { NewReceiveSettings.Single(g => g.PK == Receiveitem.PK).ConnectionFlag = "斷線"; } } else { if (NewReceiveSettings.SingleOrDefault(g => g.PK == Receiveitem.PK) != null) { NewReceiveSettings.Single(g => g.PK == Receiveitem.PK).ConnectionFlag = "連線"; ChungHsin_MySqlMethod.UpdataReceive_Time(Receiveitem, false); } } } else { if (ChungHsin_MySqlMethod.AI64Load(Receiveitem)) { if (NewReceiveSettings.SingleOrDefault(g => g.PK == Receiveitem.PK) != null) { NewReceiveSettings.Single(g => g.PK == Receiveitem.PK).ConnectionFlag = "斷線"; //ChungHsin_MySqlMethod.UpdataReceive_Time(Receiveitem, true); } } else { if (NewReceiveSettings.SingleOrDefault(g => g.PK == Receiveitem.PK) != null) { NewReceiveSettings.Single(g => g.PK == Receiveitem.PK).ConnectionFlag = "連線"; ChungHsin_MySqlMethod.UpdataReceive_Time(Receiveitem, false); } } } } #endregion } CaseSettings = NewCaseSettings; ReceiveSettings = NewReceiveSettings; DeviceConfigs = NewDeviceConfigs; ConnectionTime = DateTime.Now; } else { Thread.Sleep(80); } } }
public Result Notify([FromQuery] string content, NotifyMsgEnum msgEnum, NotifyTypeEnum notifyType, NotifyMsgTypeEnum msgType, string[] atMobiles, bool isAtAll = false) { return(Result.GenError <Result>(Error.Success)); }
private void Connection_Mysql() { while (myWorkState) { TimeSpan timeSpan = DateTime.Now.Subtract(ConnectionTime); if (timeSpan.TotalMilliseconds > 5000) //每一秒查詢動作 { var NewCaseSettings = Ewatch_MySqlMethod.CaseLoad(); var NewAiSettings = Ewatch_MySqlMethod.AiLoad(); var NewElectricSettings = Ewatch_MySqlMethod.ElectricLoad(); var casevalue = Ewatch_MySqlMethod.CaseLoad(); foreach (var caseitem in casevalue) { #region AI接收 var aivalue = Ewatch_MySqlMethod.AiLoad(caseitem); foreach (var aiitem in aivalue) { if (aiitem.NotifyFlag) //AI點位需要發報 { if (Ewatch_MySqlMethod.AI64Load(aiitem)) //檢查即時數值是否超過時間 { var TimeValue = Ewatch_MySqlMethod.Ai_Time(aiitem); //檢查發報數值是否達到 if (TimeValue == null || TimeValue >= aiitem.TimeoutSpan) { if (NewAiSettings.SingleOrDefault(g => g.PK == aiitem.PK) != null) { NewAiSettings.Single(g => g.PK == aiitem.PK).ConnectionFlag = "斷線"; NotifyTypeEnum notifyTypeEnum = (NotifyTypeEnum)caseitem.NotifyTypeEnum; switch (notifyTypeEnum) { case NotifyTypeEnum.None: break; case NotifyTypeEnum.Line: { LineNotifyClass lineNotifyClass = new LineNotifyClass(); lineNotifyClass.LineNotifyFunction(caseitem.NotifyToken, $"設備名稱:{aiitem.AiName} \r最後上傳時間 : {Ewatch_MySqlMethod.AI_LastTime(aiitem)}\r上傳逾時請檢查"); } break; case NotifyTypeEnum.Telegram: { TelegramBotClass telegramBotClass = new TelegramBotClass(caseitem.NotifyApi) { Chat_ID = caseitem.NotifyToken }; telegramBotClass.Send_Message_Group($"設備名稱:{aiitem.AiName} \r最後上傳時間 : {Ewatch_MySqlMethod.AI_LastTime(aiitem)}\r上傳逾時請檢查"); } break; } Ewatch_MySqlMethod.UpdataAi_Time(aiitem, true); } } else { NewAiSettings.Single(g => g.PK == aiitem.PK).ConnectionFlag = "斷線"; } } else { if (NewAiSettings.SingleOrDefault(g => g.PK == aiitem.PK) != null) { NewAiSettings.Single(g => g.PK == aiitem.PK).ConnectionFlag = "連線"; Ewatch_MySqlMethod.UpdataAi_Time(aiitem, false); } } } else { //AiSettings.Single(g => g.PK == aiitem.PK).ConnectionFlag = "不使用"; if (Ewatch_MySqlMethod.AI64Load(aiitem))//檢查即時數值是否超過時間 { if (NewAiSettings.SingleOrDefault(g => g.PK == aiitem.PK) != null) { NewAiSettings.Single(g => g.PK == aiitem.PK).ConnectionFlag = "斷線"; //Ewatch_MySqlMethod.UpdataAi_Time(aiitem, true); } } else { if (NewAiSettings.SingleOrDefault(g => g.PK == aiitem.PK) != null) { NewAiSettings.Single(g => g.PK == aiitem.PK).ConnectionFlag = "連線"; Ewatch_MySqlMethod.UpdataAi_Time(aiitem, false); } } } } #endregion #region 電表接收 var electricvalue = Ewatch_MySqlMethod.ElectricLoad(caseitem); foreach (var electricitem in electricvalue) { if (electricitem.NotifyFlag)//電表點位需要發報 { if (Ewatch_MySqlMethod.ElectricMeterLoad(electricitem)) { var TimeValue = Ewatch_MySqlMethod.ElectricMeter_Time(electricitem); if (TimeValue == null || TimeValue >= electricitem.TimeoutSpan) { if (NewElectricSettings.SingleOrDefault(g => g.PK == electricitem.PK) != null) { NewElectricSettings.Single(g => g.PK == electricitem.PK).ConnectionFlag = "斷線"; NotifyTypeEnum notifyTypeEnum = (NotifyTypeEnum)caseitem.NotifyTypeEnum; switch (notifyTypeEnum) { case NotifyTypeEnum.None: break; case NotifyTypeEnum.Line: { LineNotifyClass lineNotifyClass = new LineNotifyClass(); lineNotifyClass.LineNotifyFunction(caseitem.NotifyToken, $"設備名稱:{electricitem.ElectricName} \r最後上傳時間 : {Ewatch_MySqlMethod.ElectricMeter_LastTime(electricitem)}\r上傳逾時請檢查"); } break; case NotifyTypeEnum.Telegram: { TelegramBotClass telegramBotClass = new TelegramBotClass(caseitem.NotifyApi) { Chat_ID = caseitem.NotifyToken }; telegramBotClass.Send_Message_Group($"設備名稱:{electricitem.ElectricName} \r最後上傳時間 : {Ewatch_MySqlMethod.ElectricMeter_LastTime(electricitem)}\r上傳逾時請檢查"); } break; } Ewatch_MySqlMethod.UpdataElectricMeter_Time(electricitem, true); } } else { NewElectricSettings.Single(g => g.PK == electricitem.PK).ConnectionFlag = "斷線"; } } else { if (NewElectricSettings.SingleOrDefault(g => g.PK == electricitem.PK) != null) { NewElectricSettings.Single(g => g.PK == electricitem.PK).ConnectionFlag = "連線"; Ewatch_MySqlMethod.UpdataElectricMeter_Time(electricitem, false); } } } else { //ElectricSettings.Single(g => g.PK == electricitem.PK).ConnectionFlag = "不使用"; var TimeValue = Ewatch_MySqlMethod.ElectricMeter_Time(electricitem); if (TimeValue == null || TimeValue >= electricitem.TimeoutSpan) { if (NewElectricSettings.SingleOrDefault(g => g.PK == electricitem.PK) != null) { NewElectricSettings.Single(g => g.PK == electricitem.PK).ConnectionFlag = "斷線"; } } else { if (NewElectricSettings.SingleOrDefault(g => g.PK == electricitem.PK) != null) { NewElectricSettings.Single(g => g.PK == electricitem.PK).ConnectionFlag = "連線"; Ewatch_MySqlMethod.UpdataElectricMeter_Time(electricitem, false); } } } } #endregion } CaseSettings = NewCaseSettings; AiSettings = NewAiSettings; ElectricSettings = NewElectricSettings; ConnectionTime = DateTime.Now; } else { Thread.Sleep(80); } } }