コード例 #1
0
        /// <summary>恢复被挂起的TaskInstance</summary>
        /// <param name="taskInstanceId"></param>
        /// <returns></returns>
        public ITaskInstance restoreTaskInstance(String taskInstanceId)
        {
            ITaskInstance taskInst = this.findTaskInstanceById(taskInstanceId);

            taskInst.restore();
            return(taskInst);
        }
コード例 #2
0
        /// <summary>
        /// 实现任务分配工作,该方法一般的实现逻辑是:
        /// 首先根据performerName查询出所有的操作员,可以把performerName当作角色名称。
        /// 然后调用asignable.asignToActor(String actorId,Boolean needSign)或者
        /// asignable.asignToActor(String actorId)或者asignable.asignToActorS(List actorIds)
        /// 进行任务分配。
        /// </summary>
        /// <param name="asignable">IAssignable实现类,在FireWorkflow中实际上就是TaskInstance对象。</param>
        /// <param name="performerName">角色名称</param>
        public void assign(IAssignable asignable, String performerName)// throws EngineException, KernelException
        {
            if (ActorIdsList == null || ActorIdsList.Count == 0)
            {
                TaskInstance taskInstance = (TaskInstance)asignable;
                throw new EngineException(taskInstance.ProcessInstanceId, taskInstance.WorkflowProcess, taskInstance.TaskId,
                                          "actorIdsList can not be empty");
            }

            List <IWorkItem> workItems = asignable.assignToActors(ActorIdsList);

            ITaskInstance taskInst = (ITaskInstance)asignable;

            //如果不需要签收,这里自动进行签收,(FormTask的strategy="all"或者=any并且工作项数量为1)
            if (!IsNeedClaim)
            {
                if (FormTaskEnum.ALL == taskInst.AssignmentStrategy || (FormTaskEnum.ANY == taskInst.AssignmentStrategy && ActorIdsList.Count == 1))
                {
                    for (int i = 0; i < workItems.Count; i++)
                    {
                        IWorkItem wi = workItems[i];
                        wi.claim();
                    }
                }
            }
        }
コード例 #3
0
        public ITaskInstance suspendTaskInstance(String taskInstanceId)
        {
            ITaskInstance taskInst = this.findTaskInstanceById(taskInstanceId);

            taskInst.suspend();
            return(taskInst);
        }
コード例 #4
0
        /// <summary>
        /// 响应任务实例的事件。通过e.getEventType区分事件的类型。
        /// </summary>
        /// <param name="e">任务实例的事件。</param>
        public void onTaskInstanceEventFired(TaskInstanceEvent e)// throws EngineException
        {
            IWorkflowSession session   = e.WorkflowSession;
            IProcessInstance proceInst = e.ProcessInstance;
            ITaskInstance    taskInst  = (ITaskInstance)e.Source;
            IWorkItem        wi        = e.WorkItem;

            switch (e.EventType)
            {
            case TaskInstanceEventEnum.BEFORE_TASK_INSTANCE_START:
                beforeTaskInstanceStart(session, proceInst, taskInst);
                break;

            case TaskInstanceEventEnum.AFTER_WORKITEM_CREATED:
                afterWorkItemCreated(session, proceInst, taskInst, wi);
                break;

            case TaskInstanceEventEnum.AFTER_WORKITEM_COMPLETE:
                afterWorkItemComplete(session, proceInst, taskInst, wi);
                break;

            case TaskInstanceEventEnum.AFTER_TASK_INSTANCE_COMPLETE:
                afterTaskInstanceCompleted(session, proceInst, taskInst);
                break;

            default:
                break;
            }
        }
コード例 #5
0
        public void execute(ITaskInstance taskInstance)
        {
            IProcessInstance processInstance = ((TaskInstance)taskInstance).AliveProcessInstance;
            String           goodsName       = (String)processInstance.getProcessInstanceVariable("goodsName");
            String           customerName    = (String)processInstance.getProcessInstanceVariable("customerName");

            //这里为模拟。在服务器上弹出消息框。
            System.Windows.Forms.MessageBox.Show("FireflowExample模拟调用后台程序:" + customerName + "你好,你购买的" + goodsName + "即将送货,请注意查收。");
        }
コード例 #6
0
 //throws EngineException ,KernelException
 public Boolean taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext,
     IProcessInstance processInstance, ITaskInstance taskInstance)
 {
     IPersistenceService persistenceService = runtimeContext.PersistenceService;
     Int32 aliveWorkItemCount = persistenceService.GetAliveWorkItemCountForTaskInstance(taskInstance.Id);
     if (aliveWorkItemCount == 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #7
0
        public Boolean taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext,
                                                  IProcessInstance processInstance, ITaskInstance taskInstance)//throws EngineException ,KernelException
        {
            IPersistenceService persistenceService = runtimeContext.PersistenceService;
            Int32 aliveWorkItemCount = persistenceService.GetAliveWorkItemCountForTaskInstance(taskInstance.Id);

            if (aliveWorkItemCount == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #8
0
        public static TaskInstanceModel Create(ITaskInstance task)
        {
            var model = new TaskInstanceModel();

            model.Id                = task.Id;
            model.Name              = task.Name;
            model.Created           = task.Created;
            model.State             = task.State.ToString();
            model.StateName         = task.State.ToString();
            model.Priority          = task.Priority;
            model.Assignee          = task.Assignee;
            model.ProcessInstanceId = task.ProcessInstanceId;
            //model.ActivityInstanceId = task.ActivityInstance?.Id;

            return(model);
        }
        //throws EngineException ,KernelException
        /// <summary>
        /// 判断任务实例是否可以终止
        /// </summary>
        /// <param name="currentSession"></param>
        /// <param name="runtimeContext"></param>
        /// <param name="processInstance"></param>
        /// <param name="taskInstance"></param>
        /// <returns>true表示可以终止,false不能终止</returns>
        public Boolean taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext,
            IProcessInstance processInstance, ITaskInstance taskInstance)
        {
            //在Fire Workflow 中,系统默认每个子流程仅创建一个实例,所以当子流程实例完成后,SubflowTaskInstance都可以被completed
            //所以,应该直接返回true;
            return true;

            //如果系统动态创建了多个并发子流程实例,则需要检查是否存在活动的子流程实例,如果存在则返回false,否则返回true。
            //可以用下面的代码实现
            //        IPersistenceService persistenceService = runtimeContext.PersistenceService;
            //        Int32 count = persistenceService.getAliveProcessInstanceCountForParentTaskInstance(taskInstance.Id);
            //        if (count>0){
            //            return false;
            //        }else{
            //            return true;
            //        }
        }
        /// <summary>
        /// 判断任务实例是否可以终止
        /// </summary>
        /// <param name="currentSession"></param>
        /// <param name="runtimeContext"></param>
        /// <param name="processInstance"></param>
        /// <param name="taskInstance"></param>
        /// <returns>true表示可以终止,false不能终止</returns>
        public Boolean taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext,
                                                  IProcessInstance processInstance, ITaskInstance taskInstance)//throws EngineException ,KernelException
        {
            //在Fire Workflow 中,系统默认每个子流程仅创建一个实例,所以当子流程实例完成后,SubflowTaskInstance都可以被completed
            //所以,应该直接返回true;
            return(true);

            //如果系统动态创建了多个并发子流程实例,则需要检查是否存在活动的子流程实例,如果存在则返回false,否则返回true。
            //可以用下面的代码实现
            //        IPersistenceService persistenceService = runtimeContext.PersistenceService;
            //        Int32 count = persistenceService.getAliveProcessInstanceCountForParentTaskInstance(taskInstance.Id);
            //        if (count>0){
            //            return false;
            //        }else{
            //            return true;
            //        }
        }
コード例 #11
0
        /// <summary>
        /// <para>正常结束工作流</para>
        /// <para>1、首先检查有无活动的token,如果有则直接返回,如果没有则结束当前流程</para>
        /// <para>2、执行结束流程的操作,将state的值设置为结束状态</para>
        /// 3、然后检查parentTaskInstanceId是否为null,如果不为null则,调用父taskinstance的complete操作。
        /// </summary>
        public void complete()
        {
            List <IToken> tokens         = this.RuntimeContext.PersistenceService.FindTokensForProcessInstance(this.Id, null);
            Boolean       canBeCompleted = true;

            for (int i = 0; tokens != null && i < tokens.Count; i++)
            {
                IToken token = tokens[i];
                if (token.IsAlive)
                {
                    canBeCompleted = false;
                    break;
                }
            }
            if (!canBeCompleted)
            {
                return;
            }

            this.State = ProcessInstanceEnum.COMPLETED;
            //记录结束时间
            this.EndTime = this.RuntimeContext.CalendarService.getSysDate();
            this.RuntimeContext.PersistenceService.SaveOrUpdateProcessInstance(this);

            //删除所有的token
            for (int i = 0; tokens != null && i < tokens.Count; i++)
            {
                IToken token = tokens[i];
                this.RuntimeContext.PersistenceService.DeleteToken(token);
            }

            //触发事件
            ProcessInstanceEvent pevent = new ProcessInstanceEvent();

            pevent.EventType = ProcessInstanceEventEnum.AFTER_PROCESS_INSTANCE_COMPLETE;
            pevent.Source    = this;
            this.fireProcessInstanceEvent(pevent);
            if (!String.IsNullOrEmpty(this.ParentTaskInstanceId.Trim()))
            {
                ITaskInstance taskInstance = this.RuntimeContext.PersistenceService.FindAliveTaskInstanceById(this.ParentTaskInstanceId);
                ((IRuntimeContextAware)taskInstance).RuntimeContext          = this.RuntimeContext;
                ((IWorkflowSessionAware)taskInstance).CurrentWorkflowSession = this.CurrentWorkflowSession;
                ((TaskInstance)taskInstance).complete(null);
            }
        }
コード例 #12
0
        // throws EngineException, KernelException
        public void run(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance)
        {
            if (taskInstance.TaskType != TaskTypeEnum.TOOL)
            {
                throw new EngineException(processInstance, taskInstance.Activity,
                        "DefaultToolTaskInstanceRunner:TaskInstance的任务类型错误,只能为TOOL类型");
            }
            Task task = taskInstance.Task;
            if (task == null)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                        "The Task is null,can NOT start the taskinstance,");
            }
            if (((ToolTask)task).Application == null || ((ToolTask)task).Application.Handler == null)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                        "The task.Application is null or task.Application.Handler is null,can NOT start the taskinstance,");
            }

            Object obj = runtimeContext.getBeanByName(((ToolTask)task).Application.Handler);

            if (obj == null || !(obj is IApplicationHandler))
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                        "Run tool task instance error! Not found the instance of " + ((ToolTask)task).Application.Handler + " or the instance not implements IApplicationHandler");
            }

            try
            {
                ((IApplicationHandler)obj).execute(taskInstance);
            }
            catch (Exception )
            {//TODO wmj2003 对tool类型的task抛出的错误应该怎么处理? 这个时候引擎会如何?整个流程是否还可以继续?
                throw new EngineException(processInstance, taskInstance.Activity,
                        "DefaultToolTaskInstanceRunner:TaskInstance的任务执行失败!");
            }

            ITaskInstanceManager taskInstanceManager = runtimeContext.TaskInstanceManager;
            taskInstanceManager.completeTaskInstance(currentSession, processInstance, taskInstance, null);
        }
