WFRuntimeService.cs 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046
  1. using LeaRun.Application.Code;
  2. using LeaRun.Application.Entity.BaseManage;
  3. using LeaRun.Application.Entity.FlowManage;
  4. using LeaRun.Application.Entity.SystemManage;
  5. using LeaRun.Application.IService.BaseManage;
  6. using LeaRun.Application.IService.FlowManage;
  7. using LeaRun.Application.IService.SystemManage;
  8. using LeaRun.Application.Service.BaseManage;
  9. using LeaRun.Application.Service.SystemManage;
  10. using LeaRun.Data.Repository;
  11. using LeaRun.Util;
  12. using LeaRun.Util.FlowWork;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Data;
  16. namespace LeaRun.Application.Service.FlowManage
  17. {
  18. /// <summary>
  19. /// 版 本 6.1
  20. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  21. /// 创建人:陈彬彬
  22. /// 日 期:2016.04.12 15:54
  23. /// 描 述:工作流运行实例处理方法类
  24. /// </summary>
  25. public class WFRuntimeService :RepositoryFactory, WFRuntimeIService
  26. {
  27. private WFSchemeInfoIService wfSchemeInfoService = new WFSchemeInfoService();
  28. private WFSchemeContentIService wfSchemeContentService = new WFSchemeContentService();
  29. private WFProcessInstanceIService wfProcessInstanceService = new WFProcessInstanceService();
  30. private WFProcessSchemeIService wfProcessSchemeService = new WFProcessSchemeService();
  31. private WFProcessOperationHistoryIService wfProcessOperationHistoryService = new WFProcessOperationHistoryService();
  32. private WFProcessTransitionHistoryIService wfProcessTransitionHistoryService = new WFProcessTransitionHistoryService();
  33. private WFDelegateRuleIService wfDelegateRuleService = new WFDelegateRuleService();
  34. private IUserService userService = new UserService();//用户数据库操作类
  35. private IDepartmentService departmentService = new DepartmentService();
  36. private IOrganizeService organizeService = new OrganizeService();
  37. private IDataBaseLinkService dataBaseLinkService = new DataBaseLinkService();
  38. private string delegateUserList = "";
  39. #region 流程处理API
  40. /// <summary>
  41. /// 创建一个实例
  42. /// </summary>
  43. /// <param name="processId">进程GUID</param>
  44. /// <param name="schemeInfoId">模板信息ID</param>
  45. /// <param name="wfLevel"></param>
  46. /// <param name="code">进程编号</param>
  47. /// <param name="customName">自定义名称</param>
  48. /// <param name="description">备注</param>
  49. /// <param name="frmData">表单数据信息</param>
  50. /// <returns></returns>
  51. public bool CreateInstance(Guid processId, string schemeInfoId, WFProcessInstanceEntity wfProcessInstanceEntity, string frmData = null)
  52. {
  53. try
  54. {
  55. WFSchemeInfoEntity wfSchemeInfoEntity = wfSchemeInfoService.GetEntity(schemeInfoId);
  56. WFSchemeContentEntity wfSchemeContentEntity = wfSchemeContentService.GetEntity(schemeInfoId, wfSchemeInfoEntity.SchemeVersion);
  57. WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
  58. {
  59. schemeContent = wfSchemeContentEntity.SchemeContent,
  60. currentNodeId = "",
  61. frmData = frmData,
  62. processId = processId.ToString()
  63. };
  64. IWF_Runtime wfruntime = null;
  65. if (wfSchemeInfoEntity.FrmType == 0)
  66. {
  67. if(frmData == null)
  68. {
  69. throw new Exception("自定义表单需要提交表单数据");
  70. }
  71. else
  72. {
  73. wfruntime = new WF_Runtime(wfRuntimeInitModel);
  74. }
  75. }
  76. else
  77. {
  78. wfruntime = new WF_Runtime(wfRuntimeInitModel, GetFrmData);
  79. }
  80. #region 实例信息
  81. wfProcessInstanceEntity.ActivityId = wfruntime.runtimeModel.nextNodeId;
  82. wfProcessInstanceEntity.ActivityType = wfruntime.GetStatus();//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
  83. wfProcessInstanceEntity.ActivityName = wfruntime.runtimeModel.nextNode.name;
  84. wfProcessInstanceEntity.PreviousId = wfruntime.runtimeModel.currentNodeId;
  85. wfProcessInstanceEntity.SchemeType = wfSchemeInfoEntity.SchemeType;
  86. wfProcessInstanceEntity.FrmType = wfSchemeInfoEntity.FrmType;
  87. wfProcessInstanceEntity.EnabledMark = 1;//正式运行
  88. wfProcessInstanceEntity.MakerList =(wfruntime.GetStatus() != 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
  89. wfProcessInstanceEntity.isFinish = (wfruntime.GetStatus() == 4 ? 1 : 0);
  90. #endregion
  91. #region 实例模板
  92. var data = new
  93. {
  94. SchemeContent = wfSchemeContentEntity.SchemeContent,
  95. frmData = frmData
  96. };
  97. WFProcessSchemeEntity wfProcessSchemeEntity = new WFProcessSchemeEntity {
  98. WFSchemeInfoId = schemeInfoId,
  99. SchemeVersion = wfSchemeInfoEntity.SchemeVersion,
  100. ProcessType = 1,//1正式,0草稿
  101. SchemeContent = data.ToJson().ToString()
  102. };
  103. #endregion
  104. #region 流程操作记录
  105. WFProcessOperationHistoryEntity processOperationHistoryEntity = new WFProcessOperationHistoryEntity();
  106. processOperationHistoryEntity.Content = "【创建】" + OperatorProvider.Provider.Current().UserName + "创建了一个流程进程【" + wfProcessInstanceEntity.Code + "/" + wfProcessInstanceEntity.CustomName + "】";
  107. #endregion
  108. #region 流转记录
  109. WFProcessTransitionHistoryEntity processTransitionHistoryEntity = new WFProcessTransitionHistoryEntity();
  110. processTransitionHistoryEntity.fromNodeId = wfruntime.runtimeModel.currentNodeId;
  111. processTransitionHistoryEntity.fromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
  112. processTransitionHistoryEntity.fromNodeType = wfruntime.runtimeModel.currentNodeType;
  113. processTransitionHistoryEntity.toNodeId = wfruntime.runtimeModel.nextNodeId;
  114. processTransitionHistoryEntity.toNodeName = wfruntime.runtimeModel.nextNode.name.Value;
  115. processTransitionHistoryEntity.toNodeType = wfruntime.runtimeModel.nextNodeType;
  116. processTransitionHistoryEntity.TransitionSate =0;
  117. processTransitionHistoryEntity.isFinish = (processTransitionHistoryEntity.toNodeType == 4 ? 1 : 0);
  118. #endregion
  119. #region 委托记录
  120. List<WFDelegateRecordEntity> delegateRecordEntitylist = GetDelegateRecordList(schemeInfoId, wfProcessInstanceEntity.Code, wfProcessInstanceEntity.CustomName, wfProcessInstanceEntity.MakerList);
  121. wfProcessInstanceEntity.MakerList += delegateUserList;
  122. #endregion
  123. wfProcessInstanceService.SaveProcess(wfruntime.runtimeModel, wfProcessInstanceEntity, wfProcessSchemeEntity, processOperationHistoryEntity, processTransitionHistoryEntity, delegateRecordEntitylist);
  124. return true;
  125. }
  126. catch
  127. {
  128. throw;
  129. }
  130. }
  131. /// <summary>
  132. /// 创建一个实例(草稿创建)
  133. /// </summary>
  134. /// <param name="processId"></param>
  135. /// <param name="code"></param>
  136. /// <param name="customName"></param>
  137. /// <param name="description"></param>
  138. /// <param name="frmData"></param>
  139. /// <returns></returns>
  140. public bool CreateInstance(WFProcessInstanceEntity wfProcessInstanceEntity, string frmData = null)
  141. {
  142. try
  143. {
  144. WFProcessInstanceEntity _wfProcessInstanceEntity = wfProcessInstanceService.GetEntity(wfProcessInstanceEntity.Id);
  145. WFProcessSchemeEntity wfProcessSchemeEntity = wfProcessSchemeService.GetEntity(wfProcessInstanceEntity.ProcessSchemeId);
  146. dynamic schemeContentJson = wfProcessSchemeEntity.SchemeContent.ToJson();//获取工作流模板内容的json对象;
  147. WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
  148. {
  149. schemeContent = schemeContentJson.SchemeContent.Value,
  150. currentNodeId = "",
  151. frmData = frmData,
  152. processId = wfProcessSchemeEntity.Id
  153. };
  154. IWF_Runtime wfruntime = null;
  155. if (_wfProcessInstanceEntity.FrmType == 0)
  156. {
  157. if (frmData == null)
  158. {
  159. throw new Exception("自定义表单需要提交表单数据");
  160. }
  161. else
  162. {
  163. wfruntime = new WF_Runtime(wfRuntimeInitModel);
  164. }
  165. }
  166. else
  167. {
  168. wfruntime = new WF_Runtime(wfRuntimeInitModel, GetFrmData);
  169. }
  170. #region 实例信息
  171. wfProcessInstanceEntity.ActivityId = wfruntime.runtimeModel.nextNodeId;
  172. wfProcessInstanceEntity.ActivityType = wfruntime.GetStatus();//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
  173. wfProcessInstanceEntity.ActivityName = wfruntime.runtimeModel.nextNode.name;
  174. wfProcessInstanceEntity.PreviousId = wfruntime.runtimeModel.currentNodeId;
  175. wfProcessInstanceEntity.EnabledMark = 1;//正式运行
  176. wfProcessInstanceEntity.MakerList = (wfruntime.GetStatus() != 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
  177. wfProcessInstanceEntity.isFinish = (wfruntime.GetStatus() == 4 ? 1 : 0);
  178. #endregion
  179. #region 实例模板
  180. var data = new
  181. {
  182. SchemeContent = schemeContentJson.SchemeContent.Value,
  183. frmData = frmData
  184. };
  185. wfProcessSchemeEntity.ProcessType = 1;//1正式,0草稿
  186. wfProcessSchemeEntity.SchemeContent = data.ToJson().ToString();
  187. #endregion
  188. #region 流程操作记录
  189. WFProcessOperationHistoryEntity processOperationHistoryEntity = new WFProcessOperationHistoryEntity();
  190. processOperationHistoryEntity.Content = "【创建】" + OperatorProvider.Provider.Current().UserName + "创建了一个流程进程【" + wfProcessInstanceEntity.Code + "/" + wfProcessInstanceEntity.CustomName + "】";
  191. #endregion
  192. #region 流转记录
  193. WFProcessTransitionHistoryEntity processTransitionHistoryEntity = new WFProcessTransitionHistoryEntity();
  194. processTransitionHistoryEntity.fromNodeId = wfruntime.runtimeModel.currentNodeId;
  195. processTransitionHistoryEntity.fromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
  196. processTransitionHistoryEntity.fromNodeType = wfruntime.runtimeModel.currentNodeType;
  197. processTransitionHistoryEntity.toNodeId = wfruntime.runtimeModel.nextNodeId;
  198. processTransitionHistoryEntity.toNodeName = wfruntime.runtimeModel.nextNode.name.Value;
  199. processTransitionHistoryEntity.toNodeType = wfruntime.runtimeModel.nextNodeType;
  200. processTransitionHistoryEntity.TransitionSate = 0;
  201. processTransitionHistoryEntity.isFinish = (processTransitionHistoryEntity.toNodeType == 4 ? 1 : 0);
  202. #endregion
  203. #region 委托记录
  204. List<WFDelegateRecordEntity> delegateRecordEntitylist = GetDelegateRecordList(wfProcessSchemeEntity.WFSchemeInfoId, wfProcessInstanceEntity.Code, wfProcessInstanceEntity.CustomName, wfProcessInstanceEntity.MakerList);
  205. wfProcessInstanceEntity.MakerList += delegateUserList;
  206. #endregion
  207. wfProcessInstanceService.SaveProcess(wfruntime.runtimeModel, wfProcessInstanceEntity, wfProcessSchemeEntity, processOperationHistoryEntity, processTransitionHistoryEntity, delegateRecordEntitylist);
  208. return true;
  209. }
  210. catch
  211. {
  212. throw;
  213. }
  214. }
  215. /// <summary>
  216. /// 编辑表单再次提交(驳回后处理)
  217. /// </summary>
  218. /// <param name="processId"></param>
  219. /// <param name="description"></param>
  220. /// <param name="frmData"></param>
  221. /// <returns></returns>
  222. public bool EditionInstance(string processId, string description, string frmData = null)
  223. {
  224. try
  225. {
  226. WFProcessInstanceEntity wfProcessInstanceEntity = wfProcessInstanceService.GetEntity(processId);
  227. WFProcessSchemeEntity wfProcessSchemeEntity = wfProcessSchemeService.GetEntity(wfProcessInstanceEntity.ProcessSchemeId);
  228. dynamic schemeContentJson = wfProcessSchemeEntity.SchemeContent.ToJson();//获取工作流模板内容的json对象;
  229. var data = new
  230. {
  231. SchemeContent = schemeContentJson.SchemeContent.Value,
  232. frmData = frmData
  233. };
  234. wfProcessSchemeEntity.SchemeContent = data.ToJson().ToString();
  235. wfProcessInstanceEntity.isFinish = 0;
  236. if (string.IsNullOrEmpty(description))
  237. {
  238. wfProcessInstanceEntity.Description = description;
  239. }
  240. wfProcessInstanceEntity.CreateDate = DateTime.Now;
  241. #region 流程操作记录
  242. WFProcessOperationHistoryEntity processOperationHistoryEntity = new WFProcessOperationHistoryEntity();
  243. processOperationHistoryEntity.Content = "【创建】" + OperatorProvider.Provider.Current().UserName + "创建了一个流程进程【" + wfProcessInstanceEntity.Code + "/" + wfProcessInstanceEntity.CustomName + "】";
  244. #endregion
  245. #region 委托记录
  246. List<WFDelegateRecordEntity> delegateRecordEntitylist = GetDelegateRecordList(wfProcessSchemeEntity.WFSchemeInfoId, wfProcessInstanceEntity.Code, wfProcessInstanceEntity.CustomName, wfProcessInstanceEntity.MakerList);
  247. wfProcessInstanceEntity.MakerList += delegateUserList;
  248. #endregion
  249. wfProcessInstanceService.SaveProcess(wfProcessInstanceEntity, wfProcessSchemeEntity, processOperationHistoryEntity, delegateRecordEntitylist);
  250. return true;
  251. }
  252. catch
  253. {
  254. throw;
  255. }
  256. }
  257. /// <summary>
  258. /// 创建一个草稿
  259. /// </summary>
  260. /// <param name="processId"></param>
  261. /// <param name="schemeInfoId"></param>
  262. /// <param name="wfLevel"></param>
  263. /// <param name="code"></param>
  264. /// <param name="customName"></param>
  265. /// <param name="description"></param>
  266. /// <param name="frmData"></param>
  267. /// <returns></returns>
  268. public bool CreateRoughdraft(Guid processId, string schemeInfoId, WFProcessInstanceEntity wfProcessInstanceEntity, string frmData = null)
  269. {
  270. try
  271. {
  272. WFSchemeInfoEntity wfSchemeInfoEntity = wfSchemeInfoService.GetEntity(schemeInfoId);
  273. WFSchemeContentEntity wfSchemeContentEntity = wfSchemeContentService.GetEntity(schemeInfoId, wfSchemeInfoEntity.SchemeVersion);
  274. wfProcessInstanceEntity.ActivityId = "";
  275. wfProcessInstanceEntity.ActivityName = "";
  276. wfProcessInstanceEntity.ActivityType = 0;//开始节点
  277. wfProcessInstanceEntity.isFinish = 0;
  278. wfProcessInstanceEntity.SchemeType = wfSchemeInfoEntity.SchemeType;
  279. wfProcessInstanceEntity.EnabledMark = 3;//草稿
  280. wfProcessInstanceEntity.CreateDate = DateTime.Now;
  281. wfProcessInstanceEntity.FrmType = wfSchemeInfoEntity.FrmType;
  282. WFProcessSchemeEntity wfProcessSchemeEntity = new WFProcessSchemeEntity();
  283. wfProcessSchemeEntity.WFSchemeInfoId = schemeInfoId;
  284. wfProcessSchemeEntity.SchemeVersion = wfSchemeInfoEntity.SchemeVersion;
  285. wfProcessSchemeEntity.ProcessType = wfProcessInstanceEntity.EnabledMark;
  286. var data = new
  287. {
  288. SchemeContent = wfSchemeContentEntity.SchemeContent,
  289. frmData = frmData
  290. };
  291. wfProcessSchemeEntity.SchemeContent = data.ToJson().ToString();
  292. wfProcessInstanceService.SaveProcess(processId.ToString(),wfProcessInstanceEntity, wfProcessSchemeEntity);
  293. return true;
  294. }
  295. catch
  296. {
  297. throw;
  298. }
  299. }
  300. /// <summary>
  301. /// 创建一个草稿
  302. /// </summary>
  303. /// <param name="wfProcessInstanceEntity"></param>
  304. /// <param name="frmData"></param>
  305. /// <returns></returns>
  306. public bool EditionRoughdraft(WFProcessInstanceEntity wfProcessInstanceEntity, string frmData = null)
  307. {
  308. try
  309. {
  310. WFProcessSchemeEntity wfProcessSchemeEntity = wfProcessSchemeService.GetEntity(wfProcessInstanceEntity.ProcessSchemeId);
  311. dynamic schemeContentJson = wfProcessSchemeEntity.SchemeContent.ToJson();//获取工作流模板内容的json对象;
  312. var data = new
  313. {
  314. SchemeContent = schemeContentJson.SchemeContent.Value,
  315. frmData = frmData
  316. };
  317. wfProcessSchemeEntity.SchemeContent = data.ToJson().ToString();
  318. wfProcessInstanceEntity.isFinish = 0;
  319. wfProcessInstanceEntity.CreateDate = DateTime.Now;
  320. wfProcessInstanceService.SaveProcess(wfProcessInstanceEntity.Id,wfProcessInstanceEntity, wfProcessSchemeEntity);
  321. return true;
  322. }
  323. catch
  324. {
  325. throw;
  326. }
  327. }
  328. /// <summary>
  329. /// 节点审核
  330. /// </summary>
  331. /// <param name="processId"></param>
  332. /// <returns></returns>
  333. public bool NodeVerification(string processId, bool flag, string description = "")
  334. {
  335. bool _res = false;
  336. try
  337. {
  338. string _sqlstr="", _dbbaseId="";
  339. WFProcessInstanceEntity wfProcessInstanceEntity = wfProcessInstanceService.GetEntity(processId);
  340. WFProcessSchemeEntity wfProcessSchemeEntity = wfProcessSchemeService.GetEntity(wfProcessInstanceEntity.ProcessSchemeId);
  341. WFProcessOperationHistoryEntity wfProcessOperationHistoryEntity = new WFProcessOperationHistoryEntity();//操作记录
  342. WFProcessTransitionHistoryEntity processTransitionHistoryEntity = null;//流转记录
  343. List<WFDelegateRecordEntity> delegateRecordEntitylist = new List<WFDelegateRecordEntity>();//委托记录
  344. dynamic schemeContentJson = wfProcessSchemeEntity.SchemeContent.ToJson();//获取工作流模板内容的json对象;
  345. WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
  346. {
  347. schemeContent = schemeContentJson.SchemeContent.Value,
  348. currentNodeId = wfProcessInstanceEntity.ActivityId,
  349. frmData = schemeContentJson.frmData.Value,
  350. previousId = wfProcessInstanceEntity.PreviousId,
  351. processId = processId
  352. };
  353. IWF_Runtime wfruntime = null;
  354. if (wfProcessInstanceEntity.FrmType == 0)//自定义表单
  355. {
  356. wfruntime = new WF_Runtime(wfRuntimeInitModel);
  357. }
  358. else
  359. {
  360. wfruntime = new WF_Runtime(wfRuntimeInitModel, GetFrmData);
  361. }
  362. #region 会签
  363. if (wfProcessInstanceEntity.ActivityType == 0)//会签
  364. {
  365. wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 1,"");//标记当前节点通过
  366. ///寻找需要审核的节点Id
  367. string _VerificationNodeId = "";
  368. List<string> _nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.currentNodeId);
  369. string _makerList = "";
  370. foreach (string item in _nodelist)
  371. {
  372. _makerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[item], wfruntime.runtimeModel.processId);
  373. if (_makerList != "-1")
  374. {
  375. foreach (string one in _makerList.Split(','))
  376. {
  377. if (OperatorProvider.Provider.Current().UserId == one || OperatorProvider.Provider.Current().ObjectId.IndexOf(one) != -1)
  378. {
  379. _VerificationNodeId = item;
  380. break;
  381. }
  382. }
  383. }
  384. }
  385. if (_VerificationNodeId != "")
  386. {
  387. if (flag)
  388. {
  389. wfProcessOperationHistoryEntity.Content = "【" + OperatorProvider.Provider.Current().UserName + "】【" + wfruntime.runtimeModel.nodeDictionary[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
  390. }
  391. else
  392. {
  393. wfProcessOperationHistoryEntity.Content = "【" + OperatorProvider.Provider.Current().UserName + "】【" + wfruntime.runtimeModel.nodeDictionary[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description;
  394. }
  395. string _Confluenceres = wfruntime.NodeConfluence(_VerificationNodeId, flag, OperatorProvider.Provider.Current().UserId, description);
  396. var _data = new {
  397. SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
  398. frmData = (wfProcessInstanceEntity.FrmType == 0?wfruntime.runtimeModel.frmData:null)
  399. };
  400. wfProcessSchemeEntity.SchemeContent = _data.ToJson().ToString();
  401. switch (_Confluenceres)
  402. {
  403. case "-1"://不通过
  404. wfProcessInstanceEntity.isFinish = 3;
  405. break;
  406. case "1"://等待
  407. break;
  408. default://通过
  409. wfProcessInstanceEntity.PreviousId = wfProcessInstanceEntity.ActivityId;
  410. wfProcessInstanceEntity.ActivityId = wfruntime.runtimeModel.nextNodeId;
  411. wfProcessInstanceEntity.ActivityType = wfruntime.runtimeModel.nextNodeType;//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
  412. wfProcessInstanceEntity.ActivityName = wfruntime.runtimeModel.nextNode.name;
  413. wfProcessInstanceEntity.isFinish = (wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0);
  414. wfProcessInstanceEntity.MakerList = (wfruntime.runtimeModel.nextNodeType == 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
  415. #region 流转记录
  416. processTransitionHistoryEntity = new WFProcessTransitionHistoryEntity();
  417. processTransitionHistoryEntity.fromNodeId = wfruntime.runtimeModel.currentNodeId;
  418. processTransitionHistoryEntity.fromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
  419. processTransitionHistoryEntity.fromNodeType = wfruntime.runtimeModel.currentNodeType;
  420. processTransitionHistoryEntity.toNodeId = wfruntime.runtimeModel.nextNodeId;
  421. processTransitionHistoryEntity.toNodeName = wfruntime.runtimeModel.nextNode.name.Value;
  422. processTransitionHistoryEntity.toNodeType = wfruntime.runtimeModel.nextNodeType;
  423. processTransitionHistoryEntity.TransitionSate = 0;
  424. processTransitionHistoryEntity.isFinish = (processTransitionHistoryEntity.toNodeType == 4 ? 1 : 0);
  425. #endregion
  426. #region 委托记录
  427. WFDelegateRecordEntity delegateRecordEntity = null;
  428. DataTable dt = wfDelegateRuleService.GetEntityBySchemeInfoId(wfProcessSchemeEntity.WFSchemeInfoId, wfProcessInstanceEntity.MakerList.Split(','));
  429. foreach (DataRow dr in dt.Rows)
  430. {
  431. if (!string.IsNullOrEmpty(dr["Id"].ToString()))
  432. {
  433. delegateRecordEntity = new WFDelegateRecordEntity();
  434. delegateRecordEntity.WFDelegateRuleId = dr["Id"].ToString();
  435. delegateRecordEntity.FromUserId = dr["CreateUserId"].ToString();
  436. delegateRecordEntity.FromUserName = dr["CreateUserName"].ToString();
  437. delegateRecordEntity.ToUserId = dr["ToUserId"].ToString();
  438. delegateRecordEntity.ToUserName = dr["ToUserName"].ToString();
  439. delegateRecordEntity.ProcessCode = wfProcessInstanceEntity.Code;
  440. delegateRecordEntity.ProcessName = wfProcessInstanceEntity.CustomName;
  441. delegateRecordEntitylist.Add(delegateRecordEntity);
  442. wfProcessInstanceEntity.MakerList += "," + dr["ToUserId"].ToString();
  443. }
  444. }
  445. #endregion
  446. if (wfruntime.runtimeModel.currentNode.setInfo != null && wfruntime.runtimeModel.currentNode.setInfo.NodeSQL != null)
  447. {
  448. _sqlstr = wfruntime.runtimeModel.currentNode.setInfo.NodeSQL.Value;
  449. _dbbaseId = wfruntime.runtimeModel.currentNode.setInfo.NodeDataBaseToSQL.Value;
  450. }
  451. break;
  452. }
  453. }
  454. else
  455. {
  456. throw(new Exception("审核异常,找不到审核节点"));
  457. }
  458. }
  459. #endregion
  460. #region 一般审核
  461. else//一般审核
  462. {
  463. if (flag)
  464. {
  465. wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 1, OperatorProvider.Provider.Current().UserId, description);
  466. wfProcessInstanceEntity.PreviousId = wfProcessInstanceEntity.ActivityId;
  467. wfProcessInstanceEntity.ActivityId = wfruntime.runtimeModel.nextNodeId;
  468. wfProcessInstanceEntity.ActivityType = wfruntime.runtimeModel.nextNodeType;//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
  469. wfProcessInstanceEntity.ActivityName = wfruntime.runtimeModel.nextNode.name;
  470. wfProcessInstanceEntity.MakerList = (wfruntime.runtimeModel.nextNodeType == 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
  471. wfProcessInstanceEntity.isFinish = (wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0);
  472. #region 流转记录
  473. processTransitionHistoryEntity = new WFProcessTransitionHistoryEntity();
  474. processTransitionHistoryEntity.fromNodeId = wfruntime.runtimeModel.currentNodeId;
  475. processTransitionHistoryEntity.fromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
  476. processTransitionHistoryEntity.fromNodeType = wfruntime.runtimeModel.currentNodeType;
  477. processTransitionHistoryEntity.toNodeId = wfruntime.runtimeModel.nextNodeId;
  478. processTransitionHistoryEntity.toNodeName = wfruntime.runtimeModel.nextNode.name.Value;
  479. processTransitionHistoryEntity.toNodeType = wfruntime.runtimeModel.nextNodeType;
  480. processTransitionHistoryEntity.TransitionSate = 0;
  481. processTransitionHistoryEntity.isFinish = (processTransitionHistoryEntity.toNodeType == 4 ? 1 : 0);
  482. #endregion
  483. #region 委托记录
  484. WFDelegateRecordEntity delegateRecordEntity = null;
  485. DataTable dt = wfDelegateRuleService.GetEntityBySchemeInfoId(wfProcessSchemeEntity.WFSchemeInfoId, wfProcessInstanceEntity.MakerList.Split(','));
  486. foreach (DataRow dr in dt.Rows)
  487. {
  488. if (!string.IsNullOrEmpty(dr["Id"].ToString()))
  489. {
  490. delegateRecordEntity = new WFDelegateRecordEntity();
  491. delegateRecordEntity.WFDelegateRuleId = dr["Id"].ToString();
  492. delegateRecordEntity.FromUserId = dr["CreateUserId"].ToString();
  493. delegateRecordEntity.FromUserName = dr["CreateUserName"].ToString();
  494. delegateRecordEntity.ToUserId = dr["ToUserId"].ToString();
  495. delegateRecordEntity.ToUserName = dr["ToUserName"].ToString();
  496. delegateRecordEntity.ProcessCode = wfProcessInstanceEntity.Code;
  497. delegateRecordEntity.ProcessName = wfProcessInstanceEntity.CustomName;
  498. delegateRecordEntitylist.Add(delegateRecordEntity);
  499. wfProcessInstanceEntity.MakerList += "," + dr["ToUserId"].ToString();
  500. }
  501. }
  502. #endregion
  503. if (wfruntime.runtimeModel.currentNode.setInfo != null && wfruntime.runtimeModel.currentNode.setInfo.NodeSQL != null)
  504. {
  505. _sqlstr = wfruntime.runtimeModel.currentNode.setInfo.NodeSQL.Value;
  506. _dbbaseId = wfruntime.runtimeModel.currentNode.setInfo.NodeDataBaseToSQL.Value;
  507. }
  508. wfProcessOperationHistoryEntity.Content = "【" + OperatorProvider.Provider.Current().UserName + "】【" + wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
  509. }
  510. else
  511. {
  512. wfProcessInstanceEntity.isFinish = 3; //表示该节点不同意
  513. wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, -1, OperatorProvider.Provider.Current().UserId, description);
  514. wfProcessOperationHistoryEntity.Content = "【" + OperatorProvider.Provider.Current().UserName + "】【" + wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description;
  515. }
  516. var data = new
  517. {
  518. SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
  519. frmData = (wfProcessInstanceEntity.FrmType == 0 ? wfruntime.runtimeModel.frmData : null)
  520. };
  521. wfProcessSchemeEntity.SchemeContent = data.ToJson().ToString();
  522. }
  523. #endregion
  524. _res = true;
  525. wfProcessInstanceService.SaveProcess(_sqlstr, _dbbaseId,wfProcessInstanceEntity, wfProcessSchemeEntity, wfProcessOperationHistoryEntity, delegateRecordEntitylist, processTransitionHistoryEntity);
  526. return _res;
  527. }
  528. catch {
  529. throw;
  530. }
  531. }
  532. /// <summary>
  533. /// 驳回
  534. /// </summary>
  535. /// <param name="processId"></param>
  536. /// <param name="nodeId"></param>
  537. /// <param name="description"></param>
  538. /// <returns></returns>
  539. public bool NodeReject(string processId,string nodeId, string description = "")
  540. {
  541. try
  542. {
  543. WFProcessInstanceEntity wfProcessInstanceEntity = wfProcessInstanceService.GetEntity(processId);
  544. WFProcessSchemeEntity wfProcessSchemeEntity = wfProcessSchemeService.GetEntity(wfProcessInstanceEntity.ProcessSchemeId);
  545. WFProcessOperationHistoryEntity wfProcessOperationHistoryEntity = new WFProcessOperationHistoryEntity();
  546. WFProcessTransitionHistoryEntity processTransitionHistoryEntity = null;
  547. dynamic schemeContentJson = wfProcessSchemeEntity.SchemeContent.ToJson();//获取工作流模板内容的json对象;
  548. WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
  549. {
  550. schemeContent = schemeContentJson.SchemeContent.Value,
  551. currentNodeId = wfProcessInstanceEntity.ActivityId,
  552. frmData = schemeContentJson.frmData.Value,
  553. previousId = wfProcessInstanceEntity.PreviousId,
  554. processId = processId
  555. };
  556. IWF_Runtime wfruntime = null;
  557. if (wfProcessInstanceEntity.FrmType == 0)//自定义表单
  558. {
  559. wfruntime = new WF_Runtime(wfRuntimeInitModel);
  560. }
  561. else
  562. {
  563. wfruntime = new WF_Runtime(wfRuntimeInitModel, GetFrmData);
  564. }
  565. string resnode = "";
  566. if (nodeId == "")
  567. {
  568. resnode = wfruntime.RejectNode();
  569. }
  570. else
  571. {
  572. resnode = nodeId;
  573. }
  574. wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, 0, OperatorProvider.Provider.Current().UserId, description);
  575. wfProcessInstanceEntity.isFinish = 4;//4表示驳回(需要申请者重新提交表单)
  576. if (resnode != "")
  577. {
  578. wfProcessInstanceEntity.PreviousId = wfProcessInstanceEntity.ActivityId;
  579. wfProcessInstanceEntity.ActivityId = resnode;
  580. wfProcessInstanceEntity.ActivityType = wfruntime.GetNodeStatus(resnode);//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
  581. wfProcessInstanceEntity.ActivityName = wfruntime.runtimeModel.nodeDictionary[resnode].name;
  582. wfProcessInstanceEntity.MakerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[resnode], wfProcessInstanceEntity.PreviousId);//当前节点可执行的人信息
  583. #region 流转记录
  584. processTransitionHistoryEntity = new WFProcessTransitionHistoryEntity();
  585. processTransitionHistoryEntity.fromNodeId = wfruntime.runtimeModel.currentNodeId;
  586. processTransitionHistoryEntity.fromNodeName = wfruntime.runtimeModel.currentNode.name.Value;
  587. processTransitionHistoryEntity.fromNodeType = wfruntime.runtimeModel.currentNodeType;
  588. processTransitionHistoryEntity.toNodeId = wfruntime.runtimeModel.nextNodeId;
  589. processTransitionHistoryEntity.toNodeName = wfruntime.runtimeModel.nextNode.name.Value;
  590. processTransitionHistoryEntity.toNodeType = wfruntime.runtimeModel.nextNodeType;
  591. processTransitionHistoryEntity.TransitionSate = 1;//
  592. processTransitionHistoryEntity.isFinish = (processTransitionHistoryEntity.toNodeType == 4 ? 1 : 0);
  593. #endregion
  594. }
  595. var data = new
  596. {
  597. SchemeContent = wfruntime.runtimeModel.schemeContentJson.ToString(),
  598. frmData = (wfProcessInstanceEntity.FrmType == 0 ? wfruntime.runtimeModel.frmData : null)
  599. };
  600. wfProcessSchemeEntity.SchemeContent = data.ToJson().ToString();
  601. wfProcessOperationHistoryEntity.Content = "【" + OperatorProvider.Provider.Current().UserName + "】【" + wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:" + description;
  602. wfProcessInstanceService.SaveProcess(wfProcessInstanceEntity, wfProcessSchemeEntity, wfProcessOperationHistoryEntity,null, processTransitionHistoryEntity);
  603. return true;
  604. }
  605. catch
  606. {
  607. throw;
  608. }
  609. }
  610. /// <summary>
  611. /// 召回流程进程
  612. /// </summary>
  613. /// <param name="processId"></param>
  614. public void CallingBackProcess(string processId)
  615. {
  616. try
  617. {
  618. wfProcessInstanceService.OperateVirtualProcess(processId,2);
  619. }
  620. catch
  621. {
  622. throw;
  623. }
  624. }
  625. /// <summary>
  626. /// 终止一个实例(彻底删除)
  627. /// </summary>
  628. /// <param name="processId"></param>
  629. /// <returns></returns>
  630. public void KillProcess(string processId)
  631. {
  632. try
  633. {
  634. wfProcessInstanceService.DeleteProcess(processId);
  635. }
  636. catch
  637. {
  638. throw;
  639. }
  640. }
  641. /// <summary>
  642. /// 获取某个节点(审核人所能看到的提交表单的权限)
  643. /// </summary>
  644. /// <param name="data"></param>
  645. /// <returns></returns>
  646. public string GetProcessSchemeContentByNodeId(string data, string nodeId)
  647. {
  648. try
  649. {
  650. List<dynamic> list = new List<dynamic>();
  651. dynamic schemeContentJson = data.ToJson();//获取工作流模板内容的json对象;
  652. string schemeContent1 = schemeContentJson.SchemeContent.Value;
  653. dynamic schemeContentJson1 = schemeContent1.ToJson();
  654. string FrmContent = schemeContentJson1.Frm.FrmContent.Value;
  655. dynamic FrmContentJson = FrmContent.ToJson();
  656. foreach (var item in schemeContentJson1.Flow.nodes)
  657. {
  658. if (item.id.Value == nodeId)
  659. {
  660. foreach (var item1 in item.setInfo.frmPermissionInfo)
  661. {
  662. foreach (var item2 in FrmContentJson)
  663. {
  664. if (item2.control_field.Value == item1.fieldid.Value)
  665. {
  666. if (item1.look.Value == true)
  667. {
  668. if (item1.down != null)
  669. {
  670. item2.down = item1.down.Value;
  671. }
  672. list.Add(item2);
  673. }
  674. break;
  675. }
  676. }
  677. }
  678. break;
  679. }
  680. }
  681. schemeContentJson1.Frm.FrmContent = list.ToJson().ToString();
  682. schemeContentJson.SchemeContent = schemeContentJson1.ToString();
  683. return schemeContentJson.ToString();
  684. }
  685. catch
  686. {
  687. throw;
  688. }
  689. }
  690. /// <summary>
  691. /// 获取某个节点(审核人所能看到的提交表单的权限)
  692. /// </summary>
  693. /// <param name="data"></param>
  694. /// <param name="userId"></param>
  695. /// <returns></returns>
  696. public string GetProcessSchemeContentByUserId(string data, string userId)
  697. {
  698. try
  699. {
  700. List<dynamic> list = new List<dynamic>();
  701. dynamic schemeContentJson = data.ToJson();//获取工作流模板内容的json对象;
  702. string schemeContent1 = schemeContentJson.SchemeContent.Value;
  703. dynamic schemeContentJson1 = schemeContent1.ToJson();
  704. string FrmContent = schemeContentJson1.Frm.FrmContent.Value;
  705. dynamic FrmContentJson = FrmContent.ToJson();
  706. foreach (var item in schemeContentJson1.Flow.nodes)
  707. {
  708. if (item.setInfo != null && item.setInfo.UserId != null && item.setInfo.UserId.Value == userId)
  709. {
  710. foreach (var item1 in item.setInfo.frmPermissionInfo)
  711. {
  712. foreach (var item2 in FrmContentJson)
  713. {
  714. if (item2.control_field.Value == item1.fieldid.Value)
  715. {
  716. if (item1.look.Value == true)
  717. {
  718. if (item1.down != null)
  719. {
  720. item2.down = item1.down.Value;
  721. }
  722. list.Add(item2);
  723. }
  724. break;
  725. }
  726. }
  727. }
  728. break;
  729. }
  730. }
  731. schemeContentJson1.Frm.FrmContent = list.ToJson().ToString();
  732. schemeContentJson.SchemeContent = schemeContentJson1.ToString();
  733. return schemeContentJson.ToString();
  734. }
  735. catch
  736. {
  737. throw;
  738. }
  739. }
  740. #endregion
  741. #region 工作流流程处理方法(公用)
  742. /// <summary>
  743. /// 寻找该节点执行人
  744. /// </summary>
  745. /// <param name="wfruntime"></param>
  746. /// <returns></returns>
  747. private string GetMakerList(IWF_Runtime wfruntime)
  748. {
  749. try
  750. {
  751. string makerList = "";
  752. if (wfruntime.runtimeModel.nextNodeId == "-1")
  753. {
  754. throw (new Exception("无法寻找到下一个节点"));
  755. }
  756. if (wfruntime.runtimeModel.nextNodeType == 0)//如果是会签节点
  757. {
  758. List<string> _nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.nextNodeId);
  759. string _makerList = "";
  760. foreach (string item in _nodelist)
  761. {
  762. _makerList = GetMakerList(wfruntime.runtimeModel.nodeDictionary[item], wfruntime.runtimeModel.processId);
  763. if (_makerList == "-1")
  764. {
  765. throw (new Exception("无法寻找到会签节点的审核者,请查看流程设计是否有问题!"));
  766. }
  767. else if (_makerList == "1")
  768. {
  769. throw (new Exception("会签节点的审核者不能为所有人,请查看流程设计是否有问题!"));
  770. }
  771. else
  772. {
  773. if (makerList != "")
  774. {
  775. makerList += ",";
  776. }
  777. makerList += _makerList;
  778. }
  779. }
  780. }
  781. else
  782. {
  783. makerList = GetMakerList(wfruntime.runtimeModel.nextNode, wfruntime.runtimeModel.processId);
  784. if (makerList == "-1")
  785. {
  786. throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"));
  787. }
  788. }
  789. return makerList;
  790. }
  791. catch
  792. {
  793. throw;
  794. }
  795. }
  796. /// <summary>
  797. /// 寻找该节点执行人
  798. /// </summary>
  799. /// <param name="node"></param>
  800. /// <returns></returns>
  801. private string GetMakerList(dynamic node, string processId)
  802. {
  803. try
  804. {
  805. string makerlsit = "";
  806. if (node.setInfo == null)
  807. {
  808. makerlsit = "-1";
  809. }
  810. else
  811. {
  812. if (node.setInfo.NodeDesignate.Value == "NodeDesignateType1")//所有成员
  813. {
  814. makerlsit = "1";
  815. }
  816. else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType2")//指定成员
  817. {
  818. makerlsit = ArrwyToString(node.setInfo.NodeDesignateData.role, makerlsit);
  819. makerlsit = ArrwyToString(node.setInfo.NodeDesignateData.post, makerlsit);
  820. makerlsit = ArrwyToString(node.setInfo.NodeDesignateData.usergroup, makerlsit);
  821. makerlsit = ArrwyToString(node.setInfo.NodeDesignateData.user, makerlsit);
  822. if (makerlsit == "")
  823. {
  824. makerlsit = "-1";
  825. }
  826. }
  827. else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType3")//发起者领导
  828. {
  829. UserEntity userEntity = userService.GetEntity(OperatorProvider.Provider.Current().UserId);
  830. if (string.IsNullOrEmpty(userEntity.ManagerId))
  831. {
  832. makerlsit = "-1";
  833. }
  834. else
  835. {
  836. makerlsit = userEntity.ManagerId;
  837. }
  838. }
  839. else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType4")//前一步骤领导
  840. {
  841. WFProcessTransitionHistoryEntity transitionHistoryEntity = wfProcessTransitionHistoryService.GetEntity(processId, node.id.Value);
  842. UserEntity userEntity = userService.GetEntity(transitionHistoryEntity.CreateUserId);
  843. if (string.IsNullOrEmpty(userEntity.ManagerId))
  844. {
  845. makerlsit = "-1";
  846. }
  847. else
  848. {
  849. makerlsit = userEntity.ManagerId;
  850. }
  851. }
  852. else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType5")//发起者部门领导
  853. {
  854. UserEntity userEntity = userService.GetEntity(OperatorProvider.Provider.Current().UserId);
  855. DepartmentEntity departmentEntity = departmentService.GetEntity(userEntity.DepartmentId);
  856. if (string.IsNullOrEmpty(departmentEntity.ManagerId))
  857. {
  858. makerlsit = "-1";
  859. }
  860. else
  861. {
  862. makerlsit = departmentEntity.ManagerId;
  863. }
  864. }
  865. else if (node.setInfo.NodeDesignate.Value == "NodeDesignateType6")//发起者公司领导
  866. {
  867. UserEntity userEntity = userService.GetEntity(OperatorProvider.Provider.Current().UserId);
  868. OrganizeEntity organizeEntity = organizeService.GetEntity(userEntity.OrganizeId);
  869. if (string.IsNullOrEmpty(organizeEntity.ManagerId))
  870. {
  871. makerlsit = "-1";
  872. }
  873. else
  874. {
  875. makerlsit = organizeEntity.ManagerId;
  876. }
  877. }
  878. }
  879. return makerlsit;
  880. }
  881. catch
  882. {
  883. throw;
  884. }
  885. }
  886. /// <summary>
  887. /// 将数组转化成逗号相隔的字串
  888. /// </summary>
  889. /// <param name="data"></param>
  890. /// <param name="Str"></param>
  891. /// <returns></returns>
  892. private string ArrwyToString(dynamic data, string Str)
  893. {
  894. string resStr = Str;
  895. foreach (var item in data)
  896. {
  897. if (resStr != "")
  898. {
  899. resStr += ",";
  900. }
  901. resStr += item.Value;
  902. }
  903. return resStr;
  904. }
  905. /// <summary>
  906. /// 获取系统表单信息
  907. /// </summary>
  908. /// <param name="DataBaseId"></param>
  909. /// <param name="tableName"></param>
  910. /// <param name="tableFiled"></param>
  911. /// <param name="processId"></param>
  912. /// <returns></returns>
  913. private string GetFrmData(string DataBaseId, string tableName, string tableFiled, string processId)
  914. {
  915. string res = "";
  916. try
  917. {
  918. if (DataBaseId == "" || DataBaseId == "" || DataBaseId == "")
  919. {
  920. return "";
  921. }
  922. DataBaseLinkEntity dataBaseLinkEntity = dataBaseLinkService.GetEntity(DataBaseId);//获取
  923. string sqlstr = string.Format("Select * from {0} where {1} = '{2}' ", tableName, tableFiled, processId);
  924. DataTable dt = this.BaseRepository(dataBaseLinkEntity.DbConnection).FindTable(sqlstr);
  925. res = dt.ToJson();
  926. return res;
  927. }
  928. catch
  929. {
  930. throw;
  931. }
  932. }
  933. /// <summary>
  934. /// 获取委托记录列表
  935. /// </summary>
  936. /// <param name="wfSchemeInfoId"></param>
  937. /// <param name="code"></param>
  938. /// <param name="customName"></param>
  939. /// <param name="makerList"></param>
  940. /// <returns></returns>
  941. private List<WFDelegateRecordEntity> GetDelegateRecordList(string wfSchemeInfoId, string code, string customName, string makerList)
  942. {
  943. try
  944. {
  945. delegateUserList = "";
  946. WFDelegateRecordEntity delegateRecordEntity = null;
  947. List<WFDelegateRecordEntity> delegateRecordEntitylist = new List<WFDelegateRecordEntity>();
  948. DataTable dt = wfDelegateRuleService.GetEntityBySchemeInfoId(wfSchemeInfoId, makerList.Split(','));
  949. foreach (DataRow dr in dt.Rows)
  950. {
  951. if (!string.IsNullOrEmpty(dr["Id"].ToString()))
  952. {
  953. delegateRecordEntity = new WFDelegateRecordEntity();
  954. delegateRecordEntity.WFDelegateRuleId = dr["Id"].ToString();
  955. delegateRecordEntity.FromUserId = dr["CreateUserId"].ToString();
  956. delegateRecordEntity.FromUserName = dr["CreateUserName"].ToString();
  957. delegateRecordEntity.ToUserId = dr["ToUserId"].ToString();
  958. delegateRecordEntity.ToUserName = dr["ToUserName"].ToString();
  959. delegateRecordEntity.ProcessCode = code;
  960. delegateRecordEntity.ProcessName = customName;
  961. delegateRecordEntitylist.Add(delegateRecordEntity);
  962. delegateUserList += "," + dr["ToUserId"].ToString();
  963. }
  964. }
  965. return delegateRecordEntitylist;
  966. }
  967. catch {
  968. throw;
  969. }
  970. }
  971. #endregion
  972. }
  973. }