public async Task <ActionResult> Verification(VerificationExtend entity) { try { await _service.Verification(entity); return(await Success("操作成功。", "", entity.F_FlowInstanceId, DbLogType.Submit)); } catch (Exception ex) { return(await Error(ex.Message, "", entity.F_FlowInstanceId, DbLogType.Submit)); } }
public async Task Verification(VerificationExtend entity) { var user = currentuser; var tag = new Tag { UserName = user.UserName, UserId = user.UserId, Description = entity.F_VerificationOpinion, Taged = Int32.Parse(entity.F_VerificationFinally) }; bool isReject = TagState.Reject.Equals((TagState)tag.Taged); if (isReject) //驳回 { await NodeReject(entity); } else { await NodeVerification(entity.F_FlowInstanceId, tag); } await CacheHelper.Remove(cacheKey + entity.F_FlowInstanceId); await CacheHelper.Remove(cacheKey + "list"); }
/// <summary> /// 驳回 /// 如果NodeRejectStep不为空,优先使用;否则按照NodeRejectType驳回 /// </summary> /// <returns></returns> public async Task <bool> NodeReject(VerificationExtend reqest) { var user = currentuser; FlowinstanceEntity flowInstance = await GetForm(reqest.F_FlowInstanceId); FlowRuntime wfruntime = new FlowRuntime(flowInstance); string resnode = ""; resnode = string.IsNullOrEmpty(reqest.NodeRejectStep) ? wfruntime.RejectNode(reqest.NodeRejectType) : reqest.NodeRejectStep; var tag = new Tag { Description = reqest.F_VerificationOpinion, Taged = (int)TagState.Reject, UserId = user.UserId, UserName = user.UserName }; wfruntime.MakeTagNode(wfruntime.currentNodeId, tag); flowInstance.F_IsFinish = 4;//4表示驳回(需要申请者重新提交表单) uniwork.BeginTrans(); if (resnode != "") { wfruntime.RemoveNode(resnode); flowInstance.F_SchemeContent = wfruntime.ToSchemeObj().ToJson(); flowInstance.F_ActivityId = resnode; var prruntime = new FlowRuntime(flowInstance); prruntime.MakeTagNode(prruntime.currentNodeId, tag); flowInstance.F_PreviousId = prruntime.previousId; flowInstance.F_ActivityType = prruntime.GetNodeType(resnode); flowInstance.F_ActivityName = prruntime.Nodes[resnode].name; if (resnode == wfruntime.startNodeId) { flowInstance.F_MakerList = flowInstance.F_CreatorUserId; } else { flowInstance.F_MakerList = await uniwork.IQueryable <FlowInstanceTransitionHistory>(a => a.F_FromNodeId == resnode && a.F_ToNodeId == prruntime.nextNodeId).OrderByDesc(a => a.F_CreatorTime).Select(a => a.F_CreatorUserId).FirstAsync();//当前节点可执行的人信息 } await AddRejectTransHistory(wfruntime, prruntime); await repository.Update(flowInstance); } await uniwork.Insert(new FlowInstanceOperationHistory { F_Id = Utils.GuId(), F_InstanceId = reqest.F_FlowInstanceId , F_CreatorUserId = user.UserId , F_CreatorUserName = user.UserName , F_CreatorTime = DateTime.Now , F_Content = "【" + wfruntime.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:" + reqest.F_VerificationOpinion }); MessageEntity msg = new MessageEntity(); if (resnode == wfruntime.startNodeId) { msg.F_MessageInfo = flowInstance.F_CustomName + "--流程驳回"; var module = uniwork.IQueryable <ModuleEntity>(a => a.F_EnCode == className.Substring(0, className.Length - 7)).FirstOrDefault(); msg.F_Href = module.F_UrlAddress; msg.F_HrefTarget = module.F_Target; msg.F_ToUserId = flowInstance.F_CreatorUserId; msg.F_ToUserName = flowInstance.F_CreatorUserName; msg.F_ClickRead = true; msg.F_KeyValue = flowInstance.F_Id; } else { msg.F_MessageInfo = flowInstance.F_CustomName + "--流程待处理"; var module = uniwork.IQueryable <ModuleEntity>(a => a.F_EnCode == className.Substring(0, className.Length - 7)).FirstOrDefault(); msg.F_Href = module.F_UrlAddress.Remove(module.F_UrlAddress.Length - 5, 5) + "ToDoFlow"; msg.F_HrefTarget = module.F_Target; msg.F_ToUserId = flowInstance.F_MakerList == "1" ? "" : flowInstance.F_MakerList; msg.F_ClickRead = false; msg.F_KeyValue = flowInstance.F_Id; } msg.F_CreatorUserName = currentuser.UserName; msg.F_EnabledMark = true; msg.F_MessageType = 2; var lastmsg = uniwork.IQueryable <MessageEntity>(a => a.F_ClickRead == false && a.F_KeyValue == flowInstance.F_Id).OrderByDesc(a => a.F_CreatorTime).FirstOrDefault(); if (lastmsg != null && uniwork.IQueryable <MessageHistoryEntity>(a => a.F_MessageId == lastmsg.F_Id).Count() == 0) { await messageApp.ReadMsgForm(lastmsg.F_Id); } await messageApp.SubmitForm(msg); uniwork.Commit(); wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), tag); return(true); }