WFFrmMainService.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using LeaRun.Application.Entity.FlowManage;
  2. using LeaRun.Application.IService.FlowManage;
  3. using LeaRun.Data;
  4. using LeaRun.Data.Repository;
  5. using LeaRun.Util;
  6. using LeaRun.Util.Extension;
  7. using LeaRun.Util.WebControl;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Data.Common;
  12. using System.Text;
  13. namespace LeaRun.Application.Service.FlowManage
  14. {
  15. /// <summary>
  16. /// 版 本 6.1
  17. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  18. /// 创建人:陈彬彬
  19. /// 日 期:2016.01.14 11:02
  20. /// 描 述:表单管理(支持:SqlServer)
  21. /// </summary>
  22. public class WFFrmMainService : RepositoryFactory, WFFrmMainIService
  23. {
  24. #region 获取数据
  25. /// <summary>
  26. /// 获取表单列表分页数据
  27. /// </summary>
  28. /// <param name="pagination">分页参数</param>
  29. /// <param name="queryJson">查询条件</param>
  30. /// <returns></returns>
  31. public DataTable GetPageList(Pagination pagination, string queryJson)
  32. {
  33. try
  34. {
  35. var strSql = new StringBuilder();
  36. strSql.Append(@"SELECT
  37. w.FrmMainId,
  38. w.FrmCode,
  39. w.FrmName,
  40. w.FrmType,
  41. t2.ItemName AS FrmTypeName,
  42. w.FrmDbId,
  43. t1.DBName,
  44. w.FrmTable,
  45. w.FrmTableId,
  46. w.isSystemTable,
  47. w.FrmContent,
  48. w.SortCode,
  49. w.DeleteMark,
  50. w.EnabledMark,
  51. w.Description,
  52. w.CreateDate,
  53. w.CreateUserId,
  54. w.CreateUserName,
  55. w.ModifyDate,
  56. w.ModifyUserId,
  57. w.ModifyUserName
  58. FROM
  59. WF_FrmMain w
  60. LEFT JOIN
  61. Base_DatabaseLink t1 ON t1.DatabaseLinkId = w.FrmDbId
  62. LEFT JOIN
  63. Base_DataItemDetail t2 ON t2.ItemDetailId = w.FrmType
  64. WHERE w.DeleteMark = 0 ");
  65. var parameter = new List<DbParameter>();
  66. var queryParam = queryJson.ToJObject();
  67. //数据库Id查询
  68. if (!queryParam["FrmType"].IsEmpty())
  69. {
  70. strSql.Append(" AND w.FrmType = @FrmType ");
  71. parameter.Add(DbParameters.CreateDbParameter("@FrmType", queryParam["FrmType"].ToString()));
  72. }
  73. else if (!queryParam["Keyword"].IsEmpty())//关键字查询
  74. {
  75. string keyord = queryParam["Keyword"].ToString();
  76. strSql.Append(@" AND ( w.FrmCode LIKE @keyword
  77. or w.FrmName LIKE @keyword
  78. or w.Description LIKE @keyword
  79. )");
  80. parameter.Add(DbParameters.CreateDbParameter("@keyword", '%' + keyord + '%'));
  81. }
  82. return this.BaseRepository().FindTable(strSql.ToString(), parameter.ToArray(), pagination);
  83. }
  84. catch (Exception)
  85. {
  86. throw;
  87. }
  88. }
  89. /// <summary>
  90. /// 获取表单数据ALL(用于下拉框)
  91. /// </summary>
  92. /// <returns></returns>
  93. public DataTable GetAllList()
  94. {
  95. try
  96. {
  97. var strSql = new StringBuilder();
  98. strSql.Append(@"SELECT
  99. w.FrmMainId,
  100. w.FrmName,
  101. w.FrmType,
  102. t2.ItemName AS FrmTypeName
  103. FROM
  104. WF_FrmMain w
  105. LEFT JOIN
  106. Base_DataItemDetail t2 ON t2.ItemDetailId = w.FrmType
  107. WHERE w.DeleteMark = 0 and w.EnabledMark = 1 order by w.FrmType");
  108. var parameter = new List<DbParameter>();
  109. return this.BaseRepository().FindTable(strSql.ToString());
  110. }
  111. catch (Exception)
  112. {
  113. throw;
  114. }
  115. }
  116. /// <summary>
  117. /// 设置表单
  118. /// </summary>
  119. /// <param name="keyValue">主键</param>
  120. /// <returns></returns>
  121. public WFFrmMainEntity GetForm(string keyValue)
  122. {
  123. try
  124. {
  125. return this.BaseRepository().FindEntity<WFFrmMainEntity>(keyValue);
  126. }
  127. catch (Exception)
  128. {
  129. throw;
  130. }
  131. }
  132. #endregion
  133. #region 提交数据
  134. /// <summary>
  135. /// 删除表单
  136. /// </summary>
  137. /// <param name="keyValue">主键</param>
  138. public void RemoveForm(string keyValue)
  139. {
  140. try
  141. {
  142. WFFrmMainEntity entity = new WFFrmMainEntity();
  143. entity.Modify(keyValue);
  144. entity.DeleteMark = 1;
  145. this.BaseRepository().Update(entity);
  146. }
  147. catch (Exception)
  148. {
  149. throw;
  150. }
  151. }
  152. /// <summary>
  153. /// 保存表单
  154. /// </summary>
  155. /// <param name="entity">表单模板实体类</param>
  156. /// <param name="keyValue">主键</param>
  157. /// <returns></returns>
  158. public int SaveForm(string keyValue,WFFrmMainEntity entity)
  159. {
  160. try
  161. {
  162. if (string.IsNullOrEmpty(keyValue))
  163. {
  164. entity.Create();
  165. this.BaseRepository().Insert(entity);
  166. }
  167. else
  168. {
  169. entity.Modify(keyValue);
  170. this.BaseRepository().Update(entity);
  171. }
  172. return 1;
  173. }
  174. catch(Exception)
  175. {
  176. throw;
  177. }
  178. }
  179. /// <summary>
  180. /// 更新表单模板状态(启用,停用)
  181. /// </summary>
  182. /// <param name="keyValue">主键</param>
  183. /// <param name="status">状态 1:启用;0.停用</param>
  184. public void UpdateState(string keyValue, int state)
  185. {
  186. try
  187. {
  188. WFFrmMainEntity entity = new WFFrmMainEntity();
  189. entity.Modify(keyValue);
  190. entity.EnabledMark = state;
  191. this.BaseRepository().Update(entity);
  192. }
  193. catch (Exception)
  194. {
  195. throw;
  196. }
  197. }
  198. #endregion
  199. }
  200. }