示例#1
0
        /// <summary>
        /// 进行流程跳转
        /// </summary>
        /// <param name="context"></param>
        public void Jump(WorkflowContext context)
        {
            WorkflowInstance instance = context.Instance;

            if (instance.State == WorkflowInstanceState.Running)
            {
                WorkflowNode current = instance.Current;

                context.SetOperation(WorkflowAction.Jump);

                if (CheckAuthorization(context) == false)
                {
                    return;
                }

                long transitionTo = current.Transitions
                                    .FirstOrDefault(e => e.NID == context.TransitionID).DESTINATION;

                current.SetActor(context.ActorID, context.ActorName, WorkflowAction.Jump);
                instance.Jump(transitionTo);

                ASTNode to = current.GetNode(transitionTo);
                OnExecuteProcess(new ExecutingContext()
                {
                    From         = current,
                    To           = to,
                    TransitionID = context.TransitionID,
                    Instance     = instance,
                    Data         = context.Data,
                    Operation    = context.Operation,
                    ActorID      = context.ActorID,
                    ActorName    = context.ActorName
                });

                if (to.NodeType == WorkflowNodeCategeory.End)
                {
                    instance.State = WorkflowInstanceState.End;
                    instance.Transfer();
                }
                else if (to.NodeType == WorkflowNodeCategeory.Decision)
                {
                    WorkflowDecision wfDecision = WorkflowDecision.ConvertToReallyType(to);
                    Transition       transition = wfDecision.GetTransition();
                    if (transition == null)
                    {
                        return;
                    }
                    Jump(new WorkflowContext()
                    {
                        Instance     = WorkflowInstance.GetInstance(instance.InstanceID),
                        TransitionID = transition.NID,
                        ActorID      = context.ActorID,
                        Data         = context.Data
                    });
                }
            }
        }
示例#2
0
        /// <summary>
        /// 获取决策节点实例
        /// </summary>
        /// <param name="node">抽象节点</param>
        /// <returns>决策节点实例</returns>
        public static WorkflowDecision ConvertToReallyType(ASTNode node)
        {
            WorkflowDecision wfNode = new WorkflowDecision();

            wfNode.INSTANCEID     = node.INSTANCEID;
            wfNode.NID            = node.NID;
            wfNode.IDENTIFICATION = node.IDENTIFICATION;
            wfNode.APPELLATION    = node.APPELLATION;
            wfNode.NodeType       = node.NodeType;
            return(wfNode);
        }
示例#3
0
        /// <summary>
        /// 获取决策节点实例
        /// </summary>
        /// <param name="node">抽象节点</param>
        /// <returns>决策节点实例</returns>
        public static WorkflowDecision ConvertToReallyType(ASTNode node)
        {
            WorkflowDecision wfNode = new WorkflowDecision();

            wfNode.InstanceID = node.InstanceID;
            wfNode.NID        = node.NID;
            wfNode.ID         = node.ID;
            wfNode.Name       = node.Name;
            wfNode.NodeType   = node.NodeType;
            return(wfNode);
        }
        /// <summary>
        /// 进行流程跳转
        /// </summary>
        /// <param name="context"></param>
        public void Jump(WorkflowContext context)
        {
            WorkflowInstance instance = context.Instance;

            if (instance.State == WorkflowInstanceState.Running)
            {
                WorkflowNode current = instance.Current;


                string transitionTo = current.Transitions
                                      .FirstOrDefault(e => e.NID == context.TransitionID).Destination;


                instance.Jump(transitionTo);

                ASTNode to = current.GetNode(transitionTo);
                OnExecuteProcess(new ExecutingContext()
                {
                    From         = current,
                    To           = to,
                    TransitionID = context.TransitionID,
                    Instance     = instance,
                    Data         = context.Data,
                    ActorID      = context.ActorID,
                    ActorName    = context.ActorName
                });

                if (to.NodeType == WorkflowNodeCategory.End)
                {
                    instance.Transfer(WorkflowInstanceState.End);
                }
                else if (to.NodeType == WorkflowNodeCategory.Decision)
                {
                    WorkflowDecision wfDecision = WorkflowDecision.ConvertToReallyType(to);
                    Transition       transition = wfDecision.GetTransition();
                    if (transition == null)
                    {
                        return;
                    }
                    Jump(new WorkflowContext()
                    {
                        Instance     = WorkflowInstance.GetInstance(instance.InstanceID),
                        TransitionID = transition.NID,
                        ActorID      = context.ActorID,
                        Data         = context.Data
                    });
                }
            }
        }
示例#5
0
 public List <Transition> GetTransitions()
 {
     foreach (Smartflow.Elements.Transition transition in this.Transitions)
     {
         ASTNode    an = this.GetNode(transition.Destination);
         Transition decisionTransition = transition;
         while (an.NodeType == Enums.WorkflowNodeCategory.Decision)
         {
             WorkflowDecision decision = WorkflowDecision.ConvertToReallyType(an);
             decisionTransition = decision.GetTransition();
             an = this.GetNode(decisionTransition.Destination);
         }
         transition.Name = decisionTransition.Name;
     }
     return(this.Transitions);
 }
示例#6
0
        /// <summary>
        /// 获取当前执行的跳转路线
        /// </summary>
        /// <param name="transitionID">跳转ID</param>
        /// <returns>跳转对象</returns>
        protected Transition GetExecuteTransition(string transitionID)
        {
            Transition executeTransition = Transitions
                                           .FirstOrDefault(t => t.NID == transitionID);

            ASTNode    an = this.GetNode(executeTransition.Destination);
            Transition returnTransition = executeTransition;

            while (an.NodeType == Enums.WorkflowNodeCategory.Decision)
            {
                WorkflowDecision decision = WorkflowDecision.ConvertToReallyType(an);
                returnTransition = decision.GetTransition();
                an = this.GetNode(returnTransition.Destination);
            }
            return(returnTransition);
        }