Пример #1
0
        internal override void ExecuteInstanceImp(ISession session)
        {
            //修改流程实例为返签状态
            var pim = new ProcessInstanceManager();
            pim.Reverse(base.BackwardContext.ProcessInstance.ProcessInstanceGUID, base.ActivityResource.LogonUser, session);

            //创建新任务节点
            var workItem = (WorkItem)WorkItemNodeFactory.CreateNewNode(base.BackwardContext.BackwardToTaskActivity);
            workItem.CreateActivityTaskAndTransitionInstances(base.BackwardContext.ProcessInstance,
                base.BackwardContext.FromActivityInstance,
                base.BackwardContext.BackwardToTargetTransition,
                TransitionTypeEnum.Backward,
                base.ActivityResource,
                session);

            //构造回调函数需要的数据
            base.WfExecutedResult = WfExecutedResult.Success();
        }
Пример #2
0
        internal override void ExecuteInstanceImp(ISession session)
        {
            //创建新任务节点
            var workItem = (WorkItem)WorkItemNodeFactory.CreateNewNode(base.BackwardContext.BackwardToTaskActivity);

            workItem.CreateActivityTaskAndTransitionInstances(base.BackwardContext.ProcessInstance,
                                                              base.BackwardContext.FromActivityInstance,
                                                              base.BackwardContext.BackwardToTargetTransition,
                                                              TransitionTypeEnum.Withdrawed,
                                                              base.ActivityResource,
                                                              session);

            //更新当前办理节点的状态(从准备或运行状态更新为退回状态)
            var aim = new ActivityInstanceManager();

            aim.Reject(base.BackwardContext.FromActivityInstance.ActivityInstanceGUID, base.ActivityResource.LogonUser, session);

            //构造回调函数需要的数据
            base.WfExecutedResult = WfExecutedResult.Success();
        }
Пример #3
0
        /// <summary>
        /// 递归执行节点
        /// </summary>
        /// <param name="root"></param>
        /// <param name="fromNode"></param>
        /// <param name="conditionKeyValuePair"></param>
        protected void ContinueForwardCurrentNodeRecurisivly(NextActivityComponent root,
                                                             NodeBase fromNode,
                                                             IDictionary <string, string> conditionKeyValuePair)
        {
            foreach (NextActivityComponent c in root)
            {
                if (c.HasChildren)
                {
                    //此节点类型为分支或合并节点类型:首先需要实例化当前节点(自动完成)
                    NodeBase gatewayNode = GatewayNodeFactory.CreateNewNode(c.Activity);
                    ICompleteAutomaticlly autoGatewayNode = (ICompleteAutomaticlly)gatewayNode;
                    GatewayExecutedResult gatewayResult   = autoGatewayNode.CompleteAutomaticlly(WfExecutionContext.ProcessInstance,
                                                                                                 c.Transition,
                                                                                                 fromNode.ActivityInstance,
                                                                                                 WfExecutionContext.ActivityResource,
                                                                                                 Session);

                    if (gatewayResult.Status == GatewayExecutedStatus.Successed)
                    {
                        //遍历后续子节点
                        ContinueForwardCurrentNodeRecurisivly(c,
                                                              gatewayNode,
                                                              conditionKeyValuePair);
                    }
                    else
                    {
                        WfExecutedResult workItemExecutedResult = WfExecutedResult.Exception(
                            WfExecutedStatus.FallBehindOfXOrJoin,
                            "第一个满足条件的节点已经被成功执行,此后的节点被阻止在XOrJoin节点!");
                    }
                }
                else if (c.Activity.IsWorkItemNode)
                {
                    //此节点类型为任务节点:根据fromActivityInstance的类型判断是否可以创建任务
                    if (fromNode.ActivityInstance.State == (short)NodeStateEnum.Completed)
                    {
                        //创建新任务节点
                        WorkItem workItem = (WorkItem)WorkItemNodeFactory.CreateNewNode(c.Activity);
                        workItem.CreateActivityTaskAndTransitionInstances(WfExecutionContext.ProcessInstance,
                                                                          fromNode.ActivityInstance,
                                                                          c.Transition,
                                                                          c.Transition.DirectionType == TransitionDirectionTypeEnum.Loop ?
                                                                          TransitionTypeEnum.Loop : TransitionTypeEnum.Forward, //根据Direction方向确定是否是自身循环
                                                                          WfExecutionContext.ActivityResource,
                                                                          Session);

                        //新任务加入队列
                        if (workItem.IsAutomanticWorkItem)
                        {
                            ToDoAutoWorkItemQueue.Enqueue(workItem);
                        }
                    }
                    else
                    {
                        //下一步的任务节点没有创建,需给出提示信息
                        if ((fromNode.Activity.GatewayDirectionType | GatewayDirectionEnum.AllJoinType)
                            == GatewayDirectionEnum.AllJoinType)
                        {
                            WfExecutedResult workItemExecutedResult = WfExecutedResult.Exception(
                                WfExecutedStatus.WaitingForOthersJoin,
                                "等待其它需要合并的分支!");
                        }
                    }
                }
                else if (c.Activity.NodeType == NodeTypeEnum.EndNode)
                {
                    //此节点为完成结束节点,结束流程
                    NodeBase endNode = new EndNode(c.Activity);
                    ICompleteAutomaticlly autoEndNode = (ICompleteAutomaticlly)endNode;
                    autoEndNode.CompleteAutomaticlly(WfExecutionContext.ProcessInstance,
                                                     c.Transition,
                                                     fromNode.ActivityInstance,
                                                     WfExecutionContext.ActivityResource,
                                                     Session);
                }
                else
                {
                    WfExecutedResult workItemExecutedResult = WfExecutedResult.XmlError(
                        string.Format("XML文件定义了未知的节点类型,执行失败,节点类型信息:{0}",
                                      c.Activity.NodeType.ToString()));
                }
            }
        }