コード例 #13
0
        // throws EngineException, KernelException
        public void run(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance)
        {
            if (taskInstance.TaskType!= TaskTypeEnum.FORM)//!Task.FORM.Equals(taskInstance.TaskType))
            {
                throw new EngineException(processInstance, taskInstance.Activity,
                        "DefaultFormTaskInstanceRunner:TaskInstance的任务类型错误,只能为FORM类型");
            }

            DynamicAssignmentHandler dynamicAssignmentHandler = ((WorkflowSession)currentSession).consumeCurrentDynamicAssignmentHandler();
            FormTask task = (FormTask)taskInstance.Task;
            // performer(id,name,type,handler)
            Participant performer = task.Performer;
            if (performer == null || performer.AssignmentHandler.Trim().Equals(""))
            {
                throw new EngineException(processInstance, taskInstance.Activity,
                        "流程定义错误,Form类型的 task必须指定performer及其AssignmentHandler");
            }
            assign(currentSession, processInstance, runtimeContext, taskInstance, task, performer, dynamicAssignmentHandler);
        }
コード例 #14
0
        /// <summary>
        /// 终止当前TaskInstance,检查是否可以中止当前ActivityInstance,如果可以,
        /// 则结束当前ActivityInstance,并触发targetActivityInstance或后继ActivityInstance
        /// </summary>
        /// <param name="currentSession"></param>
        /// <param name="processInstance"></param>
        /// <param name="taskInstance"></param>
        /// <param name="targetActivityInstance"></param>
        public void completeTaskInstance(IWorkflowSession currentSession, IProcessInstance processInstance,
            ITaskInstance taskInstance, IActivityInstance targetActivityInstance)
        {
            //如果TaskInstance处于结束状态,则直接返回
            if (taskInstance.State == TaskInstanceStateEnum.COMPLETED || taskInstance.State == TaskInstanceStateEnum.CANCELED)
            {
                return;
            }
            if (taskInstance.State == TaskInstanceStateEnum.INITIALIZED)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process,
                        taskInstance.TaskId,
                        "Complete task insatance failed.The state of the task insatnce[id=" + taskInstance.Id + "] is " + taskInstance.State);
            }
            if (taskInstance.IsSuspended())
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process,
                        taskInstance.TaskId,
                        "Complete task insatance failed. The task instance [id=" + taskInstance.Id + "] is suspended");
            }

            if (targetActivityInstance != null)
            {
                ((TaskInstance)taskInstance).TargetActivityId=targetActivityInstance.Activity.Id;
            }

            IPersistenceService persistenceService = this.RuntimeContext.PersistenceService;

            //第一步,首先结束当前taskInstance
            if (!this.taskInstanceCanBeCompleted(currentSession, this.RuntimeContext, processInstance, taskInstance))
            {
                return;
            }
            ((TaskInstance)taskInstance).State=TaskInstanceStateEnum.COMPLETED;
            ((TaskInstance)taskInstance).CanBeWithdrawn=false;
            ((TaskInstance)taskInstance).EndTime=RuntimeContext.CalendarService.getSysDate();
            persistenceService.SaveOrUpdateTaskInstance(taskInstance);
            //触发相应的事件
            TaskInstanceEvent e = new TaskInstanceEvent();
            e.Source=taskInstance;
            e.WorkflowSession=currentSession;
            e.ProcessInstance=processInstance;
            e.EventType = TaskInstanceEventEnum.AFTER_TASK_INSTANCE_COMPLETE;
            if (this.DefaultTaskInstanceEventListener != null)
            {
                this.DefaultTaskInstanceEventListener.onTaskInstanceEventFired(e);
            }

            this.fireTaskInstanceEvent(taskInstance, e);

            //第二步,检查ActivityInstance是否可以结束
            if (!activityInstanceCanBeCompleted(taskInstance))
            {
                return;
            }

            //第三步,尝试结束对应的activityInstance
            List<IToken> tokens = persistenceService.FindTokensForProcessInstance(taskInstance.ProcessInstanceId, taskInstance.ActivityId);
            //        System.out.println("Inside TaskInstance.complete(targetActivityInstance):: tokens.size is "+tokens.Count);
            if (tokens == null || tokens.Count == 0)
            {
                return;//表明activityInstance已经结束了。
            }
            if (tokens.Count > 1)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                        "与activityId=" + taskInstance.ActivityId + "对应的token数量(=" + tokens.Count + ")不正确,正确只能为1,因此无法完成complete操作");
            }
            IToken token = tokens[0];
            //stepNumber不相等,不允许执行结束操作。
            if (token.StepNumber != taskInstance.StepNumber)
            {
                return;
            }
            if (token.IsAlive == false)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process,
                        taskInstance.TaskId,
                        "与activityId=" + taskInstance.ActivityId + "对应的token.alive=false,因此无法完成complete操作");
            }

            INetInstance netInstance = this.RuntimeContext.KernelManager.getNetInstance(taskInstance.ProcessId, taskInstance.Version);
            Object obj = netInstance.getWFElementInstance(taskInstance.ActivityId);
            if (obj == null)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                        "系统没有找到与activityId=" + taskInstance.ActivityId + "对应activityInstance,无法执行complete操作。");
            }

            token.ProcessInstance = processInstance;

            ((IActivityInstance)obj).complete(token, targetActivityInstance);
        }
コード例 #15
0
        public void abortTaskInstanceEx(IWorkflowSession currentSession, IProcessInstance processInstance, 
            ITaskInstance thisTaskInst, String targetActivityId)
        {
            // 如果TaskInstance处于结束状态,则直接返回
            if (thisTaskInst.State == TaskInstanceStateEnum.COMPLETED || thisTaskInst.State == TaskInstanceStateEnum.CANCELED)
            {
                return;
            }

            // Initialized状态的TaskInstance也可以中止,20090830
            // if (taskInstance.State == ITaskInstance.INITIALIZED) {
            // WorkflowProcess process = taskInstance.getWorkflowProcess();
            // throw new EngineException(taskInstance.getProcessInstanceId(),
            // process,
            // taskInstance.getTaskId(),
            // "Complete task insatance failed.The state of the task insatnce[id=" +
            // taskInstance.getId() + "] is " + taskInstance.State);
            // }
            if (thisTaskInst.IsSuspended())
            {
                WorkflowProcess process = thisTaskInst.WorkflowProcess;
                throw new EngineException(thisTaskInst.ProcessInstanceId,
                        process, thisTaskInst.TaskId,
                        "Abort task insatance failed. The task instance [id="
                                + thisTaskInst.Id + "] is suspended");
            }

            //
            IPersistenceService persistenceService = this.RuntimeContext.PersistenceService;
            WorkflowProcess workflowProcess = thisTaskInst.WorkflowProcess;
            List<IToken> allTokens = null;
            List<String> aliveActivityIdsAfterJump = new List<String>();
            if (targetActivityId != null)
            {
                String thisActivityId = thisTaskInst.ActivityId;
                Boolean isInSameLine = workflowProcess.isInSameLine(thisActivityId, targetActivityId);

                if (isInSameLine)
                {
                    this.abortTaskInstance(currentSession, processInstance, thisTaskInst, targetActivityId);
                }

                //合法性检查
                allTokens = persistenceService.FindTokensForProcessInstance(thisTaskInst.ProcessInstanceId, null);

                aliveActivityIdsAfterJump.Add(targetActivityId);

                for (int i = 0; allTokens != null && i < allTokens.Count; i++)
                {
                    IToken tokenTmp = allTokens[i];
                    IWFElement workflowElement = workflowProcess.findWFElementById(tokenTmp.NodeId);
                    if ((workflowElement is Activity) && !workflowElement.Id.Equals(thisActivityId))
                    {
                        aliveActivityIdsAfterJump.Add(workflowElement.Id);

                        if (workflowProcess.isReachable(targetActivityId, workflowElement.Id)
                            || workflowProcess.isReachable(workflowElement.Id, targetActivityId))
                        {
                            throw new EngineException(
                                    thisTaskInst.ProcessInstanceId,
                                    thisTaskInst.WorkflowProcess,
                                    thisTaskInst.TaskId,
                                    "Abort refused because of the business-logic conflict!");

                        }
                    }
                }

                //1)检查是否在同一个“执行线”上(不做该检查,20091008)
                //			if (!isInSameLine) {
                //				throw new EngineException(
                //						taskInstance.getProcessInstanceId(),
                //						taskInstance.getWorkflowProcess(),
                //						taskInstance.getTaskId(),
                //						"Jumpto refused because of the current activitgy and the target activity are NOT in the same 'Execution Thread'.");
                //			}
            }

            INetInstance netInstance = this.RuntimeContext.KernelManager.getNetInstance(workflowProcess.Id, thisTaskInst.Version);
            IActivityInstance targetActivityInstance = null;
            if (targetActivityId != null)
            {
                targetActivityInstance = (IActivityInstance)netInstance.getWFElementInstance(targetActivityId);
            }

            IActivityInstance thisActivityInstance = (IActivityInstance)netInstance.getWFElementInstance(thisTaskInst.ActivityId);
            if (thisActivityInstance == null)
            {
                WorkflowProcess process = thisTaskInst.WorkflowProcess;
                throw new EngineException(thisTaskInst.ProcessInstanceId, process, thisTaskInst.TaskId,
                    "系统没有找到与activityId=" + thisTaskInst.ActivityId + "对应activityInstance,无法执行abort操作。");
            }

            if (targetActivityInstance != null)
            {
                ((TaskInstance)thisTaskInst).TargetActivityId=targetActivityInstance.Activity.Id;
            }

            // 第一步,首先Abort当前taskInstance
            persistenceService.AbortTaskInstance((TaskInstance)thisTaskInst);

            // 触发相应的事件
            TaskInstanceEvent e = new TaskInstanceEvent();
            e.Source=thisTaskInst;
            e.WorkflowSession=currentSession;
            e.ProcessInstance=processInstance;
            e.EventType = TaskInstanceEventEnum.AFTER_TASK_INSTANCE_COMPLETE;
            if (this.DefaultTaskInstanceEventListener != null)
            {
                this.DefaultTaskInstanceEventListener.onTaskInstanceEventFired(e);
            }

            this.fireTaskInstanceEvent(thisTaskInst, e);

            // 第二步,检查ActivityInstance是否可以结束
            if (!activityInstanceCanBeCompleted(thisTaskInst))
            {
                return;
            }

            // 第三步,尝试结束对应的activityInstance
            List<IToken> tokens = persistenceService.FindTokensForProcessInstance(thisTaskInst.ProcessInstanceId, thisTaskInst.ActivityId);
            // System.out.println("Inside TaskInstance.complete(targetActivityInstance):: tokens.size is "+tokens.size());
            if (tokens == null || tokens.Count == 0)
            {
                return;// 表明activityInstance已经结束了。
            }
            if (tokens.Count > 1)
            {
                WorkflowProcess process = thisTaskInst.WorkflowProcess;
                throw new EngineException(thisTaskInst.ProcessInstanceId, process, thisTaskInst.TaskId,
                    "与activityId=" + thisTaskInst.ActivityId + "对应的token数量(=" + tokens.Count + ")不正确,正确只能为1,因此无法完成complete操作");
            }
            IToken token = tokens[0];
            // stepNumber不相等,不允许执行结束操作。
            if (token.StepNumber != thisTaskInst.StepNumber)
            {
                return;
            }
            if (token.IsAlive == false)
            {
                WorkflowProcess process = thisTaskInst.WorkflowProcess;
                throw new EngineException(thisTaskInst.ProcessInstanceId, process, thisTaskInst.TaskId,
                    "与activityId=" + thisTaskInst.ActivityId + "对应的token.alive=false,因此无法完成complete操作");
            }

            token.ProcessInstance = processInstance;

            //调整token布局
            if (targetActivityId != null)
            {
                List<Synchronizer> allSynchronizersAndEnds = new List<Synchronizer>();
                allSynchronizersAndEnds.AddRange(workflowProcess.Synchronizers);
                allSynchronizersAndEnds.AddRange((IEnumerable<Synchronizer>)workflowProcess.EndNodes.ToArray());
                //allSynchronizersAndEnds.AddRange((List<Synchronizer>));
                for (int i = 0; i < allSynchronizersAndEnds.Count; i++)
                {
                    Synchronizer synchronizer = allSynchronizersAndEnds[i];
                    if (synchronizer.Name.Equals("Synchronizer4"))
                    {
                        //System.out.println(synchronizer.Name);
                    }
                    int volumn = 0;
                    if (synchronizer is EndNode)
                    {
                        volumn = synchronizer.EnteringTransitions.Count;
                    }
                    else
                    {
                        volumn = synchronizer.EnteringTransitions.Count * synchronizer.LeavingTransitions.Count;
                    }
                    IToken tokenTmp = new Token();
                    tokenTmp.NodeId = synchronizer.Id;
                    tokenTmp.IsAlive = false;
                    tokenTmp.ProcessInstanceId = thisTaskInst.ProcessInstanceId;
                    tokenTmp.StepNumber = -1;

                    List<String> incomingTransitionIds = new List<String>();
                    Boolean reachable = false;
                    List<Transition> enteringTrans = synchronizer.EnteringTransitions;
                    for (int m = 0; m < aliveActivityIdsAfterJump.Count; m++)
                    {
                        String aliveActivityId = aliveActivityIdsAfterJump[m];
                        if (workflowProcess.isReachable(aliveActivityId, synchronizer.Id))
                        {
                            Transition trans = null;
                            reachable = true;
                            for (int j = 0; j < enteringTrans.Count; j++)
                            {
                                trans = enteringTrans[j];
                                Node fromNode = (Node)trans.FromNode;
                                if (workflowProcess.isReachable(aliveActivityId, fromNode.Id))
                                {
                                    if (!incomingTransitionIds.Contains(trans.Id))
                                    {
                                        incomingTransitionIds.Add(trans.Id);
                                    }
                                }
                            }
                        }
                    }
                    if (reachable)
                    {
                        tokenTmp.Value = volumn - (incomingTransitionIds.Count * volumn / enteringTrans.Count);

                        IToken virtualToken = getJoinInfo(allTokens, synchronizer.Id);

                        if (virtualToken != null)
                        {
                            persistenceService.DeleteTokensForNode(thisTaskInst.ProcessInstanceId, synchronizer.Id);
                        }

                        if (tokenTmp.Value != 0)
                        {
                            tokenTmp.ProcessInstance = processInstance;
                            persistenceService.SaveOrUpdateToken(tokenTmp);
                        }
                    }
                }
            }
            thisActivityInstance.complete(token, targetActivityInstance);
        }
