Sin descripción

T_Sys_UserAccount.cs 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. using CallCenter.Utility;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace CallCenterApi.BLL
  9. {
  10. /// <summary>
  11. /// T_Sys_UserAccount
  12. /// </summary>
  13. public partial class T_Sys_UserAccount
  14. {
  15. private readonly DAL.T_Sys_UserAccount dal = new DAL.T_Sys_UserAccount();
  16. public T_Sys_UserAccount()
  17. { }
  18. #region BasicMethod
  19. /// <summary>
  20. /// 得到最大ID
  21. /// </summary>
  22. public int GetMaxId()
  23. {
  24. return dal.GetMaxId();
  25. }
  26. /// <summary>
  27. /// 是否存在该记录
  28. /// </summary>
  29. public bool Exists(int F_UserId)
  30. {
  31. return dal.Exists(F_UserId);
  32. }
  33. /// <summary>
  34. /// 增加一条数据
  35. /// </summary>
  36. public int Add(Model.T_Sys_UserAccount model)
  37. {
  38. OutRedis();
  39. return dal.Add(model);
  40. }
  41. /// <summary>
  42. /// 更新一条数据
  43. /// </summary>
  44. public bool Update(Model.T_Sys_UserAccount model)
  45. {
  46. OutRedis();
  47. return dal.Update(model);
  48. }
  49. /// <summary>
  50. /// 删除一条数据
  51. /// </summary>
  52. public bool Delete(int F_UserId)
  53. {
  54. OutRedis();
  55. return dal.Delete(F_UserId);
  56. }
  57. /// <summary>
  58. /// 删除一条数据
  59. /// </summary>
  60. public bool DeleteList(string F_UserIdlist)
  61. {
  62. OutRedis();
  63. return dal.DeleteList(F_UserIdlist);
  64. }
  65. /// <summary>
  66. /// 更新数据状态 批量
  67. /// </summary>
  68. public bool DeleteList(string F_UserIdlist, int state)
  69. {
  70. OutRedis();
  71. return dal.DeleteList(F_UserIdlist, state);
  72. }
  73. /// <summary>
  74. /// 得到一个对象实体
  75. /// </summary>
  76. public Model.T_Sys_UserAccount GetModel(int F_UserId)
  77. {
  78. var dt = GetRedis();
  79. if (dt != null)
  80. {
  81. var dr = dt.Select("F_UserId=" + F_UserId);
  82. if (dr != null && dr.Count() > 0)
  83. {
  84. return dal.DataRowToModel(dr[0]);
  85. }
  86. else
  87. {
  88. return null;
  89. }
  90. }
  91. else
  92. {
  93. return dal.GetModel(F_UserId);
  94. }
  95. // return dal.GetModel(F_UserId);
  96. }
  97. /// <summary>
  98. /// 得到一个对象实体
  99. /// </summary>
  100. public Model.T_Sys_UserAccount GetModel(string F_UserCode)
  101. {
  102. var dt = GetRedis();
  103. if (dt != null)
  104. {
  105. var dr = dt.Select("F_UserCode='" + F_UserCode + "'");
  106. if (dr != null && dr.Count() > 0)
  107. {
  108. return dal.DataRowToModel(dr[0]);
  109. }
  110. else
  111. {
  112. return null;
  113. }
  114. }
  115. else
  116. {
  117. return dal.GetModel(F_UserCode);
  118. }
  119. //return dal.GetModel(F_UserCode);
  120. }
  121. /// <summary>
  122. /// 得到一个对象实体
  123. /// </summary>
  124. public Model.T_Sys_UserAccount GetModelByWxOpenId(string F_UserCode)
  125. {
  126. return dal.GetModelByWxOpenId(F_UserCode);
  127. }
  128. /// <summary>
  129. /// 登录得到一个对象实体
  130. /// </summary>
  131. public Model.T_Sys_UserAccount LoginGetModel(string F_UserCode, string F_Password)
  132. {
  133. return dal.LoginGetModel(F_UserCode, F_Password);
  134. }
  135. ///// <summary>
  136. ///// 得到一个对象实体,从缓存中
  137. ///// </summary>
  138. //public Model.T_Sys_UserAccount GetModelByCache(int F_UserId)
  139. //{
  140. // string CacheKey = "T_Sys_UserAccountModel-" + F_UserId;
  141. // object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
  142. // if (objModel == null)
  143. // {
  144. // try
  145. // {
  146. // objModel = dal.GetModel(F_UserId);
  147. // if (objModel != null)
  148. // {
  149. // int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
  150. // Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
  151. // }
  152. // }
  153. // catch{}
  154. // }
  155. // return (Model.T_Sys_UserAccount)objModel;
  156. //}
  157. /// <summary>
  158. /// 获得数据列表
  159. /// </summary>
  160. public DataSet GetList(string strWhere, string filedOrder = "")
  161. {
  162. return dal.GetList(strWhere, filedOrder);
  163. // return dal.GetList(strWhere, filedOrder);
  164. }
  165. /// <summary>
  166. /// 获得数据列表
  167. /// </summary>
  168. public DataSet GetListNoCache(string strWhere)
  169. {
  170. return dal.GetList(strWhere);
  171. }
  172. public DataSet GetListView(string strWhere)
  173. {
  174. return dal.GetListView(strWhere);
  175. }
  176. /// <summary>
  177. /// 获得前几行数据
  178. /// </summary>
  179. public DataSet GetList(int Top, string strWhere, string filedOrder)
  180. {
  181. return dal.GetList(Top, strWhere, filedOrder);
  182. }
  183. /// <summary>
  184. /// 获得前几行数据
  185. /// </summary>
  186. public DataSet GetSeatList(string strWhere, string filedOrder)
  187. {
  188. return dal.GetList(strWhere, filedOrder);
  189. }
  190. /// <summary>
  191. /// 获得数据列表
  192. /// </summary>
  193. public List<Model.T_Sys_UserAccount> GetModelList(string strWhere, string filedOrder = "")
  194. {
  195. var dt = GetRedis();
  196. if (dt != null)
  197. {
  198. var dtnew = new DataTable();
  199. var drs = dt.Select(strWhere, filedOrder);
  200. if (drs.Length > 0)
  201. {
  202. dtnew = drs.CopyToDataTable();
  203. }
  204. return DataTableToList(dtnew);
  205. }
  206. else
  207. {
  208. DataSet ds = dal.GetList(strWhere, filedOrder);
  209. return DataTableToList(ds.Tables[0]);
  210. }
  211. // DataSet ds = dal.GetList(strWhere, filedOrder);
  212. // return DataTableToList(ds.Tables[0]);
  213. }
  214. /// <summary>
  215. /// 获得数据列表
  216. /// </summary>
  217. public List<CallCenterApi.Model.T_Sys_UserAccount> GetModelListNoCache(string strWhere, string filedOrder = "")
  218. {
  219. DataSet ds = dal.GetList(strWhere, filedOrder);
  220. return DataTableToList(ds.Tables[0]);
  221. }
  222. /// <summary>
  223. /// 获得数据列表
  224. /// </summary>
  225. public List<Model.T_Sys_UserAccount> DataTableToList(DataTable dt)
  226. {
  227. List<Model.T_Sys_UserAccount> modelList = new List<Model.T_Sys_UserAccount>();
  228. int rowsCount = dt.Rows.Count;
  229. if (rowsCount > 0)
  230. {
  231. Model.T_Sys_UserAccount model;
  232. for (int n = 0; n < rowsCount; n++)
  233. {
  234. model = dal.DataRowToModel(dt.Rows[n]);
  235. if (model != null)
  236. {
  237. modelList.Add(model);
  238. }
  239. }
  240. }
  241. return modelList;
  242. }
  243. public List<Model.T_Sys_UserAccount> DataTableToList1(DataTable dt)
  244. {
  245. List<Model.T_Sys_UserAccount> modelList = new List<Model.T_Sys_UserAccount>();
  246. int rowsCount = dt.Rows.Count;
  247. if (rowsCount > 0)
  248. {
  249. Model.T_Sys_UserAccount model;
  250. for (int n = 0; n < rowsCount; n++)
  251. {
  252. model = dal.DataRowToModel1(dt.Rows[n]);
  253. if (model != null)
  254. {
  255. modelList.Add(model);
  256. }
  257. }
  258. }
  259. return modelList;
  260. }
  261. /// <summary>
  262. /// 获得数据列表
  263. /// </summary>
  264. public DataSet GetAllList()
  265. {
  266. return GetList("");
  267. }
  268. /// <summary>
  269. /// 分页获取数据列表
  270. /// </summary>
  271. public int GetRecordCount(string strWhere)
  272. {
  273. return dal.GetRecordCount(strWhere);
  274. }
  275. /// <summary>
  276. /// 分页获取数据列表
  277. /// </summary>
  278. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  279. {
  280. return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
  281. }
  282. /// <summary>
  283. /// 分页获取数据列表
  284. /// </summary>
  285. //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
  286. //{
  287. //return dal.GetList(PageSize,PageIndex,strWhere);
  288. //}
  289. #endregion BasicMethod
  290. #region ExtensionMethod
  291. #endregion ExtensionMethod
  292. private DataTable GetRedis()
  293. {
  294. var strList = RedisHelper2.StringGet("T_Sys_UserAccount");
  295. if (strList != null)
  296. {
  297. return strList.ToString().ToObject<DataTable>();
  298. }
  299. else
  300. {
  301. return InRedis();
  302. }
  303. }
  304. private DataTable InRedis()
  305. {
  306. var dt = dal.GetList("").Tables[0];
  307. RedisHelper2.StringSet("T_Sys_UserAccount", dt.ToJson(), new TimeSpan(24, 0, 0));
  308. return dt;
  309. }
  310. private void OutRedis()
  311. {
  312. RedisHelper2.KeyDelete("T_Sys_UserAccount");
  313. }
  314. }
  315. }