Esempio n. 1
0
        private string SendMessage()
        {
            SendMessageRespData respData = new SendMessageRespData();

            try
            {
                string requestData = Request["ReqContent"];
                if (!string.IsNullOrEmpty(requestData))
                {
                    Loggers.DEFAULT.Debug(new DebugLogInfo
                    {
                        Message = "发送客服消息请求数据:" + requestData
                    });
                    var reqObj             = requestData.DeserializeJSONTo <SendMessageReqData>();
                    var loggingSessionInfo = Default.GetBSLoggingSession(reqObj.common.customerId, "1");
                    CSInvokeMessageBLL bll = new CSInvokeMessageBLL(loggingSessionInfo);
                    if (!string.IsNullOrEmpty(reqObj.special.objectType))
                    {
                        bll.SendMessage(reqObj.special.csPipelineId
                                        , reqObj.common.userId
                                        , reqObj.special.isCS, reqObj.special.messageId
                                        , reqObj.special.messageContent
                                        , reqObj.special.serviceTypeId
                                        , reqObj.special.objectId
                                        , reqObj.special.messageTypeId
                                        , reqObj.special.Articles
                                        , reqObj.special.Title
                                        , reqObj.special.Description
                                        , reqObj.special.PicUrl
                                        , reqObj.special.Url
                                        , reqObj.special.objectType
                                        , reqObj.special.contetTypeId
                                        , reqObj.special.sign
                                        , reqObj.special.mobileNo, reqObj.special.VipIDInit);
                    }
                    else
                    {
                        bll.SendMessage(reqObj.special.csPipelineId
                                        , reqObj.common.userId
                                        , reqObj.special.isCS, reqObj.special.messageId
                                        , reqObj.special.messageContent
                                        , reqObj.special.serviceTypeId
                                        , reqObj.special.objectId
                                        , reqObj.special.messageTypeId
                                        , reqObj.special.contetTypeId
                                        , reqObj.special.sign
                                        , reqObj.special.mobileNo, reqObj.special.VipIDInit);
                    }
                }
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "操作失败:" + ex.Message;
                respData.exception   = ex.Message;
            }
            respData.CurrentServerDateTime = DateTime.Now.To19FormatString();
            return(respData.ToJSON());
        }
Esempio n. 2
0
        private string ReceiveMessageNew()
        {
            RecevieMessageNewRespData respData = new RecevieMessageNewRespData();

            try
            {
                string requestData = Request["ReqContent"];
                if (!string.IsNullOrEmpty(requestData))
                {
                    Loggers.DEFAULT.Debug(new DebugLogInfo
                    {
                        Message = "接收客服消息请求数据:" + requestData
                    });
                    var reqObj             = requestData.DeserializeJSONTo <RecevieMessageNewReqData>();
                    var loggingSessionInfo = Default.GetBSLoggingSession(reqObj.common.customerId, "1");
                    CSInvokeMessageBLL bll = new CSInvokeMessageBLL(loggingSessionInfo);
                    int      recordCount;
                    DateTime?CurrentGetTimeNew = null;
                    DateTime?NextTimeNew       = null;
                    IList <CSConversationEntity> conversationEntities = bll.ReceiveMessageNew(reqObj.common.userId
                                                                                              , reqObj.special.isCS
                                                                                              , reqObj.special.messageId
                                                                                              , reqObj.special.pageSize
                                                                                              , reqObj.special.pageIndex
                                                                                              , reqObj.common.customerId
                                                                                              , reqObj.special.ReceiveType
                                                                                              , reqObj.special.CurrentGetTime   //会不会导致更改后的时间没有返回?
                                                                                              , reqObj.special.NextTime
                                                                                              , out recordCount
                                                                                              , out CurrentGetTimeNew
                                                                                              , out NextTimeNew
                                                                                              );
                    respData.content               = new RecevieMessageNewRespContentData();
                    respData.content.recordCount   = recordCount;
                    respData.content.conversations = conversationEntities;

                    //返回时间
                    respData.content.CurrentGetTime = CurrentGetTimeNew;
                    respData.content.NextTime       = NextTimeNew;
                }
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "操作失败:" + ex.Message;
                respData.exception   = ex.Message;
            }
            return(respData.ToJSON());
        }