コード例 #16
0
        /// <summary>
        /// 判断TaskInstance是否可以结束,缺省的判断规则是:没有活动的WorkItem即可结束。
        /// 业务代码可以重载该函数,对特定的Task采取特殊的判断规则。
        /// </summary>
        /// <param name="currentSession"></param>
        /// <param name="runtimeContext"></param>
        /// <param name="processInstance"></param>
        /// <param name="taskInstance"></param>
        /// <returns></returns>
        protected Boolean taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext,
            IProcessInstance processInstance, ITaskInstance taskInstance)
        {
            Task task = taskInstance.Task;
            String taskInstanceCompletionEvaluatorName = null;
            ITaskInstanceCompletionEvaluator taskInstanceCompletionEvaluator = null;

            TaskTypeEnum taskType = task.TaskType;

            taskInstanceCompletionEvaluatorName = task.TaskInstanceCompletionEvaluator;
            if (!String.IsNullOrEmpty(taskInstanceCompletionEvaluatorName.Trim()))
            {
                IBeanFactory beanFactory = runtimeContext.BeanFactory;
                taskInstanceCompletionEvaluator = (ITaskInstanceCompletionEvaluator)beanFactory.GetBean(taskInstanceCompletionEvaluatorName);
            }

            if (taskInstanceCompletionEvaluator == null)
            {
                if (TaskTypeEnum.FORM == taskType)
                {
                    taskInstanceCompletionEvaluatorName = processInstance.WorkflowProcess.FormTaskInstanceCompletionEvaluator;
                }
                else if (TaskTypeEnum.TOOL == taskType)
                {
                    taskInstanceCompletionEvaluatorName = processInstance.WorkflowProcess.ToolTaskInstanceCompletionEvaluator;
                }
                else if (TaskTypeEnum.SUBFLOW == taskType)
                {
                    taskInstanceCompletionEvaluatorName = processInstance.WorkflowProcess.SubflowTaskInstanceCompletionEvaluator;
                }
                if (!String.IsNullOrEmpty(taskInstanceCompletionEvaluatorName.Trim()))
                {
                    IBeanFactory beanFactory = runtimeContext.BeanFactory;
                    taskInstanceCompletionEvaluator = (ITaskInstanceCompletionEvaluator)beanFactory.GetBean(taskInstanceCompletionEvaluatorName);
                }
            }

            if (taskInstanceCompletionEvaluator == null)
            {
                if (TaskTypeEnum.FORM == taskType)
                {
                    taskInstanceCompletionEvaluator = this.DefaultFormTaskInstanceCompletionEvaluator;
                }
                else if (TaskTypeEnum.TOOL == taskType)
                {
                    taskInstanceCompletionEvaluator = this.DefaultToolTaskInstanceCompletionEvaluator;
                }
                else if (TaskTypeEnum.SUBFLOW == taskType)
                {
                    taskInstanceCompletionEvaluator = this.DefaultSubflowTaskInstanceCompletionEvaluator;
                }
            }
            if (taskInstanceCompletionEvaluator != null)
            {
                return taskInstanceCompletionEvaluator.taskInstanceCanBeCompleted(currentSession, runtimeContext, processInstance, taskInstance);
            }
            else
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                        "无法获取TaskInstanceCompletionEvaluator,TaskId=" + task.Id + ", taskType=" + taskInstance.TaskType);
            }
        }
コード例 #17
0
        /// <summary>
        /// 终止TaskInstance。将任务实例及其所有的“活的”WorkItem变成Canceled状态。
        /// "活的"WorkItem 是指状态等于INITIALIZED、STARTED或者SUSPENDED的WorkItem.
        /// </summary>
        public bool AbortTaskInstance(ITaskInstance taskInstance)
        {
            SqlTransaction transaction = SqlServerHelper.GetSqlTransaction(connectionString);
            try
            {
                String sql = "update t_ff_rt_taskinstance set state=" 
                	+ (int)TaskInstanceStateEnum.CANCELED
                	+ " ,end_time=@1 where id=@2 and (state=0 or state=1)";
                int count = SqlServerHelper.ExecuteNonQuery(transaction, CommandType.Text, sql,
                    SqlServerHelper.NewSqlParameter("@1", SqlDbType.DateTime, 11, this.RuntimeContext.CalendarService.getSysDate()),
                    SqlServerHelper.NewSqlParameter("@2", SqlDbType.VarChar, 50, taskInstance.Id)
                    );
                if (count <= 0)
                {
                    transaction.Rollback();
                    return false;
                }


                // 将与之关联的WorkItem取消掉
                String workItemSql = " update t_ff_rt_workitem set state=" + (int)WorkItemEnum.CANCELED + ",end_time=@1  "
                        + " where taskinstance_id =@2 ";
                count = SqlServerHelper.ExecuteNonQuery(transaction, CommandType.Text, workItemSql,
                    SqlServerHelper.NewSqlParameter("@1", SqlDbType.DateTime, 11, this.RuntimeContext.CalendarService.getSysDate()),
                    SqlServerHelper.NewSqlParameter("@2", SqlDbType.VarChar, 50, taskInstance.Id)
                    );
                if (count <= 0)
                {
                    transaction.Rollback();
                    return false;
                }

                taskInstance.State = TaskInstanceStateEnum.CANCELED;

                transaction.Commit();
                return true;

            }
            catch
            {
                transaction.Rollback();
                return false;
            }
            finally
            {
                if (transaction.Connection.State != ConnectionState.Closed)
                {
                    transaction.Connection.Close();
                    transaction.Dispose();
                }
            }
        }
