예제 #1
0
        /// <summary>
        /// 聊天内容输出到网页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private List <WX_CustomMsg> FansMsg(string id)
        {
            SYS_User            SYSUSER = Session["SYSUSER"] as SYS_User;
            List <WX_Queue>     list    = new WXDataBLL.WXCustom.WX_QueueManager().Where(s => s.MsgState == 1 && s.OpenID.Equals(id));
            List <WX_CustomMsg> msg     = new List <WX_CustomMsg>();

            foreach (WX_Queue item in list)
            {
                WX_CustomMsg CM = new WX_CustomMsg();
                CM.MsgId      = item.MsgId;
                CM.OpenID     = item.OpenID;
                CM.UserId     = SYSUSER.UserId;
                CM.AppId      = SYSUSER.AppId;
                CM.CreateTime = item.CreateTime;
                CM.Content    = XmlUtility.GetSingleNodeInnerText(item.XmlContent, "/xml/Content");
                CM.MsgSource  = "粉丝";
                CM.MsgType    = item.MsgType;
                CM.XmlContent = item.XmlContent;
                new WXDataBLL.WXCustom.WX_QueueManager().Delete(item.MsgId); //删除
                new WXDataBLL.WXCustom.WX_CustomMsgManager().Add(CM);        //添加到数据库
                var info = new WXDataBLL.WXCustom.WX_CustomMsgManager().GetByPK(CM.MsgId);
                msg.Add(info);                                               //添加到集合
            }
            return(msg);
        }
예제 #2
0
        public ActionResult TaleToUser(WX_CustomMsg msg)
        {
            SYS_User SYSUSER = Session["SYSUSER"] as SYS_User;

            msg.UserId     = SYSUSER.UserId;
            msg.MsgId      = Guid.NewGuid().ToString();
            msg.CreateTime = DateTime.Now;
            msg.MsgSource  = "客服";
            msg.AppId      = SYSUSER.AppId;

            //发送到微信
            CustomService customSvr = new CustomService(SYSUSER.AppId, SYSUSER.WX_App.AppSecret);

            customSvr.SendText(msg.OpenID, msg.Content);

            bool IsTrue = new WXDataBLL.WXCustom.WX_CustomMsgManager().Add(msg);

            return(Json(IsTrue, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult UserHistory(string id, int page = 3, int rows = 1)
        {
            SYS_User SYSUSER = Session["SYSUSER"] as SYS_User;
            var      list    = new WXDataBLL.WXCustom.WX_CustomMsgManager().Where(s => s.AppId == SYSUSER.AppId && s.UserId == SYSUSER.UserId && s.OpenID == id).OrderBy(x => x.CreateTime).ToList();
            var      Data    = list.Skip((page - 1) * rows).Take(rows).Select(s => new
            {
                s.AppId,
                s.CreateTime,
                s.Content,
                s.WX_User.UserNick
            });
            var pageData = new
            {
                total = list.Count,
                rows  = Data
            };

            return(Json(pageData, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public void Send(string OpenId, int UserId, string AppId)
        {
            List <WX_Queue>     list = new WXDataBLL.WXCustom.WX_QueueManager().Where(s => s.MsgState == 1 && s.OpenID.Equals(OpenId));
            List <WX_CustomMsg> msg  = new List <WX_CustomMsg>();

            foreach (WX_Queue item in list)
            {
                WX_CustomMsg CM = new WX_CustomMsg();
                CM.MsgId      = item.MsgId;
                CM.OpenID     = item.OpenID;
                CM.UserId     = UserId;
                CM.AppId      = AppId;
                CM.CreateTime = item.CreateTime;
                CM.Content    = XmlUtility.GetSingleNodeInnerText(item.XmlContent, "/xml/Content");
                CM.MsgSource  = "粉丝";
                CM.MsgType    = item.MsgType;
                CM.XmlContent = item.XmlContent;
                new WXDataBLL.WXCustom.WX_QueueManager().Delete(item.MsgId); //删除
                new WXDataBLL.WXCustom.WX_CustomMsgManager().Add(CM);        //添加到数据库
                var info = new WXDataBLL.WXCustom.WX_CustomMsgManager().GetByPK(CM.MsgId);
                msg.Add(info);                                               //添加到集合
            }
            Clients.User(UserId.ToString()).Send(msg);
        }