/// <summary> /// 续保调用第三方接口传数据 /// </summary> /// <param name="agent"></param> /// <param name="viewModel"></param> public void PostThirdPart(int agent, ViewModels.GetReInfoViewModel viewModel) { //请求第三方Url string strUrl = string.Empty; //取缓存值 var cacheKey = string.Format("camera_url_{0}", agent); strUrl = CacheProvider.Get <string>(cacheKey); if (string.IsNullOrEmpty(strUrl)) { bx_config config = _configRepository.Find(agent.ToString(), 4); strUrl = config != null ? config.config_value : ""; CacheProvider.Set(cacheKey, strUrl, 10800); } //判断url是否为空 if (string.IsNullOrEmpty(strUrl)) { return; } IBxAgent agentModel = _getAgentInfoService.GetAgentModelFactory(agent); string secretKey = agentModel == null ? "" : agentModel.SecretKey; //执行post请求方法 Task.Factory.StartNew(() => SendPost(agent, secretKey, strUrl, viewModel)); }
public bx_config Find(string configKey, int configType) { try { bx_config model = DataContextFactory.GetDataContext().bx_config.FirstOrDefault(i => i.config_key.Equals(configKey) && i.config_type == configType && i.is_delete == 0); return(model); } catch (Exception ex) { logError.Info("发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException); } return(null); }
/// <summary> /// /// </summary> /// <param name="cacheKey">缓存key</param> /// <param name="configType">bx_config对应类型</param> /// <returns></returns> public string GetConfigValue(string configKey, int configType, string cacheKey) { string strValue = string.Empty; //取缓存值 strValue = CacheProvider.Get <string>(cacheKey); if (string.IsNullOrEmpty(strValue)) { bx_config config = _configRepository.Find(configKey, configType); if (config != null) { strValue = config.config_value ?? ""; CacheProvider.Set(cacheKey, strValue, 21600); } } return(strValue); }