/// <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> /// 获取默认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); }