コード例 #18
0
        /*****************************************************************************/
        /************                                                        **********/
        /************            task instance 相关的持久化方法               **********/
        /************            Persistence methods for task instance       **********/
        /************                                                        **********/
        /******************************************************************************/

        /// <summary>
        /// <para>插入或者更新TaskInstance。</para>
        /// <para>Save or update task instance. If the taskInstance.id is null then insert a new task instance record</para>
        /// <para>and generate a new id for it { throw new NotImplementedException(); }</para>
        /// <para>otherwise update the existent one. </para>
        /// </summary>
        public bool SaveOrUpdateTaskInstance(ITaskInstance taskInstance)
        {
            if (String.IsNullOrEmpty(taskInstance.Id))
            {
                ((TaskInstance)taskInstance).Id = Guid.NewGuid().ToString().Replace("-", "");
                string insert = "INSERT INTO T_FF_RT_TASKINSTANCE (" +
                "ID, BIZ_TYPE, TASK_ID, ACTIVITY_ID, NAME, " +
                "DISPLAY_NAME, STATE, SUSPENDED, TASK_TYPE, CREATED_TIME, " +
                "STARTED_TIME, EXPIRED_TIME, END_TIME, ASSIGNMENT_STRATEGY, PROCESSINSTANCE_ID, " +
                "PROCESS_ID, VERSION, TARGET_ACTIVITY_ID, FROM_ACTIVITY_ID, STEP_NUMBER, " +
                "CAN_BE_WITHDRAWN, BIZ_INFO )VALUES(@1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21, @22)";
                SqlParameter[] insertParms = { 
    				SqlServerHelper.NewSqlParameter("@1", SqlDbType.VarChar, 50, taskInstance.Id), 
    				SqlServerHelper.NewSqlParameter("@2", SqlDbType.VarChar, 250, taskInstance.GetType().Name), 
    				SqlServerHelper.NewSqlParameter("@3", SqlDbType.VarChar, 300, taskInstance.TaskId), 
    				SqlServerHelper.NewSqlParameter("@4", SqlDbType.VarChar, 200, taskInstance.ActivityId), 
    				SqlServerHelper.NewSqlParameter("@5", SqlDbType.VarChar, 100, taskInstance.Name), 
    				SqlServerHelper.NewSqlParameter("@6", SqlDbType.VarChar, 128, taskInstance.DisplayName), 
    				SqlServerHelper.NewSqlParameter("@7", SqlDbType.Int, (int)taskInstance.State), 
    				SqlServerHelper.NewSqlParameter("@8", SqlDbType.SmallInt, SqlServerHelper.OraBit(taskInstance.IsSuspended())), 
    				SqlServerHelper.NewSqlParameter("@9", SqlDbType.VarChar, 10, taskInstance.TaskType), 
    				SqlServerHelper.NewSqlParameter("@10", SqlDbType.DateTime, 11, taskInstance.CreatedTime), 
    				SqlServerHelper.NewSqlParameter("@11", SqlDbType.DateTime, 11, taskInstance.StartedTime), 
    				SqlServerHelper.NewSqlParameter("@12", SqlDbType.DateTime, 11, taskInstance.ExpiredTime), 
    				SqlServerHelper.NewSqlParameter("@13", SqlDbType.DateTime, 11, taskInstance.EndTime), 
    				SqlServerHelper.NewSqlParameter("@14", SqlDbType.VarChar, 10, taskInstance.AssignmentStrategy), 
    				SqlServerHelper.NewSqlParameter("@15", SqlDbType.VarChar, 50, taskInstance.ProcessInstanceId), 
    				SqlServerHelper.NewSqlParameter("@16", SqlDbType.VarChar, 100, taskInstance.ProcessId), 
    				SqlServerHelper.NewSqlParameter("@17", SqlDbType.Int, taskInstance.Version), 
    				SqlServerHelper.NewSqlParameter("@18", SqlDbType.VarChar, 100, taskInstance.TargetActivityId), 
    				SqlServerHelper.NewSqlParameter("@19", SqlDbType.VarChar, 600, ((TaskInstance) taskInstance).FromActivityId), 
    				SqlServerHelper.NewSqlParameter("@20", SqlDbType.Int, taskInstance.StepNumber), 
    				SqlServerHelper.NewSqlParameter("@21", SqlDbType.SmallInt, SqlServerHelper.OraBit(((TaskInstance) taskInstance).CanBeWithdrawn)),
    				SqlServerHelper.NewSqlParameter("@22", SqlDbType.VarChar, 500, taskInstance.BizInfo)
    			};
                if (SqlServerHelper.ExecuteNonQuery(connectionString, CommandType.Text, insert, insertParms) != 1)
                    return false;
                else return true;
            }
            else
            {
                string update = "UPDATE T_FF_RT_TASKINSTANCE SET " +
                "BIZ_TYPE=@2, TASK_ID=@3, ACTIVITY_ID=@4, NAME=@5, DISPLAY_NAME=@6, " +
                "STATE=@7, SUSPENDED=@8, TASK_TYPE=@9, CREATED_TIME=@10, STARTED_TIME=@11, " +
                "EXPIRED_TIME=@12, END_TIME=@13, ASSIGNMENT_STRATEGY=@14, PROCESSINSTANCE_ID=@15, PROCESS_ID=@16, " +
                "VERSION=@17, TARGET_ACTIVITY_ID=@18, FROM_ACTIVITY_ID=@19, STEP_NUMBER=@20, CAN_BE_WITHDRAWN=@21, BIZ_INFO=@22" +
                " WHERE ID=@1";
                SqlParameter[] updateParms = { 
    				SqlServerHelper.NewSqlParameter("@2", SqlDbType.VarChar, 250, taskInstance.GetType().Name), 
    				SqlServerHelper.NewSqlParameter("@3", SqlDbType.VarChar, 300, taskInstance.TaskId), 
    				SqlServerHelper.NewSqlParameter("@4", SqlDbType.VarChar, 200, taskInstance.ActivityId), 
    				SqlServerHelper.NewSqlParameter("@5", SqlDbType.VarChar, 100, taskInstance.Name), 
    				SqlServerHelper.NewSqlParameter("@6", SqlDbType.VarChar, 128, taskInstance.DisplayName), 
    				SqlServerHelper.NewSqlParameter("@7", SqlDbType.Int, (int)taskInstance.State), 
    				SqlServerHelper.NewSqlParameter("@8", SqlDbType.SmallInt, SqlServerHelper.OraBit(taskInstance.IsSuspended())), 
    				SqlServerHelper.NewSqlParameter("@9", SqlDbType.VarChar, 10, taskInstance.TaskType), 
    				SqlServerHelper.NewSqlParameter("@10", SqlDbType.DateTime, 11, taskInstance.CreatedTime), 
    				SqlServerHelper.NewSqlParameter("@11", SqlDbType.DateTime, 11, taskInstance.StartedTime), 
    				SqlServerHelper.NewSqlParameter("@12", SqlDbType.DateTime, 11, taskInstance.ExpiredTime), 
    				SqlServerHelper.NewSqlParameter("@13", SqlDbType.DateTime, 11, taskInstance.EndTime), 
    				SqlServerHelper.NewSqlParameter("@14", SqlDbType.VarChar, 10, taskInstance.AssignmentStrategy), 
    				SqlServerHelper.NewSqlParameter("@15", SqlDbType.VarChar, 50, taskInstance.ProcessInstanceId), 
    				SqlServerHelper.NewSqlParameter("@16", SqlDbType.VarChar, 100, taskInstance.ProcessId), 
    				SqlServerHelper.NewSqlParameter("@17", SqlDbType.Int, taskInstance.Version), 
    				SqlServerHelper.NewSqlParameter("@18", SqlDbType.VarChar, 100, taskInstance.TargetActivityId), 
    				SqlServerHelper.NewSqlParameter("@19", SqlDbType.VarChar, 600, ((TaskInstance) taskInstance).FromActivityId), 
    				SqlServerHelper.NewSqlParameter("@20", SqlDbType.Int, taskInstance.StepNumber), 
    				SqlServerHelper.NewSqlParameter("@21", SqlDbType.SmallInt, SqlServerHelper.OraBit(((TaskInstance) taskInstance).CanBeWithdrawn)),
    				SqlServerHelper.NewSqlParameter("@22", SqlDbType.VarChar, 500, taskInstance.BizInfo),
    				SqlServerHelper.NewSqlParameter("@1", SqlDbType.VarChar, 50, taskInstance.Id)
    			};
                if (SqlServerHelper.ExecuteNonQuery(connectionString, CommandType.Text, update, updateParms) != 1)
                    return false;
                else return true;
            }
        }
コード例 #19
0
 protected void afterWorkItemCreated(IWorkflowSession currentSession, IProcessInstance processInstance,
                                     ITaskInstance taskInstance, IWorkItem workItem)//throws EngineException
 {
 }
コード例 #20
0
 protected void beforeTaskInstanceStart(IWorkflowSession currentSession, IProcessInstance processInstance, ITaskInstance taskInstance)//throws EngineException
 {
 }
コード例 #21
0
        public bool taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance)
        {
            IPersistenceService persistenceService = runtimeContext.PersistenceService;
            List <IWorkItem>    workItems          = persistenceService.FindWorkItemsForTaskInstance(taskInstance.Id);

            //从流程变量中获取业务流水号
            String sn = (String)processInstance.getProcessInstanceVariable("sn");

            //已经完成的WorkItem数量
            int completedWorkItemCount = 0;

            //审批同意的决定的数量
            int approvedDecitionCount = 0;

            StringBuilder examinerList = new StringBuilder(); //所有审核人名单
            StringBuilder approverList = new StringBuilder(); //同意者名单
            StringBuilder opponentList = new StringBuilder(); //不同意者名单

            for (int i = 0; i < workItems.Count; i++)
            {
                IWorkItem wi = workItems[i];

                if (wi.State == WorkItemEnum.COMPLETED)
                {
                    completedWorkItemCount++;
                    WebDemo.Example.LoanProcess.Persistence.ApproveInfo approveInfo = approveInfoDAO.findBySnAndUserId(sn, wi.ActorId);
                    if (approveInfo != null)
                    {
                        examinerList.Append(approveInfo.Approver).Append(",");
                        if (approveInfo.Decision)
                        {
                            approvedDecitionCount++;
                            approverList.Append(approveInfo.Approver).Append(",");
                        }
                        else
                        {
                            opponentList.Append(approveInfo.Approver).Append(",");
                        }
                    }
                }
            }


            //------------------判断是否可以结束该汇签任务-----------
            float size    = (float)workItems.Count;
            float theRule = 2 / 3f;
            float currentCompletedPercentage = completedWorkItemCount / size; //已经完成的工单占总工单的比例
            float currentAggreePercentage    = approvedDecitionCount / size;  //已经同意的比例



            //如果完成的工单数量小于2/3,则直接返回false,即不可以结束TaskInstance
            if (currentCompletedPercentage < theRule)
            {
                return(false);
            }
            //如果同意的数量达到2/3则直接结束TaskInstance
            else if (currentAggreePercentage >= theRule)
            {
                //修改流程变量的值
                processInstance.setProcessInstanceVariable("Decision", true);

                //将最终审批决定纪录到业务表中
                LoanInfo loanInfo = loanInfoDAO.findBySn(sn);
                if (loanInfo != null)
                {
                    loanInfo.Decision     = true;
                    loanInfo.ExaminerList = examinerList.ToString();
                    loanInfo.ApproverList = approverList.ToString();
                    loanInfo.OpponentList = opponentList.ToString();
                    loanInfoDAO.attachDirty(loanInfo);
                }

                return(true);
            }
            //当所有的workItem结束时,可以结束TaskInstance
            else if (completedWorkItemCount == workItems.Count)
            {
                LoanInfo loanInfo = loanInfoDAO.findBySn(sn);

                if (currentAggreePercentage < theRule)
                {
                    //修改流程变量的值
                    processInstance.setProcessInstanceVariable("Decision", false);

                    //将最终审批决定记录到业务表中
                    if (loanInfo != null)
                    {
                        loanInfo.Decision = false;
                    }
                    loanInfo.ExaminerList = examinerList.ToString();
                    loanInfo.ApproverList = approverList.ToString();
                    loanInfo.OpponentList = opponentList.ToString();
                    loanInfoDAO.attachDirty(loanInfo);
                }
                else
                {
                    //修改流程变量的值
                    processInstance.setProcessInstanceVariable("Decision", true);

                    //将最终审批决定记录到业务表中
                    if (loanInfo != null)
                    {
                        loanInfo.Decision = true;
                    }
                    loanInfo.ExaminerList = examinerList.ToString();
                    loanInfo.ApproverList = approverList.ToString();
                    loanInfo.OpponentList = opponentList.ToString();
                    loanInfoDAO.attachDirty(loanInfo);
                }

                return(true);
            }
            return(false);
        }
コード例 #22
0
        public void run(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance) // throws EngineException, KernelException
        {
            if (taskInstance.TaskType != TaskTypeEnum.FORM)                                                                                           //!Task.FORM.Equals(taskInstance.TaskType))
            {
                throw new EngineException(processInstance, taskInstance.Activity,
                                          "DefaultFormTaskInstanceRunner:TaskInstance的任务类型错误,只能为FORM类型");
            }

            DynamicAssignmentHandler dynamicAssignmentHandler = ((WorkflowSession)currentSession).consumeCurrentDynamicAssignmentHandler();
            FormTask task = (FormTask)taskInstance.Task;
            // performer(id,name,type,handler)
            Participant performer = task.Performer;

            if (performer == null || performer.AssignmentHandler.Trim().Equals(""))
            {
                throw new EngineException(processInstance, taskInstance.Activity,
                                          "流程定义错误,Form类型的 task必须指定performer及其AssignmentHandler");
            }
            assign(currentSession, processInstance, runtimeContext, taskInstance, task, performer, dynamicAssignmentHandler);
        }
