示例#1
0
        /// <summary>
        /// 根据父ID获取此ID下一级栏目,只显示一级子分类,包含删除的和未启用的
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        public static IList <CategoryInfo> ListByParentId(int parentId)
        {
            var _list = ArticleCategoryManage.ListByParentId(parentId);

            foreach (var item in _list)
            {
                LoadExtionsion(item);
            }
            return(_list);
        }
示例#2
0
        /// <summary>
        /// 根据父ID获取此ID下一级栏目,不能获取此栏目下的所有节点
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="useCache">是否使用缓存</param>
        /// <param name="showEnabled">是否显示启用项</param>
        /// <param name="showDeleted">是否显示删掉项</param>
        /// <returns></returns>
        public static IList <CategoryInfo> ListByParentId(int parentId, bool useCache, bool showEnabled, bool showDeleted)
        {
            if (!useCache)
            {
                IEnumerable <CategoryInfo> _list = ArticleCategoryManage.ListByParentId(parentId);
                if (showEnabled)
                {
                    //显示启用的
                    _list = _list.Where(p => p.IsEnabled == true);
                }
                if (!showDeleted)
                {
                    //显示已删除掉的
                    _list = _list.Where(p => p.IsDeleted == false);
                }
                return(_list.ToList());
            }
            ;
            //需要加缓存
            string CACHEKEY = string.Format("LIST_BY_PARENT_ID_{0}", parentId);

            var list = (IEnumerable <CategoryInfo>)webCache[CACHEKEY];

            if (list == null)
            {
                list = ArticleCategoryManage.ListByParentId(parentId);
                if (showEnabled)
                {
                    //显示启用的
                    list = list.Where(p => p.IsEnabled == true);
                }
                if (!showDeleted)
                {
                    //显示已删除掉的
                    list = list.Where(p => p.IsDeleted == false);
                }
                webCache.Insert(CACHEKEY, list, null, DateTime.Now.AddMinutes(CACHETIMEOUT), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
            }
            return(list.ToList());
        }