WFProcessInstanceService.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. using LeaRun.Application.Code;
  2. using LeaRun.Application.Entity.FlowManage;
  3. using LeaRun.Application.Entity.SystemManage;
  4. using LeaRun.Application.IService.FlowManage;
  5. using LeaRun.Application.IService.SystemManage;
  6. using LeaRun.Application.Service.SystemManage;
  7. using LeaRun.Data;
  8. using LeaRun.Data.Repository;
  9. using LeaRun.Util;
  10. using LeaRun.Util.FlowWork;
  11. using LeaRun.Util.Extension;
  12. using LeaRun.Util.WebControl;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Data;
  16. using System.Data.Common;
  17. using System.Text;
  18. namespace LeaRun.Application.Service.FlowManage
  19. {
  20. /// <summary>
  21. /// 版 本 6.1
  22. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  23. /// 创建人:陈彬彬
  24. /// 日 期:2016.03.18 15:54
  25. /// 描 述:工作流实例表操作
  26. /// </summary>
  27. public class WFProcessInstanceService : RepositoryFactory, WFProcessInstanceIService
  28. {
  29. private IDataBaseLinkService dataBaseLinkService = new DataBaseLinkService();
  30. #region 获取数据
  31. /// <summary>
  32. /// 获取流程监控数据(用于流程监控)
  33. /// </summary>
  34. /// <param name="pagination"></param>
  35. /// <param name="queryJson"></param>
  36. /// <returns></returns>
  37. public DataTable GetPageList(Pagination pagination, string queryJson)
  38. {
  39. try{
  40. var strSql = new StringBuilder();
  41. strSql.Append(@"SELECT
  42. w.Id,
  43. w.Code,
  44. w.CustomName,
  45. w.wfLevel,
  46. w.ActivityId,
  47. w.ActivityName,
  48. w.ActivityType,
  49. w.ProcessSchemeId,
  50. w.SchemeType,
  51. t2.ItemName AS SchemeTypeName,
  52. w.EnabledMark,
  53. w.CreateDate,
  54. w.CreateUserId,
  55. w.CreateUserName,
  56. w.Description,
  57. w.isFinish
  58. FROM
  59. WF_ProcessInstance w
  60. LEFT JOIN
  61. WF_ProcessScheme w1 ON w1.Id = w.ProcessSchemeId
  62. LEFT JOIN
  63. Base_DataItemDetail t2 ON t2.ItemDetailId = w.SchemeType
  64. WHERE w.EnabledMark != 3 ");//3表示草稿
  65. var parameter = new List<DbParameter>();
  66. var queryParam = queryJson.ToJObject();
  67. if (!queryParam["WFSchemeInfoId"].IsEmpty())
  68. {
  69. strSql.Append(" AND w1.WFSchemeInfoId = @WFSchemeInfoId ");
  70. parameter.Add(DbParameters.CreateDbParameter("@WFSchemeInfoId", queryParam["WFSchemeInfoId"].ToString()));
  71. }
  72. else if (!queryParam["Keyword"].IsEmpty())//关键字查询
  73. {
  74. string keyord = queryParam["Keyword"].ToString();
  75. strSql.Append(@" AND ( w.Code LIKE @keyword
  76. or w.CustomName LIKE @keyword
  77. or w.CreateUserName LIKE @keyword
  78. )");
  79. parameter.Add(DbParameters.CreateDbParameter("@keyword", '%' + keyord + '%'));
  80. }
  81. return this.BaseRepository().FindTable(strSql.ToString(), parameter.ToArray(), pagination);
  82. }
  83. catch {
  84. throw;
  85. }
  86. }
  87. /// <summary>
  88. /// 获取流程实例分页数据
  89. /// </summary>
  90. /// <param name="pagination">分页参数</param>
  91. /// <param name="queryJson">查询条件</param>
  92. /// <param name="type">3草稿</param>
  93. /// <returns></returns>
  94. public DataTable GetPageList(Pagination pagination, string queryJson,string type)
  95. {
  96. try
  97. {
  98. var strSql = new StringBuilder();
  99. strSql.Append(@"SELECT
  100. w.Id,
  101. w.Code,
  102. w.CustomName,
  103. w.wfLevel,
  104. w.ActivityId,
  105. w.ActivityName,
  106. w.ActivityType,
  107. w.ProcessSchemeId,
  108. w.SchemeType,
  109. t2.ItemName AS SchemeTypeName,
  110. w.EnabledMark,
  111. w.CreateDate,
  112. w.CreateUserId,
  113. w.CreateUserName,
  114. w.Description,
  115. w.isFinish
  116. FROM
  117. WF_ProcessInstance w
  118. LEFT JOIN
  119. Base_DataItemDetail t2 ON t2.ItemDetailId = w.SchemeType");//3表示草稿
  120. if (type == "3")
  121. {
  122. strSql.Append(@" WHERE w.EnabledMark = 3 AND w.isFinish != 2 ");
  123. }
  124. else
  125. {
  126. strSql.Append(@" WHERE w.EnabledMark != 3 AND w.isFinish != 2 ");
  127. }
  128. if (!OperatorProvider.Provider.Current().IsSystem)
  129. {
  130. strSql.Append(string.Format(" AND w.CreateUserId = '{0}' ", OperatorProvider.Provider.Current().UserId ));
  131. }
  132. var parameter = new List<DbParameter>();
  133. var queryParam = queryJson.ToJObject();
  134. if (!queryParam["SchemeType"].IsEmpty())
  135. {
  136. strSql.Append(" AND w.SchemeType = @SchemeType ");
  137. parameter.Add(DbParameters.CreateDbParameter("@SchemeType", queryParam["SchemeType"].ToString()));
  138. }
  139. else if (!queryParam["Keyword"].IsEmpty())//关键字查询
  140. {
  141. string keyord = queryParam["Keyword"].ToString();
  142. strSql.Append(@" AND ( w.Code LIKE @keyword
  143. or w.CustomName LIKE @keyword
  144. or w.CreateUserName LIKE @keyword
  145. )");
  146. parameter.Add(DbParameters.CreateDbParameter("@keyword", '%' + keyord + '%'));
  147. }
  148. return this.BaseRepository().FindTable(strSql.ToString(), parameter.ToArray(), pagination);
  149. }
  150. catch (Exception)
  151. {
  152. throw;
  153. }
  154. }
  155. /// <summary>
  156. /// 获取登录者需要处理的流程
  157. /// </summary>
  158. /// <param name="pagination"></param>
  159. /// <param name="queryJson"></param>
  160. /// <returns></returns>
  161. public DataTable GetToMeBeforePageList(Pagination pagination, string queryJson)
  162. {
  163. try
  164. {
  165. var strSql = new StringBuilder();
  166. strSql.Append(@"SELECT
  167. w.Id,
  168. w.Code,
  169. w.CustomName,
  170. w.ActivityId,
  171. w.ActivityName,
  172. w.ActivityType,
  173. w.ProcessSchemeId,
  174. w.SchemeType,
  175. t2.ItemName AS SchemeTypeName,
  176. w.MakerList,
  177. w.EnabledMark,
  178. w.CreateDate,
  179. w.CreateUserId,
  180. w.CreateUserName,
  181. w.isFinish,
  182. w.Description,
  183. w.wfLevel
  184. FROM
  185. WF_ProcessInstance w
  186. LEFT JOIN
  187. Base_DataItemDetail t2 ON t2.ItemDetailId = w.SchemeType
  188. WHERE w.EnabledMark = 1 AND w.isFinish = 0 ");
  189. var parameter = new List<DbParameter>();
  190. var queryParam = queryJson.ToJObject();
  191. if (!queryParam["SchemeType"].IsEmpty())
  192. {
  193. strSql.Append(" AND w.SchemeType = @SchemeType ");
  194. parameter.Add(DbParameters.CreateDbParameter("@SchemeType", queryParam["SchemeType"].ToString()));
  195. }
  196. else if (!queryParam["Keyword"].IsEmpty())//关键字查询
  197. {
  198. string keyord = queryParam["Keyword"].ToString();
  199. strSql.Append(@" AND ( w.Code LIKE @keyword
  200. or w.CustomName LIKE @keyword
  201. or w.CreateUserName LIKE @keyword
  202. )");
  203. parameter.Add(DbParameters.CreateDbParameter("@keyword", '%' + keyord + '%'));
  204. }
  205. strSql.Append(string.Format(@" AND ( w.MakerList LIKE '{0}' or w.MakerList = '1' ", OperatorProvider.Provider.Current().UserId));
  206. foreach (var objectid in OperatorProvider.Provider.Current().ObjectId.Split(','))
  207. {
  208. strSql.Append(string.Format(@" or w.MakerList LIKE '{0}' ", objectid ));
  209. }
  210. strSql.Append(")");
  211. return this.BaseRepository().FindTable(strSql.ToString(), parameter.ToArray(), pagination);
  212. }
  213. catch (Exception)
  214. {
  215. throw;
  216. }
  217. }
  218. /// <summary>
  219. /// 获取登录者已经处理的流程
  220. /// </summary>
  221. /// <param name="pagination"></param>
  222. /// <param name="queryJson"></param>
  223. /// <returns></returns>
  224. public DataTable GetToMeAfterPageList(Pagination pagination, string queryJson)
  225. {
  226. try
  227. {
  228. var strSql = new StringBuilder();
  229. strSql.Append(string.Format(@"SELECT
  230. w.Id,
  231. w.Code,
  232. w.CustomName,
  233. w.ActivityId,
  234. w.ActivityName,
  235. w.ActivityType,
  236. w.ProcessSchemeId,
  237. w.SchemeType,
  238. t2.ItemName AS SchemeTypeName,
  239. w.MakerList,
  240. w.EnabledMark,
  241. w.CreateDate,
  242. w.CreateUserId,
  243. w.CreateUserName,
  244. w2.Content,
  245. w.isFinish,
  246. w.Description,
  247. w.wfLevel
  248. FROM
  249. WF_ProcessInstance w
  250. LEFT JOIN Base_DataItemDetail t2 ON t2.ItemDetailId = w.SchemeType
  251. LEFT JOIN WF_ProcessOperationHistory w2 ON w2.ProcessId = w.Id
  252. WHERE
  253. w.EnabledMark = 1 AND w2.CreateUserId = '{0}' And w.CreateUserId != '{0}' ", OperatorProvider.Provider.Current().UserId));
  254. var parameter = new List<DbParameter>();
  255. var queryParam = queryJson.ToJObject();
  256. if (!queryParam["SchemeType"].IsEmpty())
  257. {
  258. strSql.Append(" AND w.SchemeType = @SchemeType ");
  259. parameter.Add(DbParameters.CreateDbParameter("@SchemeType", queryParam["SchemeType"].ToString()));
  260. }
  261. else if (!queryParam["Keyword"].IsEmpty())//关键字查询
  262. {
  263. string keyord = queryParam["Keyword"].ToString();
  264. strSql.Append(@" AND ( w.Code LIKE @keyword
  265. or w.CustomName LIKE @keyword
  266. or w.CreateUserName LIKE @keyword
  267. )");
  268. parameter.Add(DbParameters.CreateDbParameter("@keyword", '%' + keyord + '%'));
  269. }
  270. return this.BaseRepository().FindTable(strSql.ToString(), parameter.ToArray(), pagination);
  271. }
  272. catch (Exception)
  273. {
  274. throw;
  275. }
  276. }
  277. /// <summary>
  278. /// 获取实例进程信息实体
  279. /// </summary>
  280. /// <param name="keyVlaue"></param>
  281. /// <returns></returns>
  282. public WFProcessInstanceEntity GetEntity(string keyVlaue)
  283. {
  284. try
  285. {
  286. return this.BaseRepository().FindEntity<WFProcessInstanceEntity>(keyVlaue);
  287. }
  288. catch
  289. {
  290. throw;
  291. }
  292. }
  293. #endregion
  294. #region 提交数据
  295. /// <summary>
  296. /// 存储工作流实例进程(编辑草稿用)
  297. /// </summary>
  298. /// <param name="processInstanceEntity"></param>
  299. /// <param name="processSchemeEntity"></param>
  300. /// <param name="wfOperationHistoryEntity"></param>
  301. /// <returns></returns>
  302. public int SaveProcess(string processId, WFProcessInstanceEntity processInstanceEntity, WFProcessSchemeEntity processSchemeEntity, WFProcessOperationHistoryEntity wfOperationHistoryEntity = null)
  303. {
  304. IRepository db = this.BaseRepository().BeginTrans();
  305. try
  306. {
  307. if (string.IsNullOrEmpty(processInstanceEntity.Id))
  308. {
  309. processSchemeEntity.Create();
  310. db.Insert(processSchemeEntity);
  311. processInstanceEntity.Create();
  312. processInstanceEntity.Id = processId;
  313. processInstanceEntity.ProcessSchemeId = processSchemeEntity.Id;
  314. db.Insert(processInstanceEntity);
  315. }
  316. else
  317. {
  318. processInstanceEntity.Modify(processId);
  319. db.Update(processInstanceEntity);
  320. processSchemeEntity.Modify(processInstanceEntity.ProcessSchemeId);
  321. db.Update(processSchemeEntity);
  322. }
  323. if (wfOperationHistoryEntity != null)
  324. {
  325. wfOperationHistoryEntity.Create();
  326. wfOperationHistoryEntity.ProcessId = processId;
  327. db.Insert(wfOperationHistoryEntity);
  328. }
  329. db.Commit();
  330. return 1;
  331. }
  332. catch
  333. {
  334. db.Rollback();
  335. throw;
  336. }
  337. }
  338. /// <summary>
  339. /// 存储工作流实例进程(创建实例进程)
  340. /// </summary>
  341. /// <param name="wfRuntimeModel"></param>
  342. /// <param name="processInstanceEntity"></param>
  343. /// <param name="processSchemeEntity"></param>
  344. /// <param name="processOperationHistoryEntity"></param>
  345. /// <param name="delegateRecordEntity"></param>
  346. /// <returns></returns>
  347. public int SaveProcess(WF_RuntimeModel wfRuntimeModel, WFProcessInstanceEntity processInstanceEntity, WFProcessSchemeEntity processSchemeEntity, WFProcessOperationHistoryEntity processOperationHistoryEntity, WFProcessTransitionHistoryEntity processTransitionHistoryEntity, List<WFDelegateRecordEntity> delegateRecordEntityList)
  348. {
  349. IRepository db = this.BaseRepository().BeginTrans();
  350. try
  351. {
  352. if (string.IsNullOrEmpty(processInstanceEntity.Id))
  353. {
  354. processSchemeEntity.Create();
  355. db.Insert(processSchemeEntity);
  356. processInstanceEntity.Create();
  357. processInstanceEntity.Id = wfRuntimeModel.processId;
  358. processInstanceEntity.ProcessSchemeId = processSchemeEntity.Id;
  359. db.Insert(processInstanceEntity);
  360. }
  361. else
  362. {
  363. processInstanceEntity.Modify(processInstanceEntity.Id);
  364. db.Update(processSchemeEntity);
  365. db.Update(processInstanceEntity);
  366. }
  367. processOperationHistoryEntity.Create();
  368. processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
  369. db.Insert(processOperationHistoryEntity);
  370. if (processTransitionHistoryEntity != null)
  371. {
  372. processTransitionHistoryEntity.Create();
  373. processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
  374. db.Insert(processTransitionHistoryEntity);
  375. }
  376. foreach (var item in delegateRecordEntityList)
  377. {
  378. item.Create();
  379. item.ProcessId = processInstanceEntity.Id;
  380. db.Insert(item);
  381. }
  382. if (processInstanceEntity.FrmType == 0)
  383. {
  384. DataBaseLinkEntity dataBaseLinkEntity = dataBaseLinkService.GetEntity(wfRuntimeModel.schemeContentJson.Frm.FrmDbId.Value);//获取
  385. if (wfRuntimeModel.schemeContentJson.Frm.isSystemTable.Value != 0)
  386. {
  387. this.BaseRepository(dataBaseLinkEntity.DbConnection).ExecuteBySql(wfRuntimeModel.sqlFrm);
  388. }
  389. }
  390. db.Commit();
  391. return 1;
  392. }
  393. catch
  394. {
  395. db.Rollback();
  396. throw;
  397. }
  398. }
  399. /// <summary>
  400. /// 存储工作流实例进程(审核驳回重新提交)
  401. /// </summary>
  402. /// <param name="processInstanceEntity"></param>
  403. /// <param name="processSchemeEntity"></param>
  404. /// <param name="processOperationHistoryEntity"></param>
  405. /// <param name="processTransitionHistoryEntity"></param>
  406. /// <returns></returns>
  407. public int SaveProcess(WFProcessInstanceEntity processInstanceEntity, WFProcessSchemeEntity processSchemeEntity, WFProcessOperationHistoryEntity processOperationHistoryEntity, List<WFDelegateRecordEntity> delegateRecordEntityList, WFProcessTransitionHistoryEntity processTransitionHistoryEntity = null)
  408. {
  409. IRepository db = this.BaseRepository().BeginTrans();
  410. try
  411. {
  412. processInstanceEntity.Modify(processInstanceEntity.Id);
  413. db.Update(processSchemeEntity);
  414. db.Update(processInstanceEntity);
  415. processOperationHistoryEntity.Create();
  416. processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
  417. db.Insert(processOperationHistoryEntity);
  418. if (processTransitionHistoryEntity != null)
  419. {
  420. processTransitionHistoryEntity.Create();
  421. processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
  422. db.Insert(processTransitionHistoryEntity);
  423. }
  424. if (delegateRecordEntityList != null)
  425. {
  426. foreach (var item in delegateRecordEntityList)
  427. {
  428. item.Create();
  429. item.ProcessId = processInstanceEntity.Id;
  430. db.Insert(item);
  431. }
  432. }
  433. db.Commit();
  434. return 1;
  435. }
  436. catch
  437. {
  438. db.Rollback();
  439. throw;
  440. }
  441. }
  442. /// <summary>
  443. /// 更新流程实例 审核节点用
  444. /// </summary>
  445. /// <param name="sql"></param>
  446. /// <param name="dbbaseId"></param>
  447. /// <param name="processInstanceEntity"></param>
  448. /// <param name="processSchemeEntity"></param>
  449. /// <param name="processOperationHistoryEntity"></param>
  450. /// <param name="delegateRecordEntityList"></param>
  451. /// <param name="processTransitionHistoryEntity"></param>
  452. /// <returns></returns>
  453. public int SaveProcess(string sql,string dbbaseId, WFProcessInstanceEntity processInstanceEntity, WFProcessSchemeEntity processSchemeEntity, WFProcessOperationHistoryEntity processOperationHistoryEntity, List<WFDelegateRecordEntity> delegateRecordEntityList, WFProcessTransitionHistoryEntity processTransitionHistoryEntity = null)
  454. {
  455. IRepository db = this.BaseRepository().BeginTrans();
  456. try
  457. {
  458. processInstanceEntity.Modify(processInstanceEntity.Id);
  459. db.Update(processSchemeEntity);
  460. db.Update(processInstanceEntity);
  461. processOperationHistoryEntity.Create();
  462. processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
  463. db.Insert(processOperationHistoryEntity);
  464. if (processTransitionHistoryEntity != null)
  465. {
  466. processTransitionHistoryEntity.Create();
  467. processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
  468. db.Insert(processTransitionHistoryEntity);
  469. }
  470. if (delegateRecordEntityList != null)
  471. {
  472. foreach (var item in delegateRecordEntityList)
  473. {
  474. item.Create();
  475. item.ProcessId = processInstanceEntity.Id;
  476. db.Insert(item);
  477. }
  478. }
  479. //if (!string.IsNullOrEmpty(dbbaseId) && !string.IsNullOrEmpty(sql))//测试环境不允许执行sql语句
  480. //{
  481. // DataBaseLinkEntity dataBaseLinkEntity = dataBaseLinkService.GetEntity(dbbaseId);//获取
  482. // this.BaseRepository(dataBaseLinkEntity.DbConnection).ExecuteBySql(sql.Replace("{0}", processInstanceEntity.Id));
  483. //}
  484. db.Commit();
  485. return 1;
  486. }
  487. catch
  488. {
  489. db.Rollback();
  490. throw;
  491. }
  492. }
  493. /// <summary>
  494. /// 保存工作流进程实例
  495. /// </summary>
  496. /// <param name="processInstanceEntity"></param>
  497. /// <returns></returns>
  498. public int SaveProcess(WFProcessInstanceEntity processInstanceEntity)
  499. {
  500. try
  501. {
  502. int num;
  503. WFProcessInstanceEntity isExistEntity = this.BaseRepository().FindEntity<WFProcessInstanceEntity>(processInstanceEntity.Id);
  504. if (isExistEntity == null)
  505. {
  506. processInstanceEntity.Create();
  507. num = this.BaseRepository().Insert(processInstanceEntity);
  508. }
  509. else
  510. {
  511. processInstanceEntity.Modify(processInstanceEntity.Id);
  512. num = this.BaseRepository().Update(processInstanceEntity);
  513. }
  514. return num;
  515. }
  516. catch
  517. {
  518. throw;
  519. }
  520. }
  521. /// <summary>
  522. /// 删除工作流实例进程(删除草稿使用)
  523. /// </summary>
  524. /// <param name="keyValue">主键</param>
  525. /// <returns></returns>
  526. public int DeleteProcess(string keyValue)
  527. {
  528. IRepository db = this.BaseRepository().BeginTrans();
  529. try
  530. {
  531. WFProcessInstanceEntity entity = this.BaseRepository().FindEntity<WFProcessInstanceEntity>(keyValue);
  532. db.Delete<WFProcessSchemeEntity>(entity.ProcessSchemeId);
  533. db.Delete<WFProcessInstanceEntity>(keyValue);
  534. db.Commit();
  535. return 1;
  536. }
  537. catch {
  538. db.Rollback();
  539. throw;
  540. }
  541. }
  542. /// <summary>
  543. /// 虚拟操作实例
  544. /// </summary>
  545. /// <param name="keyValue"></param>
  546. /// <param name="state">0暂停,1启用,2取消(召回)</param>
  547. /// <returns></returns>
  548. public int OperateVirtualProcess(string keyValue,int state)
  549. {
  550. IRepository db = this.BaseRepository().BeginTrans();
  551. try
  552. {
  553. WFProcessInstanceEntity entity = this.BaseRepository().FindEntity<WFProcessInstanceEntity>(keyValue);
  554. if (entity.isFinish == 1)
  555. {
  556. throw new Exception("实例已经审核完成,操作失败");
  557. }
  558. else if (entity.isFinish == 2)
  559. {
  560. throw new Exception("实例已经取消,操作失败");
  561. }
  562. /// 流程是否完成(0运行中,1运行结束,2被召回,3不同意,4表示被驳回)
  563. string content = "";
  564. switch (state)
  565. {
  566. case 0:
  567. if (entity.EnabledMark == 0)
  568. {
  569. return 1;
  570. }
  571. entity.EnabledMark = 0;
  572. content = "【暂停】" + OperatorProvider.Provider.Current().UserName + "暂停了一个流程进程【" + entity.Code + "/" + entity.CustomName + "】";
  573. break;
  574. case 1:
  575. if (entity.EnabledMark == 1)
  576. {
  577. return 1;
  578. }
  579. entity.EnabledMark = 1;
  580. content = "【启用】" + OperatorProvider.Provider.Current().UserName + "启用了一个流程进程【" + entity.Code + "/" + entity.CustomName + "】";
  581. break;
  582. case 2:
  583. entity.isFinish = 2;
  584. content = "【召回】" + OperatorProvider.Provider.Current().UserName + "召回了一个流程进程【" + entity.Code + "/" + entity.CustomName + "】";
  585. break;
  586. }
  587. db.Update<WFProcessInstanceEntity>(entity);
  588. WFProcessOperationHistoryEntity processOperationHistoryEntity = new WFProcessOperationHistoryEntity();
  589. processOperationHistoryEntity.Create();
  590. processOperationHistoryEntity.ProcessId = entity.Id;
  591. processOperationHistoryEntity.Content = content;
  592. db.Insert(processOperationHistoryEntity);
  593. db.Commit();
  594. return 1;
  595. }
  596. catch
  597. {
  598. db.Rollback();
  599. throw;
  600. }
  601. }
  602. /// <summary>
  603. /// 流程指派
  604. /// </summary>
  605. /// <param name="processId"></param>
  606. /// <param name="makeLists"></param>
  607. public void DesignateProcess(string processId, string makeLists)
  608. {
  609. try
  610. {
  611. WFProcessInstanceEntity entity = new WFProcessInstanceEntity();
  612. entity.Id = processId;
  613. entity.MakerList = makeLists;
  614. this.BaseRepository().Update(entity);
  615. }
  616. catch {
  617. throw;
  618. }
  619. }
  620. #endregion
  621. }
  622. }