コード例 #23
0
        // throws EngineException, KernelException
        public void run(IWorkflowSession currentSession, RuntimeContext runtimeContext,
            IProcessInstance processInstance, ITaskInstance taskInstance)
        {
            if (taskInstance.TaskType != TaskTypeEnum.SUBFLOW)
            {
                throw new EngineException(processInstance, taskInstance.Activity,
                        "DefaultSubflowTaskInstanceRunner:TaskInstance的任务类型错误,只能为SUBFLOW类型");
            }
            Task task = taskInstance.Task;
            SubWorkflowProcess Subflow = ((SubflowTask)task).SubWorkflowProcess;

            WorkflowDefinition subWorkflowDef = runtimeContext.DefinitionService.GetTheLatestVersionOfWorkflowDefinition(Subflow.WorkflowProcessId);
            if (subWorkflowDef == null)
            {
                WorkflowProcess parentWorkflowProcess = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, parentWorkflowProcess, taskInstance.TaskId,
                        "系统中没有Id为" + Subflow.WorkflowProcessId + "的流程定义");
            }
            WorkflowProcess subWorkflowProcess = subWorkflowDef.getWorkflowProcess();

            if (subWorkflowProcess == null)
            {
                WorkflowProcess parentWorkflowProcess = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, parentWorkflowProcess, taskInstance.TaskId,
                        "系统中没有Id为" + Subflow.WorkflowProcessId + "的流程定义");
            }

            IPersistenceService persistenceService = runtimeContext.PersistenceService;
            //更改任务的状态和开始时间
            ((TaskInstance)taskInstance).State = TaskInstanceStateEnum.RUNNING;
            ((TaskInstance)taskInstance).StartedTime = runtimeContext.CalendarService.getSysDate();
            persistenceService.SaveOrUpdateTaskInstance(taskInstance);

            IProcessInstance subProcessInstance = currentSession.createProcessInstance(subWorkflowProcess.Name, taskInstance);

            //初始化流程变量,从父实例获得初始值
            Dictionary<String, Object> processVars = ((TaskInstance)taskInstance).AliveProcessInstance.ProcessInstanceVariables;
            List<DataField> datafields = subWorkflowProcess.DataFields;
            for (int i = 0; datafields != null && i < datafields.Count; i++)
            {
                DataField df = (DataField)datafields[i];
                if (df.DataType == DataTypeEnum.STRING)
                {
                    if (processVars[df.Name] != null && (processVars[df.Name] is String))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, df.InitialValue);
                    }
                    else
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, "");
                    }
                }
                else if (df.DataType == DataTypeEnum.INTEGER)
                {
                    if (processVars[df.Name] != null && (processVars[df.Name] is Int32))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        try
                        {
                            Int32 intValue = Int32.Parse(df.InitialValue);
                            subProcessInstance.setProcessInstanceVariable(df.Name, intValue);
                        }
                        catch { }
                    }
                    else
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, (Int32)0);
                    }
                }
                else if (df.DataType == DataTypeEnum.FLOAT)
                {
                    if (processVars[df.Name] != null && (processVars[df.Name] is float))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        float floatValue = float.Parse(df.InitialValue);
                        subProcessInstance.setProcessInstanceVariable(df.Name, floatValue);
                    }
                    else
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, (float)0);
                    }
                }
                else if (df.DataType == DataTypeEnum.BOOLEAN)
                {
                    if (processVars[df.Name] != null && (processVars[df.Name] is Boolean))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        Boolean booleanValue = Boolean.Parse(df.InitialValue);
                        subProcessInstance.setProcessInstanceVariable(df.Name, booleanValue);
                    }
                    else
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, false);
                    }
                }
                else if (df.DataType == DataTypeEnum.DATETIME)
                {
                    //TODO 需要完善一下 ( 父子流程数据传递——时间类型的数据还未做传递-不知道为什么?)
                    //wmj2003 20090925 补充上了
                    if (processVars[df.Name] != null && (processVars[df.Name] is DateTime))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        try
                        {
                            DateTime dateTmp = DateTime.Parse(df.InitialValue);
                            subProcessInstance.setProcessInstanceVariable(df.Name, dateTmp);
                        }
                        catch
                        {
                            subProcessInstance.setProcessInstanceVariable(df.Name, null);
                        }
                    }
                }
                //TODO 应将下面这句删除!这里还需要吗?应该直接subProcessInstance.run()就可以了。
                runtimeContext.PersistenceService.SaveOrUpdateProcessInstance(subProcessInstance);
                subProcessInstance.run();
            }
        }
コード例 #24
0
        /*****************************************************************************/
        /************                                                        **********/
        /************            task instance 相关的持久化方法               **********/
        /************            Persistence methods for task instance       **********/
        /************                                                        **********/
        /******************************************************************************/

        /// <summary>
        /// <para>插入或者更新TaskInstance。</para>
        /// <para>Save or update task instance. If the taskInstance.id is null then insert a new task instance record</para>
        /// <para>and generate a new id for it { throw new NotImplementedException(); }</para>
        /// <para>otherwise update the existent one. </para>
        /// </summary>
        public bool SaveOrUpdateTaskInstance(ITaskInstance taskInstance)
        {
            if (String.IsNullOrEmpty(taskInstance.Id))
            {
                ((TaskInstance)taskInstance).Id = Guid.NewGuid().ToString().Replace("-", "");
                string insert = "INSERT INTO T_FF_RT_TASKINSTANCE (" +
                "ID, BIZ_TYPE, TASK_ID, ACTIVITY_ID, NAME, " +
                "DISPLAY_NAME, STATE, SUSPENDED, TASK_TYPE, CREATED_TIME, " +
                "STARTED_TIME, EXPIRED_TIME, END_TIME, ASSIGNMENT_STRATEGY, PROCESSINSTANCE_ID, " +
                "PROCESS_ID, VERSION, TARGET_ACTIVITY_ID, FROM_ACTIVITY_ID, STEP_NUMBER, " +
                "CAN_BE_WITHDRAWN, BIZ_INFO )VALUES(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22)";
    			OracleParameter[] insertParms = { 
    				OracleHelper.NewOracleParameter(":1", OracleType.VarChar, 50, taskInstance.Id), 
    				OracleHelper.NewOracleParameter(":2", OracleType.VarChar, 250, taskInstance.GetType().Name), 
    				OracleHelper.NewOracleParameter(":3", OracleType.VarChar, 300, taskInstance.TaskId), 
    				OracleHelper.NewOracleParameter(":4", OracleType.VarChar, 200, taskInstance.ActivityId), 
    				OracleHelper.NewOracleParameter(":5", OracleType.VarChar, 100, taskInstance.Name), 
    				OracleHelper.NewOracleParameter(":6", OracleType.VarChar, 128, taskInstance.DisplayName), 
    				OracleHelper.NewOracleParameter(":7", OracleType.Int32, (int)taskInstance.State), 
    				OracleHelper.NewOracleParameter(":8", OracleType.Int16, OracleHelper.OraBit(taskInstance.IsSuspended())), 
    				OracleHelper.NewOracleParameter(":9", OracleType.VarChar, 10, taskInstance.TaskType), 
    				OracleHelper.NewOracleParameter(":10", OracleType.Timestamp, 11, taskInstance.CreatedTime), 
    				OracleHelper.NewOracleParameter(":11", OracleType.Timestamp, 11, taskInstance.StartedTime), 
    				OracleHelper.NewOracleParameter(":12", OracleType.Timestamp, 11, taskInstance.ExpiredTime), 
    				OracleHelper.NewOracleParameter(":13", OracleType.Timestamp, 11, taskInstance.EndTime), 
    				OracleHelper.NewOracleParameter(":14", OracleType.VarChar, 10, taskInstance.AssignmentStrategy), 
    				OracleHelper.NewOracleParameter(":15", OracleType.VarChar, 50, taskInstance.ProcessInstanceId), 
    				OracleHelper.NewOracleParameter(":16", OracleType.VarChar, 100, taskInstance.ProcessId), 
    				OracleHelper.NewOracleParameter(":17", OracleType.Int32, taskInstance.Version), 
    				OracleHelper.NewOracleParameter(":18", OracleType.VarChar, 100, taskInstance.TargetActivityId), 
    				OracleHelper.NewOracleParameter(":19", OracleType.VarChar, 600, ((TaskInstance) taskInstance).FromActivityId), 
    				OracleHelper.NewOracleParameter(":20", OracleType.Int32, taskInstance.StepNumber), 
    				OracleHelper.NewOracleParameter(":21", OracleType.Int16, OracleHelper.OraBit(((TaskInstance) taskInstance).CanBeWithdrawn)),
    				OracleHelper.NewOracleParameter(":22", OracleType.VarChar, 500, taskInstance.BizInfo)
    			};
    			if (OracleHelper.ExecuteNonQuery(connectionString, CommandType.Text, insert, insertParms) != 1)
    				return false;
    			else return true;
            }
            else
            {
                string update = "UPDATE T_FF_RT_TASKINSTANCE SET " +
                "BIZ_TYPE=:2, TASK_ID=:3, ACTIVITY_ID=:4, NAME=:5, DISPLAY_NAME=:6, " +
                "STATE=:7, SUSPENDED=:8, TASK_TYPE=:9, CREATED_TIME=:10, STARTED_TIME=:11, " +
                "EXPIRED_TIME=:12, END_TIME=:13, ASSIGNMENT_STRATEGY=:14, PROCESSINSTANCE_ID=:15, PROCESS_ID=:16, " +
                "VERSION=:17, TARGET_ACTIVITY_ID=:18, FROM_ACTIVITY_ID=:19, STEP_NUMBER=:20, CAN_BE_WITHDRAWN=:21, BIZ_INFO=:22" +
                " WHERE ID=:1";
                OracleParameter[] updateParms = { 
    				OracleHelper.NewOracleParameter(":2", OracleType.VarChar, 250, taskInstance.GetType().Name), 
    				OracleHelper.NewOracleParameter(":3", OracleType.VarChar, 300, taskInstance.TaskId), 
    				OracleHelper.NewOracleParameter(":4", OracleType.VarChar, 200, taskInstance.ActivityId), 
    				OracleHelper.NewOracleParameter(":5", OracleType.VarChar, 100, taskInstance.Name), 
    				OracleHelper.NewOracleParameter(":6", OracleType.VarChar, 128, taskInstance.DisplayName), 
    				OracleHelper.NewOracleParameter(":7", OracleType.Int32, (int)taskInstance.State), 
    				OracleHelper.NewOracleParameter(":8", OracleType.Int16, OracleHelper.OraBit(taskInstance.IsSuspended())), 
    				OracleHelper.NewOracleParameter(":9", OracleType.VarChar, 10, taskInstance.TaskType), 
    				OracleHelper.NewOracleParameter(":10", OracleType.Timestamp, 11, taskInstance.CreatedTime), 
    				OracleHelper.NewOracleParameter(":11", OracleType.Timestamp, 11, taskInstance.StartedTime), 
    				OracleHelper.NewOracleParameter(":12", OracleType.Timestamp, 11, taskInstance.ExpiredTime), 
    				OracleHelper.NewOracleParameter(":13", OracleType.Timestamp, 11, taskInstance.EndTime), 
    				OracleHelper.NewOracleParameter(":14", OracleType.VarChar, 10, taskInstance.AssignmentStrategy), 
    				OracleHelper.NewOracleParameter(":15", OracleType.VarChar, 50, taskInstance.ProcessInstanceId), 
    				OracleHelper.NewOracleParameter(":16", OracleType.VarChar, 100, taskInstance.ProcessId), 
    				OracleHelper.NewOracleParameter(":17", OracleType.Int32, taskInstance.Version), 
    				OracleHelper.NewOracleParameter(":18", OracleType.VarChar, 100, taskInstance.TargetActivityId), 
    				OracleHelper.NewOracleParameter(":19", OracleType.VarChar, 600, ((TaskInstance) taskInstance).FromActivityId), 
    				OracleHelper.NewOracleParameter(":20", OracleType.Int32, taskInstance.StepNumber), 
    				OracleHelper.NewOracleParameter(":21", OracleType.Int16, OracleHelper.OraBit(((TaskInstance) taskInstance).CanBeWithdrawn)),
    				OracleHelper.NewOracleParameter(":22", OracleType.VarChar, 500, taskInstance.BizInfo),
    				OracleHelper.NewOracleParameter(":1", OracleType.VarChar, 50, taskInstance.Id)
    			};
                if (OracleHelper.ExecuteNonQuery(connectionString, CommandType.Text, update, updateParms) != 1)
                    return false;
                else return true;
            }
        }
コード例 #25
0
 public bool AbortTaskInstance(ITaskInstance taskInstance)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
 public bool SaveOrUpdateTaskInstance(ITaskInstance taskInstance)
 {
     throw new NotImplementedException();
 }
