示例#1
0
        /// <summary>
        /// 跳转客服
        /// </summary>
        /// <param name="requestMessage"></param>
        /// <param name="Indexid"></param>
        /// <param name="wid"></param>
        /// <returns></returns>
        ///

        public IResponseMessageBase GetResponseMessageTxt(RequestMessageText requestMessage, int Indexid, int wid)
        {
            BLL.wx_userweixin   wBll       = new XCWeiXin.BLL.wx_userweixin();
            Model.wx_userweixin weixininfo = wBll.GetModel(wid);
            string weixincode = weixininfo.weixinCode;
            int    contt      = Account_count();


            //   if(a<contt)

            string str = requestMessage.Content;

            if (str.Contains("客服"))
            {
                string str_new = str.Replace("客服", "");
                if (str_new == "1")
                {
                    str_new = "4";
                }
                if (str_new == "2")
                {
                    str_new = "5";
                }
                if (str_new == "3")
                {
                    str_new = "6";
                }

                string kfcoont = "kf200" + str_new + "@" + weixincode;
                if (Zaixian().Trim().ToString().Contains(kfcoont))
                {
                    var    responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageTransfer_Customer_Service>(requestMessage);
                    string openid          = requestMessage.FromUserName;

                    string token = ConvertDateTimeInt(DateTime.Now).ToString();

                    var    result   = UserApi.Info(stoce(), openid);
                    string pickname = result.nickname;
                    string image    = result.headimgurl;
                    wxResponseBaseMgr.Add(wid, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "Transfer_Customer_Service", responseMessage.MsgType.ToString(), requestMessage.ToUserName, pickname, image);

                    CustomerServiceAccount ss = new CustomerServiceAccount();
                    ss.KfAccount = "kf200" + str_new + "@" + weixincode;
                    List <CustomerServiceAccount> listss = new List <CustomerServiceAccount>();
                    listss.Add(ss);
                    responseMessage.TransInfo = listss;
                    return(responseMessage);
                }
                else
                {
                    var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageText>(requestMessage);

                    string openid = requestMessage.FromUserName;
                    string token  = ConvertDateTimeInt(DateTime.Now).ToString();
                    responseMessage.Content = getDataTxtComm(wid, Indexid, openid, token);
                    var    result   = UserApi.Info(stoce(), openid);
                    string pickname = result.nickname;
                    string image    = result.headimgurl;
                    wxResponseBaseMgr.Add(wid, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", responseMessage.Content, requestMessage.ToUserName, pickname, image);
                    responseMessage.Content = "客服" + str_new + "不在线,请稍后再试!";
                    return(responseMessage);
                }
            }
            else
            {
                ///进入文字处理
                var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageText>(requestMessage);

                string openid = requestMessage.FromUserName;
                string token  = ConvertDateTimeInt(DateTime.Now).ToString();
                responseMessage.Content = getDataTxtComm(wid, Indexid, openid, token);
                var    result   = UserApi.Info(stoce(), openid);
                string pickname = result.nickname;
                string image    = result.headimgurl;
                wxResponseBaseMgr.Add(wid, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", responseMessage.Content, requestMessage.ToUserName, pickname, image);
                //responseMessage.Content ="openid=" + requestMessage.FromUserName;
                return(responseMessage);
            }
        }
示例#2
0
        /// <summary>
        /// 推送纯文字
        /// </summary>
        /// <param name="requestMessage"></param>
        /// <param name="Indexid"></param>
        /// <param name="wid"></param>
        /// <returns></returns>
        public IResponseMessageBase GetResponseMessageTxt_zhaohang(RequestMessageText requestMessage, int Indexid, int wid)
        {
            //   if(a<contt)

            string str = requestMessage.Content;


            if (str.Contains("客服"))
            {
                BLL.wx_userweixin   wBll       = new XCWeiXin.BLL.wx_userweixin();
                Model.wx_userweixin weixininfo = wBll.GetModel(wid);
                string weixincode = weixininfo.weixinCode;
                int    contt      = int.Parse(Account_count_1());

                string str_new = str.Replace("客服", "");

                if (int.Parse(str_new) > contt)
                {
                    var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageText>(requestMessage);

                    string openid = requestMessage.FromUserName;
                    string token  = ConvertDateTimeInt(DateTime.Now).ToString();
                    responseMessage.Content = getDataTxtComm(wid, Indexid, openid, token);
                    var    result   = UserApi.Info(stoce(), openid);
                    string pickname = result.nickname;
                    string image    = result.headimgurl;
                    wxResponseBaseMgr.Add(wid, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", responseMessage.Content, requestMessage.ToUserName, pickname, image);
                    //responseMessage.Content ="openid=" + requestMessage.FromUserName;
                    responseMessage.Content = "不存在客服" + int.Parse(str_new) + "!";
                    return(responseMessage);
                }
                else
                {
                    string              kfcoont = "";
                    int                 number  = 1;
                    BLL.wx_userweixin   bll     = new BLL.wx_userweixin();
                    Model.wx_userweixin model   = bll.GetModel(wid);
                    number = int.Parse(model.extInt.ToString());
                    if (int.Parse(str_new) < 10)
                    {
                        kfcoont = "kf200" + (int.Parse(str_new) + number) + "@" + weixincode;
                    }
                    else
                    {
                        kfcoont = "kf20" + (int.Parse(str_new) + number) + "@" + weixincode;
                    }

                    if (Zaixian().Contains(kfcoont))
                    {
                        var    responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageTransfer_Customer_Service>(requestMessage);
                        string openid          = requestMessage.FromUserName;

                        string token    = ConvertDateTimeInt(DateTime.Now).ToString();
                        var    result   = UserApi.Info(stoce(), openid);
                        string pickname = result.nickname;
                        string image    = result.headimgurl;
                        wxResponseBaseMgr.Add(wid, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "Transfer_Customer_Service", responseMessage.MsgType.ToString(), requestMessage.ToUserName, pickname, image);

                        CustomerServiceAccount ss = new CustomerServiceAccount();
                        ss.KfAccount = kfcoont;
                        List <CustomerServiceAccount> listss = new List <CustomerServiceAccount>();
                        listss.Add(ss);
                        responseMessage.TransInfo = listss;


                        return(responseMessage);
                    }
                    else
                    {
                        var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageText>(requestMessage);

                        string openid = requestMessage.FromUserName;
                        string token  = ConvertDateTimeInt(DateTime.Now).ToString();
                        responseMessage.Content = getDataTxtComm(wid, Indexid, openid, token);
                        var    result   = UserApi.Info(stoce(), openid);
                        string pickname = result.nickname;
                        string image    = result.headimgurl;
                        wxResponseBaseMgr.Add(wid, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", responseMessage.Content, requestMessage.ToUserName, pickname, image);
                        responseMessage.Content = "客服" + str_new + "不在线,请稍后再试!";
                        return(responseMessage);
                    }
                }
            }
            else if (str.Contains("小招"))
            {
                var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageText>(requestMessage);

                string openid = requestMessage.FromUserName;

                string token = ConvertDateTimeInt(DateTime.Now).ToString();
                //responseMessage.Content = getDataTxtComm(wid, Indexid, openid, token);
                var    result   = UserApi.Info(stoce(), openid);
                string pickname = result.nickname;
                string image    = result.headimgurl;
                wxResponseBaseMgr.Add(wid, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", responseMessage.Content, requestMessage.ToUserName, pickname, image);

                wxResponseBaseMgr.updata_1(str, openid);
                responseMessage.Content = "消息已受到,请耐心等待!切勿输入其他文字";
                return(responseMessage);
            }
            else
            {
                ///进入文字处理
                var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageText>(requestMessage);
                //<xml>
                //  <ToUserName><![CDATA[oFo2Hjq6_yMhyz6cQ2MZtmxODOVU]]></ToUserName>
                //  <FromUserName><![CDATA[gh_2cb6c9131eb6]]></FromUserName>
                //  <CreateTime>1472450395</CreateTime>
                //  <MsgType><![CDATA[text]]></MsgType>
                //  <Content><![CDATA[hello]]></Content>
                //</xml>
                string openid  = requestMessage.ToUserName;
                string openids = requestMessage.FromUserName;

                //  string openid = requestMessage.ToUserName;
                string token = ConvertDateTimeInt(DateTime.Now).ToString();
                responseMessage.Content = getDataTxtComm(wid, Indexid, openid, token);
                var    result   = UserApi.Info(stoce(), openids);
                string pickname = result.nickname;
                string image    = result.headimgurl;

                wxResponseBaseMgr dd      = new wxResponseBaseMgr();
                string            extstr3 = dd.ccc(openids);


                wxResponseBaseMgr.Add(wid, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", responseMessage.Content, requestMessage.ToUserName, pickname, image);
                wxResponseBaseMgr.updata(extstr3, openids);


                //responseMessage.Content ="openid=" + requestMessage.FromUserName;
                return(responseMessage);
            }
        }