/// <summary>
        /// 回复消息(微信信息返回)
        /// </summary>
        /// <param name="weixinXML"></param>
        private void ResponseMsg(WXCUST_MSG_HIS requestXML)
        {
            WriteTxt(requestXML.MSGTYPE);
            string resxml = "<xml><ToUserName><![CDATA[" + requestXML.FROMUSERNAME + "]]></ToUserName><FromUserName><![CDATA[" + requestXML.TOUSERNAME + "]]></FromUserName><CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime>";

            try
            {
                if (requestXML.MSGTYPE == "text")
                {
                    if (requestXML.CONTENT == "海报")
                    {
                    }
                    else
                    {
                        int count = 0;
                        List <Information_EX> list = sbo.GetModelList(string.Format("  ((KeyWords like '%{0}%' and MatchingType=0) or (KeyWords ='{0}' and MatchingType=1)) AND replytype={1} and ToUserName='******'", requestXML.CONTENT, 1, requestXML.TOUSERNAME));
                        if (list.Count == 1 || (list.Count > 1 && list[0].MsgType != "news"))
                        {
                            Information_EX f = list[0];// ibo.GetModel(requestXML.EventKey, 4); //自定义菜单回复

                            if (f != null)
                            {
                                switch (f.MsgType)
                                {
                                case "text":
                                    resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[" + f.Content + "]]></Content><FuncFlag>0</FuncFlag></xml>";
                                    break;

                                case "news":
                                    resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>1</ArticleCount><Articles>";
                                    resxml += "<item><Title><![CDATA[" + f.Title + "]]></Title><Description><![CDATA[" + f.Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl + "]]></PicUrl><Url><![CDATA[" + (f.IsURL ? (f.FulltextUrl.Contains("?id") ? (f.FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (f.FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + f.DID)) + "]]></Url></item>";    //URL是点击之后跳转去那里,这里跳转到百度
                                    resxml += "</Articles><FuncFlag>0</FuncFlag></xml>";
                                    break;

                                case "music":
                                    resxml += string.Format(@"<MsgType><![CDATA[music]]></MsgType>
                                 <Music>
                                 <Title><![CDATA[{0}]]></Title>
                                 <Description><![CDATA[{1}]]></Description>
                                 <MusicUrl><![CDATA[{2}]]></MusicUrl>
                                 <HQMusicUrl><![CDATA[{2}]]></HQMusicUrl>
                                 </Music>
                                 <FuncFlag>0</FuncFlag>
                                 </xml>", f.Title, f.Description, ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl);
                                    break;

                                default:
                                    //resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[感谢您的支持]]></Content><FuncFlag>0</FuncFlag></xml>";
                                    break;
                                }
                            }
                        }
                        else if (list.Count > 1) //多图
                        {
                            count   = list.Count;
                            resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>" + count + "</ArticleCount><Articles>";
                            for (int i = 0; i < count; i++)
                            {
                                resxml += "<item><Title><![CDATA[" + list[i].Title + "]]></Title><Description><![CDATA[" + list[i].Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + list[i].PicUrl + "]]></PicUrl><Url><![CDATA[" + (list[i].IsURL ? (list[i].FulltextUrl.Contains("?id") ? (list[i].FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (list[i].FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + list[i].DID)) + "]]></Url></item>";//URL是点击之后跳转去那里,这里跳转到百度
                            }
                            resxml += "</Articles><FuncFlag>0</FuncFlag></xml>";
                        }
                        else
                        {
                            list = sbo.GetModelList(string.Format("   replytype={0} and ToUserName='******'", 3, requestXML.TOUSERNAME));
                            if (list.Count == 1 || (list.Count > 1 && list[0].MsgType != "news"))
                            {
                                Information_EX f = list[0];

                                if (f != null)
                                {
                                    switch (f.MsgType)
                                    {
                                    case "text":
                                        resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[" + f.Content + "]]></Content><FuncFlag>0</FuncFlag></xml>";
                                        break;

                                    case "news":
                                        resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>1</ArticleCount><Articles>";
                                        resxml += "<item><Title><![CDATA[" + f.Title + "]]></Title><Description><![CDATA[" + f.Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl + "]]></PicUrl><Url><![CDATA[" + (f.IsURL ? (f.FulltextUrl.Contains("?id") ? (f.FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (f.FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + f.DID)) + "]]></Url></item>";    //URL是点击之后跳转去那里,这里跳转到百度
                                        resxml += "</Articles><FuncFlag>0</FuncFlag></xml>";
                                        break;

                                    case "music":
                                        resxml += string.Format(@"<MsgType><![CDATA[music]]></MsgType>
                                 <Music>
                                 <Title><![CDATA[{0}]]></Title>
                                 <Description><![CDATA[{1}]]></Description>
                                 <MusicUrl><![CDATA[{2}]]></MusicUrl>
                                 <HQMusicUrl><![CDATA[{2}]]></HQMusicUrl>
                                 </Music>
                                 <FuncFlag>0</FuncFlag>
                                 </xml>", f.Title, f.Description, ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl);
                                        break;

                                    default:
                                        //resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[感谢您的支持]]></Content><FuncFlag>0</FuncFlag></xml>";
                                        break;
                                    }
                                }
                            }
                            else if (list.Count > 1) //多图
                            {
                                int count2 = list.Count;
                                resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>" + count + "</ArticleCount><Articles>";
                                for (int z = 0; z < count2; z++)
                                {
                                    resxml += "<item><Title><![CDATA[" + list[z].Title + "]]></Title><Description><![CDATA[" + list[z].Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + list[z].PicUrl + "]]></PicUrl><Url><![CDATA[" + (list[z].IsURL ? (list[z].FulltextUrl.Contains("?id") ? (list[z].FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (list[z].FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + list[z].DID)) + "]]></Url></item>";//URL是点击之后跳转去那里,这里跳转到百度
                                }
                                resxml += "</Articles><FuncFlag>0</FuncFlag></xml>";
                            }
                        }
                    }
                }

                else if (requestXML.MSGTYPE == "event")
                {
                    if (requestXML.WXEVENT == "CLICK")
                    {
                        WriteTxt("CLICK");
                        if (requestXML.EVENTKEY == InviteMenuId)
                        {
                            resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[分享海报邀请新用户,福利多多:\n• 邀请关注,赢佰草集太极.昼御夜养.源生霜、清肌养颜太极泥、三丽鸥KITTY礼品杯\n• 关注后注册绑定,还可获得380元代金券 \n\n点击进入<a href='" + WebUrl + "/wechat/SPA/HFOldAndNew.aspx'>活动主会场</a>\n分享海报,赢惊喜大礼!]]></Content><FuncFlag>0</FuncFlag></xml>";
                        }
                        else
                        {
                            List <CustomMenu_EX> list = sbo.GetCustomMenuModelList(string.Format("  c.ID='{0}'", requestXML.EVENTKEY));
                            if (list.Count == 1 || (list.Count > 1 && list[0].MsgType != "news"))
                            {
                                CustomMenu_EX f = list[0];// ibo.GetModel(requestXML.EventKey, 4); //自定义菜单回复

                                if (f != null)
                                {
                                    switch (f.MsgType)
                                    {
                                    case "text":

                                        resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[" + f.Content + "]]></Content><FuncFlag>0</FuncFlag></xml>";
                                        break;

                                    case "news":
                                        resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>1</ArticleCount><Articles>";
                                        resxml += "<item><Title><![CDATA[" + f.Title + "]]></Title><Description><![CDATA[" + f.Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl + "]]></PicUrl><Url><![CDATA[" + (f.IsURL ? (f.FulltextUrl.Contains("?id") ? (f.FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (f.FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + f.DID)) + "]]></Url></item>";    //URL是点击之后跳转去那里,这里跳转到百度
                                        resxml += "</Articles><FuncFlag>0</FuncFlag></xml>";
                                        break;

                                    case "music":
                                        resxml += string.Format(@"<MsgType><![CDATA[music]]></MsgType>
                                 <Music>
                                 <Title><![CDATA[{0}]]></Title>
                                 <Description><![CDATA[{1}]]></Description>
                                 <MusicUrl><![CDATA[{2}]]></MusicUrl>
                                 <HQMusicUrl><![CDATA[{2}]]></HQMusicUrl>
                                 </Music>
                                 <FuncFlag>0</FuncFlag>
                                 </xml>", f.Title, f.Description, ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl);
                                        break;

                                    default:
                                        //resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[感谢您的支持]]></Content><FuncFlag>0</FuncFlag></xml>";
                                        break;
                                    }
                                }
                            }
                            else if (list.Count > 1) //多图
                            {
                                int count = list.Count;
                                resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>" + count + "</ArticleCount><Articles>";
                                for (int i = 0; i < count; i++)
                                {
                                    resxml += "<item><Title><![CDATA[" + list[i].Title + "]]></Title><Description><![CDATA[" + list[i].Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + list[i].PicUrl + "]]></PicUrl><Url><![CDATA[" + (list[i].IsURL ? (list[i].FulltextUrl.Contains("?id") ? (list[i].FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (list[i].FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + list[i].DID)) + "]]></Url></item>";//URL是点击之后跳转去那里,这里跳转到百度
                                }
                                resxml += "</Articles><FuncFlag>0</FuncFlag></xml>";
                            }
                        }
                    }
                    else if (requestXML.WXEVENT == "unsubscribe")
                    {
                        //取消关注 把粉丝表更新状态为0
                        WriteTxt("取消关注");
                        if (DateTime.Now < DateTime.Parse(ActiveEndDate))
                        {
                            InsertFS(requestXML.FROMUSERNAME, requestXML.TOUSERNAME, 0);  //插入粉丝信息
                            if (DateTime.Now < DateTime.Parse(ActiveEndDate))
                            {
                                MySmallShopService mss = new MySmallShopService();
                                //将表Cust_Old_New中的Jie改成 - 1 ToUserName = openid
                                //将表Cust_Old_New中的Jie改成 - 1 FromUserName = openid  ToUserName = fx
                                mss.UpdateCustOldNewJie(requestXML.FROMUSERNAME);
                                //将表OAauth_Log中的字段SeaImg = '' 参加活动数量-1
                                OAauth_Log oa = mss.GetOA(requestXML.FROMUSERNAME);
                                if (oa != null)
                                {
                                    oa.SeaImg    = "";
                                    oa.SeaSource = null;
                                    mss.SaveOA(oa);
                                }
                            }
                        }
                    }
                    else if (requestXML.WXEVENT.ToLower() == "location") //获取地理位置
                    {
                        WriteTxt("获取地理位置");
                    }
                    else if (requestXML.WXEVENT.ToLower() == "scan" || (requestXML.WXEVENT.ToLower() == "subscribe" && requestXML.EVENTKEY.ToLower().Contains("qrscene"))) //扫描二维码
                    {
                        WriteTxt("扫二维码");
                        string EVENTKEY = requestXML.EVENTKEY;
                        requestXML.EVENTKEY = requestXML.EVENTKEY.ToLower().Contains("qrscene") ? requestXML.EVENTKEY.Split('_')[1] : requestXML.EVENTKEY;
                        int num = int.Parse(requestXML.EVENTKEY);

                        if (requestXML.WXEVENT.ToLower() == "subscribe")
                        {
                            if (num > 10000) //邀请海报
                            {
                                resxml = OldAndNew(requestXML, resxml, num);
                            }
                            resxml = Subscribe(requestXML, resxml);
                        }
                    }

                    //关注
                    else if (requestXML.WXEVENT.ToLower() == "subscribe")
                    {
                        WriteTxt("关注");
                        resxml = Subscribe(requestXML, resxml);
                        if (DateTime.Now < DateTime.Parse(ActiveEndDate))
                        {
                        }
                    }
                }
                requestXML.RESXML = resxml;
                if (!resxml.Contains("</xml>"))
                {
                    resxml = "";
                }


                AddCUST_MSG_HISHandler handler = new AddCUST_MSG_HISHandler(sbo.AddCUST_MSG_HIS);
                int result = handler.Invoke(requestXML);
                //sbo.AddCUST_MSG_HIS(requestXML);
            }
            catch (Exception ex)
            {
                resxml = "";
            }
            finally
            {
                Response.Write(resxml);
                Response.End();
            }
        }