using CP.Cache; using CP.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CP.Business { /// /// 菜单相关的逻辑操作类 /// public class ChartBll { /// /// 缓存 /// static WMCache cache = WMCache.GetCacheService(); #region menus /// /// cache中的所有menus list /// /// public static List GetList() { string key = string.Format(CacheKeys.SYSTEM_MENUS); List list = cache.GetObject>(key); if (list == null) { var dc = new DataConnect(); list = dc.db.Fetch("order by seq asc"); cache.AddObject(key, list, (int)CacheTime.System); } return list; } public static List GetList(int cid, SiteTypeEnum siteType = SiteTypeEnum.PC) { string key = string.Format(CacheKeys.SYSTEM_MENUS); List list = cache.GetObject>(key); if (list == null) { var dc = new DataConnect(); list = dc.db.Fetch("order by seq asc"); cache.AddObject(key, list, (int)CacheTime.System); } return list.Where(m => m.cid == cid && m.SiteType == siteType).OrderBy(m => m.seq).ToList() ?? new List(); } public static Chart GetChart(int id) { string key = string.Format(CacheKeys.SYSTEM_MENUS); List list = cache.GetObject>(key); if (list == null) { var dc = new DataConnect(); list = dc.db.Fetch("order by seq asc"); cache.AddObject(key, list, (int)CacheTime.System); } return list.FirstOrDefault(m => m.chartid == id) ?? new Chart(); } #endregion } }