Aucune description

T_Sys_UserAccount.cs 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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. var dt = GetRedis();
  163. if (dt != null)
  164. {
  165. var ds = new DataSet();
  166. if (string.IsNullOrEmpty(strWhere))
  167. {
  168. ds.Tables.Add(dt.Copy());
  169. }
  170. else
  171. {
  172. var drs = dt.Select(strWhere, filedOrder);
  173. if (drs.Length > 0)
  174. {
  175. ds.Tables.Add(drs.CopyToDataTable());
  176. }
  177. else
  178. {
  179. ds.Tables.Add(new DataTable());
  180. }
  181. }
  182. return ds;
  183. }
  184. else
  185. {
  186. return dal.GetList(strWhere, filedOrder);
  187. }
  188. // return dal.GetList(strWhere, filedOrder);
  189. }
  190. /// <summary>
  191. /// 获得数据列表
  192. /// </summary>
  193. public DataSet GetListNoCache(string strWhere)
  194. {
  195. return dal.GetList(strWhere);
  196. }
  197. public DataSet GetListView(string strWhere)
  198. {
  199. return dal.GetListView(strWhere);
  200. }
  201. /// <summary>
  202. /// 获得前几行数据
  203. /// </summary>
  204. public DataSet GetList(int Top, string strWhere, string filedOrder)
  205. {
  206. return dal.GetList(Top, strWhere, filedOrder);
  207. }
  208. /// <summary>
  209. /// 获得前几行数据
  210. /// </summary>
  211. public DataSet GetSeatList(string strWhere, string filedOrder)
  212. {
  213. return dal.GetList(strWhere, filedOrder);
  214. }
  215. /// <summary>
  216. /// 获得数据列表
  217. /// </summary>
  218. public List<Model.T_Sys_UserAccount> GetModelList(string strWhere, string filedOrder = "")
  219. {
  220. var dt = GetRedis();
  221. if (dt != null)
  222. {
  223. var dtnew = new DataTable();
  224. var drs = dt.Select(strWhere, filedOrder);
  225. if (drs.Length > 0)
  226. {
  227. dtnew = drs.CopyToDataTable();
  228. }
  229. return DataTableToList(dtnew);
  230. }
  231. else
  232. {
  233. DataSet ds = dal.GetList(strWhere, filedOrder);
  234. return DataTableToList(ds.Tables[0]);
  235. }
  236. // DataSet ds = dal.GetList(strWhere, filedOrder);
  237. // return DataTableToList(ds.Tables[0]);
  238. }
  239. /// <summary>
  240. /// 获得数据列表
  241. /// </summary>
  242. public List<CallCenterApi.Model.T_Sys_UserAccount> GetModelListNoCache(string strWhere, string filedOrder = "")
  243. {
  244. DataSet ds = dal.GetList(strWhere, filedOrder);
  245. return DataTableToList(ds.Tables[0]);
  246. }
  247. /// <summary>
  248. /// 获得数据列表
  249. /// </summary>
  250. public List<Model.T_Sys_UserAccount> DataTableToList(DataTable dt)
  251. {
  252. List<Model.T_Sys_UserAccount> modelList = new List<Model.T_Sys_UserAccount>();
  253. int rowsCount = dt.Rows.Count;
  254. if (rowsCount > 0)
  255. {
  256. Model.T_Sys_UserAccount model;
  257. for (int n = 0; n < rowsCount; n++)
  258. {
  259. model = dal.DataRowToModel(dt.Rows[n]);
  260. if (model != null)
  261. {
  262. modelList.Add(model);
  263. }
  264. }
  265. }
  266. return modelList;
  267. }
  268. public List<Model.T_Sys_UserAccount> DataTableToList1(DataTable dt)
  269. {
  270. List<Model.T_Sys_UserAccount> modelList = new List<Model.T_Sys_UserAccount>();
  271. int rowsCount = dt.Rows.Count;
  272. if (rowsCount > 0)
  273. {
  274. Model.T_Sys_UserAccount model;
  275. for (int n = 0; n < rowsCount; n++)
  276. {
  277. model = dal.DataRowToModel1(dt.Rows[n]);
  278. if (model != null)
  279. {
  280. modelList.Add(model);
  281. }
  282. }
  283. }
  284. return modelList;
  285. }
  286. /// <summary>
  287. /// 获得数据列表
  288. /// </summary>
  289. public DataSet GetAllList()
  290. {
  291. return GetList("");
  292. }
  293. /// <summary>
  294. /// 分页获取数据列表
  295. /// </summary>
  296. public int GetRecordCount(string strWhere)
  297. {
  298. return dal.GetRecordCount(strWhere);
  299. }
  300. /// <summary>
  301. /// 分页获取数据列表
  302. /// </summary>
  303. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  304. {
  305. return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
  306. }
  307. /// <summary>
  308. /// 分页获取数据列表
  309. /// </summary>
  310. //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
  311. //{
  312. //return dal.GetList(PageSize,PageIndex,strWhere);
  313. //}
  314. #endregion BasicMethod
  315. #region ExtensionMethod
  316. #endregion ExtensionMethod
  317. private DataTable GetRedis()
  318. {
  319. var strList = RedisHelper2.StringGet("T_Sys_UserAccount");
  320. if (strList != null)
  321. {
  322. return strList.ToString().ToObject<DataTable>();
  323. }
  324. else
  325. {
  326. return InRedis();
  327. }
  328. }
  329. private DataTable InRedis()
  330. {
  331. var dt = dal.GetList("").Tables[0];
  332. RedisHelper2.StringSet("T_Sys_UserAccount", dt.ToJson(), new TimeSpan(24, 0, 0));
  333. return dt;
  334. }
  335. private void OutRedis()
  336. {
  337. RedisHelper2.KeyDelete("T_Sys_UserAccount");
  338. }
  339. }
  340. }