No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

263 líneas
8.1 KiB

  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_ItemName,
  27. t.F_IsTree,
  28. t.F_IsNav,
  29. t.F_SortCode,
  30. t.F_DeleteMark,
  31. t.F_EnabledMark,
  32. t.F_Description,
  33. t.F_CreateDate,
  34. t.F_CreateUserId,
  35. t.F_CreateUserName,
  36. t.F_ModifyDate,
  37. t.F_ModifyUserId,
  38. t.F_ModifyUserName
  39. ";
  40. detailFieldSql = @"
  41. t.F_ItemDetailId,
  42. t.F_ItemId,
  43. t.F_ParentId,
  44. t.F_ItemCode,
  45. t.F_ItemName,
  46. t.F_ItemValue,
  47. t.F_QuickQuery,
  48. t.F_SimpleSpelling,
  49. t.F_IsDefault,
  50. t.F_SortCode,
  51. t.F_DeleteMark,
  52. t.F_EnabledMark,
  53. t.F_Description,
  54. t.F_CreateDate,
  55. t.F_CreateUserId,
  56. t.F_CreateUserName,
  57. t.F_ModifyDate,
  58. t.F_ModifyUserId,
  59. t.F_ModifyUserName,
  60. t.F_Type,t.F_Length,t.F_Constraint,t.F_ValueSpace,t.F_Explain,t.F_ReferenceNum
  61. ";
  62. }
  63. #endregion
  64. #region 数据字典分类管理
  65. /// <summary>
  66. /// 分类列表
  67. /// </summary>
  68. /// <returns></returns>
  69. public IEnumerable<DataItemEntity> GetClassifyList()
  70. {
  71. try
  72. {
  73. StringBuilder strSql = new StringBuilder();
  74. strSql.Append("SELECT " + fieldSql + " FROM LR_Base_DataItem t WHERE t.F_DeleteMark = 0 Order By t.F_ParentId,t.F_SortCode ");
  75. return this.BaseRepository().FindList<DataItemEntity>(strSql.ToString());
  76. }
  77. catch (Exception ex)
  78. {
  79. if (ex is ExceptionEx)
  80. {
  81. throw;
  82. }
  83. else
  84. {
  85. throw ExceptionEx.ThrowServiceException(ex);
  86. }
  87. }
  88. }
  89. /// <summary>
  90. /// 虚拟删除分类数据
  91. /// </summary>
  92. /// <param name="keyValue">主键</param>
  93. public void VirtualDeleteClassify(string keyValue)
  94. {
  95. try
  96. {
  97. DataItemEntity entity = new DataItemEntity()
  98. {
  99. F_ItemId = keyValue,
  100. F_DeleteMark = 1
  101. };
  102. this.BaseRepository().Update(entity);
  103. }
  104. catch (Exception ex)
  105. {
  106. if (ex is ExceptionEx)
  107. {
  108. throw;
  109. }
  110. else
  111. {
  112. throw ExceptionEx.ThrowServiceException(ex);
  113. }
  114. }
  115. }
  116. /// <summary>
  117. /// 保存分类数据实体
  118. /// </summary>
  119. /// <param name="keyValue">主键</param>
  120. /// <param name="entity">实体</param>
  121. public void SaveClassifyEntity(string keyValue, DataItemEntity entity) {
  122. try
  123. {
  124. if (string.IsNullOrEmpty(keyValue))
  125. {
  126. entity.Create();
  127. this.BaseRepository().Insert(entity);
  128. }
  129. else {
  130. entity.Modify(keyValue);
  131. this.BaseRepository().Update(entity);
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. if (ex is ExceptionEx)
  137. {
  138. throw;
  139. }
  140. else
  141. {
  142. throw ExceptionEx.ThrowServiceException(ex);
  143. }
  144. }
  145. }
  146. #endregion
  147. #region 数据字典明细
  148. /// <summary>
  149. /// 获取数据字典明显根据分类编号
  150. /// </summary>
  151. /// <param name="itemCode">分类编号</param>
  152. /// <returns></returns>
  153. public IEnumerable<DataItemDetailEntity> GetDetailList(string itemCode)
  154. {
  155. try
  156. {
  157. StringBuilder strSql = new StringBuilder();
  158. strSql.Append("SELECT " + detailFieldSql + @" FROM LR_Base_DataItemDetail t
  159. INNER JOIN LR_Base_DataItem t2 ON t.F_ItemId = t2.F_ItemId
  160. WHERE t2.F_ItemCode = @itemCode AND t.F_DeleteMark = 0 Order By t.F_SortCode
  161. ");
  162. return this.BaseRepository().FindList<DataItemDetailEntity>(strSql.ToString(), new { itemCode = itemCode });
  163. }
  164. catch (Exception ex)
  165. {
  166. if (ex is ExceptionEx)
  167. {
  168. throw;
  169. }
  170. else
  171. {
  172. throw ExceptionEx.ThrowServiceException(ex);
  173. }
  174. }
  175. }
  176. /// <summary>
  177. /// 获取数据字典明细实体类
  178. /// </summary>
  179. /// <param name="keyValue">主键</param>
  180. /// <returns></returns>
  181. public DataItemDetailEntity GetDetailEntity(string keyValue) {
  182. try
  183. {
  184. return this.BaseRepository().FindEntity<DataItemDetailEntity>(keyValue);
  185. }
  186. catch (Exception ex)
  187. {
  188. if (ex is ExceptionEx)
  189. {
  190. throw;
  191. }
  192. else
  193. {
  194. throw ExceptionEx.ThrowServiceException(ex);
  195. }
  196. }
  197. }
  198. /// <summary>
  199. /// 虚拟删除明细数据
  200. /// </summary>
  201. /// <param name="keyValue">主键</param>
  202. public void VirtualDeleteDetail(string keyValue)
  203. {
  204. try
  205. {
  206. DataItemDetailEntity entity = new DataItemDetailEntity()
  207. {
  208. F_ItemDetailId = keyValue,
  209. F_DeleteMark = 1
  210. };
  211. this.BaseRepository().Update(entity);
  212. }
  213. catch (Exception ex)
  214. {
  215. if (ex is ExceptionEx)
  216. {
  217. throw;
  218. }
  219. else
  220. {
  221. throw ExceptionEx.ThrowServiceException(ex);
  222. }
  223. }
  224. }
  225. /// <summary>
  226. /// 保存明细数据实体
  227. /// </summary>
  228. /// <param name="keyValue">主键</param>
  229. /// <param name="entity">实体</param>
  230. public void SaveDetailEntity(string keyValue, DataItemDetailEntity entity)
  231. {
  232. try
  233. {
  234. if (string.IsNullOrEmpty(keyValue))
  235. {
  236. entity.Create();
  237. this.BaseRepository().Insert(entity);
  238. }
  239. else
  240. {
  241. entity.Modify(keyValue);
  242. this.BaseRepository().Update(entity);
  243. }
  244. }
  245. catch (Exception ex)
  246. {
  247. if (ex is ExceptionEx)
  248. {
  249. throw;
  250. }
  251. else
  252. {
  253. throw ExceptionEx.ThrowServiceException(ex);
  254. }
  255. }
  256. }
  257. #endregion
  258. }
  259. }