Exemplo n.º 1
0
 protected internal virtual void registerScriptResolver(ProcessEngineConfigurationImpl processEngineConfiguration)
 {
     processEngineConfiguration.EnvScriptResolvers.Add(new SpinScriptEnvResolver());
 }
 public MybatisExecutionDataManager(ProcessEngineConfigurationImpl processEngineConfiguration) : base(processEngineConfiguration)
 {
     this.performanceSettings = processEngineConfiguration.PerformanceSettings;
 }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="processEngineConfiguration"></param>
 public DefaultJobManager(ProcessEngineConfigurationImpl processEngineConfiguration)
 {
     this.processEngineConfiguration = processEngineConfiguration;
 }
Exemplo n.º 4
0
 public override ProcessEngineConfiguration configureEngine(ProcessEngineConfigurationImpl configuration)
 {
     return(outerInstance.configure(configuration, HistoryEventTypes.INCIDENT_CREATE));
 }
Exemplo n.º 5
0
 public virtual void BeforeInit(ProcessEngineConfigurationImpl processEngineConfiguration)
 {
 }
Exemplo n.º 6
0
        protected internal virtual ProcessEngineConfigurationImpl buildProcessEngine(ProcessEngineConfigurationImpl config)
        {
            processEngine = config.BuildProcessEngine();

            return((ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration);
        }
Exemplo n.º 7
0
 public MybatisEventSubscriptionDataManager(ProcessEngineConfigurationImpl processEngineConfiguration) : base(processEngineConfiguration)
 {
 }
Exemplo n.º 8
0
        public override void Execute(IExecutionEntity execution)
        {
            ICommandContext    commandContext    = Context.CommandContext;
            ITaskEntityManager taskEntityManager = commandContext.TaskEntityManager;

            ITaskEntity task = taskEntityManager.Create();

            task.Execution         = execution;
            task.TaskDefinitionKey = userTask.Id;
            task.IsRuntimeAssignee();

            task.CanTransfer  = userTask.CanTransfer;
            task.OnlyAssignee = task.OnlyAssignee;

            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;
            ExpressionManager expressionManager = processEngineConfiguration.ExpressionManager;


            string         activeTaskName;
            string         activeTaskDescription;
            string         activeTaskDueDate;
            string         activeTaskCategory;
            string         activeTaskSkipExpression;
            string         activeTaskPriority;
            string         activeTaskFormKey;
            string         activeTaskAssignee;
            string         activeTaskOwner;
            IList <string> activeTaskCandidateUsers;
            IList <string> activeTaskCandidateGroups;

            if (Context.ProcessEngineConfiguration.EnableProcessDefinitionInfoCache)
            {
                JToken taskElementProperties = Context.GetBpmnOverrideElementProperties(userTask.Id, execution.ProcessDefinitionId);
                activeTaskName            = GetActiveValue(userTask.Name, DynamicBpmnConstants.USER_TASK_NAME, taskElementProperties);
                activeTaskDescription     = GetActiveValue(userTask.Documentation, DynamicBpmnConstants.USER_TASK_DESCRIPTION, taskElementProperties);
                activeTaskDueDate         = GetActiveValue(userTask.DueDate, DynamicBpmnConstants.USER_TASK_DUEDATE, taskElementProperties);
                activeTaskPriority        = GetActiveValue(userTask.Priority, DynamicBpmnConstants.USER_TASK_PRIORITY, taskElementProperties);
                activeTaskCategory        = GetActiveValue(userTask.Category, DynamicBpmnConstants.USER_TASK_CATEGORY, taskElementProperties);
                activeTaskFormKey         = GetActiveValue(userTask.FormKey, DynamicBpmnConstants.USER_TASK_FORM_KEY, taskElementProperties);
                activeTaskSkipExpression  = GetActiveValue(userTask.SkipExpression, DynamicBpmnConstants.TASK_SKIP_EXPRESSION, taskElementProperties);
                activeTaskAssignee        = GetActiveValue(userTask.Assignee, DynamicBpmnConstants.USER_TASK_ASSIGNEE, taskElementProperties);
                activeTaskOwner           = GetActiveValue(userTask.Owner, DynamicBpmnConstants.USER_TASK_OWNER, taskElementProperties);
                activeTaskCandidateUsers  = GetActiveValueList(userTask.CandidateUsers, DynamicBpmnConstants.USER_TASK_CANDIDATE_USERS, taskElementProperties);
                activeTaskCandidateGroups = GetActiveValueList(userTask.CandidateGroups, DynamicBpmnConstants.USER_TASK_CANDIDATE_GROUPS, taskElementProperties);
            }
            else
            {
                activeTaskName            = userTask.Name;
                activeTaskDescription     = userTask.Documentation;
                activeTaskDueDate         = userTask.DueDate;
                activeTaskPriority        = userTask.Priority;
                activeTaskCategory        = userTask.Category;
                activeTaskFormKey         = userTask.FormKey;
                activeTaskSkipExpression  = userTask.SkipExpression;
                activeTaskAssignee        = userTask.Assignee;
                activeTaskOwner           = userTask.Owner;
                activeTaskCandidateUsers  = userTask.CandidateUsers;
                activeTaskCandidateGroups = userTask.CandidateGroups;
            }

            if (!string.IsNullOrWhiteSpace(activeTaskName))
            {
                string name;
                try
                {
                    name = (string)expressionManager.CreateExpression(activeTaskName).GetValue(execution);
                }
                catch (ActivitiException e)
                {
                    name = activeTaskName;
                    log.LogWarning("property not found in task name expression " + e.Message);
                }
                task.Name = name;
            }

            if (!string.IsNullOrWhiteSpace(activeTaskDescription))
            {
                string description;
                try
                {
                    description = (string)expressionManager.CreateExpression(activeTaskDescription).GetValue(execution);
                }
                catch (ActivitiException e)
                {
                    description = activeTaskDescription;
                    log.LogWarning("property not found in task description expression " + e.Message);
                }
                task.Description = description;
            }

            if (!string.IsNullOrWhiteSpace(activeTaskDueDate))
            {
                object dueDate = expressionManager.CreateExpression(activeTaskDueDate).GetValue(execution);
                if (dueDate != null)
                {
                    if (dueDate is DateTime)
                    {
                        task.DueDate = (DateTime)dueDate;
                    }
                    else if (dueDate is string)
                    {
                        string businessCalendarName;
                        if (!string.IsNullOrWhiteSpace(userTask.BusinessCalendarName))
                        {
                            businessCalendarName = expressionManager.CreateExpression(userTask.BusinessCalendarName).GetValue(execution).ToString();
                        }
                        else
                        {
                            businessCalendarName = DueDateBusinessCalendar.NAME;
                        }

                        IBusinessCalendar businessCalendar = Context.ProcessEngineConfiguration.BusinessCalendarManager.GetBusinessCalendar(businessCalendarName);
                        task.DueDate = businessCalendar.ResolveDuedate((string)dueDate);
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("Due date expression does not resolve to a Date or Date string: " + activeTaskDueDate);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(activeTaskPriority))
            {
                object priority = expressionManager.CreateExpression(activeTaskPriority).GetValue(execution);
                if (priority != null)
                {
                    if (priority is string)
                    {
                        try
                        {
                            task.Priority = Convert.ToInt32((string)priority);
                        }
                        catch (FormatException e)
                        {
                            throw new ActivitiIllegalArgumentException("Priority does not resolve to a number: " + priority, e);
                        }
                    }
                    else if (priority is int || priority is long)
                    {
                        task.Priority = ((int)priority);
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("Priority expression does not resolve to a number: " + activeTaskPriority);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(activeTaskCategory))
            {
                object category = expressionManager.CreateExpression(activeTaskCategory).GetValue(execution);
                if (category != null)
                {
                    if (category is string)
                    {
                        task.Category = category.ToString();
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("Category expression does not resolve to a string: " + activeTaskCategory);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(activeTaskFormKey))
            {
                object formKey = expressionManager.CreateExpression(activeTaskFormKey).GetValue(execution);
                if (formKey != null)
                {
                    if (formKey is string)
                    {
                        task.FormKey = formKey.ToString();
                    }
                    else
                    {
                        throw new ActivitiIllegalArgumentException("FormKey expression does not resolve to a string: " + activeTaskFormKey);
                    }
                }
            }

            taskEntityManager.Insert(task, execution);

            bool skipUserTask = false;

            if (!string.IsNullOrWhiteSpace(activeTaskSkipExpression))
            {
                IExpression skipExpression = expressionManager.CreateExpression(activeTaskSkipExpression);
                skipUserTask = SkipExpressionUtil.IsSkipExpressionEnabled(execution, skipExpression) && SkipExpressionUtil.ShouldSkipFlowElement(execution, skipExpression);
            }

            // Handling assignments need to be done after the task is inserted, to have an id
            if (!skipUserTask)
            {
                HandleAssignments(taskEntityManager, activeTaskAssignee, activeTaskOwner, activeTaskCandidateUsers, activeTaskCandidateGroups, task, expressionManager, execution);
            }

            processEngineConfiguration.ListenerNotificationHelper.ExecuteTaskListeners(task, BaseTaskListenerFields.EVENTNAME_CREATE);

            // All properties set, now fire events
            if (Context.ProcessEngineConfiguration.EventDispatcher.Enabled)
            {
                IActivitiEventDispatcher eventDispatcher = Context.ProcessEngineConfiguration.EventDispatcher;
                eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.TASK_CREATED, task));
                if (task.Assignee is object)
                {
                    eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.TASK_ASSIGNED, task));
                }
            }

            if (skipUserTask)
            {
                taskEntityManager.DeleteTask(task, null, false, false);
                Leave(execution);
            }
        }
 public MybatisProcessDefinitionInfoDataManager(ProcessEngineConfigurationImpl processEngineConfiguration) : base(processEngineConfiguration)
 {
 }
 public MybatisCommentDataManager(ProcessEngineConfigurationImpl processEngineConfiguration) : base(processEngineConfiguration)
 {
 }
Exemplo n.º 11
0
 protected internal override BatchJobHandler getBatchJobHandler(ProcessEngineConfigurationImpl processEngineConfiguration)
 {
     return(processEngineConfiguration.BatchHandlers[org.camunda.bpm.engine.batch.Batch_Fields.TYPE_BATCH_SET_REMOVAL_TIME]);
 }
Exemplo n.º 12
0
 public DefaultHistoryManager(ProcessEngineConfigurationImpl processEngineConfiguration, HistoryLevel historyLevel) : base(processEngineConfiguration)
 {
     this.historyLevel = historyLevel;
 }
Exemplo n.º 13
0
        // private static Logger log = LoggerFactory.getLogger(typeof(ExclusiveGatewayActivityBehavior));

        /// <summary>
        /// The default behaviour of BPMN, taking every outgoing sequence flow (where the condition evaluates to true), is not valid for an exclusive gateway.
        ///
        /// Hence, this behaviour is overridden and replaced by the correct behavior: selecting the first sequence flow which condition evaluates to true (or which hasn't got a condition) and leaving the
        /// activity through that sequence flow.
        ///
        /// If no sequence flow is selected (ie all conditions evaluate to false), then the default sequence flow is taken (if defined).
        /// </summary>
        public override void Leave(IExecutionEntity execution)
        {
            if (log.IsEnabled(LogLevel.Debug))
            {
                log.LogDebug($"Leaving exclusive gateway '{execution.CurrentActivityId}'");
            }

            ExclusiveGateway exclusiveGateway = (ExclusiveGateway)execution.CurrentFlowElement;

            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;

            if (!(processEngineConfiguration is null) && processEngineConfiguration.EventDispatcher.Enabled)
            {
                processEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateActivityEvent(ActivitiEventType.ACTIVITY_COMPLETED, exclusiveGateway.Id, exclusiveGateway.Name, execution.Id, execution.ProcessInstanceId, execution.ProcessDefinitionId, exclusiveGateway));
            }

            SequenceFlow outgoingSequenceFlow  = null;
            SequenceFlow defaultSequenceFlow   = null;
            string       defaultSequenceFlowId = exclusiveGateway.DefaultFlow;

            // Determine sequence flow to take
            foreach (SequenceFlow sequenceFlow in exclusiveGateway.OutgoingFlows)
            {
                string skipExpressionString = sequenceFlow.SkipExpression;
                if (!SkipExpressionUtil.IsSkipExpressionEnabled(execution, skipExpressionString))
                {
                    bool conditionEvaluatesToTrue = ConditionUtil.HasTrueCondition(sequenceFlow, execution);
                    if (conditionEvaluatesToTrue && (defaultSequenceFlowId is null || !defaultSequenceFlowId.Equals(sequenceFlow.Id)))
                    {
                        if (log.IsEnabled(LogLevel.Debug))
                        {
                            log.LogDebug($"Sequence flow '{sequenceFlow.Id}'selected as outgoing sequence flow.");
                        }
                        outgoingSequenceFlow = sequenceFlow;
                        break;
                    }
                }
                else if (SkipExpressionUtil.ShouldSkipFlowElement(Context.CommandContext, execution, skipExpressionString))
                {
                    outgoingSequenceFlow = sequenceFlow;
                    break;
                }

                // Already store it, if we would need it later. Saves one for loop.
                if (!(defaultSequenceFlowId is null) && defaultSequenceFlowId.Equals(sequenceFlow.Id))
                {
                    defaultSequenceFlow = sequenceFlow;
                }
            }

            // We have to record the end here, or else we're already past it
            Context.CommandContext.HistoryManager.RecordActivityEnd(execution, null);

            // Leave the gateway
            if (outgoingSequenceFlow != null)
            {
                execution.CurrentFlowElement = outgoingSequenceFlow;
            }
            else
            {
                if (defaultSequenceFlow != null)
                {
                    execution.CurrentFlowElement = defaultSequenceFlow;
                }
                else
                {
                    // No sequence flow could be found, not even a default one
                    throw new ActivitiException("No outgoing sequence flow of the exclusive gateway '" + exclusiveGateway.Id + "' could be selected for continuing the process");
                }
            }

            base.Leave(execution);
        }
Exemplo n.º 14
0
        public virtual Void execute(CommandContext commandContext)
        {
            ensureNotNull("jobId", jobId);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.persistence.entity.JobEntity job = commandContext.getDbEntityManager().selectById(org.camunda.bpm.engine.impl.persistence.entity.JobEntity.class, jobId);
            JobEntity job = commandContext.DbEntityManager.selectById(typeof(JobEntity), jobId);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration = org.camunda.bpm.engine.impl.context.Context.getProcessEngineConfiguration();
            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.IdentityService identityService = processEngineConfiguration.getIdentityService();
            IdentityService identityService = processEngineConfiguration.IdentityService;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.jobexecutor.JobExecutorContext jobExecutorContext = org.camunda.bpm.engine.impl.context.Context.getJobExecutorContext();
            JobExecutorContext jobExecutorContext = Context.JobExecutorContext;

            if (job == null)
            {
                if (jobExecutorContext != null)
                {
                    // CAM-1842
                    // Job was acquired but does not exist anymore. This is not a problem.
                    // It usually means that the job has been deleted after it was acquired which can happen if the
                    // the activity instance corresponding to the job is cancelled.
                    LOG.debugAcquiredJobNotFound(jobId);
                    return(null);
                }
                else
                {
                    throw LOG.jobNotFoundException(jobId);
                }
            }

            jobFailureCollector.Job = job;

            if (jobExecutorContext == null)
            {     // if null, then we are not called by the job executor
                foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
                {
                    checker.checkUpdateJob(job);
                }
                // write a user operation log since we're not called by the job executor
                commandContext.OperationLogManager.logJobOperation(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_EXECUTE, jobId, job.JobDefinitionId, job.ProcessInstanceId, job.ProcessDefinitionId, job.ProcessDefinitionKey, PropertyChange.EMPTY_CHANGE);
            }
            else
            {
                jobExecutorContext.CurrentJob = job;

                // if the job is called by the job executor then set the tenant id of the job
                // as authenticated tenant to enable tenant checks
                string tenantId = job.TenantId;
                if (!string.ReferenceEquals(tenantId, null))
                {
                    identityService.setAuthentication(null, null, Collections.singletonList(tenantId));
                }
            }

            try
            {
                // register as command context close lister to intercept exceptions on flush
                commandContext.registerCommandContextListener(jobFailureCollector);

                commandContext.CurrentJob = job;

                job.execute(commandContext);
            }
            finally
            {
                if (jobExecutorContext != null)
                {
                    jobExecutorContext.CurrentJob = null;
                    identityService.clearAuthentication();
                }
            }

            return(null);
        }
Exemplo n.º 15
0
 public override ProcessEngineConfiguration ConfigureEngine(ProcessEngineConfigurationImpl configuration)
 {
     return(configuration.SetJobExecutor(OuterInstance.BuildControllableJobExecutor()));
 }
Exemplo n.º 16
0
 public override ProcessEngineConfiguration configureEngine(ProcessEngineConfigurationImpl configuration)
 {
     configuration.CmmnEnabled = false;
     return(configuration);
 }
Exemplo n.º 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void init()
        public virtual void init()
        {
            processEngineConfiguration = engineRule.ProcessEngineConfiguration;
            authorizationService       = engineRule.AuthorizationService;
        }
Exemplo n.º 18
0
		  public override ProcessEngineConfiguration configureEngine(ProcessEngineConfigurationImpl configuration)
		  {
			return outerInstance.configure(configuration, HistoryEventTypes.PROCESS_INSTANCE_START);
		  }
Exemplo n.º 19
0
 public TimerJobEntityManagerImpl(ProcessEngineConfigurationImpl processEngineConfiguration, ITimerJobDataManager jobDataManager) : base(processEngineConfiguration)
 {
     this.jobDataManager = jobDataManager;
 }
Exemplo n.º 20
0
	  protected internal override BatchJobHandler<DeleteProcessInstanceBatchConfiguration> getBatchJobHandler(ProcessEngineConfigurationImpl processEngineConfiguration)
	  {
		return (BatchJobHandler<DeleteProcessInstanceBatchConfiguration>) processEngineConfiguration.BatchHandlers[org.camunda.bpm.engine.batch.Batch_Fields.TYPE_PROCESS_INSTANCE_DELETION];
	  }
Exemplo n.º 21
0
 public CreateNoSchemaProcessEngineImpl(ProcessEngineConfigurationImpl processEngineConfiguration) : base(processEngineConfiguration)
 {
 }
Exemplo n.º 22
0
 public ExecutionEntityManagerImpl(ProcessEngineConfigurationImpl processEngineConfiguration, IExecutionDataManager executionDataManager) : base(processEngineConfiguration)
 {
     this.executionDataManager = executionDataManager;
 }
Exemplo n.º 23
0
 public MybatisHistoricTaskInstanceDataManager(ProcessEngineConfigurationImpl processEngineConfiguration) : base(processEngineConfiguration)
 {
 }
Exemplo n.º 24
0
 public override ProcessEngineConfiguration configureEngine(ProcessEngineConfigurationImpl configuration)
 {
     configuration.HistoryCleanupDegreeOfParallelism = 3;
     return(configuration);
 }
Exemplo n.º 25
0
 public virtual void Configure(ProcessEngineConfigurationImpl processEngineConfiguration)
 {
 }
Exemplo n.º 26
0
 public TaskServiceImpl(ProcessEngineConfigurationImpl processEngineConfiguration) : base(processEngineConfiguration)
 {
 }
Exemplo n.º 27
0
        public virtual BpmnParse Execute()
        {
            try
            {
                ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;
                BpmnXMLConverter converter = new BpmnXMLConverter();

                bool   enableSafeBpmnXml = false;
                string encoding          = null;
                if (processEngineConfiguration != null)
                {
                    enableSafeBpmnXml = processEngineConfiguration.EnableSafeBpmnXml;
                    encoding          = processEngineConfiguration.XmlEncoding;
                }

                if (!(encoding is null))
                {
                    bpmnModel = converter.ConvertToBpmnModel(streamSource, validateSchema, enableSafeBpmnXml, encoding);
                }
                else
                {
                    bpmnModel = converter.ConvertToBpmnModel(streamSource, validateSchema, enableSafeBpmnXml);
                }

                // XSD validation goes first, then process/semantic validation
                if (validateProcess)
                {
                    IProcessValidator processValidator = processEngineConfiguration.ProcessValidator;
                    if (processValidator == null)
                    {
                        logger.LogWarning("Process should be validated, but no process validator is configured on the process engine configuration!");
                    }
                    else
                    {
                        IList <ValidationError> validationErrors = processValidator.Validate(bpmnModel);
                        if (validationErrors != null && validationErrors.Count > 0)
                        {
                            StringBuilder warningBuilder = new StringBuilder();
                            StringBuilder errorBuilder   = new StringBuilder();

                            foreach (ValidationError error in validationErrors)
                            {
                                if (error.Warning)
                                {
                                    warningBuilder.Append(error.ToString());
                                    warningBuilder.Append("\n");
                                }
                                else
                                {
                                    errorBuilder.Append(error.ToString());
                                    errorBuilder.Append("\n");
                                }
                            }

                            // Throw exception if there is any error
                            if (validationErrors.Any(x => x.Warning == false))
                            {
                                logger.LogError($"Following errors encounted during process validation:\r\n{errorBuilder.ToString()}");

                                throw new ActivitiValidationException(validationErrors);
                            }

                            // Write out warnings (if any)
                            if (warningBuilder.Length > 0)
                            {
                                logger.LogWarning($"Following warnings encountered during process validation: {warningBuilder.ToString()}");
                            }
                        }
                    }
                }

                bpmnModel.SourceSystemId = sourceSystemId;
                bpmnModel.EventSupport   = new ActivitiEventSupport();

                // Validation successful (or no validation)

                // Attach logic to the processes (eg. map ActivityBehaviors to bpmn model elements)
                ApplyParseHandlers();

                // Finally, process the diagram interchange info
                ProcessDI();
            }
Exemplo n.º 28
0
        public ITask[] Execute(ICommandContext commandContext)
        {
            ProcessEngineConfigurationImpl pec = commandContext.ProcessEngineConfiguration;
            IRuntimeService runtimeService     = pec.RuntimeService;
            ITaskService    taskService        = pec.TaskService;
            IIdGenerator    idGenerator        = pec.IdGenerator;

            ITask            task      = taskService.CreateTaskQuery().SetTaskId(taskId).SingleResult();
            IExecutionEntity execution = runtimeService.CreateExecutionQuery().SetExecutionId(task.ExecutionId).SingleResult() as IExecutionEntity;
            IExecutionEntity parent    = execution.Parent;

            //查找当前待追加人员是否已经存在在任务列表中,proc_inst_id_
            IList <ITask> assignTasks = taskService.CreateTaskQuery()
                                        .SetProcessInstanceId(execution.ProcessInstanceId)
                                        .SetTaskAssigneeIds(assignees)
                                        .List();

            var users = assignees.Where(x => assignTasks.Any(y => x == y.Assignee) == false).ToList();

            if (users.Count == 0)
            {
                throw new NotFoundAssigneeException();
            }

            if (parent.IsMultiInstanceRoot && parent.CurrentFlowElement is UserTask mTask)
            {
                string varName = mTask.LoopCharacteristics.InputDataItem;
                Match  match   = VARNAME_PATTERN.Match(varName);
                varName = match.Groups[1].Value;

                IList <string> list = parent.GetLoopVariable <IList <string> >(varName);

                parent.SetLoopVariable(varName, users.Union(list).Distinct().ToArray());
            }

            IList <ITask> tasks = new List <ITask>(users.Count);

            foreach (var assignee in users)
            {
                //创建父活动的子活动
                IExecutionEntity newExecution = pec.CommandExecutor.Execute(new CreateChildExecutionCmd(parent));
                //设置为激活 状态
                newExecution.IsActive    = true;
                newExecution.ActivityId  = execution.ActivityId;
                newExecution.BusinessKey = execution.BusinessKey;
                //该属性表示创建的newExecution对象为分支,非常重要,不可缺少
                newExecution.IsConcurrent = execution.IsConcurrent;
                newExecution.IsScope      = false;
                ITaskEntity taskEntity = pec.CommandExecutor.Execute(new NewTaskCmd(pec.IdGenerator.GetNextId()));
                taskEntity.ProcessDefinitionId = task.ProcessDefinitionId;
                taskEntity.TaskDefinitionKey   = task.TaskDefinitionKey;
                taskEntity.ProcessInstanceId   = task.ProcessInstanceId;
                taskEntity.ExecutionId         = newExecution.Id;
                taskEntity.Name = task.Name;

                if (string.IsNullOrWhiteSpace(taskEntity.Id))
                {
                    string taskId = idGenerator.GetNextId();
                    taskEntity.Id = taskId;
                }
                taskEntity.Execution = newExecution;
                taskEntity.Assignee  = assignee;
                if (string.IsNullOrWhiteSpace(assignee) == false)
                {
                    //TODO: 考虑性能问题,暂时不要获取人员信息
                    //taskEntity.AssigneeUser = userService.GetUser(assignee).GetAwaiter().GetResult()?.FullName;
                }
                taskEntity.TenantId = task.TenantId;
                taskEntity.FormKey  = task.FormKey;
                taskEntity.IsAppend = true;

                taskService.SaveTask(taskEntity);

                tasks.Add(taskEntity);
            }

            //修改执行实例父级实例变量数和活动实例变量数
            int nrOfInstances          = parent.GetLoopVariable <int>(MultiInstanceActivityBehavior.NUMBER_OF_INSTANCES);
            int nrOfActiveIntance      = parent.GetLoopVariable <int>(MultiInstanceActivityBehavior.NUMBER_OF_ACTIVE_INSTANCES);
            int nrOfCompletedInstances = parent.GetLoopVariable <int>(MultiInstanceActivityBehavior.NUMBER_OF_COMPLETED_INSTANCES);

            parent.SetLoopVariable(MultiInstanceActivityBehavior.NUMBER_OF_INSTANCES, nrOfInstances + users.Count);
            parent.SetLoopVariable(MultiInstanceActivityBehavior.NUMBER_OF_ACTIVE_INSTANCES, nrOfInstances - nrOfCompletedInstances + users.Count);

            return(tasks.ToArray());
        }
Exemplo n.º 29
0
 public override ProcessEngineConfiguration configureEngine(ProcessEngineConfigurationImpl configuration)
 {
     return(configuration.setJobExecutor(new ControllableJobExecutor()));
 }
Exemplo n.º 30
0
 protected internal virtual void registerFallbackSerializer(ProcessEngineConfigurationImpl processEngineConfiguration)
 {
     processEngineConfiguration.FallbackSerializerFactory = new SpinFallbackSerializerFactory();
 }