/// <summary> /// 获取所有实体 /// </summary> /// <returns></returns> public static List <T> GetAllEntityCache() { List <string> names = CachesHelper.GetCache(cacheListName) as List <string>; List <T> list = new List <T>(); foreach (string name in names) { var value = CachesHelper.GetCache(name); T entity = (T)value; list.Add(entity); } return(list); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// 获取实体 /// </summary> /// <param name="id"></param> /// <returns></returns> public static T GetEntityCache(object id) { string thisCacheName = cacheName + "_" + id.ToString(); return((T)CachesHelper.GetCache(thisCacheName)); }