From a77c52fd46a9ec5cee337c16a48b30b9edee91b3 Mon Sep 17 00:00:00 2001 From: yashen Date: Fri, 14 Oct 2016 14:15:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=AE=E4=BF=A1=E5=8F=91?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- B3WeChat/Entities/MeassageBody.cs | 2 +- B3WeChat/Rpcs/ApproveMessageRpc.cs | 4 +-- B3WeChat/Rpcs/ClientRpc.cs | 3 +- B3WeChat/Utils/SendMessageUtil.cs | 52 +++++++++++++----------------- 4 files changed, 27 insertions(+), 34 deletions(-) diff --git a/B3WeChat/Entities/MeassageBody.cs b/B3WeChat/Entities/MeassageBody.cs index b4da643..610786e 100644 --- a/B3WeChat/Entities/MeassageBody.cs +++ b/B3WeChat/Entities/MeassageBody.cs @@ -34,7 +34,7 @@ namespace BWP.B3WeChat.Entities } - public ValueColor(string value, string color = "#173177") + public ValueColor(string value, string color = null) { this.value = value; this.color = color; diff --git a/B3WeChat/Rpcs/ApproveMessageRpc.cs b/B3WeChat/Rpcs/ApproveMessageRpc.cs index a75e3d3..c6f3513 100644 --- a/B3WeChat/Rpcs/ApproveMessageRpc.cs +++ b/B3WeChat/Rpcs/ApproveMessageRpc.cs @@ -91,14 +91,14 @@ namespace BWP.B3WeChat.Rpcs public static void ExecuteSuccess(string messageID) { var message = bl.Load(messageID); - SendMessageUtil.SendFeedbackNotice(message.OpenID, "你好,你的审批结果ERP系统已收到并处理", "微信审批", message.ID, message.CreateTime, true); + SendMessageUtil.SendFeedbackNotice(message.OpenID, "你好,你的审批结果ERP系统已收到并处理", "微信审批接收", "消息号" + message.ID, message.CreateTime, true); bl.Delete(messageID); } [Rpc] public static void ExecuteFail(string messageID,string reason){ var message = bl.Load(messageID); - SendMessageUtil.SendFeedbackNotice(message.OpenID, "你好,你的审批结果ERP系统已收到并处理", "微信审批", message.ID, message.CreateTime, false, reason); + SendMessageUtil.SendFeedbackNotice(message.OpenID, "你好,你的审批结果ERP系统已收到并处理", "微信审批接收", "消息号" + message.ID, message.CreateTime, false, reason); bl.Delete(messageID); } } diff --git a/B3WeChat/Rpcs/ClientRpc.cs b/B3WeChat/Rpcs/ClientRpc.cs index c393ad5..6ed1654 100644 --- a/B3WeChat/Rpcs/ClientRpc.cs +++ b/B3WeChat/Rpcs/ClientRpc.cs @@ -37,8 +37,7 @@ namespace BWP.B3WeChat.Rpcs [Rpc] public static void Send(string username, string content) { - string oppenid = GetOpenId(username); - SendMessageUtil.SendInformInfo(oppenid, "青花瓷软件温馨提醒", DateTime.Now.ToString("yyyy-MM-dd HH:mm"), content, string.Empty, string.Empty, string.Empty, string.Empty); + SendMessageUtil.SendSystemMessage(CustomerUserContext.Current.GetOpenID(username), username, content); } static string GetOpenId(string username) diff --git a/B3WeChat/Utils/SendMessageUtil.cs b/B3WeChat/Utils/SendMessageUtil.cs index 85cb170..7ae9ab4 100644 --- a/B3WeChat/Utils/SendMessageUtil.cs +++ b/B3WeChat/Utils/SendMessageUtil.cs @@ -30,10 +30,10 @@ namespace BWP.B3WeChat.Utils var remark = "你可以点击本消息进入处理界面"; Dictionary dic = new Dictionary(); - dic.Add("first", new ValueColor() { value = first, color = "#173177" }); - dic.Add("keyword1", new ValueColor() { value = keyword1, color = "#173177" }); - dic.Add("keyword2", new ValueColor() { value = keyword2, color = "#173177" }); - dic.Add("remark", new ValueColor() { value = remark, color = "#173177" }); + dic.Add("first", new ValueColor() { value = first }); + dic.Add("keyword1", new ValueColor() { value = keyword1 }); + dic.Add("keyword2", new ValueColor() { value = keyword2 }); + dic.Add("remark", new ValueColor() { value = remark }); InOutMessageUtil.SendTemplateMessage(openID, "qsaZh8axp__2V8Ut8owpUGu-wFH39fHt_DeBqoHiWI4", dic, url); } @@ -47,7 +47,7 @@ namespace BWP.B3WeChat.Utils //提交时间:{{keyword3.DATA}} //处理结果:{{keyword4.DATA}} //{{remark.DATA}} - public static void SendFeedbackNotice(string openID,string first,string type,string info,DateTime submitTime,bool success,string remark=null) + public static void SendFeedbackNotice(string openID, string first, string type, string info, DateTime submitTime, bool success, string remark = null) { var dic = new Dictionary(); dic.Add("first", new ValueColor(first)); @@ -57,35 +57,29 @@ namespace BWP.B3WeChat.Utils dic.Add("keyword2", new ValueColor(keyword2)); var keyword3 = FormatTime(submitTime); dic.Add("keyword3", new ValueColor(keyword3)); - var keyword4 = success ? "成功":"失败"; - dic.Add("keyword4", new ValueColor(keyword4,success ?"green":"red")); + var keyword4 = success ? "成功" : "失败"; + dic.Add("keyword4", new ValueColor(keyword4, success ? "green" : "red")); dic.Add("remark", new ValueColor(remark)); InOutMessageUtil.SendTemplateMessage(openID, "wMmuu5928fuhDhXEBWSfVUj7up_F6xs2V9sBTvnVVcA", dic); } - /// - /// 发送系统提醒 - /// - /// - /// 题目 - /// 提醒时间 - /// 提醒内容 - /// 操作人 - /// IP地址 - /// 操作时间 - /// 备注 - /// - public static void SendInformInfo(string openid, string title, string informtime, string informcontent, string who, string ip, string when, string remark, string url = "") + + //标题:系统运维通知 + //行业:IT科技 - IT软件与服务 + //详细内容 + //{{first.DATA}} + //时间:{{keyword1.DATA}} + //描述:{{keyword2.DATA}} + //{{remark.DATA}} + public static void SendSystemMessage(string openID,string name,string content) { - Dictionary dic = new Dictionary(); - dic.Add("first", new ValueColor() { value = title, color = "#173177" }); - dic.Add("keyword1", new ValueColor() { value = informtime, color = "#173177" }); - dic.Add("keyword2", new ValueColor() { value = informcontent, color = "#173177" }); - dic.Add("keyword3", new ValueColor() { value = who, color = "#173177" }); - dic.Add("keyword4", new ValueColor() { value = ip, color = "#173177" }); - dic.Add("keyword5", new ValueColor() { value = when, color = "#173177" }); - dic.Add("remark", new ValueColor() { value = remark, color = "#173177" }); - InOutMessageUtil.SendTemplateMessage(openid, "JEOjjJ-L-hflfWoHEf7dRMlhj7fCs9NoOYf1iTQ03D4", dic, url); + var dict = new Dictionary(); + var first = string.Format("你好,ERP系统中的用户{0},系统发给你下面的消息", name); + dict.Add("first",new ValueColor(first)); + dict.Add("keyword1", new ValueColor(FormatTime(DateTime.Now))); + dict.Add("keyword2", new ValueColor(content)); + InOutMessageUtil.SendTemplateMessage(openID, "QEgY8xa4BuAAcyTex1qXuN9KeKM93O9XHCz2Ti-oCpc", dict); + } } }