Example #1
0
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="cacheName">缓存名称</param>
        /// <param name="entity">缓存值</param>
        /// <returns></returns>
        public static void AddEntityCache(object id, T entity)
        {
            string thisCacheName = cacheName + "_" + id.ToString();

            CachesHelper.AddCache(thisCacheName, entity);

            AddCacheNames(thisCacheName);
        }
Example #2
0
        /// <summary>
        /// 所有数据字典信息
        /// </summary>
        /// <returns></returns>
        public static List <TB_System_Dictionary> GetAllDictionaries()
        {
            List <TB_System_Dictionary> list = new List <TB_System_Dictionary>();

            if (CachesHelper.GetCache(CacheNames.AllDictionaries.ToStr()) != null)
            {
                list = (List <TB_System_Dictionary>)CachesHelper.GetCache(CacheNames.AllDictionaries.ToStr());
            }
            else
            {
                list = SystemService.DictionaryService.Search().OrderBy(r => r.OrderBy).ToList();
                CachesHelper.AddCache(CacheNames.AllDictionaries.ToStr(), list, null);
            }
            return(list);
        }
Example #3
0
        /// <summary>
        /// 获取所有权限资源
        /// </summary>
        /// <returns></returns>
        public static List <TB_Admin_Resources> GetPermission()
        {
            List <TB_Admin_Resources> list = new List <TB_Admin_Resources>();

            if (CachesHelper.GetCache(CacheNames.AllResources.ToStr()) != null)
            {
                list = (List <TB_Admin_Resources>)CachesHelper.GetCache(CacheNames.AllResources.ToStr());
            }
            else
            {
                list = AdminService.ResourcesService.Search().OrderBy(r => r.OrderBy).ToList();
                CachesHelper.AddCache(CacheNames.AllResources.ToStr(), list, null);
            }
            return(list);
        }
Example #4
0
        /// <summary>
        /// 获取商品类别
        /// </summary>
        /// <param name="level"></param>
        /// <returns></returns>
        public static List <TB_Product_Categorys> GetProductCategory()
        {
            List <TB_Product_Categorys> list = new List <TB_Product_Categorys>();

            if (CachesHelper.GetCache(CacheNames.ProductCategorys.ToStr()) != null)
            {
                list = (List <TB_Product_Categorys>)CachesHelper.GetCache(CacheNames.ProductCategorys.ToStr());
            }
            else
            {
                List <Expression> express = new List <Expression>();
                express.Add(new Expression("IsDelete", "=", "0"));
                express.Add(new Expression("IsHidden", "=", "0"));
                list = ProductService.CategoryService.Search(express, "OrderBy asc");
                CachesHelper.AddCache(CacheNames.ProductCategorys.ToStr(), list, null);
            }
            return(list);
        }
Example #5
0
        /// <summary>
        /// 获取首页商品推荐
        /// </summary>
        /// <returns></returns>
        public static List <List <TB_Product_Products> > GetIndexVouchProducts()
        {
            List <List <TB_Product_Products> > list = new List <List <TB_Product_Products> >();

            if (CachesHelper.GetCache(CacheNames.IndexVouch.ToStr()) != null)
            {
                list = (List <List <TB_Product_Products> >)CachesHelper.GetCache(CacheNames.IndexVouch.ToStr());
            }
            else
            {
                List <Expression> express = new List <Expression>();
                express.Add(new Expression("Mark", "=", "2"));
                express.Add(new Expression("IsDelete", "=", "0"));
                int recordCount = 0;
                list.Add(ProductService.ProductsService.Search(6, 1, express, ref recordCount));
                list.Add(ProductService.ProductsService.Search(6, 2, express, ref recordCount));
                list.Add(ProductService.ProductsService.Search(6, 3, express, ref recordCount));
                list.Add(ProductService.ProductsService.Search(6, 4, express, ref recordCount));
                CachesHelper.AddCache(CacheNames.IndexVouch.ToStr(), list, null);
            }
            return(list);
        }
Example #6
0
        /// <summary>
        /// 添加缓存名称至缓存名称列表
        /// </summary>
        /// <param name="thisCacheName"></param>
        /// <param name="isAdd">是否为添加缓存值,true为添加,false为移除</param>
        private static void AddCacheNames(string thisCacheName, bool isAdd = true)
        {
            List <string> list = CachesHelper.GetCache(cacheListName) as List <string>;

            if (list == null)
            {
                list = new List <string>();
            }
            if (list.Contains(thisCacheName))
            {
                if (isAdd == false)
                {
                    list.Remove(thisCacheName);
                }
            }
            else
            {
                if (isAdd)
                {
                    list.Add(thisCacheName);
                }
            }
            CachesHelper.AddCache(cacheListName, list);
        }