Exemple #1
0
        /// <summary>
        /// 获取县区
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="province">省份</param>
        /// <param name="city">城市</param>
        /// <returns>县区数组</returns>
        public string[] GetDistrict(BaseUserInfo userInfo, string province, string city)
        {
            string[] result = null;

#if Redis
            result = BaseOrganizeManager.GetDistrictByCache(province, city);
#else
            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());
            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                System.Web.Caching.Cache cache = HttpRuntime.Cache;
                string cacheObject             = "AreaOrganizeDistrict" + city;

                if (cache != null && cache[cacheObject] == null)
                {
                    // BaseAreaManager areaManager = new BaseAreaManager(dbHelper, result);
                    // result = areaManager.GetDistrictList(cityId);
                    var manager = new BaseOrganizeManager(dbHelper, userInfo);
                    result      = manager.GetDistrict(province, city);
                    cache.Add(cacheObject, result, null, DateTime.Now.AddHours(8), TimeSpan.Zero, CacheItemPriority.Normal, null);
                }

                result = cache[cacheObject] as string[];
            });
#endif

            return(result);
        }