コード例 #27
0
        public bool taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance)
        {
            IPersistenceService persistenceService = runtimeContext.PersistenceService;
            List<IWorkItem> workItems = persistenceService.FindWorkItemsForTaskInstance(taskInstance.Id);

            //从流程变量中获取业务流水号
            String sn = (String)processInstance.getProcessInstanceVariable("sn");

            //已经完成的WorkItem数量
            int completedWorkItemCount = 0;

            //审批同意的决定的数量
            int approvedDecitionCount = 0;

            StringBuilder examinerList = new StringBuilder();//所有审核人名单
            StringBuilder approverList = new StringBuilder();//同意者名单
            StringBuilder opponentList = new StringBuilder();//不同意者名单
            for (int i = 0; i < workItems.Count; i++)
            {
                IWorkItem wi = workItems[i];

                if (wi.State == WorkItemEnum.COMPLETED)
                {
                    completedWorkItemCount++;
                    WebDemo.Example.LoanProcess.Persistence.ApproveInfo approveInfo = approveInfoDAO.findBySnAndUserId(sn, wi.ActorId);
                    if (approveInfo != null)
                    {
                        examinerList.Append(approveInfo.Approver).Append(",");
                        if (approveInfo.Decision)
                        {
                            approvedDecitionCount++;
                            approverList.Append(approveInfo.Approver).Append(",");
                        }
                        else
                        {
                            opponentList.Append(approveInfo.Approver).Append(",");
                        }
                    }
                }
            }

            //------------------判断是否可以结束该汇签任务-----------
            float size =(float)workItems.Count;
            float theRule = 2 / 3f;
            float currentCompletedPercentage = completedWorkItemCount / size;//已经完成的工单占总工单的比例
            float currentAggreePercentage = approvedDecitionCount / size;//已经同意的比例

            //如果完成的工单数量小于2/3,则直接返回false,即不可以结束TaskInstance
            if (currentCompletedPercentage < theRule)
            {
                return false;
            }
            //如果同意的数量达到2/3则直接结束TaskInstance
            else if (currentAggreePercentage >= theRule)
            {

                //修改流程变量的值
                processInstance.setProcessInstanceVariable("Decision", true);

                //将最终审批决定纪录到业务表中
                LoanInfo loanInfo = loanInfoDAO.findBySn(sn);
                if (loanInfo!=null)
                {
                    loanInfo.Decision = true;
                    loanInfo.ExaminerList=examinerList.ToString();
                    loanInfo.ApproverList=approverList.ToString();
                    loanInfo.OpponentList=opponentList.ToString();
                    loanInfoDAO.attachDirty(loanInfo);
                }

                return true;
            }
            //当所有的workItem结束时,可以结束TaskInstance
            else if (completedWorkItemCount == workItems.Count)
            {
                LoanInfo loanInfo = loanInfoDAO.findBySn(sn);

                if (currentAggreePercentage < theRule)
                {
                    //修改流程变量的值
                    processInstance.setProcessInstanceVariable("Decision", false);

                    //将最终审批决定记录到业务表中
                    if (loanInfo != null) loanInfo.Decision = false;
                    loanInfo.ExaminerList=examinerList.ToString();
                    loanInfo.ApproverList=approverList.ToString();
                    loanInfo.OpponentList=opponentList.ToString();
                    loanInfoDAO.attachDirty(loanInfo);
                }
                else
                {
                    //修改流程变量的值
                    processInstance.setProcessInstanceVariable("Decision", true);

                    //将最终审批决定记录到业务表中
                    if (loanInfo != null) loanInfo.Decision = true;
                    loanInfo.ExaminerList=examinerList.ToString();
                    loanInfo.ApproverList=approverList.ToString();
                    loanInfo.OpponentList=opponentList.ToString();
                    loanInfoDAO.attachDirty(loanInfo);
                }

                return true;
            }
            return false;
        }
コード例 #28
0
        // throws EngineException, KernelException
        /// <summary>分配, 按照当前任务的参与者插入工单</summary>
        /// <param name="currentSession"></param>
        /// <param name="processInstance"></param>
        /// <param name="runtimeContext"></param>
        /// <param name="taskInstance"></param>
        /// <param name="formTask"></param>
        /// <param name="part"></param>
        /// <param name="dynamicAssignmentHandler"></param>
        protected void assign(IWorkflowSession currentSession, IProcessInstance processInstance, RuntimeContext runtimeContext, ITaskInstance taskInstance, FormTask formTask, Participant part, DynamicAssignmentHandler dynamicAssignmentHandler)
        {
            //如果有指定的Actor,则按照指定的Actor分配任务
            if (dynamicAssignmentHandler != null)
            {
                dynamicAssignmentHandler.assign((IAssignable)taskInstance, part.Name);
            }
            else
            {
                IPersistenceService persistenceService = runtimeContext.PersistenceService;
                List<ITaskInstance> taskInstanceList = persistenceService.FindTaskInstancesForProcessInstance(taskInstance.ProcessInstanceId, taskInstance.ActivityId);
                ITaskInstance theLastCompletedTaskInstance = null;

                for (int i = 0; taskInstanceList != null && i < taskInstanceList.Count; i++)
                {
                    ITaskInstance tmp = (ITaskInstance)taskInstanceList[i];
                    if (tmp.Id.Equals(taskInstance.Id)) continue;
                    if (!tmp.TaskId.Equals(taskInstance.TaskId)) continue;
                    if (tmp.State != TaskInstanceStateEnum.COMPLETED) continue;
                    if (theLastCompletedTaskInstance == null)
                    {
                        theLastCompletedTaskInstance = tmp;
                    }
                    else
                    {
                        if (theLastCompletedTaskInstance.StepNumber < tmp.StepNumber)
                        {
                            theLastCompletedTaskInstance = tmp;
                        }
                    }
                }

                //如果是循环且LoopStrategy==REDO,则分配个上次完成该工作的操作员
                if (theLastCompletedTaskInstance != null && (LoopStrategyEnum.REDO==formTask.LoopStrategy || currentSession.isInWithdrawOrRejectOperation()))
                {
                    List<IWorkItem> workItemList = persistenceService.FindCompletedWorkItemsForTaskInstance(theLastCompletedTaskInstance.Id);
                    ITaskInstanceManager taskInstanceMgr = runtimeContext.TaskInstanceManager;
                    for (int k = 0; k < workItemList.Count; k++)
                    {
                        IWorkItem completedWorkItem = (IWorkItem)workItemList[k];

                        IWorkItem newFromWorkItem = taskInstanceMgr.createWorkItem(currentSession, processInstance, taskInstance, completedWorkItem.ActorId);
                        newFromWorkItem.claim();//并自动签收
                    }
                }
                else
                {
                    IBeanFactory beanFactory = runtimeContext.BeanFactory;
                    //从spring中获取到对应任务的Performer,创建工单
                    //201004 add lwz 参与者通过业务接口实现默认获取用户
                    switch (part.AssignmentType)
                    {
                        case AssignmentTypeEnum.Current:
                            runtimeContext.AssignmentBusinessHandler.assignCurrent(
                                currentSession, processInstance, (IAssignable)taskInstance);
                            break;
                        case AssignmentTypeEnum.Role:
                            runtimeContext.AssignmentBusinessHandler.assignRole(
                                currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue);
                            break;
                        case AssignmentTypeEnum.Agency:
                            runtimeContext.AssignmentBusinessHandler.assignAgency(
                                currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue);
                            break;
                        case AssignmentTypeEnum.Fixed:
                            runtimeContext.AssignmentBusinessHandler.assignFixed(
                                currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue);
                            break;
                        case AssignmentTypeEnum.Superiors:
                            runtimeContext.AssignmentBusinessHandler.assignSuperiors(
                                currentSession, processInstance, (IAssignable)taskInstance);
                            break;
                        default:
                            IAssignmentHandler assignmentHandler = (IAssignmentHandler)beanFactory.GetBean(part.AssignmentHandler);
                            //modified by wangmj 20090904
                            ((IAssignmentHandler)assignmentHandler).assign((IAssignable)taskInstance, part.PerformerValue);
                            break;
                    }
                }
            }
        }
コード例 #29
0
        /// <summary>
        /// <para>实现任务分配工作,该方法一般的实现逻辑是:</para>
        /// <para>首先根据performerName查询出所有的操作员,可以把performerName当作角色名称。</para>
        /// <para>然后调用asignable.asignToActor(String actorId,Boolean needSign)或者</para>
        /// <para>asignable.asignToActor(String actorId)或者asignable.asignToActorS(List actorIds)</para>
        /// 进行任务分配。
        /// </summary>
        /// <param name="asignable">IAssignable实现类,在FireWorkflow中实际上就是TaskInstance对象。</param>
        /// <param name="performerName">角色名称</param>
        public void assign(IAssignable asignable, string performerName)
        {
            ITaskInstance taskInst = (ITaskInstance)asignable;

            String        roleName = performerName == null ? "" : performerName.Trim();
            List <String> users    = new List <string>();

            switch (roleName)
            {
            case "WarehouseKeeper":
                users = new List <string>()
                {
                    "warehousekeeper1", "warehousekeeper2"
                };
                break;

            case "Deliveryman":
                users = new List <string>()
                {
                    "deliveryman1", "deliveryman2", "deliveryman3"
                };
                break;

            case "RiskEvaluator":
                users = new List <string>()
                {
                    "riskevaluator1", "riskevaluator2"
                };
                break;

            case "Approver":
                users = new List <string>()
                {
                    "approver1", "approver2", "approver3"
                };
                break;

            case "LendMoneyOfficer":
                users = new List <string>()
                {
                    "lendmoneyofficer1"
                };
                break;

            default:
                break;
            }
            if (users == null || users.Count <= 0)
            {
                throw new EngineException(taskInst.ProcessInstanceId,
                                          taskInst.WorkflowProcess, taskInst.TaskId, "没有任何用户和角色" + performerName + "相关联,无法分配任务实例[id=" + taskInst.Id + ",任务名称=" + taskInst.DisplayName);
            }
            List <String> userIds = new List <string>();

            foreach (string item in users)
            {
                userIds.Add(item);
            }

            asignable.assignToActors(userIds);
        }
コード例 #30
0
 protected void afterTaskInstanceCompleted(IWorkflowSession currentSession,
                                           IProcessInstance processInstance, ITaskInstance taskInstance)//throws EngineException
 {
 }
コード例 #31
0
 //throws EngineException ,KernelException
 /// <summary>
 /// 判断任务实例是否可以终止
 /// </summary>
 /// <param name="currentSession"></param>
 /// <param name="runtimeContext"></param>
 /// <param name="processInstance"></param>
 /// <param name="taskInstance"></param>
 /// <returns>true表示可以终止,false不能终止</returns>
 public Boolean taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext,
     IProcessInstance processInstance, ITaskInstance taskInstance)
 {
     //Tool类型的TaskInstance在handler执行完后,都可以直接结束。
     return true;
 }
コード例 #32
0
 protected void afterWorkItemComplete(IWorkflowSession currentSession, IProcessInstance processInstance,
                                      ITaskInstance taskInstance, IWorkItem workItem)
 {
     //      System.out.println("---------------------------------after workitem complete!!!!!!!!!!!!!!");
 }
コード例 #33
0
        protected Boolean activityInstanceCanBeCompleted(ITaskInstance taskInstance)
        {
            IPersistenceService persistenceService = this.RuntimeContext.PersistenceService;
            Activity thisActivity = (Activity)taskInstance.Activity;
            //检查是否有尚未创建的TaskInstance
            if (thisActivity.getTasks().Count > 1)
            {
                List<ITaskInstance> taskInstanceList = persistenceService.FindTaskInstancesForProcessInstanceByStepNumber(taskInstance.ProcessInstanceId, taskInstance.StepNumber);
                if (taskInstanceList == null || taskInstanceList.Count < thisActivity.getTasks().Count)
                {
                    return false;
                }
            }
            if (thisActivity.CompletionStrategy == FormTaskEnum.ALL)
            {
                Int32 aliveTaskInstanceCount4ThisActivity = persistenceService.GetAliveTaskInstanceCountForActivity(taskInstance.ProcessInstanceId, taskInstance.ActivityId);

                if (aliveTaskInstanceCount4ThisActivity > 0)
                {
                    return false;//尚有未结束的TaskInstance
                }
                else
                {
                    return true;
                }
            }
            else
            {
                return true;//此处应该不需要判断,因为对于已经结束的Activity已经没有对应的token。所以继续往下执行不会导致逻辑错误。
            }
        }
