/// <summary>
        /// 刷新公众号token
        /// </summary>
        private void RefeshToken(string appID)
        {
            if (Access_TokenInfoDic.ContainsKey(appID))
            {
                DateTime     now         = DateTime.Now;
                MWeixinParam weixinParam = null;
                // 如果已经超时
                if (Access_TokenInfoDic[appID].OutTime <= now)
                {
                    weixinParam = new MWeixinParam(Access_TokenInfoDic[appID].AppID, Access_TokenInfoDic[appID].AppSecret);
                    AccessTokenRequest request = new AccessTokenRequest(weixinParam);
                    // 重新获取token
                    var response = Client.Execute(request);
                    if (response.IsError)
                    {
                        throw new Exception(response.ErrorMessage);
                    }
                    // 修改授权
                    Access_TokenInfoDic[appID].OutTime      = now.AddSeconds(response.Expires_In);
                    Access_TokenInfoDic[appID].Access_Token = response.Access_Token;

                    // 更新
                    BUpdateAccess_Token updateToken = new BUpdateAccess_Token(Access_TokenInfoDic[appID].KeyID, SecurityUtility.EncryptDES(Access_TokenInfoDic[appID].Access_Token), string.Empty, Access_TokenInfoDic[appID].OutTime);
                    updateToken.Execute();


                    // 更新ticket
                    this.RefeshTicket(response.Access_Token);
                }
            }
        }
        /// <summary>
        /// 根据微信ID获取微信授权token
        /// </summary>
        /// <param name="appid"></param>
        /// <returns></returns>
        public string GetTokenByWeixinID(string weixinID)
        {
            if (WeixinAppInfoDic.ContainsKey(weixinID))
            {
                MWeixinParam weixinParam = WeixinAppInfoDic[weixinID];

                if (Access_TokenInfoDic.ContainsKey(weixinParam.AppID))
                {
                    if (String.IsNullOrEmpty(Access_TokenInfoDic[weixinParam.AppID].Access_Token) || DateTime.Now >= Access_TokenInfoDic[weixinParam.AppID].OutTime)
                    {
                        RefeshToken(weixinParam.AppID);
                    }

                    return(Access_TokenInfoDic[weixinParam.AppID].Access_Token);
                }
                else
                {
                    return(string.Empty);
                }
            }
            else
            {
                return(string.Empty);
            }
        }
        /// <summary>
        /// 根据微信ID获取ticket
        /// </summary>
        /// <param name="weixinID"></param>
        /// <returns></returns>
        public string GetTicketByWeixinID(string weixinID)
        {
            Dictionary <string, object> bugobjd = new Dictionary <string, object>();
            string ticket = string.Empty;

            try
            {
                bugobjd.Add("根据微信ID获取ticket", "根据微信ID获取ticket");
                bugobjd.Add("WeixinAppInfoDic", WeixinAppInfoDic);
                if (WeixinAppInfoDic.ContainsKey(weixinID))
                {
                    MWeixinParam weixinParam = WeixinAppInfoDic[weixinID];

                    bugobjd.Add("weixinParam", weixinParam);

                    if (Access_TokenInfoDic.ContainsKey(weixinParam.AppID))
                    {
                        MAccess_Token access_Token = Access_TokenInfoDic[weixinParam.AppID];

                        if (String.IsNullOrEmpty(access_Token.Access_Token) || DateTime.Now >= access_Token.OutTime)
                        {
                            RefeshToken(weixinParam.AppID);
                            access_Token = Access_TokenInfoDic[weixinParam.AppID];
                        }

                        if (WeixinTicketDic.ContainsKey(access_Token.Access_Token))
                        {
                            if (String.IsNullOrEmpty(WeixinTicketDic[access_Token.Access_Token].Ticket) || DateTime.Now >= WeixinTicketDic[access_Token.Access_Token].OutTime)
                            {
                                RefeshTicket(Access_TokenInfoDic[weixinParam.AppID].Access_Token);
                            }
                        }
                        else
                        {
                            RefeshTicket(Access_TokenInfoDic[weixinParam.AppID].Access_Token);
                        }

                        bugobjd.Add(" Access_TokenInfo", Access_TokenInfoDic[weixinParam.AppID]);
                        bugobjd.Add(" WeixinTicket", WeixinTicketDic[Access_TokenInfoDic[weixinParam.AppID].Access_Token]);
                        ticket = WeixinTicketDic[Access_TokenInfoDic[weixinParam.AppID].Access_Token].Ticket;
                    }
                }
            }
            catch (Exception ex)
            {
                TxtLogHelper.WriteLog_Day(new TxtLogInfoObject()
                {
                    LogType    = EnumLogType.Error,
                    LogMessage = string.Format(" 根据微信ID获取ticket错误信息{0};堆栈信息{1}", ex.Message, ex.StackTrace),
                });
                throw;
            }
            finally
            {
                TxtLogHelper.WriteDebugLog(bugobjd);
            }

            return(ticket);
        }
        /// <summary>
        /// 获取默认公众号token
        /// </summary>
        /// <returns></returns>
        public string GetDefaultToken()
        {
            if (Access_TokenInfoDic.ContainsKey(AppSettingFactory.GetAppID()))
            {
                if (String.IsNullOrEmpty(Access_TokenInfoDic[AppSettingFactory.GetAppID()].Access_Token) || DateTime.Now >= Access_TokenInfoDic[AppSettingFactory.GetAppID()].OutTime)
                {
                    RefeshToken(AppSettingFactory.GetAppID());
                }

                return(Access_TokenInfoDic[AppSettingFactory.GetAppID()].Access_Token);
            }
            else
            {
                return(string.Empty);
            }
        }
        /// <summary>
        /// 获取公众号token
        /// </summary>
        /// <returns></returns>
        public string GetCurrentToken(string appID)
        {
            if (Access_TokenInfoDic.ContainsKey(appID))
            {
                if (String.IsNullOrEmpty(Access_TokenInfoDic[appID].Access_Token) || DateTime.Now >= Access_TokenInfoDic[appID].OutTime)
                {
                    RefeshToken(appID);
                }

                return(Access_TokenInfoDic[appID].Access_Token);
            }
            else
            {
                return(string.Empty);
            }
        }
        /// <summary>
        /// 获取默认微信信息
        /// </summary>
        /// <returns></returns>
        public MAccess_Token GetDefaultWeixinInfo()
        {
            if (Access_TokenInfoDic.ContainsKey(AppSettingFactory.GetAppID()))
            {
                if (String.IsNullOrEmpty(Access_TokenInfoDic[AppSettingFactory.GetAppID()].Access_Token) || DateTime.Now >= Access_TokenInfoDic[AppSettingFactory.GetAppID()].OutTime)
                {
                    RefeshToken(AppSettingFactory.GetAppID());
                }

                return(Access_TokenInfoDic[AppSettingFactory.GetAppID()]);
            }
            else
            {
                return(new MAccess_Token()
                {
                    AppID = AppSettingFactory.GetAppID(), AppSecret = AppSettingFactory.GetAppSecret(), WeixinID = AppSettingFactory.GetWeixinID()
                });
            }
        }
        /// <summary>
        /// 获取默认ticket
        /// </summary>
        /// <returns></returns>
        public string GetDefaultTicket()
        {
            string ticket = string.Empty;

            if (Access_TokenInfoDic.ContainsKey(AppSettingFactory.GetAppID()))
            {
                if (String.IsNullOrEmpty(Access_TokenInfoDic[AppSettingFactory.GetAppID()].Access_Token) || DateTime.Now >= Access_TokenInfoDic[AppSettingFactory.GetAppID()].OutTime)
                {
                    RefeshToken(AppSettingFactory.GetAppID());
                }

                if (WeixinTicketDic.ContainsKey(Access_TokenInfoDic[AppSettingFactory.GetAppID()].Access_Token))
                {
                    ticket = WeixinTicketDic[Access_TokenInfoDic[AppSettingFactory.GetAppID()].Access_Token].Ticket;
                }
            }
            else
            {
                ticket = string.Empty;
            }

            return(ticket);
        }