/// <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>
        /// 获取默认微信信息
        /// </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);
        }
Esempio n. 4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public ApiRequestBase()
 {
     this.WeixinParam = new MWeixinParam(AppSettingFactory.GetAppID(), AppSettingFactory.GetAppSecret());
 }