public async Task <IActionResult> Create(CreateAttachmentModel model) { if (model.EntityId.Equals(Guid.Empty) || model.ObjectId.Equals(Guid.Empty)) { return(JError(T["parameter_error"])); } if (model.Attachments.NotEmpty()) { var result = await _attachmentCreater.CreateManyAsync(model.EntityId, model.ObjectId, model.Attachments).ConfigureAwait(false); if (result.NotEmpty()) { return(JOk(T["saved_success"], result)); } } return(SaveFailure()); }
public async Task <IActionResult> Post([FromForm] SaveDataModel model) { if (model.EntityId.Equals(Guid.Empty)) { return(NotFound()); } var entityMetaData = _entityFinder.FindById(model.EntityId); if (entityMetaData == null) { return(NotFound()); } AggregateRoot aggregateRoot = new AggregateRoot(); var attributeMetaDatas = _attributeFinder.FindByEntityId(model.EntityId); bool isNew = !(model.RecordId.HasValue && !model.RecordId.Value.Equals(Guid.Empty)); var thisId = Guid.Empty; try { Core.Data.Entity entity = new Core.Data.Entity(entityMetaData.Name); dynamic headData = JObject.Parse(model.Data); foreach (JProperty p in headData) { var attr = attributeMetaDatas.Find(n => n.Name.IsCaseInsensitiveEqual(p.Name)); if (attr != null && p.Value != null) { entity.SetAttributeValue(p.Name.ToString().ToLower(), entity.WrapAttributeValue(_entityFinder, attr, p.Value.ToString())); } } if (isNew) { thisId = Guid.NewGuid(); if (model.RelationShipName.IsNotEmpty() && model.ReferencedRecordId.HasValue)//如果存在关联关系 { var relationShipMetas = _relationShipFinder.FindByName(model.RelationShipName); if (null != relationShipMetas && relationShipMetas.ReferencingEntityId == model.EntityId && entity.GetStringValue(relationShipMetas.ReferencingAttributeName).IsEmpty()) { //设置当前记录关联字段的值 entity.SetAttributeValue(relationShipMetas.ReferencingAttributeName, new EntityReference(relationShipMetas.ReferencedEntityName, model.ReferencedRecordId.Value)); } } if (!model.StageId.Equals(Guid.Empty))//业务流程的阶段 { entity.SetAttributeValue("StageId", model.StageId); } //thisId = _dataCreater.Create(entity); if (!model.StageId.Equals(Guid.Empty))//业务流程的阶段 { _businessProcessFlowInstanceUpdater.UpdateForward(model.BusinessFlowId, model.BusinessFlowInstanceId, model.StageId, thisId); } } else { thisId = model.RecordId.Value; entity.SetIdValue(model.RecordId.Value); } aggregateRoot.MainEntity = entity; aggregateRoot.ChildEntities = new List <RefEntity>(); //单据体 if (model.Child.IsNotEmpty()) { var childs = JArray.Parse(model.Child.UrlDecode()); if (childs.Count > 0) { List <Core.Data.Entity> childEntities = new List <Core.Data.Entity>(); List <string> entityNames = new List <string>(); foreach (var c in childs) { dynamic root = JObject.Parse(c.ToString()); string name = root.name, relationshipname = root.relationshipname, refname = string.Empty; OperationTypeEnum?entitystatus = root.entitystatus; if (!entityNames.Exists(n => n.IsCaseInsensitiveEqual(name))) { entityNames.Add(name); } var data = root.data; var childAttributes = _attributeFinder.FindByEntityName(name); if (relationshipname.IsNotEmpty()) { var relationShipMetas = _relationShipFinder.FindByName(relationshipname); if (null != relationShipMetas && relationShipMetas.ReferencedEntityId == model.EntityId) { refname = relationShipMetas.ReferencingAttributeName; } } Core.Data.Entity detail = new Core.Data.Entity(name); RefEntity refEntity = new RefEntity() { Name = name, Relationshipname = relationshipname, Entityid = model.EntityId, Entitystatus = entitystatus }; foreach (JProperty p in data) { var attr = childAttributes.Find(n => n.Name.IsCaseInsensitiveEqual(p.Name)); if (attr != null && p.Value != null) { detail.SetAttributeValue(p.Name.ToString().ToLower(), detail.WrapAttributeValue(_entityFinder, attr, p.Value.ToString())); } refEntity.Entity = detail; } //关联主记录ID if (refname.IsNotEmpty()) { detail.SetAttributeValue(refname, new EntityReference(entityMetaData.Name, thisId)); } aggregateRoot.ChildEntities.Add(refEntity); } } } //附件保存 var files = Request.Form.Files; if (files.Count > 0) { var result = await _attachmentCreater.CreateManyAsync(model.EntityId, thisId, files.ToList()).ConfigureAwait(false); for (int i = 0; i < files.Count; i++) { var attr = attributeMetaDatas.Find(n => n.Name.IsCaseInsensitiveEqual(files[i].Name)); if (attr != null) { var etAttachement = result.Where(x => x["Name"].ToString().IsCaseInsensitiveEqual(files[i].FileName)).First(); if (etAttachement != null) { entity.SetAttributeValue(files[i].Name, entity.WrapAttributeValue(_entityFinder, attr, etAttachement["CDNPath"].ToString())); } } } } if (isNew) { thisId = _aggCreater.Create(aggregateRoot, thisId, model.FormId); } else { _aggUpdater.Update(aggregateRoot, model.FormId); } } catch (Exception ex) { return(JError(ex.InnerException != null ? ex.InnerException.Message : ex.Message)); } if (isNew) { return(CreateSuccess(new { id = thisId })); } return(UpdateSuccess(new { id = thisId })); }
/// <summary> /// 启动工作流 /// </summary> /// <param name="context"></param> /// <returns></returns> public async Task <WorkFlowExecutionResult> StartAsync(WorkFlowStartUpContext context) { var result = new WorkFlowExecutionResult(); result.IsSuccess = true; if (_WorkFlowInstanceService.Find(n => n.EntityId == context.WorkFlowMetaData.EntityId && n.ObjectId == context.ObjectId && n.StateCode == WorkFlowProcessState.Processing) != null) { result.IsSuccess = false; result.Message = _loc["workflow_processing_notallowcancel"]; } if (result.IsSuccess) { var workFlowSteps = _workFlowStepService.Query(n => n .Where(f => f.WorkFlowId == context.WorkFlowMetaData.WorkFlowId) .Sort(s => s.SortAscending(f => f.StepOrder))); //生成审批任务 var InstanceInfo = new WorkFlowInstance() { ApplicantId = context.ApplicantId , CreatedOn = DateTime.Now , Description = context.Description , EntityId = context.WorkFlowMetaData.EntityId , ObjectId = context.ObjectId , WorkFlowId = context.WorkFlowMetaData.WorkFlowId , StateCode = WorkFlowProcessState.Processing , Attachments = context.Attachments , WorkFlowInstanceId = Guid.NewGuid() }; //生成审批唯一码 var randomService = new Randoms(); //生成审批处理步骤 var wfpList = new List <WorkFlowProcess>(); //开始节点 var startNode = workFlowSteps.Find(n => n.NodeType == 0); bool hasNext = true; WorkFlowStep nextStep = startNode; WorkFlowProcess prevStep = null; int stepOrder = 1; while (hasNext) { //生成当前节点处理记录 if (nextStep.NodeType > 1) { var handlerIds = _workFlowHandlerFinder.GetCurrentHandlerId(InstanceInfo, prevStep, nextStep.HandlerIdType, nextStep.Handlers); if (handlerIds.IsEmpty()) { result.IsSuccess = false; result.Message = _loc["workflow_step_nonehandler"].FormatWith(nextStep.Name); break; } foreach (var hid in handlerIds) { var wfp = new WorkFlowProcess() { Name = nextStep.Name , StateCode = WorkFlowProcessState.Waiting , StepOrder = stepOrder , UniqueCode = randomService.CreateRandomValue(6, true) , AuthAttributes = nextStep.AuthAttributes , FormId = nextStep.FormId , AllowAssign = nextStep.AllowAssign , AllowCancel = nextStep.AllowCancel , HandlerIdType = nextStep.HandlerIdType , Handlers = nextStep.Handlers , HandlerId = hid , ReturnType = nextStep.ReturnType , ReturnTo = nextStep.ReturnTo , AttachmentRequired = nextStep.AttachmentRequired , AttachmentExts = nextStep.AttachmentExts , //Conditions = step.Conditions //, NodeName = nextStep.NodeName , WorkFlowInstanceId = InstanceInfo.WorkFlowInstanceId , WorkFlowProcessId = Guid.NewGuid() }; if (stepOrder == 1) { wfp.StartTime = DateTime.Now; wfp.StateCode = WorkFlowProcessState.Processing; result.NextHandlerId = handlerIds; } wfpList.Add(wfp); } prevStep = wfpList.Find(n => n.StepOrder == stepOrder); stepOrder++; } //获取下一节点 if (nextStep.Conditions.IsNotEmpty()) { var stepConditions = new List <WorkFlowStepCondition>().DeserializeFromJson(nextStep.Conditions); nextStep = null;//重设下一节点 //判断流转条件 foreach (var scnd in stepConditions) { var flag = true; if (scnd.Conditions.NotEmpty()) { foreach (var cnd in scnd.Conditions) { if (cnd.CompareAttributeName.IsNotEmpty()) { cnd.Values.Add(context.ObjectData.GetStringValue(cnd.CompareAttributeName)); } var attr = _attributeFinder.Find(context.EntityMetaData.EntityId, cnd.AttributeName); flag = cnd.IsTrue(attr, context.ObjectData.GetStringValue(cnd.AttributeName)); if (scnd.LogicalOperator == LogicalOperator.Or && flag) { break; } if (scnd.LogicalOperator == LogicalOperator.And && !flag) { break; } } } if (flag) { if (!scnd.NextStepId.Equals(Guid.Empty)) { nextStep = workFlowSteps.Find(n => n.WorkFlowStepId == scnd.NextStepId); hasNext = nextStep != null; } break; } else { continue; } } hasNext = nextStep != null; } else { nextStep = null; hasNext = false; } //结束节点 if (hasNext && nextStep.NodeType == 1) { nextStep = null; hasNext = false; break; } } if (wfpList.IsEmpty()) { result.IsSuccess = false; result.Message = _loc["workflow_start_failure"]; } result.Instance = InstanceInfo; result.Instance.Steps = wfpList; } OnStarting(context, result); _eventPublisher.Publish(new WorkFlowStartingEvent { Context = context, Result = result }); if (result.IsSuccess) { try { _WorkFlowInstanceService.BeginTransaction(); _WorkFlowInstanceService.Create(result.Instance); _workFlowProcessService.CreateMany(result.Instance.Steps); //更新记录流程状态 //_workFlowProcessUpdater.UpdateObjectProcessState(context.EntityMetaData, context.ObjectId, WorkFlowProcessState.Processing); //上传附件 await _attachmentCreater.CreateManyAsync(context.EntityMetaData.EntityId, result.Instance.WorkFlowInstanceId, context.AttachmentFiles).ConfigureAwait(false); _WorkFlowInstanceService.CompleteTransaction(); result.IsSuccess = true; } catch (Exception e) { _WorkFlowInstanceService.RollBackTransaction(); result.IsSuccess = false; result.Message = "error:" + e.Message; _logService.Error(e); } } OnStarted(context, result); _eventPublisher.Publish(new WorkFlowStartedEvent { Context = context, Result = result }); return(result); }
/// <summary> /// 执行工作流 /// </summary> /// <param name="context"></param> /// <returns></returns> public async Task <WorkFlowExecutionResult> ExecuteAsync(WorkFlowExecutionContext context) { var result = new WorkFlowExecutionResult(); OnExecuting(context, result); _eventPublisher.Publish(new WorkFlowExecutingEvent { Context = context }); try { _workFlowInstanceService.BeginTransaction(); //更新当前步骤处理状态 _workFlowProcessUpdater.Update(n => n .Set(f => f.StateCode, context.ProcessState) .Set(f => f.HandleTime, DateTime.Now) .Set(f => f.Description, context.Description) .Set(f => f.Attachments, context.Attachments) .Where(f => f.WorkFlowProcessId == context.ProcessInfo.WorkFlowProcessId) ); //上传附件 await _attachmentCreater.CreateManyAsync(context.EntityMetaData.EntityId, context.ProcessInfo.WorkFlowProcessId, context.AttachmentFiles).ConfigureAwait(false); //更新当前步骤其他处理者状态 _workFlowProcessUpdater.Update(n => n .Set(f => f.StateCode, WorkFlowProcessState.Disabled) .Where(f => f.WorkFlowInstanceId == context.ProcessInfo.WorkFlowInstanceId && f.StepOrder == context.ProcessInfo.StepOrder && f.WorkFlowProcessId != context.ProcessInfo.WorkFlowProcessId) ); var nextI = context.ProcessInfo.StepOrder + 1; var nextSteps = _workFlowProcessFinder.Query(n => n.Where(f => f.WorkFlowInstanceId == context.ProcessInfo.WorkFlowInstanceId && f.StepOrder == nextI)); //如果到了最后一个环节 if (nextSteps.IsEmpty()) { //如果同意 if (context.ProcessState == WorkFlowProcessState.Passed) { //更新单据状态为审批通过 //_workFlowProcessUpdater.UpdateObjectProcessState(context.EntityMetaData, context.InstanceInfo.ObjectId, context.ProcessState); //更新本次申请状态为完成 _workFlowInstanceService.Update(n => n .Set(f => f.StateCode, context.ProcessState) .Set(f => f.CompletedOn, DateTime.Now) .Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId) ); } //如果驳回 else if (context.ProcessState == WorkFlowProcessState.UnPassed) { //var steps = this.Query(n => n.Where(f => f.WorkFlowInstanceId == context.RunnerInfo.WorkFlowInstanceId)); ////第一步 //if (context.ProcessInfo.ReturnType == (int)WorkFlowStepReturnType.FirstStep) //{ // //重新生成审批步骤 // steps.ForEach((n) => // { // n.WorkFlowProcessId = Guid.NewGuid(); // n.Attachments = 0; // n.Description = string.Empty; // n.CreatedOn = DateTime.Now; // n.HandleTime = null; // n.StartTime = DateTime.Now; // n.StateCode = WorkFlowProcessState.Waiting; // }); // this.CreateMany(steps); //} ////上一步 //else if (context.ProcessInfo.ReturnType == (int)WorkFlowStepReturnType.PrevStep) //{ // var newSteps = new List<WorkFlowProcess>(); // //重新生成上一步、当前步的审批步骤 // var prevStep = steps.Find(n => n.StepOrder == context.ProcessInfo.StepOrder - 1); // prevStep.WorkFlowProcessId = Guid.NewGuid(); // prevStep.Attachments = 0; // prevStep.Description = string.Empty; // prevStep.CreatedOn = DateTime.Now; // prevStep.HandleTime = null; // prevStep.StartTime = DateTime.Now; // prevStep.StateCode = WorkFlowProcessState.Waiting; // newSteps.Add(prevStep); // var currentStep = new WorkFlowProcess(); // currentStep.WorkFlowProcessId = Guid.NewGuid(); // currentStep.WorkFlowInstanceId = context.RunnerInfo.WorkFlowInstanceId; // currentStep.Attachments = 0; // currentStep.Description = string.Empty; // currentStep.CreatedOn = DateTime.Now; // currentStep.HandleTime = null; // currentStep.StartTime = DateTime.Now; // currentStep.StateCode = WorkFlowProcessState.Waiting; // newSteps.Add(currentStep); // this.CreateMany(newSteps); //} ////某一步 //else if (context.ProcessInfo.ReturnType == (int)WorkFlowStepReturnType.SpecifyStep) //{ // var newSteps = new List<WorkFlowProcess>(); // //重新生成指定步骤、及后续步骤 // steps.Where(n => n.StepOrder >= context.ProcessInfo.ReturnTo).ToList().ForEach((n) => // { // n.WorkFlowProcessId = Guid.NewGuid(); // n.Attachments = 0; // n.Description = string.Empty; // n.CreatedOn = DateTime.Now; // n.HandleTime = null; // n.StartTime = DateTime.Now; // n.StateCode = WorkFlowProcessState.Waiting; // newSteps.Add(n); // }); // this.CreateMany(newSteps); //} ////重新提交 //else if (context.ProcessInfo.ReturnType == (int)WorkFlowStepReturnType.ReSubmit) //{ // //更新单据状态为审批不通过 // this.UpdateObjectProcessState(context.RunnerInfo.EntityId, context.RunnerInfo.ObjectId, context.ProcessState, context.EntityMetaData.Name); // //更新当前流程实例状态为完成 // runnerService.Update(n => n // .Set(f => f.StateCode, context.ProcessState) // .Set(f => f.CompletedOn, DateTime.Now) // .Where(f => f.WorkFlowInstanceId == context.RunnerInfo.WorkFlowInstanceId) // ); //} //更新单据状态为审批不通过 //_workFlowProcessUpdater.UpdateObjectProcessState(context.EntityMetaData, context.InstanceInfo.ObjectId, context.ProcessState); //更新当前流程实例状态为完成 _workFlowInstanceService.Update(n => n .Set(f => f.StateCode, context.ProcessState) .Set(f => f.CompletedOn, DateTime.Now) .Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId) ); } } //如果还有下一步 else { //驳回 if (context.ProcessState == WorkFlowProcessState.UnPassed) { // //更新未处理的步骤状态为作废 // this.Update(n => n.Set(f => f.StateCode, WorkFlowProcessState.Disabled).Where(f => f.WorkFlowInstanceId == context.RunnerInfo.WorkFlowInstanceId && f.StateCode == WorkFlowProcessState.Waiting)); // //第一步 // if (context.ProcessInfo.ReturnType == (int)WorkFlowStepReturnType.FirstStep) // { // var steps = this.Query(n => n.Where(f => f.WorkFlowInstanceId == context.RunnerInfo.WorkFlowInstanceId)); // //重新生成审批步骤 // steps.ForEach((n) => // { // n.WorkFlowProcessId = Guid.NewGuid(); // n.Attachments = 0; // n.Description = string.Empty; // n.CreatedOn = DateTime.Now; // n.HandleTime = null; // n.StartTime = DateTime.Now; // n.StateCode = WorkFlowProcessState.Waiting; // }); // this.CreateMany(steps); // } // //上一步 // else if (context.ProcessInfo.ReturnType == (int)WorkFlowStepReturnType.PrevStep) // { // } // //某一步 // else if (context.ProcessInfo.ReturnType == (int)WorkFlowStepReturnType.SpecifyStep) // { // } // //重新提交 // else if (context.ProcessInfo.ReturnType == (int)WorkFlowStepReturnType.ReSubmit) // { // //更新单据状态为审批不通过 // this.UpdateObjectProcessState(context.RunnerInfo.EntityId, context.RunnerInfo.ObjectId, context.ProcessState, context.EntityMetaData.Name); // //更新当前流程实例状态为完成 // runnerService.Update(n => n // .Set(f => f.StateCode, context.ProcessState) // .Set(f => f.CompletedOn, DateTime.Now) // .Where(f => f.WorkFlowInstanceId == context.RunnerInfo.WorkFlowInstanceId) // ); // //更新未处理的步骤状态为作废 // this.Update(n => n.Set(f => f.StateCode, WorkFlowProcessState.Disabled).Where(f => f.WorkFlowInstanceId == context.RunnerInfo.WorkFlowInstanceId && f.StateCode == WorkFlowProcessState.Waiting)); // } //更新单据状态为审批不通过 //_workFlowProcessUpdater.UpdateObjectProcessState(context.EntityMetaData, context.InstanceInfo.ObjectId, context.ProcessState); //更新当前流程实例状态为完成 _workFlowInstanceService.Update(n => n .Set(f => f.StateCode, context.ProcessState) .Set(f => f.CompletedOn, DateTime.Now) .Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId) ); //更新未处理的步骤状态为作废 _workFlowProcessUpdater.Update(n => n.Set(f => f.StateCode, WorkFlowProcessState.Disabled).Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId && f.StateCode == WorkFlowProcessState.Waiting)); } //同意则转交到下一个处理人 else if (context.ProcessState == WorkFlowProcessState.Passed) { //更新下一步骤处理状态为处理中 _workFlowProcessUpdater.Update(n => n.Set(f => f.StateCode, WorkFlowProcessState.Processing).Set(f => f.StartTime, DateTime.Now) .Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId && f.StepOrder == nextI)); result.NextHandlerId = _workFlowHandlerFinder.GetCurrentHandlerId(context.InstanceInfo, context.ProcessInfo, nextSteps.First().HandlerIdType, nextSteps.First().Handlers); } } _workFlowInstanceService.CompleteTransaction(); result.IsSuccess = true; } catch (Exception e) { _workFlowInstanceService.RollBackTransaction(); result.IsSuccess = false; result.Message = e.Message; _logService.Error(e); } OnExecuted(context, result); _eventPublisher.Publish(new WorkFlowExecutedEvent { Context = context, Result = result }); return(result); }
/// <summary> /// 执行工作流 /// </summary> /// <param name="context"></param> /// <returns></returns> public async Task <WorkFlowExecutionResult> ExecuteAsync(WorkFlowExecutionContext context) { var result = new WorkFlowExecutionResult(); OnExecuting(context, result); _eventPublisher.Publish(new WorkFlowExecutingEvent { Context = context }); try { _workFlowInstanceService.BeginTransaction(); //更新当前步骤处理状态 _workFlowProcessUpdater.Update(n => n .Set(f => f.StateCode, context.ProcessState) .Set(f => f.HandleTime, DateTime.Now) .Set(f => f.Description, context.Description) .Set(f => f.Attachments, context.Attachments) .Where(f => f.WorkFlowProcessId == context.ProcessInfo.WorkFlowProcessId) ); //上传附件 await _attachmentCreater.CreateManyAsync(context.EntityMetaData.EntityId, context.ProcessInfo.WorkFlowProcessId, context.AttachmentFiles).ConfigureAwait(false); //更新当前步骤其他处理者状态 _workFlowProcessUpdater.Update(n => n .Set(f => f.StateCode, WorkFlowProcessState.Disabled) .Where(f => f.WorkFlowInstanceId == context.ProcessInfo.WorkFlowInstanceId && f.StepOrder == context.ProcessInfo.StepOrder && f.WorkFlowProcessId != context.ProcessInfo.WorkFlowProcessId) ); var nextI = context.ProcessInfo.StepOrder + 1; var nextSteps = _workFlowProcessFinder.Query(n => n.Where(f => f.WorkFlowInstanceId == context.ProcessInfo.WorkFlowInstanceId && f.StepOrder == nextI)); //如果到了最后一个环节 if (nextSteps.IsEmpty()) { //如果同意 if (context.ProcessState == WorkFlowProcessState.Passed) { //更新本次申请状态为完成 _workFlowInstanceService.Update(n => n .Set(f => f.StateCode, context.ProcessState) .Set(f => f.CompletedOn, DateTime.Now) .Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId) ); } //如果驳回 else if (context.ProcessState == WorkFlowProcessState.UnPassed) { //更新当前流程实例状态为完成 _workFlowInstanceService.Update(n => n .Set(f => f.StateCode, context.ProcessState) .Set(f => f.CompletedOn, DateTime.Now) .Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId) ); } } //如果还有下一步 else { //驳回 if (context.ProcessState == WorkFlowProcessState.UnPassed) { //更新当前流程实例状态为完成 _workFlowInstanceService.Update(n => n .Set(f => f.StateCode, context.ProcessState) .Set(f => f.CompletedOn, DateTime.Now) .Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId) ); //更新未处理的步骤状态为作废 _workFlowProcessUpdater.Update(n => n.Set(f => f.StateCode, WorkFlowProcessState.Disabled).Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId && f.StateCode == WorkFlowProcessState.Waiting)); } //同意则转交到下一个处理人 else if (context.ProcessState == WorkFlowProcessState.Passed) { //更新下一步骤处理状态为处理中 _workFlowProcessUpdater.Update(n => n.Set(f => f.StateCode, WorkFlowProcessState.Processing).Set(f => f.StartTime, DateTime.Now) .Where(f => f.WorkFlowInstanceId == context.InstanceInfo.WorkFlowInstanceId && f.StepOrder == nextI)); result.NextHandlerId = _workFlowHandlerFinder.GetCurrentHandlerId(context.InstanceInfo, context.ProcessInfo, nextSteps.First().HandlerIdType, nextSteps.First().Handlers); } } _workFlowInstanceService.CompleteTransaction(); result.IsSuccess = true; } catch (Exception e) { _workFlowInstanceService.RollBackTransaction(); result.IsSuccess = false; result.Message = e.Message; _logService.Error(e); } OnExecuted(context, result); //发布事件 _eventPublisher.Publish(new WorkFlowExecutedEvent { Context = context, Result = result }); return(result); }