AreaBLL.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using CP.Cache;
  7. using CP.Model;
  8. namespace CP.Business
  9. {
  10. public class AreaBLL
  11. {
  12. /// <summary>
  13. /// 缓存
  14. /// </summary>
  15. static WMCache cache = WMCache.GetCacheService();
  16. /// <summary>
  17. /// 获取
  18. /// </summary>
  19. /// <returns></returns>
  20. public List<Area> GetAreaList()
  21. {
  22. string key = CacheKeys.ares;
  23. List<Area> list = cache.GetObject<List<Area>>(key);
  24. if (list == null)
  25. {
  26. var dc = new DataConnect();
  27. list = dc.db.Fetch<Area>("order by seq asc");
  28. cache.AddObject(key, list, (int)CacheTime.System);
  29. }
  30. return list;
  31. }
  32. /// <summary>
  33. /// 获取
  34. /// </summary>
  35. /// <returns></returns>
  36. public static List<Cz> GetCzByareaid(int areaid)
  37. {
  38. string key = string.Format(CacheKeys.ares_id, areaid);
  39. List<Cz> list = cache.GetObject<List<Cz>>(key);
  40. if (list == null)
  41. {
  42. list = new List<Cz>();
  43. var dc = new DataConnect();
  44. string sql = string.Format(" where areaid={0} order by seq asc", areaid);
  45. var query = dc.db.Fetch<AreaCz>(sql);
  46. for (int i = 0; i < query.Count; i++)
  47. {
  48. var listcz = CzBll.GetCz(query[i].cid);
  49. if (listcz != null)
  50. {
  51. if (listcz.cid != 0)
  52. list.Add(listcz);
  53. }
  54. }
  55. cache.AddObject(key, list, (int)CacheTime.System);
  56. }
  57. return list;
  58. }
  59. /// <summary>
  60. /// 获取
  61. /// </summary>
  62. /// <returns></returns>
  63. public static Area GetAreaByname(string ename)
  64. {
  65. string key = string.Format(CacheKeys.ares_name, ename);
  66. Area list = cache.GetObject<Area>(key);
  67. if (list == null)
  68. {
  69. var dc = new DataConnect();
  70. string sql = string.Format(" where ename='{0}' ", ename);
  71. list = dc.db.Fetch<Area>(sql).FirstOrDefault();
  72. cache.AddObject(key, list, (int)CacheTime.System);
  73. }
  74. return list;
  75. }
  76. }
  77. }