/// <summary> /// 上一个执行跳转节点 /// </summary> /// <returns></returns> public WorkflowNode GetFromNode() { if (FromTransition == null) { return(null); } ASTNode node = GetNode(FromTransition.Origin); return(WorkflowNode.ConvertToReallyType(node)); }
/// <summary> /// 撤销 /// </summary> /// <param name="context"></param> public void Cancel(WorkflowContext context) { WorkflowInstance instance = context.Instance; if (instance.State == WorkflowInstanceState.Running) { WorkflowNode current = instance.Current.GetFromNode(); context.SetOperation(WorkflowAction.Undo); if (CheckAuthorization(context) == false) { return; } //记录已经参与审批过的人信息 current.SetActor(context.ActorID, context.ActorName, WorkflowAction.Undo); instance.Jump(current.IDENTIFICATION); ASTNode to = current.GetNode(current.IDENTIFICATION); OnExecuteProcess(new ExecutingContext() { From = current, To = to, TransitionID = instance.Current.FromTransition.NID, Instance = instance, Data = context.Data, Operation = context.Operation, ActorID = context.ActorID, ActorName = context.ActorName }); if (to.NodeType == WorkflowNodeCategeory.Decision) { WorkflowNode wfDecision = WorkflowNode.ConvertToReallyType(to); Transition transition = wfDecision.FromTransition; if (transition == null) { return; } Cancel(new WorkflowContext() { Instance = WorkflowInstance.GetInstance(instance.InstanceID), ActorID = context.ActorID, Data = context.Data }); } } }
private List <IWorkflowAction> GetWorkflowActions(ASTNode to) { List <IWorkflowAction> partAction = new List <IWorkflowAction>(); WorkflowNode nodes = WorkflowNode.ConvertToReallyType(to); nodes.Actions.ForEach(el => { IWorkflowAction defaultAction = this.Scan(el.ID); if (defaultAction != null) { partAction.Add(defaultAction); } }); return(partAction); }
/// <summary> /// 获取流程实例 /// </summary> /// <param name="instanceID">实例ID</param> /// <returns>流程实例</returns> public static WorkflowInstance GetInstance(string instanceID) { WorkflowInstance workflowInstance = new WorkflowInstance(); workflowInstance.InstanceID = instanceID; string sql = ResourceManage.GetString(ResourceManage.SQL_WORKFLOW_INSTANCE); try { workflowInstance = workflowInstance.Connection.Query <WorkflowInstance, ASTNode, WorkflowInstance>(sql, (instance, node) => { instance.Current = WorkflowNode.ConvertToReallyType(node); return(instance); }, param: new { INSTANCEID = instanceID }, splitOn: "APPELLATION").FirstOrDefault <WorkflowInstance>(); return(workflowInstance); } catch (Exception ex) { throw new WorkflowException(ex, instanceID); } }