public List <AgentCacheChannelModel> GetAgentCacheChannelList(List <bx_agent_config> configs) { var list = new List <AgentCacheChannelModel>(); AgentCacheChannelModel model; //取哈希值的单条key,是配置表里的url作为key来取值的 string redisUrlKey = string.Empty; foreach (var item in configs) { //获取渠道配置url redisUrlKey = item.isurl == 1 ? item.bx_url : item.macurl; //获取单个渠道状态的模型 model = new AgentCacheChannelModel(); if (!string.IsNullOrEmpty(redisUrlKey)) { model = _hashOperator.Get <AgentCacheChannelModel>(_hashKey, redisUrlKey); if (model != null) { model.ChannelId = item.id; model.ChannelName = item.config_name; model.IsPaicApi = item.is_paic_api; list.Add(model); } } } return(list); }
/// <summary> /// 获取渠道配置url作为缓存key来查询。判断ukey表的isurl==1?bx_url:macurl /// </summary> /// <param name="url"></param> /// <returns></returns> public AgentCacheChannelModel GetAgentCacheChannel(string url) { AgentCacheChannelModel model = new AgentCacheChannelModel();; //取哈希值的单条key,是配置表里的url作为key来取值的 if (!string.IsNullOrEmpty(url)) { model = _hashOperator.Get <AgentCacheChannelModel>(_hashKey, url); return(model); } return(null); }
/// <summary> /// 获取渠道及状态 /// </summary> /// <param name="request"></param> /// <param name="pairs"></param> /// <returns></returns> public GetSingelChannelStatusResponse GetChannelStatusByUkeyId(GetChannelStatusByUkeyIdRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { GetSingelChannelStatusResponse response = new GetSingelChannelStatusResponse(); try { //参数校验 BaseResponse baseResponse = _validateService.Validate(request, pairs); if (baseResponse.Status == HttpStatusCode.Forbidden) { response.Status = HttpStatusCode.Forbidden; return(response); } string url = request.Url;//mac地址和url前端判断 bx_agent_ukey agentukey = new bx_agent_ukey(); if (request.IsId == 1) { agentukey = _agentUKeyRepository.GetModel(request.UkeyId); if (agentukey == null || agentukey.id == 0) { response.Status = HttpStatusCode.Forbidden; return(response); } if (agentukey != null && agentukey.isurl.HasValue) { url = agentukey.isurl == 1 ? agentukey.url : agentukey.macurl; } } //取缓存渠道模型 AgentCacheChannelModel channelmodel = new AgentCacheChannelModel(); channelmodel = _channelModelMapRedisService.GetAgentCacheChannel(url); //判断是否有值 if (channelmodel != null)//&& channelmodel.ChannelId!=0) { //如果修改成功,则保存用户名 response.Status = HttpStatusCode.OK; response.CacheChannel = channelmodel; } else { //修改失败 response.ErrCode = 0; response.ErrMsg = "获取信息失败"; } } catch (Exception ex) { response.Status = HttpStatusCode.ExpectationFailed; logError.Info("获取渠道及状态请求发生异常:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException + ",返回对象信息:" + request.ToJson()); } return(response); }
public static ChannelStatusBaseModel ConverToChannelViewModel(this AgentCacheChannelModel model, int agent) { return(new ChannelStatusBaseModel() { ChannelId = model.ChannelId, ChannelName = model.ChannelName, Agent = agent, ChannelStatus = model.IsUse, CityCode = model.City, ChannelStatusMessage = model.IsUse.ToEnumDescriptionString(typeof(EnumChannelStatus)), Source = SourceGroupAlgorithm.GetNewSource(model.Source), SourceName = model.Source.ToEnumDescriptionString(typeof(EnumSource)) }); }