ApplyMachineDbconn.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // using System;
  2. // using System.Collections.Generic;
  3. // using Library;
  4. // using System.Linq;
  5. // using MySystem.MainModels;
  6. // namespace MySystem
  7. // {
  8. // public class ApplyMachineDbconn
  9. // {
  10. // public readonly static ApplyMachineDbconn Instance = new ApplyMachineDbconn();
  11. // #region 获取仓库单个字段
  12. // public StoreHouse Get(int Id)
  13. // {
  14. // string key = "StoreHouse:" + Id;
  15. // if (RedisDbconn.Instance.Exists(key))
  16. // {
  17. // StoreHouse obj = RedisDbconn.Instance.Get<StoreHouse>(key);
  18. // if (obj != null)
  19. // {
  20. // return obj;
  21. // }
  22. // }
  23. // WebCMSEntities db = new WebCMSEntities();
  24. // StoreHouse storeHouse = db.StoreHouse.FirstOrDefault(m => m.Id == Id);
  25. // if (storeHouse != null)
  26. // {
  27. // RedisDbconn.Instance.Set(key, storeHouse);
  28. // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(60, 180));
  29. // }
  30. // db.Dispose();
  31. // return storeHouse;
  32. // }
  33. // #endregion
  34. // #region 获取仓库列表
  35. // public List<int> GetList(int UserId, int pageNum = 1, int pageSize = 10)
  36. // {
  37. // string key = "StoreHouseList:" + UserId;
  38. // List<int> list = new List<int>();
  39. // if (RedisDbconn.Instance.Exists(key))
  40. // {
  41. // list = RedisDbconn.Instance.GetList<int>(key, pageNum, pageSize);
  42. // if (list.Count > 0)
  43. // {
  44. // return list;
  45. // }
  46. // }
  47. // WebCMSEntities db = new WebCMSEntities();
  48. // List<int> newlist = new List<int>();
  49. // var mysqllist = db.StoreHouse.Select(m => new { m.Id, m.UserId, m.BrandId }).Where(m => m.UserId == UserId && m.BrandId != null).ToList();
  50. // if (mysqllist.Count > 0)
  51. // {
  52. // foreach (var sub in mysqllist)
  53. // {
  54. // newlist.Add(sub.Id);
  55. // }
  56. // RedisDbconn.Instance.Clear(key);
  57. // foreach (var sub in newlist)
  58. // {
  59. // RedisDbconn.Instance.AddRightList(key, sub);
  60. // }
  61. // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(60, 180));
  62. // }
  63. // db.Dispose();
  64. // return newlist;
  65. // }
  66. // #endregion
  67. // #region 获取机具申请记录单个字段
  68. // public StoreMachineApply GetApply(int Id)
  69. // {
  70. // string key = "StoreApply:" + Id;
  71. // if (RedisDbconn.Instance.Exists(key))
  72. // {
  73. // StoreMachineApply obj = RedisDbconn.Instance.Get<StoreMachineApply>(key);
  74. // if (obj != null)
  75. // {
  76. // return obj;
  77. // }
  78. // }
  79. // WebCMSEntities db = new WebCMSEntities();
  80. // StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id);
  81. // if (storeMachineApply != null)
  82. // {
  83. // RedisDbconn.Instance.Set(key, storeMachineApply);
  84. // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(60, 180));
  85. // }
  86. // db.Dispose();
  87. // return storeMachineApply;
  88. // }
  89. // #endregion
  90. // #region 获取机具申请记录列表
  91. // public List<int> GetApplyList(int UserId, int StoreId, int pageNum = 1, int pageSize = 10)
  92. // {
  93. // string key = "StoreApplyList:" + UserId + StoreId;
  94. // List<int> list = new List<int>();
  95. // if (RedisDbconn.Instance.Exists(key))
  96. // {
  97. // list = RedisDbconn.Instance.GetList<int>(key, pageNum, pageSize);
  98. // if (list.Count > 0)
  99. // {
  100. // return list;
  101. // }
  102. // }
  103. // WebCMSEntities db = new WebCMSEntities();
  104. // List<int> newlist = new List<int>();
  105. // var mysqllist = db.StoreMachineApply.Select(m => new { m.Id, m.UserId, m.StoreId }).Where(m => m.UserId == UserId && m.StoreId == StoreId).ToList();
  106. // if (mysqllist.Count > 0)
  107. // {
  108. // foreach (var sub in mysqllist)
  109. // {
  110. // newlist.Add(sub.Id);
  111. // }
  112. // RedisDbconn.Instance.Clear(key);
  113. // foreach (var sub in newlist)
  114. // {
  115. // RedisDbconn.Instance.AddRightList(key, sub);
  116. // }
  117. // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(60, 180));
  118. // }
  119. // db.Dispose();
  120. // return newlist;
  121. // }
  122. // #endregion
  123. // #region 获取机具申请记录详情
  124. // public List<int> GetApplyDetailList(int UserId, int StoreId, int StoreApplyId)
  125. // {
  126. // string key = "StoreApplyList:" + UserId + StoreId + StoreApplyId;
  127. // List<int> list = new List<int>();
  128. // if (RedisDbconn.Instance.Exists(key))
  129. // {
  130. // list = RedisDbconn.Instance.GetList<int>(key);
  131. // if (list.Count > 0)
  132. // {
  133. // return list;
  134. // }
  135. // }
  136. // WebCMSEntities db = new WebCMSEntities();
  137. // List<int> newlist = new List<int>();
  138. // var mysqllist = db.StoreMachineApply.Select(m => new { m.Id, m.UserId, m.StoreId }).Where(m => m.UserId == UserId && m.StoreId == StoreId && m.Id == StoreApplyId).ToList();
  139. // if (mysqllist.Count > 0)
  140. // {
  141. // foreach (var sub in mysqllist)
  142. // {
  143. // newlist.Add(sub.Id);
  144. // }
  145. // RedisDbconn.Instance.Clear(key);
  146. // foreach (var sub in newlist)
  147. // {
  148. // RedisDbconn.Instance.AddRightList(key, sub);
  149. // }
  150. // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(60, 180));
  151. // }
  152. // db.Dispose();
  153. // return newlist;
  154. // }
  155. // #endregion
  156. // }
  157. // }