예제 #1
0
        protected internal override void ExecuteTaskComplete(ICommandContext commandContext, ITaskEntity taskEntity, IDictionary <string, object> variables, bool localScope)
        {
            Transfer(commandContext);

            // Task complete logic

            if (taskEntity.DelegationState.HasValue && taskEntity.DelegationState.Value == DelegationState.PENDING)
            {
                throw new ActivitiException("A delegated task cannot be completed, but should be resolved instead.");
            }

            commandContext.ProcessEngineConfiguration.ListenerNotificationHelper.ExecuteTaskListeners(taskEntity, BaseTaskListenerFields.EVENTNAME_COMPLETE);
            IUserInfo user = Authentication.AuthenticatedUser;

            if (user != null && string.IsNullOrWhiteSpace(taskEntity.ProcessInstanceId) == false)
            {
                IExecutionEntity processInstanceEntity = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(taskEntity.ProcessInstanceId);//这里为什么取ProcessInstance而不是Exceution.
                commandContext.IdentityLinkEntityManager.InvolveUser(processInstanceEntity, user.Id, IdentityLinkType.PARTICIPANT);
            }

            IActivitiEventDispatcher eventDispatcher = Context.ProcessEngineConfiguration.EventDispatcher;

            if (eventDispatcher.Enabled)
            {
                if (variables != null)
                {
                    eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityWithVariablesEvent(ActivitiEventType.TASK_COMPLETED, taskEntity, variables, localScope));
                }
                else
                {
                    eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.TASK_COMPLETED, taskEntity));
                }
            }

            commandContext.TaskEntityManager.DeleteTask(taskEntity, completeReason, false, false);

            if (eventDispatcher.Enabled)
            {
                eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateCustomTaskCompletedEvent(taskEntity, ActivitiEventType.TASK_TRANSFERED));
            }

            // Continue process (if not a standalone task)
            if (taskEntity.ExecutionId is object)
            {
                IExecutionEntity executionEntity = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(taskEntity.ExecutionId);
                Context.Agenda.PlanTriggerExecutionOperation(executionEntity);
            }
        }
예제 #2
0
        protected internal override void ExecuteTaskComplete(ICommandContext commandContext, ITaskEntity taskEntity, IDictionary <string, object> variables, bool localScope)
        {
            Transfer(commandContext);

            // Task complete logic
            CompleteTask(commandContext, taskEntity, variables, localScope);

            IActivitiEventDispatcher eventDispatcher = Context.ProcessEngineConfiguration.EventDispatcher;

            if (eventDispatcher.Enabled)
            {
                eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateCustomTaskCompletedEvent(taskEntity, ActivitiEventType.TASK_TRANSFERED));
            }

            // Continue process (if not a standalone task)
            if (taskEntity.ExecutionId is object)
            {
                IExecutionEntity executionEntity = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(taskEntity.ExecutionId);
                Context.Agenda.PlanTriggerExecutionOperation(executionEntity, variables ?? new Dictionary <string, object>());
            }
        }
예제 #3
0
        protected internal override void ExecuteTaskComplete(ICommandContext commandContext, ITaskEntity taskEntity, IDictionary <string, object> variables, bool localScope)
        {
            lock (syncRoot)
            {
                // Task complete logic
                CompleteTask(commandContext, taskEntity, variables, localScope);

                IActivitiEventDispatcher eventDispatcher = Context.ProcessEngineConfiguration.EventDispatcher;

                if (eventDispatcher.Enabled)
                {
                    eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateCustomTaskCompletedEvent(taskEntity, ActivitiEventType.TASK_TERMINATED));
                }

                // Continue process (if not a standalone task)
                if (taskEntity.ExecutionId is object && isTerminateExecution)
                {
                    IExecutionEntity executionEntity = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(taskEntity.ExecutionId);
                    executionEntity.SetVariableLocal(WorkflowVariable.GLOBAL_TERMINATE_TASK_VARNAME, true);
                    Context.Agenda.PlanTriggerExecutionOperation(executionEntity, variables ?? new Dictionary <string, object>());
                }
            }
        }