Ejemplo n.º 1
0
        public List <bx_agent_config> FindConfigCityList(int agent)
        {
            var key      = string.Format("ExternalApi_{0}_ConfigCity_Find", agent);
            var cachelst = CacheProvider.Get <List <bx_agent_config> >(key);

            if (cachelst == null)
            {
                var lst = _agentConfigRepository.FindNewCity(agent);
                CacheProvider.Set(key, lst, 10800);
                return(lst);
            }
            return(cachelst);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取渠道的source集合
        /// </summary>
        /// <param name="url"></param>
        /// <param name="agentId">顶级代理Id</param>
        /// <returns></returns>
        public List <AgentCity> GetSourceList(string url, int agentId)
        {
            var viewModel = new AppAgentSourceViewModel();
            //获取城市列表
            var agentCityKey = string.Format("ExternalApi_{0}_ConfigCity_Find", agentId);
            var listTempCity = CacheProvider.Get <List <bx_agent_config> >(agentCityKey);
            var listCity     = new List <int>();

            if (listTempCity == null)
            {
                listTempCity = _agentConfig.FindNewCity(agentId);
                CacheProvider.Set(agentCityKey, listTempCity, 10800);
            }
            if (listTempCity != null)
            {
                listCity = listTempCity.Select(i => i.city_id.Value).Distinct().ToList();
            }

            //获取所有source列表
            var agentSourceKey = string.Format("agent_source_key_{0}", agentId);
            var listSource     = CacheProvider.Get <List <bx_agent_config> >(agentSourceKey);

            if (listSource == null)
            {
                listSource = _agentConfig.Find(agentId).ToList();
                CacheProvider.Set(agentSourceKey, listSource, 10800);
            }
            var citylist       = new List <AgentCity>();
            var agentCity      = new AgentCity();
            var sourcelist     = new List <Source>();
            var agentSource    = new Source();
            var tempSourceList = new List <bx_agent_config>();

            //根据城市获取source列表
            if (!listCity.Any())
            {
                return(citylist);
            }
            foreach (var c in listCity)
            {
                tempSourceList = new List <bx_agent_config>();
                tempSourceList = listSource.Where(i => i.city_id == c && i.source.HasValue).OrderBy(o => o.source.Value).Distinct().ToList();
                sourcelist     = new List <Source>();
                if (tempSourceList.Any())
                {
                    foreach (var s in tempSourceList)
                    {
                        agentSource          = new Source();
                        agentSource.Id       = s.source.Value;
                        agentSource.Name     = s.source.Value.ToEnumDescriptionString(typeof(EnumSource));
                        agentSource.NewId    = SourceGroupAlgorithm.GetNewSource(s.source.Value);
                        agentSource.ImageUrl = string.Format("{0}/Images/company/{1}.png", url, s.source.Value);
                        sourcelist.Add(agentSource);
                    }
                }
                agentCity             = new AgentCity();
                agentCity.AgentSource = sourcelist;
                agentCity.CityId      = c;
                agentCity.CityName    = _iCityRepository.FindCity(c).city_name;
                citylist.Add(agentCity);
            }
            return(citylist);
        }