diff --git a/B3WeChat/BL/IApproveMessageBL.cs b/B3WeChat/BL/IApproveMessageBL.cs index 093a3f8..44db00a 100644 --- a/B3WeChat/BL/IApproveMessageBL.cs +++ b/B3WeChat/BL/IApproveMessageBL.cs @@ -1,5 +1,6 @@ using BWP.B3WeChat.BO; using BWP.B3WeChat.BO.NamedValueTemplate; +using BWP.B3WeChat.Utils; using Forks.EnterpriseServices.BusinessInterfaces; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; @@ -53,6 +54,9 @@ namespace BWP.B3WeChat.BL var del = new DQDeleteDom(typeof(ApproveMessage)); del.Where.Conditions.Add(DQCondition.EQ("ID", messageID)); Session.ExecuteNonQuery(del); + + var message = Load(messageID); + } diff --git a/B3WeChat/CustomerUserContext.cs b/B3WeChat/CustomerUserContext.cs index d29de26..3ad67e1 100644 --- a/B3WeChat/CustomerUserContext.cs +++ b/B3WeChat/CustomerUserContext.cs @@ -24,6 +24,16 @@ namespace BWP.B3WeChat } } + string mCustomerName; + public string CustomerName + { + get + { + return mCustomerName; + } + } + + public string GetOpenID(string customerUsername) { var query = new DQueryDom(new JoinAlias(typeof(CustomerUser))); @@ -53,10 +63,16 @@ namespace BWP.B3WeChat var query = new DQueryDom(new JoinAlias(typeof(DeviceAuthentication))); query.Where.Conditions.Add(DQCondition.EQ("Ticket", user.UserTag.ToString("N"))); query.Columns.Add(DQSelectColumn.Field("DeviceNumber")); + query.Columns.Add(DQSelectColumn.Field("Name")); query.Range = SelectRange.Top(1); - var deviceNumber = query.EExecuteScalar(); + var tuple = query.EExecuteScalar(); + if (tuple == null) + { + return null; + } var context = new CustomerUserContext(); - context.mCustomerCode = deviceNumber; + context.mCustomerCode = tuple.Item1; + context.mCustomerName = tuple.Item2; if (httpContext != null) { httpContext.Items[key] = context; diff --git a/B3WeChat/Rpcs/ApproveMessageRpc.cs b/B3WeChat/Rpcs/ApproveMessageRpc.cs index 2ae0ecd..96e9ce9 100644 --- a/B3WeChat/Rpcs/ApproveMessageRpc.cs +++ b/B3WeChat/Rpcs/ApproveMessageRpc.cs @@ -45,9 +45,10 @@ namespace BWP.B3WeChat.Rpcs var mainSystemConfig = new MainSystemConfig(); var internetAccessAddress = mainSystemConfig.InternetAccessAddress.Value; var originUrl = internetAccessAddress + "app/index.html?messageid=" + message.ID; - var wechatmessage = string.Format("ERP系统给你的用户{0}发送了一个消息待您审批", message.Username); var timeStr = DateTime.Now.ToLongTimeString(); - SendMessageUtil.SendInformInfo(message.OpenID, wechatmessage, timeStr, message.Title, message.Username, BLContext.ClientIP, timeStr, "", originUrl); + + SendMessageUtil.SendTodoMessage(openID, context.CustomerName, message.Username, "微信工作流审批", message.CreateTime, originUrl); + #endif } diff --git a/B3WeChat/Utils/InOutMessageUtil.cs b/B3WeChat/Utils/InOutMessageUtil.cs index e947a4f..a2ad198 100644 --- a/B3WeChat/Utils/InOutMessageUtil.cs +++ b/B3WeChat/Utils/InOutMessageUtil.cs @@ -107,7 +107,7 @@ namespace BWP.B3WeChat.Utils return GetRequest(uriStr); } - public static SendTemplateMessageResult SendTemplateMessage(string openID, string templateID, Dictionary dic, string url = "") + public static void SendTemplateMessage(string openID, string templateID, Dictionary dic, string url = "") { string uriStr = string.Format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}", TOKEN); JavaScriptSerializer jsonHelper = new JavaScriptSerializer(); @@ -118,7 +118,7 @@ namespace BWP.B3WeChat.Utils body.url = url; body.data = dic; string postData = jsonHelper.Serialize(body); - return PostRequest(uriStr, postData); + PostRequest(uriStr, postData); } public static void SetCustomMenu(string menuJson) diff --git a/B3WeChat/Utils/SendMessageUtil.cs b/B3WeChat/Utils/SendMessageUtil.cs index bea9f18..6c02d4f 100644 --- a/B3WeChat/Utils/SendMessageUtil.cs +++ b/B3WeChat/Utils/SendMessageUtil.cs @@ -8,6 +8,53 @@ namespace BWP.B3WeChat.Utils { public static class SendMessageUtil { + //编号:OPENTM406714250 + //标题:流程待办提醒 + //{{first.DATA}} + //流程名称:{{keyword1.DATA}} + //提交时间:{{keyword2.DATA}} + //{{remark.DATA}} + public static void SendTodoMessage(string openID,string source,string toUsername,string flowName,DateTime time,string url) + { + var first = string.Format("你接收到来自{0}发送给用户{1}的新的审批任务", source, toUsername); + var keyword1 = flowName; + var keyword2 = time.ToString("yyy-MM-dd HH:mm:ss"); + 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" }); + InOutMessageUtil.SendTemplateMessage(openID, "qsaZh8axp__2V8Ut8owpUGu-wFH39fHt_DeBqoHiWI4", dic, url); + } + + + + + + //{{first.DATA}} + //审批类别:{{keyword1.DATA}} + //审批事项:{{keyword2.DATA}} + //审批意见:{{keyword3.DATA}} + //审批结果:{{keyword4.DATA}} + //{{remark.DATA}} + public static void SendApprovetMessage(string openID, string messageid) + { + var keyword1 = "微信审批"; + var keyword2 = "同意"; + var keyword3 = ""; + var keyword4 = "执行成功"; + + } + + public static void SendRejectMessage() + { + + } + + + /// /// 发送代办信息 /// @@ -17,14 +64,14 @@ namespace BWP.B3WeChat.Utils /// 未处理时间 /// 备注 /// - public static SendTemplateMessageResult SendAgentInfo(string openid, string title, string todeal, string delay, string remark) + public static void SendAgentInfo(string openid, string title, string todeal, string delay, string remark) { Dictionary dic = new Dictionary(); dic.Add("first", new ValueColor() { value = title, color = "#173177" }); dic.Add("keyword1", new ValueColor() { value = todeal, color = "#173177" }); dic.Add("keyword2", new ValueColor() { value = delay, color = "#173177" }); dic.Add("remark", new ValueColor() { value = remark, color = "#173177" }); - return InOutMessageUtil.SendTemplateMessage(openid, "uhy7GuF8zwBA6pjvjQWpn02fiKb0o9cq7dO5DWnUuMg", dic); + InOutMessageUtil.SendTemplateMessage(openid, "uhy7GuF8zwBA6pjvjQWpn02fiKb0o9cq7dO5DWnUuMg", dic); } /// /// 发送系统提醒 @@ -38,7 +85,7 @@ namespace BWP.B3WeChat.Utils /// 操作时间 /// 备注 /// - public static SendTemplateMessageResult SendInformInfo(string openid, string title, string informtime, string informcontent, string who,string ip, string when, string remark,string url="") + public static void SendInformInfo(string openid, string title, string informtime, string informcontent, string who, string ip, string when, string remark, string url = "") { Dictionary dic = new Dictionary(); dic.Add("first", new ValueColor() { value = title, color = "#173177" }); @@ -48,7 +95,7 @@ namespace BWP.B3WeChat.Utils 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" }); - return InOutMessageUtil.SendTemplateMessage(openid, "JEOjjJ-L-hflfWoHEf7dRMlhj7fCs9NoOYf1iTQ03D4", dic,url); + InOutMessageUtil.SendTemplateMessage(openid, "JEOjjJ-L-hflfWoHEf7dRMlhj7fCs9NoOYf1iTQ03D4", dic, url); } } }