Açıklama Yok

T_Sys_SystemConfig.cs 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data;
  6. using CallCenter.Utility;
  7. namespace CallCenterApi.BLL
  8. {
  9. /// <summary>
  10. /// T_Sys_SystemConfig
  11. /// </summary>
  12. public partial class T_Sys_SystemConfig
  13. {
  14. private readonly DAL.T_Sys_SystemConfig dal = new DAL.T_Sys_SystemConfig();
  15. public T_Sys_SystemConfig()
  16. { }
  17. #region BasicMethod
  18. /// <summary>
  19. /// 是否存在该记录
  20. /// </summary>
  21. public bool Exists(int F_ParamId)
  22. {
  23. return dal.Exists(F_ParamId);
  24. }
  25. /// <summary>
  26. /// 增加一条数据
  27. /// </summary>
  28. public int Add(Model.T_Sys_SystemConfig model)
  29. {
  30. OutRedis();
  31. return dal.Add(model);
  32. }
  33. /// <summary>
  34. /// 更新一条数据
  35. /// </summary>
  36. public bool Update(Model.T_Sys_SystemConfig model)
  37. {
  38. OutRedis();
  39. return dal.Update(model);
  40. }
  41. /// <summary>
  42. /// 删除一条数据
  43. /// </summary>
  44. public bool Delete(int F_ParamId)
  45. {
  46. OutRedis();
  47. return dal.Delete(F_ParamId);
  48. }
  49. /// <summary>
  50. /// 删除一条数据
  51. /// </summary>
  52. public bool DeleteList(string F_ParamIdlist)
  53. {
  54. OutRedis();
  55. return dal.DeleteList(F_ParamIdlist);
  56. }
  57. /// <summary>
  58. /// 得到一个对象实体
  59. /// </summary>
  60. public Model.T_Sys_SystemConfig GetModel(int F_ParamId)
  61. {
  62. var dt = GetRedis();
  63. if (dt != null)
  64. {
  65. var dr = dt.Select("F_ParamId=" + F_ParamId);
  66. if (dr != null && dr.Count() > 0)
  67. {
  68. return dal.DataRowToModel(dr[0]);
  69. }
  70. else
  71. {
  72. return null;
  73. }
  74. }
  75. else
  76. {
  77. return dal.GetModel(F_ParamId);
  78. }
  79. }
  80. /// <summary>
  81. /// 获得数据列表
  82. /// </summary>
  83. public DataSet GetList(string strWhere)
  84. {
  85. return dal.GetList(strWhere);
  86. }
  87. /// <summary>
  88. /// 获得前几行数据
  89. /// </summary>
  90. public DataSet GetList(int Top, string strWhere, string filedOrder)
  91. {
  92. return dal.GetList(Top, strWhere, filedOrder);
  93. }
  94. /// <summary>
  95. /// 获得数据列表
  96. /// </summary>
  97. public List<Model.T_Sys_SystemConfig> GetModelList(string strWhere)
  98. {
  99. DataSet ds = dal.GetList(strWhere);
  100. return DataTableToList(ds.Tables[0]);
  101. }
  102. /// <summary>
  103. /// 获得数据列表
  104. /// </summary>
  105. public List<Model.T_Sys_SystemConfig> DataTableToList(DataTable dt)
  106. {
  107. List<Model.T_Sys_SystemConfig> modelList = new List<Model.T_Sys_SystemConfig>();
  108. int rowsCount = dt.Rows.Count;
  109. if (rowsCount > 0)
  110. {
  111. Model.T_Sys_SystemConfig model;
  112. for (int n = 0; n < rowsCount; n++)
  113. {
  114. model = dal.DataRowToModel(dt.Rows[n]);
  115. if (model != null)
  116. {
  117. modelList.Add(model);
  118. }
  119. }
  120. }
  121. return modelList;
  122. }
  123. /// <summary>
  124. /// 获得数据列表
  125. /// </summary>
  126. public DataSet GetAllList()
  127. {
  128. return GetList("");
  129. }
  130. /// <summary>
  131. /// 分页获取数据列表
  132. /// </summary>
  133. public int GetRecordCount(string strWhere)
  134. {
  135. return dal.GetRecordCount(strWhere);
  136. }
  137. /// <summary>
  138. /// 分页获取数据列表
  139. /// </summary>
  140. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  141. {
  142. return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
  143. }
  144. #endregion BasicMethod
  145. #region ExtensionMethod
  146. #endregion ExtensionMethod
  147. /// <summary>
  148. /// 根据编号获取值
  149. /// </summary>
  150. /// <param name="p_ParamCode">编号</param>
  151. /// <returns></returns>
  152. public string GetParamValueByParamCode(string p_ParamCode)
  153. {
  154. return dal.GetParamValueByParamCode(p_ParamCode);
  155. }
  156. private DataTable GetRedis()
  157. {
  158. var strList = RedisHelper.StringGet("SysConfig");
  159. if (strList != null)
  160. {
  161. return strList.ToString().ToObject<DataTable>();
  162. }
  163. else
  164. {
  165. return InRedis();
  166. }
  167. }
  168. private DataTable InRedis()
  169. {
  170. var dt = dal.GetList("").Tables[0];
  171. RedisHelper.StringSet("SysConfig", dt.ToJson(), new TimeSpan(24, 0, 0));
  172. return dt;
  173. }
  174. private void OutRedis()
  175. {
  176. RedisHelper.KeyDelete("SysConfig");
  177. }
  178. }
  179. }