ChartBll.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using CP.Cache;
  2. using CP.Model;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace CP.Business
  9. {
  10. /// <summary>
  11. /// 菜单相关的逻辑操作类
  12. /// </summary>
  13. public class ChartBll
  14. {
  15. /// <summary>
  16. /// 缓存
  17. /// </summary>
  18. static WMCache cache = WMCache.GetCacheService();
  19. #region menus
  20. /// <summary>
  21. /// cache中的所有menus list
  22. /// </summary>
  23. /// <returns></returns>
  24. public static List<Chart> GetList()
  25. {
  26. string key = string.Format(CacheKeys.SYSTEM_MENUS);
  27. List<Chart> list = cache.GetObject<List<Chart>>(key);
  28. if (list == null)
  29. {
  30. var dc = new DataConnect();
  31. list = dc.db.Fetch<Chart>("order by seq asc");
  32. cache.AddObject(key, list, (int)CacheTime.System);
  33. }
  34. return list;
  35. }
  36. public static List<Chart> GetList(int cid, SiteTypeEnum siteType = SiteTypeEnum.PC)
  37. {
  38. string key = string.Format(CacheKeys.SYSTEM_MENUS);
  39. List<Chart> list = cache.GetObject<List<Chart>>(key);
  40. if (list == null)
  41. {
  42. var dc = new DataConnect();
  43. list = dc.db.Fetch<Chart>("order by seq asc");
  44. cache.AddObject(key, list, (int)CacheTime.System);
  45. }
  46. return list.Where(m => m.cid == cid && m.SiteType == siteType).OrderBy(m => m.seq).ToList() ?? new List<Chart>();
  47. }
  48. public static Chart GetChart(int id)
  49. {
  50. string key = string.Format(CacheKeys.SYSTEM_MENUS);
  51. List<Chart> list = cache.GetObject<List<Chart>>(key);
  52. if (list == null)
  53. {
  54. var dc = new DataConnect();
  55. list = dc.db.Fetch<Chart>("order by seq asc");
  56. cache.AddObject(key, list, (int)CacheTime.System);
  57. }
  58. return list.FirstOrDefault(m => m.chartid == id) ?? new Chart();
  59. }
  60. #endregion
  61. }
  62. }