コード例 #34
0
        /// <summary>
        /// 触发task instance相关的事件
        /// </summary>
        /// <param name="taskInstance"></param>
        /// <param name="e"></param>
        protected void fireTaskInstanceEvent(ITaskInstance taskInstance, TaskInstanceEvent e)
        {
            Task task = taskInstance.Task;
            if (task == null)
            {
                return;
            }

            List<EventListener> listeners = task.EventListeners;
            for (int i = 0; i < listeners.Count; i++)
            {
                EventListener listener = (EventListener)listeners[i];
                Object obj = RuntimeContext.getBeanByName(listener.ClassName);
                if (obj != null && (obj is ITaskInstanceEventListener))
                {
                    ((ITaskInstanceEventListener)obj).onTaskInstanceEventFired(e);
                }
            }
        }
コード例 #35
0
ファイル: WorkflowSession.cs プロジェクト: magoo-lau/fireflow
 /// <summary>
 /// 创建流程实例。如果流程定义了流程变量(DataField),则自动把流程变量初始化成流程实例变量。
 /// </summary>
 /// <param name="workflowProcessName">流程的Name属性,在Fire workflow中,流程的Name和Id是相等的而且都是唯一的。</param>
 /// <param name="parentTaskInstance">父TaskInstance</param>
 /// <returns>新创建的流程实例</returns>
 public IProcessInstance createProcessInstance(String workflowProcessName, ITaskInstance parentTaskInstance)
 {
     return _createProcessInstance(workflowProcessName, parentTaskInstance.Id,
         parentTaskInstance.ProcessInstanceId, parentTaskInstance.Id);
 }
コード例 #36
0
        public void run(IWorkflowSession currentSession, RuntimeContext runtimeContext,
                        IProcessInstance processInstance, ITaskInstance taskInstance)// throws EngineException, KernelException
        {
            if (taskInstance.TaskType != TaskTypeEnum.SUBFLOW)
            {
                throw new EngineException(processInstance, taskInstance.Activity,
                                          "DefaultSubflowTaskInstanceRunner:TaskInstance的任务类型错误,只能为SUBFLOW类型");
            }
            Task task = taskInstance.Task;
            SubWorkflowProcess Subflow = ((SubflowTask)task).SubWorkflowProcess;

            WorkflowDefinition subWorkflowDef = runtimeContext.DefinitionService.GetTheLatestVersionOfWorkflowDefinition(Subflow.WorkflowProcessId);

            if (subWorkflowDef == null)
            {
                WorkflowProcess parentWorkflowProcess = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, parentWorkflowProcess, taskInstance.TaskId,
                                          "系统中没有Id为" + Subflow.WorkflowProcessId + "的流程定义");
            }
            WorkflowProcess subWorkflowProcess = subWorkflowDef.getWorkflowProcess();

            if (subWorkflowProcess == null)
            {
                WorkflowProcess parentWorkflowProcess = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, parentWorkflowProcess, taskInstance.TaskId,
                                          "系统中没有Id为" + Subflow.WorkflowProcessId + "的流程定义");
            }

            IPersistenceService persistenceService = runtimeContext.PersistenceService;

            //更改任务的状态和开始时间
            ((TaskInstance)taskInstance).State       = TaskInstanceStateEnum.RUNNING;
            ((TaskInstance)taskInstance).StartedTime = runtimeContext.CalendarService.getSysDate();
            persistenceService.SaveOrUpdateTaskInstance(taskInstance);

            IProcessInstance subProcessInstance = currentSession.createProcessInstance(subWorkflowProcess.Name, taskInstance);

            //初始化流程变量,从父实例获得初始值
            Dictionary <String, Object> processVars = ((TaskInstance)taskInstance).AliveProcessInstance.ProcessInstanceVariables;
            List <DataField>            datafields  = subWorkflowProcess.DataFields;

            for (int i = 0; datafields != null && i < datafields.Count; i++)
            {
                DataField df = (DataField)datafields[i];
                if (df.DataType == DataTypeEnum.STRING)
                {
                    if (processVars[df.Name] != null && (processVars[df.Name] is String))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, df.InitialValue);
                    }
                    else
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, "");
                    }
                }
                else if (df.DataType == DataTypeEnum.INTEGER)
                {
                    if (processVars[df.Name] != null && (processVars[df.Name] is Int32))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        try
                        {
                            Int32 intValue = Int32.Parse(df.InitialValue);
                            subProcessInstance.setProcessInstanceVariable(df.Name, intValue);
                        }
                        catch { }
                    }
                    else
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, (Int32)0);
                    }
                }
                else if (df.DataType == DataTypeEnum.FLOAT)
                {
                    if (processVars[df.Name] != null && (processVars[df.Name] is float))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        float floatValue = float.Parse(df.InitialValue);
                        subProcessInstance.setProcessInstanceVariable(df.Name, floatValue);
                    }
                    else
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, (float)0);
                    }
                }
                else if (df.DataType == DataTypeEnum.BOOLEAN)
                {
                    if (processVars[df.Name] != null && (processVars[df.Name] is Boolean))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        Boolean booleanValue = Boolean.Parse(df.InitialValue);
                        subProcessInstance.setProcessInstanceVariable(df.Name, booleanValue);
                    }
                    else
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, false);
                    }
                }
                else if (df.DataType == DataTypeEnum.DATETIME)
                {
                    //TODO 需要完善一下 ( 父子流程数据传递——时间类型的数据还未做传递-不知道为什么?)
                    //wmj2003 20090925 补充上了
                    if (processVars[df.Name] != null && (processVars[df.Name] is DateTime))
                    {
                        subProcessInstance.setProcessInstanceVariable(df.Name, processVars[df.Name]);
                    }
                    else if (df.InitialValue != null)
                    {
                        try
                        {
                            DateTime dateTmp = DateTime.Parse(df.InitialValue);
                            subProcessInstance.setProcessInstanceVariable(df.Name, dateTmp);
                        }
                        catch
                        {
                            subProcessInstance.setProcessInstanceVariable(df.Name, null);
                        }
                    }
                }
                //TODO 应将下面这句删除!这里还需要吗?应该直接subProcessInstance.run()就可以了。
                runtimeContext.PersistenceService.SaveOrUpdateProcessInstance(subProcessInstance);
                subProcessInstance.run();
            }
        }
コード例 #37
0
 /// <summary>
 /// 创建流程实例。如果流程定义了流程变量(DataField),则自动把流程变量初始化成流程实例变量。
 /// </summary>
 /// <param name="workflowProcessName">流程的Name属性,在Fire workflow中,流程的Name和Id是相等的而且都是唯一的。</param>
 /// <param name="parentTaskInstance">父TaskInstance</param>
 /// <returns>新创建的流程实例</returns>
 public IProcessInstance createProcessInstance(String workflowProcessName, ITaskInstance parentTaskInstance)
 {
     return(_createProcessInstance(workflowProcessName, parentTaskInstance.Id,
                                   parentTaskInstance.ProcessInstanceId, parentTaskInstance.Id));
 }
コード例 #38
0
        /// <summary>分配, 按照当前任务的参与者插入工单</summary>
        /// <param name="currentSession"></param>
        /// <param name="processInstance"></param>
        /// <param name="runtimeContext"></param>
        /// <param name="taskInstance"></param>
        /// <param name="formTask"></param>
        /// <param name="part"></param>
        /// <param name="dynamicAssignmentHandler"></param>
        protected void assign(IWorkflowSession currentSession, IProcessInstance processInstance, RuntimeContext runtimeContext, ITaskInstance taskInstance, FormTask formTask, Participant part, DynamicAssignmentHandler dynamicAssignmentHandler)// throws EngineException, KernelException
        {
            //如果有指定的Actor,则按照指定的Actor分配任务
            if (dynamicAssignmentHandler != null)
            {
                dynamicAssignmentHandler.assign((IAssignable)taskInstance, part.Name);
            }
            else
            {
                IPersistenceService  persistenceService           = runtimeContext.PersistenceService;
                List <ITaskInstance> taskInstanceList             = persistenceService.FindTaskInstancesForProcessInstance(taskInstance.ProcessInstanceId, taskInstance.ActivityId);
                ITaskInstance        theLastCompletedTaskInstance = null;

                for (int i = 0; taskInstanceList != null && i < taskInstanceList.Count; i++)
                {
                    ITaskInstance tmp = (ITaskInstance)taskInstanceList[i];
                    if (tmp.Id.Equals(taskInstance.Id))
                    {
                        continue;
                    }
                    if (!tmp.TaskId.Equals(taskInstance.TaskId))
                    {
                        continue;
                    }
                    if (tmp.State != TaskInstanceStateEnum.COMPLETED)
                    {
                        continue;
                    }
                    if (theLastCompletedTaskInstance == null)
                    {
                        theLastCompletedTaskInstance = tmp;
                    }
                    else
                    {
                        if (theLastCompletedTaskInstance.StepNumber < tmp.StepNumber)
                        {
                            theLastCompletedTaskInstance = tmp;
                        }
                    }
                }

                //如果是循环且LoopStrategy==REDO,则分配个上次完成该工作的操作员
                if (theLastCompletedTaskInstance != null && (LoopStrategyEnum.REDO == formTask.LoopStrategy || currentSession.isInWithdrawOrRejectOperation()))
                {
                    List <IWorkItem>     workItemList    = persistenceService.FindCompletedWorkItemsForTaskInstance(theLastCompletedTaskInstance.Id);
                    ITaskInstanceManager taskInstanceMgr = runtimeContext.TaskInstanceManager;
                    for (int k = 0; k < workItemList.Count; k++)
                    {
                        IWorkItem completedWorkItem = (IWorkItem)workItemList[k];

                        IWorkItem newFromWorkItem = taskInstanceMgr.createWorkItem(currentSession, processInstance, taskInstance, completedWorkItem.ActorId);
                        newFromWorkItem.claim();//并自动签收
                    }
                }
                else
                {
                    IBeanFactory beanFactory = runtimeContext.BeanFactory;
                    //从spring中获取到对应任务的Performer,创建工单
                    //201004 add lwz 参与者通过业务接口实现默认获取用户
                    switch (part.AssignmentType)
                    {
                    case AssignmentTypeEnum.Current:
                        runtimeContext.AssignmentBusinessHandler.assignCurrent(
                            currentSession, processInstance, (IAssignable)taskInstance);
                        break;

                    case AssignmentTypeEnum.Role:
                        runtimeContext.AssignmentBusinessHandler.assignRole(
                            currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue);
                        break;

                    case AssignmentTypeEnum.Agency:
                        runtimeContext.AssignmentBusinessHandler.assignAgency(
                            currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue);
                        break;

                    case AssignmentTypeEnum.Fixed:
                        runtimeContext.AssignmentBusinessHandler.assignFixed(
                            currentSession, processInstance, (IAssignable)taskInstance, part.PerformerValue);
                        break;

                    case AssignmentTypeEnum.Superiors:
                        runtimeContext.AssignmentBusinessHandler.assignSuperiors(
                            currentSession, processInstance, (IAssignable)taskInstance);
                        break;

                    default:
                        IAssignmentHandler assignmentHandler = (IAssignmentHandler)beanFactory.GetBean(part.AssignmentHandler);
                        //modified by wangmj 20090904
                        ((IAssignmentHandler)assignmentHandler).assign((IAssignable)taskInstance, part.PerformerValue);
                        break;
                    }
                }
            }
        }
