Пример #1
0
        /// <summary>
        /// 正常执行的运行时
        /// </summary>
        internal override void ExecuteInstanceImp(ISession session)
        {
            var runningExecutionContext = ActivityForwardContext.CreateTaskContext(base.TaskView,
                                                                                   base.ProcessModel,
                                                                                   base.ActivityResource);

            //判断流程是否可以被运行
            if (runningExecutionContext.ProcessInstance.ProcessState != (short)ProcessStateEnum.Running)
            {
                throw new WfRuntimeException(string.Format("当期流程不在运行状态!详细信息:当前流程状态:{0}",
                                                           runningExecutionContext.ProcessInstance.ProcessState));
            }

            if (base.TaskView.ActivityState != (short)NodeStateEnum.Running)
            {
                throw new WfRuntimeException(string.Format("当期当前活动节点不在运行状态!详细信息:当前活动状态:{0}",
                                                           base.TaskView.ActivityState));
            }

            //执行节点
            base.ExecuteWorkItemIteraly(runningExecutionContext, session);

            //构造回调函数需要的数据
            base.WfExecutedResult = WfExecutedResult.Success();
        }
Пример #2
0
        internal override void ExecuteInstanceImp(ISession session)
        {
            //构造流程实例
            var processInstance = new ProcessInstanceManager()
                                  .CreateNewProcessInstanceObject(base.AppRunner.AppName, base.AppRunner.AppInstanceID,
                                                                  base.ProcessModel.ProcessEntity,
                                                                  base.AppRunner.UserID,
                                                                  base.AppRunner.UserName);

            //构造活动实例
            //1. 获取开始节点活动
            var startActivity = base.ProcessModel.GetStartActivity();

            var startExecutionContext = ActivityForwardContext.CreateStartupContext(base.ProcessModel,
                                                                                    processInstance,
                                                                                    startActivity,
                                                                                    base.ActivityResource);

            base.ExecuteWorkItemIteraly(startExecutionContext, session);

            //构造回调函数需要的数据
            base.WfExecutedResult = WfExecutedResult.Success();
            base.WfExecutedResult.ProcessInstanceGUID = processInstance.ProcessInstanceGUID;
            base.WfExecutedResult.NextActivityTree    = GetNextActivityTree(base.AppRunner.Conditions, session);
        }
Пример #3
0
 /// <summary>
 /// 创建节点执行器的抽象类
 /// </summary>
 /// <param name="processInstance"></param>
 /// <param name="activity"></param>
 /// <param name="activityResource"></param>
 /// <param name="dataContext"></param>
 /// <returns></returns>
 internal static NodeMediator CreateWorkItemMediator(ActivityForwardContext executionObject,
                                                     ISession session)
 {
     if (executionObject.Activity.IsStartNode)
     {
         return(new NodeMediatorStart(executionObject, session));
     }
     else if (executionObject.Activity.IsAutomanticWorkItem)
     {
         return(new NodeMediatorAutomantic(executionObject, session));
     }
     else
     {
         return(new NodeManualMediator(executionObject, session));
     }
 }
Пример #4
0
        /// <summary>
        /// 执行要办理的工作项
        /// </summary>
        /// <param name="ProcessInstanceEntity"></param>
        internal void ExecuteWorkItemIteraly(ActivityForwardContext executionContext,
                                             ISession session)
        {
            NodeMediator mediator = NodeMediatorFactory.CreateWorkItemMediator(executionContext, session);

            mediator.ExecuteWorkItem();

            //继续执行队列中的节点
            Queue <WorkItem> toDoQueue = mediator.ToDoAutoWorkItemQueue;

            while (toDoQueue.Count > 0)
            {
                //更新执行上下文数据
                WorkItem workItem = toDoQueue.Dequeue();
                executionContext.Activity         = workItem.Activity;
                executionContext.ActivityInstance = workItem.ActivityInstance;

                //继续向前执行...
                NodeMediator nextMediator = NodeMediatorFactory.CreateWorkItemMediator(executionContext, session);
                nextMediator.ExecuteWorkItem();

                toDoQueue = nextMediator.ToDoAutoWorkItemQueue;
            }
        }
Пример #5
0
 internal NodeMediatorAutomantic(ActivityForwardContext executionObject, ISession session)
     : base(executionObject, session)
 {
 }
Пример #6
0
 internal NodeMediator(ActivityForwardContext executionObject, ISession session)
 {
     _wfExecutionContext = executionObject;
     _session            = session;
     _processModel       = executionObject.ProcessModel;
 }
Пример #7
0
 internal NodeManualMediator(ActivityForwardContext executionObject, ISession session)
     : base(executionObject, session)
 {
 }
Пример #8
0
 internal NodeMediatorStart(ActivityForwardContext executionContext, ISession session)
     : base(executionContext, session)
 {
 }