Brak opisu

T_Sys_Department.cs 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System;
  2. using System.Data;
  3. using System.Collections.Generic;
  4. using CallCenterApi.Model;
  5. using CallCenter.Utility;
  6. namespace CallCenterApi.BLL
  7. {
  8. /// <summary>
  9. /// T_Sys_Department
  10. /// </summary>
  11. public partial class T_Sys_Department
  12. {
  13. private readonly CallCenterApi.DAL.T_Sys_Department dal = new CallCenterApi.DAL.T_Sys_Department();
  14. public T_Sys_Department()
  15. { }
  16. #region BasicMethod
  17. /// <summary>
  18. /// 是否存在该记录
  19. /// </summary>
  20. public bool Exists(int F_DeptId)
  21. {
  22. return dal.Exists(F_DeptId);
  23. }
  24. /// <summary>
  25. /// 增加一条数据
  26. /// </summary>
  27. public int Add(CallCenterApi.Model.T_Sys_Department model)
  28. {
  29. OutRedis();
  30. return dal.Add(model);
  31. }
  32. /// <summary>
  33. /// 更新一条数据
  34. /// </summary>
  35. public bool Update(CallCenterApi.Model.T_Sys_Department model)
  36. {
  37. OutRedis();
  38. return dal.Update(model);
  39. }
  40. /// <summary>
  41. /// 删除一条数据
  42. /// </summary>
  43. public bool Delete(int F_DeptId)
  44. {
  45. OutRedis();
  46. return dal.Delete(F_DeptId);
  47. }
  48. /// <summary>
  49. /// 删除一条数据
  50. /// </summary>
  51. public bool DeleteList(string F_DeptIdlist)
  52. {
  53. OutRedis();
  54. return dal.DeleteList(F_DeptIdlist);
  55. }
  56. /// <summary>
  57. /// 删除一条数据
  58. /// </summary>
  59. public bool UpdateSMSList(string F_DeptIdlist,int state)
  60. {
  61. OutRedis();
  62. return dal.UpdateSMSList(F_DeptIdlist, state);
  63. }
  64. /// <summary>
  65. /// 删除一条数据
  66. /// </summary>
  67. public bool UpdateSMS( int state)
  68. {
  69. OutRedis();
  70. return dal.UpdateSMS( state);
  71. }
  72. /// <summary>
  73. /// 得到一个对象实体
  74. /// </summary>
  75. public CallCenterApi.Model.T_Sys_Department GetModel(int F_DeptId)
  76. {
  77. var dt = GetRedis();
  78. if (dt != null)
  79. {
  80. var dr = dt.Select("F_DeptId=" + F_DeptId);
  81. if (dr != null && dr.Length > 0)
  82. {
  83. return dal.DataRowToModel(dr[0]);
  84. }
  85. else
  86. {
  87. return null;
  88. }
  89. }
  90. else
  91. {
  92. return dal.GetModel(F_DeptId);
  93. }
  94. }
  95. /// <summary>
  96. /// 获得数据列表
  97. /// </summary>
  98. public DataSet GetList(string strWhere, string filedOrder = "")
  99. {
  100. var dt = GetRedis();
  101. if (dt != null)
  102. {
  103. var ds = new DataSet();
  104. var drs = dt.Select(strWhere, filedOrder);
  105. if (drs.Length > 0)
  106. {
  107. ds.Tables.Add(drs.CopyToDataTable());
  108. }
  109. else
  110. {
  111. ds.Tables.Add(new DataTable());
  112. }
  113. return ds;
  114. }
  115. else
  116. {
  117. return dal.GetList(strWhere);
  118. }
  119. }
  120. /// <summary>
  121. /// 获得数据列表
  122. /// </summary>
  123. public DataSet GetListNoCache(string strWhere)
  124. {
  125. return dal.GetList(strWhere);
  126. }
  127. /// <summary>
  128. /// 获得前几行数据
  129. /// </summary>
  130. public DataSet GetList(int Top, string strWhere, string filedOrder)
  131. {
  132. return dal.GetList(Top, strWhere, filedOrder);
  133. }
  134. /// <summary>
  135. /// 获得数据列表
  136. /// </summary>
  137. public List<CallCenterApi.Model.T_Sys_Department> GetModelList(string strWhere, string filedOrder = "")
  138. {
  139. var dt = GetRedis();
  140. if (dt != null)
  141. {
  142. var dtnew = new DataTable();
  143. var drs = dt.Select(strWhere, filedOrder);
  144. if (drs.Length > 0)
  145. {
  146. dtnew = drs.CopyToDataTable();
  147. }
  148. return DataTableToList(dtnew);
  149. }
  150. else
  151. {
  152. DataSet ds = dal.GetList(strWhere, filedOrder);
  153. return DataTableToList(ds.Tables[0]);
  154. }
  155. }
  156. /// <summary>
  157. /// 获得数据列表
  158. /// </summary>
  159. public List<CallCenterApi.Model.T_Sys_Department> GetModelListNoCache(string strWhere, string filedOrder)
  160. {
  161. DataSet ds = dal.GetList(strWhere, filedOrder);
  162. return DataTableToList(ds.Tables[0]);
  163. }
  164. /// <summary>
  165. /// 获得数据列表
  166. /// </summary>
  167. public List<CallCenterApi.Model.T_Sys_Department> DataTableToList(DataTable dt)
  168. {
  169. List<CallCenterApi.Model.T_Sys_Department> modelList = new List<CallCenterApi.Model.T_Sys_Department>();
  170. int rowsCount = dt.Rows.Count;
  171. if (rowsCount > 0)
  172. {
  173. CallCenterApi.Model.T_Sys_Department model;
  174. for (int n = 0; n < rowsCount; n++)
  175. {
  176. model = dal.DataRowToModel(dt.Rows[n]);
  177. if (model != null)
  178. {
  179. modelList.Add(model);
  180. }
  181. }
  182. }
  183. return modelList;
  184. }
  185. /// <summary>
  186. /// 获得数据列表
  187. /// </summary>
  188. public DataSet GetAllList()
  189. {
  190. return GetList("");
  191. }
  192. /// <summary>
  193. /// 分页获取数据列表
  194. /// </summary>
  195. public int GetRecordCount(string strWhere)
  196. {
  197. return dal.GetRecordCount(strWhere);
  198. }
  199. /// <summary>
  200. /// 分页获取数据列表
  201. /// </summary>
  202. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  203. {
  204. return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
  205. }
  206. /// <summary>
  207. /// 分页获取数据列表
  208. /// </summary>
  209. //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
  210. //{
  211. //return dal.GetList(PageSize,PageIndex,strWhere);
  212. //}
  213. #endregion BasicMethod
  214. #region ExtensionMethod
  215. #endregion ExtensionMethod
  216. private DataTable GetRedis()
  217. {
  218. var strList = RedisHelper.StringGet("T_Sys_Department");
  219. if (strList != null)
  220. {
  221. return strList.ToString().ToObject<DataTable>();
  222. }
  223. else
  224. {
  225. return InRedis();
  226. }
  227. }
  228. private DataTable InRedis()
  229. {
  230. var dt = dal.GetList("").Tables[0];
  231. RedisHelper.StringSet("T_Sys_Department", dt.ToJson(), new TimeSpan(24, 0, 0));
  232. return dt;
  233. }
  234. private void OutRedis()
  235. {
  236. RedisHelper.KeyDelete("T_Sys_Department");
  237. }
  238. }
  239. }