Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

DataItemService.cs 8.1 KiB

4 anni fa
4 anni fa
4 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using Learun.DataBase.Repository;
  2. using Learun.Util;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. namespace Learun.Application.Base.SystemModule
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  10. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  11. /// 创建人:陈彬彬
  12. /// 日 期:2017.03.08
  13. /// 描 述:数据字典管理服务类
  14. /// </summary>
  15. public class DataItemService : RepositoryFactory
  16. {
  17. #region 属性 构造函数
  18. private string fieldSql;
  19. private string detailFieldSql;
  20. public DataItemService()
  21. {
  22. fieldSql = @"
  23. t.F_ItemId,
  24. t.F_ParentId,
  25. t.F_ItemCode,
  26. t.F_ItemCodeGB,
  27. t.F_ItemName,
  28. t.F_IsTree,
  29. t.F_IsNav,
  30. t.F_SortCode,
  31. t.F_DeleteMark,
  32. t.F_EnabledMark,
  33. t.F_Description,
  34. t.F_CreateDate,
  35. t.F_CreateUserId,
  36. t.F_CreateUserName,
  37. t.F_ModifyDate,
  38. t.F_ModifyUserId,
  39. t.F_ModifyUserName
  40. ";
  41. detailFieldSql = @"
  42. t.F_ItemDetailId,
  43. t.F_ItemId,
  44. t.F_ParentId,
  45. t.F_ItemCode,
  46. t.F_ItemCodeGB,
  47. t.F_ItemName,
  48. t.F_ItemValue,
  49. t.F_QuickQuery,
  50. t.F_SimpleSpelling,
  51. t.F_IsDefault,
  52. t.F_SortCode,
  53. t.F_DeleteMark,
  54. t.F_EnabledMark,
  55. t.F_Description,
  56. t.F_CreateDate,
  57. t.F_CreateUserId,
  58. t.F_CreateUserName,
  59. t.F_ModifyDate,
  60. t.F_ModifyUserId,
  61. t.F_ModifyUserName
  62. ";
  63. }
  64. #endregion
  65. #region 数据字典分类管理
  66. /// <summary>
  67. /// 分类列表
  68. /// </summary>
  69. /// <returns></returns>
  70. public IEnumerable<DataItemEntity> GetClassifyList()
  71. {
  72. try
  73. {
  74. StringBuilder strSql = new StringBuilder();
  75. strSql.Append("SELECT " + fieldSql + " FROM LR_Base_DataItem t WHERE t.F_DeleteMark = 0 Order By t.F_ParentId,t.F_SortCode ");
  76. return this.BaseRepository().FindList<DataItemEntity>(strSql.ToString());
  77. }
  78. catch (Exception ex)
  79. {
  80. if (ex is ExceptionEx)
  81. {
  82. throw;
  83. }
  84. else
  85. {
  86. throw ExceptionEx.ThrowServiceException(ex);
  87. }
  88. }
  89. }
  90. /// <summary>
  91. /// 虚拟删除分类数据
  92. /// </summary>
  93. /// <param name="keyValue">主键</param>
  94. public void VirtualDeleteClassify(string keyValue)
  95. {
  96. try
  97. {
  98. DataItemEntity entity = new DataItemEntity()
  99. {
  100. F_ItemId = keyValue,
  101. F_DeleteMark = 1
  102. };
  103. this.BaseRepository().Update(entity);
  104. }
  105. catch (Exception ex)
  106. {
  107. if (ex is ExceptionEx)
  108. {
  109. throw;
  110. }
  111. else
  112. {
  113. throw ExceptionEx.ThrowServiceException(ex);
  114. }
  115. }
  116. }
  117. /// <summary>
  118. /// 保存分类数据实体
  119. /// </summary>
  120. /// <param name="keyValue">主键</param>
  121. /// <param name="entity">实体</param>
  122. public void SaveClassifyEntity(string keyValue, DataItemEntity entity) {
  123. try
  124. {
  125. if (string.IsNullOrEmpty(keyValue))
  126. {
  127. entity.Create();
  128. this.BaseRepository().Insert(entity);
  129. }
  130. else {
  131. entity.Modify(keyValue);
  132. this.BaseRepository().Update(entity);
  133. }
  134. }
  135. catch (Exception ex)
  136. {
  137. if (ex is ExceptionEx)
  138. {
  139. throw;
  140. }
  141. else
  142. {
  143. throw ExceptionEx.ThrowServiceException(ex);
  144. }
  145. }
  146. }
  147. #endregion
  148. #region 数据字典明细
  149. /// <summary>
  150. /// 获取数据字典明显根据分类编号
  151. /// </summary>
  152. /// <param name="itemCode">分类编号</param>
  153. /// <returns></returns>
  154. public IEnumerable<DataItemDetailEntity> GetDetailList(string itemCode)
  155. {
  156. try
  157. {
  158. StringBuilder strSql = new StringBuilder();
  159. strSql.Append("SELECT " + detailFieldSql + @" FROM LR_Base_DataItemDetail t
  160. INNER JOIN LR_Base_DataItem t2 ON t.F_ItemId = t2.F_ItemId
  161. WHERE t2.F_ItemCode = @itemCode AND t.F_DeleteMark = 0 Order By t.F_SortCode
  162. ");
  163. return this.BaseRepository().FindList<DataItemDetailEntity>(strSql.ToString(), new { itemCode = itemCode });
  164. }
  165. catch (Exception ex)
  166. {
  167. if (ex is ExceptionEx)
  168. {
  169. throw;
  170. }
  171. else
  172. {
  173. throw ExceptionEx.ThrowServiceException(ex);
  174. }
  175. }
  176. }
  177. /// <summary>
  178. /// 获取数据字典明细实体类
  179. /// </summary>
  180. /// <param name="keyValue">主键</param>
  181. /// <returns></returns>
  182. public DataItemDetailEntity GetDetailEntity(string keyValue) {
  183. try
  184. {
  185. return this.BaseRepository().FindEntity<DataItemDetailEntity>(keyValue);
  186. }
  187. catch (Exception ex)
  188. {
  189. if (ex is ExceptionEx)
  190. {
  191. throw;
  192. }
  193. else
  194. {
  195. throw ExceptionEx.ThrowServiceException(ex);
  196. }
  197. }
  198. }
  199. /// <summary>
  200. /// 虚拟删除明细数据
  201. /// </summary>
  202. /// <param name="keyValue">主键</param>
  203. public void VirtualDeleteDetail(string keyValue)
  204. {
  205. try
  206. {
  207. DataItemDetailEntity entity = new DataItemDetailEntity()
  208. {
  209. F_ItemDetailId = keyValue,
  210. F_DeleteMark = 1
  211. };
  212. this.BaseRepository().Update(entity);
  213. }
  214. catch (Exception ex)
  215. {
  216. if (ex is ExceptionEx)
  217. {
  218. throw;
  219. }
  220. else
  221. {
  222. throw ExceptionEx.ThrowServiceException(ex);
  223. }
  224. }
  225. }
  226. /// <summary>
  227. /// 保存明细数据实体
  228. /// </summary>
  229. /// <param name="keyValue">主键</param>
  230. /// <param name="entity">实体</param>
  231. public void SaveDetailEntity(string keyValue, DataItemDetailEntity entity)
  232. {
  233. try
  234. {
  235. if (string.IsNullOrEmpty(keyValue))
  236. {
  237. entity.Create();
  238. this.BaseRepository().Insert(entity);
  239. }
  240. else
  241. {
  242. entity.Modify(keyValue);
  243. this.BaseRepository().Update(entity);
  244. }
  245. }
  246. catch (Exception ex)
  247. {
  248. if (ex is ExceptionEx)
  249. {
  250. throw;
  251. }
  252. else
  253. {
  254. throw ExceptionEx.ThrowServiceException(ex);
  255. }
  256. }
  257. }
  258. #endregion
  259. }
  260. }