Esempio n. 3
0
        public string SendMsg(NameValueCollection rParams)
        {
            string res            = "{success:false,msg:'操作失败'}";
            string sign           = "";
            int    isCS           = 1;
            string mobile         = "";
            string userid         = "";
            int    csPipelineId   = 1;
            string messageContent = "";
            string conn           = GetCustomerConn(CurrentUserInfo.ClientID);

            CurrentUserInfo.Conn = conn;
            CSInvokeMessageBLL bll = new CSInvokeMessageBLL(CurrentUserInfo);

            if (!string.IsNullOrEmpty(rParams["csPipelineId"]))
            {
                csPipelineId = int.Parse(rParams["csPipelineId"]);
            }
            if (!string.IsNullOrEmpty(rParams["messageContent"]))
            {
                messageContent = rParams["messageContent"];
            }
            if (!string.IsNullOrEmpty(rParams["userid"]))
            {
                userid = rParams["userid"];
            }
            if (!string.IsNullOrEmpty(rParams["mobile"]))
            {
                mobile = rParams["mobile"];
            }
            if (!string.IsNullOrEmpty(rParams["sign"]))
            {
                sign = rParams["sign"];
            }
            if (!string.IsNullOrEmpty(rParams["isCS"]))
            {
                isCS = int.Parse(rParams["isCS"]);
            }
            bll.SendMessage(csPipelineId, userid, isCS, "", messageContent, null, null, null, null, sign, mobile);
            res = "{success:true,msg:'保存成功'}";
            return(res);
        }
Esempio n. 4
0
        //处理图片消息
        public virtual void HandlerImage()
        {
            string picUrl = requestParams.XmlNode.SelectSingleNode("//PicUrl").InnerText; //图片链接
            string msgId  = requestParams.XmlNode.SelectSingleNode("//MsgId").InnerText;  //消息id,64位整型

            BaseService.WriteLogWeixin("图片链接PicUrl:---------------" + picUrl);
            BaseService.WriteLogWeixin("消息id,64位整型MsgId:---------------" + msgId);

            //推送客服消息  qianzhi  2014-03-04
            VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo);
            var    vipList    = vipService.QueryByEntity(new VipEntity
            {
                WeiXinUserId = requestParams.OpenId,
                WeiXin       = requestParams.WeixinId
            }, null);

            if (vipList != null && vipList.Length > 0)
            {
                var vipEntity          = vipList.FirstOrDefault();
                CSInvokeMessageBLL msg = new CSInvokeMessageBLL(requestParams.LoggingSessionInfo);
                msg.SendMessage(1, vipEntity.VIPID, 0, null, picUrl, null, null, null, 2);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 处理文本消息 Jermyn20140512
        /// </summary>
        public virtual void HandlerText()
        {
            var content    = requestParams.XmlNode.SelectSingleNode("//Content").InnerText.Trim(); //文本消息内容
            var weixinId   = requestParams.WeixinId;
            var keywordDAO = new WKeywordReplyDAO(requestParams.LoggingSessionInfo);
            //var ds = keywordDAO.GetMaterialByKeyword(content);
            var ds          = keywordDAO.GetMaterialByKeywordJermyn(content, weixinId, 1);
            int keywordType = 1;

            #region 如果没有关键字回复,给予自动回复内容

            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                ds          = keywordDAO.GetMaterialByKeywordJermyn(content, weixinId, 3);
                keywordType = 3;
            }

            #endregion

            #region 如果回复,调用老的接口

            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                HandlerTextOld();
                return;//执行 完老的发送信息的方法,就直接跳出请去,不往下走了****
            }

            #endregion

            //#region 复星临时代码  以后需要删除  qianzhi  2014-01-16

            ////复星临时代码  以后需要删除  qianzhi  2014-01-16
            //if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            //{
            //    ds = keywordDAO.GetMaterialByKeyword("任意回复");
            //}

            //#endregion

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string Text    = ds.Tables[0].Rows[0]["Text"].ToString();      //素材类型
                string ReplyId = ds.Tables[0].Rows[0]["ReplyId"].ToString();   //素材ID
                string typeId  = ds.Tables[0].Rows[0]["ReplyType"].ToString(); //素材ID

                BaseService.WriteLogWeixin("ReplyId:" + ReplyId);
                BaseService.WriteLogWeixin("typeId:" + typeId);

                switch (typeId)
                {
                case MaterialType.TEXT:             //回复文字消息
                    //ReplyText(materialId);
                    ReplyTextJermyn(Text);
                    break;

                case MaterialType.IMAGE_TEXT:       //回复图文消息
                    //ReplyNews(materialId);
                    ReplyNewsJermyn(ReplyId, keywordType, 1);
                    break;

                default:
                    break;
                }
            }
            else
            {
                //推送客服消息  qianzhi  2014-03-04
                VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo);
                var    vipList    = vipService.QueryByEntity(new VipEntity
                {
                    WeiXinUserId = requestParams.OpenId,
                    WeiXin       = requestParams.WeixinId
                }, null);

                if (vipList != null && vipList.Length > 0)
                {
                    var vipEntity          = vipList.FirstOrDefault();
                    CSInvokeMessageBLL msg = new CSInvokeMessageBLL(requestParams.LoggingSessionInfo);
                    msg.SendMessage(1, vipEntity.VIPID, 0, null, content, null, null, null, 1);
                }
            }
        }
