WFSchemeInfoBLL.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using LeaRun.Application.Entity.FlowManage;
  2. using LeaRun.Application.IService.FlowManage;
  3. using LeaRun.Application.Service.FlowManage;
  4. using LeaRun.Util.WebControl;
  5. using LeaRun.Data.Repository;
  6. using System;
  7. using System.Data;
  8. using LeaRun.Util.Extension;
  9. using System.Collections.Generic;
  10. namespace LeaRun.Application.Busines.FlowManage
  11. {
  12. /// <summary>
  13. /// 版 本 6.1
  14. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  15. /// 创建人:陈彬彬
  16. /// 日 期:2016.03.19 13:57
  17. /// 描 述:工作流流程模板操作(支持:SqlServer)
  18. /// </summary>
  19. public class WFSchemeInfoBLL
  20. {
  21. private WFSchemeInfoIService infoserver = new WFSchemeInfoService();
  22. private WFSchemeContentIService schemeserver = new WFSchemeContentService();
  23. #region 获取数据
  24. /// <summary>
  25. /// 获取流程列表分页数据
  26. /// </summary>
  27. /// <param name="pagination">分页参数</param>
  28. /// <param name="queryJson">查询参数</param>
  29. /// <returns></returns>
  30. public DataTable GetPageList(Pagination pagination, string queryJson)
  31. {
  32. return infoserver.GetPageList(pagination, queryJson);
  33. }
  34. /// <summary>
  35. /// 获取流程列表数据
  36. /// </summary>
  37. /// <param name="queryJson"></param>
  38. /// <returns></returns>
  39. public DataTable GetList(string queryJson)
  40. {
  41. return infoserver.GetList(queryJson);
  42. }
  43. /// <summary>
  44. /// 获取所有表单数据
  45. /// </summary>
  46. /// <returns></returns>
  47. public DataTable GetList()
  48. {
  49. return infoserver.GetList();
  50. }
  51. /// <summary>
  52. /// 获取工作流模板对象列表
  53. /// </summary>
  54. /// <param name="wfSchemeInfoId">工作流模板信息表Id</param>
  55. /// <returns></returns>
  56. public IEnumerable<WFSchemeContentEntity> GetSchemeEntityList(string wfSchemeInfoId)
  57. {
  58. return schemeserver.GetEntityList(wfSchemeInfoId);
  59. }
  60. /// <summary>
  61. /// 获取对象列表(不包括模板内容)
  62. /// </summary>
  63. /// <param name="wfSchemeInfoId">工作流模板信息表Id</param>
  64. /// <returns></returns>
  65. public DataTable GetTableList(string wfSchemeInfoId)
  66. {
  67. return schemeserver.GetTableList(wfSchemeInfoId);
  68. }
  69. /// <summary>
  70. /// 获取对象
  71. /// </summary>
  72. /// <param name="keyValue">主键</param>
  73. /// <returns></returns>
  74. public WFSchemeInfoEntity GetEntity(string keyValue)
  75. {
  76. try
  77. {
  78. return infoserver.GetEntity(keyValue);
  79. }
  80. catch (Exception)
  81. {
  82. throw;
  83. }
  84. }
  85. /// <summary>
  86. /// 获取工作流模板对象
  87. /// </summary>
  88. /// <param name="contentid"></param>
  89. /// <param name="version"></param>
  90. /// <returns></returns>
  91. public WFSchemeContentEntity GetSchemeEntity(string wfSchemeInfoId, string schemeVersion)
  92. {
  93. try
  94. {
  95. return schemeserver.GetEntity(wfSchemeInfoId, schemeVersion);
  96. }
  97. catch (Exception)
  98. {
  99. throw;
  100. }
  101. }
  102. /// <summary>
  103. /// 获取权限列表数据
  104. /// </summary>
  105. /// <param name="schemeInfoId"></param>
  106. /// <returns></returns>
  107. public IEnumerable<WFSchemeInfoAuthorizeEntity> GetAuthorizeEntityList(string schemeInfoId)
  108. {
  109. return infoserver.GetAuthorizeEntityList(schemeInfoId);
  110. }
  111. #endregion
  112. #region 提交数据
  113. /// <summary>
  114. /// 删除流程
  115. /// </summary>
  116. /// <param name="keyValue">主键</param>
  117. public void RemoveForm(string keyValue)
  118. {
  119. IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();
  120. try
  121. {
  122. WFSchemeInfoEntity entity = db.FindEntity<WFSchemeInfoEntity>(keyValue);
  123. db.Delete<WFSchemeInfoEntity>(keyValue);
  124. var expression = LinqExtensions.True<WFSchemeContentEntity>();
  125. expression = expression.And(t => t.WFSchemeInfoId == entity.Id);
  126. db.Delete<WFSchemeContentEntity>(expression);
  127. db.Commit();
  128. }
  129. catch (Exception)
  130. {
  131. db.Rollback();
  132. throw;
  133. }
  134. }
  135. /// <summary>
  136. /// 保存流程
  137. /// </summary>
  138. /// <param name="entity">表单模板实体类</param>
  139. /// <param name="keyValue">主键</param>
  140. /// <returns></returns>
  141. public int SaveForm(string keyValue, WFSchemeInfoEntity entity, WFSchemeContentEntity modelentity, string[] shcemeAuthorizeData)
  142. {
  143. IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();
  144. try
  145. {
  146. if (string.IsNullOrEmpty(keyValue))
  147. {
  148. entity.Create();
  149. entity.SchemeVersion = DateTime.Now.ToString("yyyyMMddHHmmssffff");
  150. db.Insert<WFSchemeInfoEntity>(entity);
  151. modelentity.Create();
  152. modelentity.WFSchemeInfoId = entity.Id;
  153. modelentity.SchemeVersion = entity.SchemeVersion;
  154. db.Insert<WFSchemeContentEntity>(modelentity);
  155. }
  156. else
  157. {
  158. WFSchemeContentEntity modelentityold = schemeserver.GetEntity(keyValue, entity.SchemeVersion);
  159. if (modelentityold.SchemeContent != modelentity.SchemeContent)
  160. {
  161. if (modelentity.SchemeVersion == "cg")
  162. {
  163. modelentityold.SchemeContent = modelentity.SchemeContent;
  164. modelentityold.SchemeVersion = DateTime.Now.ToString("yyyyMMddHHmmssffff");
  165. modelentity.SchemeVersion = modelentityold.SchemeVersion;
  166. db.Update<WFSchemeContentEntity>(modelentityold);
  167. }
  168. else
  169. {
  170. modelentity.Create();
  171. modelentity.WFSchemeInfoId = keyValue;
  172. modelentity.SchemeVersion = DateTime.Now.ToString("yyyyMMddHHmmssffff");
  173. db.Insert<WFSchemeContentEntity>(modelentity);
  174. }
  175. }
  176. else
  177. {
  178. modelentity.SchemeVersion = modelentityold.SchemeVersion;
  179. }
  180. entity.Modify(keyValue);
  181. entity.SchemeVersion = modelentity.SchemeVersion;
  182. db.Update<WFSchemeInfoEntity>(entity);
  183. }
  184. db.Delete<WFSchemeInfoAuthorizeEntity>(entity.Id, "SchemeInfoId");
  185. foreach (string item in shcemeAuthorizeData)
  186. {
  187. if (item != "")
  188. {
  189. WFSchemeInfoAuthorizeEntity _authorizeEntity = new WFSchemeInfoAuthorizeEntity();
  190. _authorizeEntity.Create();
  191. _authorizeEntity.SchemeInfoId = entity.Id;
  192. _authorizeEntity.ObjectId = item;
  193. db.Insert(_authorizeEntity);
  194. }
  195. }
  196. db.Commit();
  197. return 1;
  198. }
  199. catch (Exception)
  200. {
  201. db.Rollback();
  202. throw;
  203. }
  204. }
  205. /// <summary>
  206. /// 更新流程模板状态(启用,停用)
  207. /// </summary>
  208. /// <param name="keyValue">主键</param>
  209. /// <param name="status">状态 1:启用;0.停用</param>
  210. public void UpdateState(string keyValue, int state)
  211. {
  212. try
  213. {
  214. infoserver.UpdateState(keyValue, state);
  215. }
  216. catch (Exception)
  217. {
  218. throw;
  219. }
  220. }
  221. #endregion
  222. }
  223. }