/// <summary> /// 驳回 /// </summary> /// <returns></returns> public virtual async Task NodeReject(FlowVerifySubmitDto reqest) { var user = await GetCurrentUserAsync(); FlowInstance flowInstance = await Manager.GetByIdAsync(reqest.FlowInstanceId); FlowRuntime wfruntime = new FlowRuntime(flowInstance); string resnode = ""; resnode = string.IsNullOrEmpty(reqest.NodeRejectStep) ? wfruntime.RejectNode() : reqest.NodeRejectStep; var tag = new Tag { Description = reqest.VerificationOpinion, Taged = TagState.Reject, UserId = user.Id, UserName = user.Name }; wfruntime.MakeTagNode(wfruntime.currentNodeId, tag); flowInstance.InstanceStatus = InstanceStatus.Reject;//4表示驳回(需要申请者重新提交表单) if (resnode != "") { var currentNode = wfruntime.Nodes[resnode]; flowInstance.PreviousId = flowInstance.ActivityId; flowInstance.ActivityId = resnode; flowInstance.ActivityType = wfruntime.GetNodeType(resnode); flowInstance.ActivityName = currentNode.name; //如果是开始节点,则取流程实例的创建者 flowInstance.MakerList = flowInstance.ActivityType == 3?$",{flowInstance.CreatorUserId},": GetNodeMakers(currentNode);//当前节点可执行的人信息 await AddTransHistory(wfruntime); } flowInstance.SchemeContent = Newtonsoft.Json.JsonConvert.SerializeObject(wfruntime.ToSchemeObj()); await Manager.UpdateAsync(flowInstance); await FlowInstanceOperationHistoryRepository.InsertAsync(new FlowInstanceOperationHistory { FlowInstanceId = reqest.FlowInstanceId, Content = "【" + wfruntime.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:" + reqest.VerificationOpinion }); }
/// <summary> /// 节点审核 /// </summary> /// <param name="instanceId"></param> /// <returns></returns> public virtual async Task NodeVerification(int instanceId, Tag tag) { var manager = Manager as FlowInstanceManager; FlowInstance flowInstance = await manager.GetByIdAsync(instanceId); FlowInstanceOperationHistory flowInstanceOperationHistory = new FlowInstanceOperationHistory { FlowInstanceId = instanceId };//操作记录 FlowRuntime wfruntime = new FlowRuntime(flowInstance); #region 会签 if (flowInstance.ActivityType == 0)//当前节点是会签节点 { //TODO: 标记会签节点的状态,这个地方感觉怪怪的 wfruntime.MakeTagNode(wfruntime.currentNodeId, tag); string canCheckId = ""; //寻找当前登录用户可审核的节点Id foreach (string nodeId in wfruntime.FromNodeLines[wfruntime.currentNodeId].Select(u => u.to)) { var makerList = GetNodeMakers(wfruntime.Nodes[nodeId]); if (string.IsNullOrEmpty(makerList)) { continue; } if (makerList.Contains("|" + tag.UserId + "|")) { canCheckId = nodeId; } } if (canCheckId == "") { throw (new Exception("审核异常,找不到审核节点")); } flowInstanceOperationHistory.Content = "【" + wfruntime.Nodes[canCheckId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】" + (tag.Taged == TagState.Ok ? "同意" : "不同意") + ",备注:" + tag.Description; wfruntime.MakeTagNode(canCheckId, tag); //标记审核节点状态 string res = wfruntime.NodeConfluence(canCheckId, tag); if (res == TagState.No.ToString("D")) { flowInstance.InstanceStatus = InstanceStatus.DisAgree; } else if (!string.IsNullOrEmpty(res)) { flowInstance.PreviousId = flowInstance.ActivityId; flowInstance.ActivityId = wfruntime.nextNodeId; flowInstance.ActivityType = wfruntime.nextNodeType; flowInstance.ActivityName = wfruntime.nextNode.name; flowInstance.InstanceStatus = (wfruntime.nextNodeType == 4 ? InstanceStatus.Finish : InstanceStatus.Processing); flowInstance.MakerList = (wfruntime.nextNodeType == 4 ? "" : GetNextMakers(wfruntime)); await AddTransHistory(wfruntime); } } #endregion 会签 #region 一般审核 else { wfruntime.MakeTagNode(wfruntime.currentNodeId, tag); if (tag.Taged == TagState.Ok) { flowInstance.PreviousId = flowInstance.ActivityId; flowInstance.ActivityId = wfruntime.nextNodeId; flowInstance.ActivityType = wfruntime.nextNodeType; flowInstance.ActivityName = wfruntime.nextNode.name; flowInstance.MakerList = wfruntime.nextNodeType == 4 ? "" : GetNextMakers(wfruntime); flowInstance.InstanceStatus = (wfruntime.nextNodeType == 4 ? InstanceStatus.Finish : InstanceStatus.Processing); await AddTransHistory(wfruntime); } else { flowInstance.InstanceStatus = InstanceStatus.DisAgree; //表示该节点不同意 } flowInstanceOperationHistory.Content = "【" + wfruntime.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】" + (tag.Taged == TagState.Ok ? "同意" : "不同意") + ",备注:" + tag.Description; } #endregion 一般审核 flowInstance.SchemeContent = Newtonsoft.Json.JsonConvert.SerializeObject(wfruntime.ToSchemeObj()); await manager.UpdateAsync(flowInstance); if (flowInstance.InstanceStatus == InstanceStatus.Finish) { await manager.FinishInstance(flowInstance);//调用流程结束事件 } await FlowInstanceOperationHistoryRepository.InsertAsync(flowInstanceOperationHistory); }