コード例 #39
0
        /// <summary>
        /// 中止当前的TaskInstance,并使得流程流转到指定的环节。
        /// </summary>
        /// <param name="currentSession"></param>
        /// <param name="processInstance"></param>
        /// <param name="taskInstance"></param>
        /// <param name="targetActivityId"></param>
        public void abortTaskInstance(IWorkflowSession currentSession,
            IProcessInstance processInstance, ITaskInstance taskInstance,
            String targetActivityId)
        {
            // 如果TaskInstance处于结束状态,则直接返回
            if (taskInstance.State == TaskInstanceStateEnum.COMPLETED || taskInstance.State == TaskInstanceStateEnum.CANCELED)
            {
                return;
            }
            // Initialized状态的TaskInstance也可以中止,20090830
            // if (taskInstance.State == ITaskInstance.INITIALIZED) {
            // WorkflowProcess process = taskInstance.getWorkflowProcess();
            // throw new EngineException(taskInstance.getProcessInstanceId(),
            // process,
            // taskInstance.getTaskId(),
            // "Complete task insatance failed.The state of the task insatnce[id=" +
            // taskInstance.getId() + "] is " + taskInstance.State);
            // }
            if (taskInstance.IsSuspended())
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId,
                        process, taskInstance.TaskId,
                        "Abort task insatance failed. The task instance [id="
                                + taskInstance.Id + "] is suspended");
            }

            // 1)检查是否在同一个“执行线”上
            WorkflowProcess workflowProcess = taskInstance.WorkflowProcess;
            if (targetActivityId != null)
            {
                String thisActivityId = taskInstance.ActivityId;
                Boolean isInSameLine = workflowProcess.isInSameLine(thisActivityId,
                        targetActivityId);
                if (!isInSameLine)
                {
                    throw new EngineException(
                            taskInstance.ProcessInstanceId,
                            taskInstance.WorkflowProcess,
                            taskInstance.TaskId,
                            "Jumpto refused because of the current activitgy and the target activity are NOT in the same 'Execution Thread'.");
                }
            }

            INetInstance netInstance = this.RuntimeContext.KernelManager.getNetInstance(workflowProcess.Id, taskInstance.Version);
            IActivityInstance targetActivityInstance = (IActivityInstance)netInstance.getWFElementInstance(targetActivityId);

            IActivityInstance thisActivityInstance = (IActivityInstance)netInstance.getWFElementInstance(taskInstance.ActivityId);
            if (thisActivityInstance == null)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                    "系统没有找到与activityId=" + taskInstance.ActivityId + "对应activityInstance,无法执行abort操作。");
            }

            if (targetActivityInstance != null)
            {
                ((TaskInstance)taskInstance).TargetActivityId=targetActivityInstance.Activity.Id;
            }

            IPersistenceService persistenceService = this.RuntimeContext.PersistenceService;

            // 第一步,首先Abort当前taskInstance
            persistenceService.AbortTaskInstance((TaskInstance)taskInstance);

            // 触发相应的事件
            TaskInstanceEvent e = new TaskInstanceEvent();
            e.Source=taskInstance;
            e.WorkflowSession=currentSession;
            e.ProcessInstance=processInstance;
            e.EventType = TaskInstanceEventEnum.AFTER_TASK_INSTANCE_COMPLETE;
            if (this.DefaultTaskInstanceEventListener != null)
            {
                this.DefaultTaskInstanceEventListener.onTaskInstanceEventFired(e);
            }

            this.fireTaskInstanceEvent(taskInstance, e);

            // 第二步,检查ActivityInstance是否可以结束
            if (!activityInstanceCanBeCompleted(taskInstance))
            {
                return;
            }

            // 第三步,尝试结束对应的activityInstance
            List<IToken> tokens = persistenceService.FindTokensForProcessInstance(taskInstance.ProcessInstanceId, taskInstance.ActivityId);
            // System.out.println("Inside TaskInstance.complete(targetActivityInstance):: tokens.size is "+tokens.size());
            if (tokens == null || tokens.Count == 0)
            {
                return;// 表明activityInstance已经结束了。
            }
            if (tokens.Count > 1)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                    "与activityId=" + taskInstance.ActivityId + "对应的token数量(=" + tokens.Count + ")不正确,正确只能为1,因此无法完成complete操作");
            }
            IToken token = tokens[0];
            // stepNumber不相等,不允许执行结束操作。
            if (token.StepNumber != taskInstance.StepNumber)
            {
                return;
            }
            if (token.IsAlive == false)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                    "与activityId=" + taskInstance.ActivityId + "对应的token.alive=false,因此无法完成complete操作");
            }

            token.ProcessInstance = processInstance;

            thisActivityInstance.complete(token, targetActivityInstance);
        }
コード例 #40
0
 /// <summary>
 /// 判断任务实例是否可以终止
 /// </summary>
 /// <param name="currentSession"></param>
 /// <param name="runtimeContext"></param>
 /// <param name="processInstance"></param>
 /// <param name="taskInstance"></param>
 /// <returns>true表示可以终止,false不能终止</returns>
 public Boolean taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext,
                                           IProcessInstance processInstance, ITaskInstance taskInstance)//throws EngineException ,KernelException
 {
     //Tool类型的TaskInstance在handler执行完后,都可以直接结束。
     return(true);
 }
コード例 #41
0
        public WorkItem createWorkItem(IWorkflowSession currentSession, IProcessInstance processInstance, ITaskInstance taskInstance, String actorId)
        {
            IPersistenceService persistenceService = this.RuntimeContext.PersistenceService;

            WorkItem wi = new WorkItem();
            wi.TaskInstance=taskInstance;
            wi.ActorId=actorId;
            wi.State=WorkItemEnum.INITIALIZED;
            wi.CreatedTime = this.RuntimeContext.CalendarService.getSysDate();
            wi.RuntimeContext = this.RuntimeContext;
            wi.CurrentWorkflowSession=currentSession;
            //保存到数据库
            persistenceService.SaveOrUpdateWorkItem(wi);

            //触发事件
            //触发相应的事件
            TaskInstanceEvent e = new TaskInstanceEvent();
            e.Source=taskInstance;
            e.WorkItem=wi;
            e.WorkflowSession=currentSession;
            e.ProcessInstance=processInstance;

            e.EventType = TaskInstanceEventEnum.AFTER_WORKITEM_CREATED;
            if (this.DefaultTaskInstanceEventListener != null)
            {
                this.DefaultTaskInstanceEventListener.onTaskInstanceEventFired(e);
            }
            this.fireTaskInstanceEvent(taskInstance, e);

            return wi;
        }
コード例 #42
0
        public void run(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance)// throws EngineException, KernelException
        {
            if (taskInstance.TaskType != TaskTypeEnum.TOOL)
            {
                throw new EngineException(processInstance, taskInstance.Activity,
                                          "DefaultToolTaskInstanceRunner:TaskInstance的任务类型错误,只能为TOOL类型");
            }
            Task task = taskInstance.Task;

            if (task == null)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                                          "The Task is null,can NOT start the taskinstance,");
            }
            if (((ToolTask)task).Application == null || ((ToolTask)task).Application.Handler == null)
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                                          "The task.Application is null or task.Application.Handler is null,can NOT start the taskinstance,");
            }

            Object obj = runtimeContext.getBeanByName(((ToolTask)task).Application.Handler);

            if (obj == null || !(obj is IApplicationHandler))
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process, taskInstance.TaskId,
                                          "Run tool task instance error! Not found the instance of " + ((ToolTask)task).Application.Handler + " or the instance not implements IApplicationHandler");
            }

            try
            {
                ((IApplicationHandler)obj).execute(taskInstance);
            }
            catch (Exception)
            {//TODO wmj2003 对tool类型的task抛出的错误应该怎么处理? 这个时候引擎会如何?整个流程是否还可以继续?
                throw new EngineException(processInstance, taskInstance.Activity,
                                          "DefaultToolTaskInstanceRunner:TaskInstance的任务执行失败!");
            }

            ITaskInstanceManager taskInstanceManager = runtimeContext.TaskInstanceManager;

            taskInstanceManager.completeTaskInstance(currentSession, processInstance, taskInstance, null);
        }
コード例 #43
0
        /// <summary>
        /// 启动TaskInstance。
        /// 该方法定义为final,不允许子类扩展。
        /// </summary>
        public void startTaskInstance(IWorkflowSession currentSession, IProcessInstance processInstance, ITaskInstance taskInstance)
        {
            //触发事件
            TaskInstanceEvent e = new TaskInstanceEvent();
            e.Source=taskInstance;
            e.WorkflowSession=currentSession;
            e.ProcessInstance=processInstance;
            e.EventType = TaskInstanceEventEnum.BEFORE_TASK_INSTANCE_START;
            if (DefaultTaskInstanceEventListener != null)
            {
                DefaultTaskInstanceEventListener.onTaskInstanceEventFired(e);
            }
            this.fireTaskInstanceEvent(taskInstance, e);

            ((TaskInstance)taskInstance).State=TaskInstanceStateEnum.RUNNING;
            ((TaskInstance)taskInstance).StartedTime=this.RuntimeContext.CalendarService.getSysDate();
            this.RuntimeContext.PersistenceService.SaveOrUpdateTaskInstance(taskInstance);

            Task task = taskInstance.Task;
            String taskInstanceRunnerName = null;
            ITaskInstanceRunner taskInstanceRunner = null;

            TaskTypeEnum taskType = task.TaskType;

            taskInstanceRunnerName = task.TaskInstanceRunner;
            if (!String.IsNullOrEmpty(taskInstanceRunnerName.Trim()))
            {
                IBeanFactory beanFactory = this.RuntimeContext.BeanFactory;
                taskInstanceRunner = (ITaskInstanceRunner)beanFactory.GetBean(taskInstanceRunnerName);
            }

            if (taskInstanceRunner == null)
            {
                if (TaskTypeEnum.FORM == taskType)
                {
                    taskInstanceRunnerName = processInstance.WorkflowProcess.FormTaskInstanceRunner;
                }
                else if (TaskTypeEnum.TOOL == taskType)
                {
                    taskInstanceRunnerName = processInstance.WorkflowProcess.ToolTaskInstanceRunner;
                }
                else if (TaskTypeEnum.SUBFLOW == taskType)
                {
                    taskInstanceRunnerName = processInstance.WorkflowProcess.SubflowTaskInstanceRunner;
                }
                if (!String.IsNullOrEmpty(taskInstanceRunnerName.Trim()))
                {
                    IBeanFactory beanFactory = this.RuntimeContext.BeanFactory;
                    taskInstanceRunner = (ITaskInstanceRunner)beanFactory.GetBean(taskInstanceRunnerName);
                }
            }

            if (taskInstanceRunner == null)
            {
                if (TaskTypeEnum.FORM == taskType)
                {
                    taskInstanceRunner = DefaultFormTaskInstanceRunner;
                }
                else if (TaskTypeEnum.TOOL == taskType)
                {
                    taskInstanceRunner = DefaultToolTaskInstanceRunner;
                }
                else if (TaskTypeEnum.SUBFLOW == taskType)
                {
                    taskInstanceRunner = DefaultSubflowTaskInstanceRunner;
                }
            }
            if (taskInstanceRunner != null)
            {
                taskInstanceRunner.run(currentSession, this.RuntimeContext, processInstance, taskInstance);
            }
            else
            {
                WorkflowProcess process = taskInstance.WorkflowProcess;
                throw new EngineException(taskInstance.ProcessInstanceId, process,
                        taskInstance.TaskId,
                        "无法获取TaskInstanceRunner,TaskId=" + task.Id + ", taskType=" + taskInstance.TaskType);
            }
        }