Esempio n. 6
0
        //处理文本消息
        public void HandlerTextOld()
        {
            var content = requestParams.XmlNode.SelectSingleNode("//Content").InnerText.Trim();   //文本消息内容

            var keywordDAO = new WKeywordReplyDAO(requestParams.LoggingSessionInfo);
            var ds         = keywordDAO.GetMaterialByKeyword(content);

            #region  星临时代码  以后需要删除  qianzhi  2014-01-16

            //复星临时代码  以后需要删除  qianzhi  2014-01-16
            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
            {
                ds = keywordDAO.GetMaterialByKeyword("任意回复");
            }

            #endregion

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string typeId     = ds.Tables[0].Rows[0]["MaterialTypeId"].ToString(); //素材类型
                string materialId = ds.Tables[0].Rows[0]["MaterialId"].ToString();     //素材ID

                BaseService.WriteLogWeixin("typeId:" + typeId);
                BaseService.WriteLogWeixin("materialId:" + materialId);

                switch (typeId)
                {
                case MaterialType.TEXT:             //回复文字消息
                    ReplyText(materialId);
                    break;

                case MaterialType.IMAGE_TEXT:       //回复图文消息
                    ReplyNews(materialId);
                    break;

                default:
                    break;
                }
            }
            else//如果取不到关键字回复或者自动回复,就使用客服信息程序
            {
                //推送客服消息  qianzhi  2014-03-04
                VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo);
                var    vipList    = vipService.QueryByEntity(new VipEntity
                {
                    WeiXinUserId = requestParams.OpenId,
                    WeiXin       = requestParams.WeixinId
                }, null);

                if (vipList != null && vipList.Length > 0)
                {
                    var vipEntity          = vipList.FirstOrDefault();
                    CSInvokeMessageBLL msg = new CSInvokeMessageBLL(requestParams.LoggingSessionInfo);//调用客服信息

                    /// <summary>
                    /// 发送消息
                    /// </summary>
                    /// <param name="csPipelineId">消息通道ID1:微信2:短信3:IOS4:Android</param>
                    /// <param name="userId">发送者ID</param>
                    /// <param name="isCS">是否是客服1:是0:否</param>
                    /// <param name="messageId">要回复的消息ID,如果为首次请求,请传NULL</param>
                    /// <param name="messageContent">消息内容</param>
                    /// <param name="serviceTypeId">服务类型,用于特殊类型的服务,如订单咨询</param>
                    /// <param name="objectId">服务对象ID,请求对的对象ID,如订单ID</param>
                    /// <param name="messageTypeId">消息类型,默认为NULL,如果是特殊类型的消息,则传特殊类型定义ID,现在暂定=5的ID为 微信优先、短信其次、App再次发送</param>
                    /// <param name="contentTypeId">消息内容类型默认NULL或 1文本 2图片 3语音 4 视频 </param>
                    /// <param name="sign">短信签名</param>
                    /// <param name="mobileNo"></param>
                    msg.SendMessage(1, vipEntity.VIPID, 0, null, content, null, null, null, 1);
                }
            }
        }