예제 #1
0
        /// <summary>
        /// 回复消息
        /// </summary>
        /// <param name="context"></param>
        private void ReplyMsg1(HttpContext context)
        {
            var hashtable = new Hashtable();
            var msgId = context.Request["msgId"] ?? "";
            var openId = context.Request["openId"] ?? "";
            var replyContent = context.Request["replyContent"] ?? "";
            try
            {
                var jsonWx = "{\"touser\":\"" + openId + "\",\"msgtype\":\"text\",\"text\":{\"content\":\"" +
                             replyContent + "\"}}";
                var accessToken = new AccessToken();
                var sendDataToWeChat = new SendDataToWeChat();

                var token = accessToken.GetExistAccessToken();
                var back = sendDataToWeChat.GetPage("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + token, jsonWx);

                hashtable = new Hashtable();
                hashtable["data"] = back;
                hashtable["error"] = false;
                ReplyMsgBll bll = new ReplyMsgBll();
                bll.Add(new Model.common.ReplyMsg()
                    {
                        ReceiveMsgId = msgId,
                        AcceptName = openId,
                        TextMsg = replyContent,
                        IsSend = 2,
                    });
                var json = _jss.Serialize(hashtable);
                context.Response.Write(json);
            }
            catch (Exception e)
            {
                hashtable["error"] = true;
                var json = _jss.Serialize(hashtable);
                context.Response.Write(json);
                Log.Error(e);
            }
        }
예제 #2
0
 private void QueryReplyInfo(HttpContext context)
 {
     var hashtable = new Hashtable();
     var msgId = context.Request["msgId"] ?? "";
     var total = 0;
     var page = int.Parse(context.Request["page"] ?? "1");
     var rows = int.Parse(context.Request["rows"] ?? "20");
     try
     {
         ReplyMsgBll bll = new ReplyMsgBll();
         DataTable dt = bll.Query(new Model.common.ReplyMsg()
             {
                 ReceiveMsgId = msgId,
             });
         var list = ConvertHelper<Model.common.ReplyMsg>.ConvertToList(dt);
         hashtable["rows"] = list.ToArray();
         hashtable["total"] = total;
         var json = _jss.Serialize(hashtable);
         context.Response.Write(json);
     }
     catch (Exception e)
     {
         Log.Debug(e);
         context.Response.Write("{\"success\":false,\"msg\":\"查询失败!\"}");
     }
 }