/// <summary>
        /// 回复消息(微信信息返回)
        /// </summary>
        /// <param name="weixinXML"></param>
        private void ResponseMsg(WXCUST_MSG_HIS requestXML)
        {
            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 == "海报")
                    {
                        new SeaNews().SeadSeaNews(requestXML.FROMUSERNAME);
                        resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[生成海报]]></Content><FuncFlag>0</FuncFlag></xml>";
                    }
                    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")
                    {
                        if (requestXML.EVENTKEY.ToLower() == "dkf") //多客服接口
                        {
                            resxml += "<MsgType><![CDATA[transfer_customer_service]]></MsgType></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

                        InsertFS(requestXML.FROMUSERNAME, requestXML.TOUSERNAME, 0); //插入粉丝信息
                    }
                    else if (requestXML.WXEVENT.ToLower() == "location")             //获取地理位置
                    {
                    }
                    else if (requestXML.WXEVENT.ToLower() == "scan" || (requestXML.WXEVENT.ToLower() == "subscribe" && requestXML.EVENTKEY.ToLower().Contains("qrscene"))) //扫描二维码
                    {
                        string EVENTKEY = requestXML.EVENTKEY;
                        requestXML.EVENTKEY = requestXML.EVENTKEY.ToLower().Contains("qrscene") ? requestXML.EVENTKEY.Split('_')[1] : requestXML.EVENTKEY;
                        new MySmallShopService().SaveQRLog(new ORG_WX_QRLog {
                            CreateTime = DateTime.Now, FromUserName = requestXML.FROMUSERNAME, QRCodeID = int.Parse(requestXML.EVENTKEY), EVENTKEY = EVENTKEY
                        });
                        if (requestXML.WXEVENT.ToLower() == "subscribe")
                        {
                            resxml = Subscribe(requestXML, resxml);
                        }
                        //string jg = InsertQR(requestXML.FROMUSERNAME, requestXML.EVENTKEY);  //插入扫描记录
                        //if (jg == "扫描成功")
                        //{
                        //    WXGraphicDetail i = sbo.GetGraphicDetail(53);
                        //    if (i != null)
                        //    {

                        //        resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>1</ArticleCount><Articles>";
                        //        resxml += "<item><Title><![CDATA[" + i.Title + "]]></Title><Description><![CDATA[" + i.Describe + "]]></Description><PicUrl><![CDATA[" + WebUrl() + i.URL + "]]></PicUrl><Url><![CDATA[" + (i.IsURL.Value ? (i.URL.Contains("?id") ? (i.URL + "&FromUserName="******"&ToUserName="******"") : (i.URL + "?FromUserName="******"&ToUserName="******"")) : (WebUrl() + "/GraphicDisplay.aspx?id=" + i.ID)) + "]]></Url></item>";//URL是点击之后跳转去那里,这里跳转到百度
                        //        resxml += "</Articles><FuncFlag>0</FuncFlag></xml>";
                        //    }
                        //}
                        //else
                        //resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[" + jg + "]]></Content><FuncFlag>0</FuncFlag></xml>";
                    }

                    //关注
                    else if (requestXML.WXEVENT.ToLower() == "subscribe")
                    {
                        resxml = Subscribe(requestXML, resxml);
                    }
                }
                requestXML.RESXML = resxml;
                if (!resxml.Contains("</xml>"))
                {
                    resxml = "";
                    //resxml += "<MsgType><![CDATA[text]]></MsgType><Content></Content><FuncFlag>0</FuncFlag></xml>";
                }
                if (requestXML.MSGTYPE == "text")
                {
                    try
                    {
                        WXCUST_MSG_RECORD msg = new WXCUST_MSG_RECORD();
                        msg.CONTENT      = requestXML.CONTENT;
                        msg.CREATE_DATE  = DateTime.Now;
                        msg.FROMUSERNAME = requestXML.FROMUSERNAME;
                        msg.GraphicID    = 0;
                        msg.IS_RETURN    = false;
                        msg.IS_STAR      = false;
                        msg.MSGTYPE      = "text";
                        msg.ReturnID     = 0;
                        msg.State        = 0;
                        msg.TOUSERNAME   = requestXML.TOUSERNAME;
                        sbo.SaveCUST_MSG_RECORD(msg);
                    }
                    catch (Exception)
                    {
                    }
                }
                sbo.AddCUST_MSG_HIS(requestXML);
            }
            catch (Exception ex)
            {
                //WriteTxt("异常:" + ex.Message);
                //WriteTxt(sql);
                resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[" + ex.Message.ToString() + "]]></Content><FuncFlag>0</FuncFlag></xml>";
                Response.Write(resxml);
            }
            //if (!resxml.Contains("</xml>"))
            //{
            //    resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[]]></Content><FuncFlag>0</FuncFlag></xml>";
            //}
            WriteTxt("返回给粉丝的消息:" + resxml);

            Response.Write(resxml);
            Response.End();
        }