public object Model(int id = 0, int infoId = 0) { if (id == 0 && infoId == 0) { throw new Exception("缺少参数ID或InfoID"); } FlowData flowData = null; if (id > 0) { flowData = Core.FlowDataManager.Get(id); } else if (infoId > 0) { var info = Core.FormInfoManager.GetModel(infoId); flowData = info.FlowData; } if (flowData == null) { return(BadRequest("参数不正确,没有获取到流程数据")); } var flowNodeData = flowData.GetUserLastNodeData(Identity.ID); var lastNodeData = flowData.GetLastNodeData(); return(new { flowData, flowNodeData = lastNodeData, freeFlowNodeData = lastNodeData.GetLastFreeNodeData(Identity.ID), canBack = Core.FlowDataManager.CanBack(flowData), canSubmitFlow = Core.FlowDataManager.CanSubmit(flowData, flowNodeData), canComplete = Core.FlowDataManager.CanComplete(flowData.Flow, lastNodeData), canSubmitFreeFlow = Core.FreeFlowDataManager.CanSubmit(flowData, Identity.ID), }); }
public bool CanSubmit(FlowData flowData, int userId) { if (flowData.Completed) { return(false); } var flowNodeData = flowData.GetLastNodeData(); if (flowNodeData.FlowNode.FreeFlowId == 0) { return(false); } var freeFlowData = flowNodeData.FreeFlowData; if (freeFlowData == null) { //如果用户是该主流程的处理人,则可以submit if (userId == flowNodeData.UserId) { return(true); } } else { if (freeFlowData.Completed) { return(flowNodeData.UserId == userId); } //就算提交过,也可以转发给其他人 return(freeFlowData.Nodes.Any(e => e.UserId == userId)); } return(false); }
public FlowNodeData CreateNextNodeData(FlowData flowData, int toUserId, int extendId = 0) { var lastNodeData = flowData.GetLastNodeData(); var flowNode = flowData.Flow.GetNextStep(lastNodeData == null ? 0 : lastNodeData.FlowNodeId); return(CreateNodeData(flowData.ID, flowNode, toUserId, extendId)); }
/// <summary> /// 是否可以退回 /// </summary> public bool CanBack(FlowData flowData) { if (flowData.Nodes.Count == 0) { return(false); } if (flowData.Nodes.Count == 1 && flowData.Nodes[0].Submited) { return(false); } var lastNodeData = flowData.GetLastNodeData(); var lastNode = flowData.Flow.GetFirstNode(); return(lastNodeData.FlowNodeId != lastNode.ID); }
public bool CanComplete(FlowData flowData, User user) { if (flowData.Completed) { return(false); } var lastNodeData = flowData.GetLastNodeData(); if (lastNodeData.FlowNode.FreeFlowId == 0) { return(false); } if (lastNodeData.FreeFlowData == null || lastNodeData.FreeFlowData.Completed) { return(false); } return(lastNodeData.FlowNode.FreeFlow.IsCompleteUser(user)); }