// helper /////////////////////////////////////////////////////////

        protected internal virtual bool IsHistoryEventProduced(HistoryEventTypes eventType, IExternalTask externalTask)
        {
            ProcessEngineConfigurationImpl configuration = context.Impl.Context.ProcessEngineConfiguration;
            IHistoryLevel historyLevel = configuration.HistoryLevel;

            return(historyLevel.IsHistoryEventProduced(eventType, externalTask));
        }
        public ProcessEngineImpl(ProcessEngineConfigurationImpl processEngineConfiguration)
        {
            this.processEngineConfiguration = processEngineConfiguration;
            Name = processEngineConfiguration.ProcessEngineName;

            RepositoryService    = processEngineConfiguration.RepositoryService;
            RuntimeService       = processEngineConfiguration.RuntimeService;
            HistoryService       = processEngineConfiguration.HistoryService;
            IdentityService      = processEngineConfiguration.IdentityService;
            TaskService          = processEngineConfiguration.TaskService;
            FormService          = processEngineConfiguration.FormService;
            ManagementService    = processEngineConfiguration.ManagementService;
            AuthorizationService = processEngineConfiguration.AuthorizationService;
            //this.caseService = processEngineConfiguration.CaseService;
            FilterService       = processEngineConfiguration.FilterService;
            ExternalTaskService = processEngineConfiguration.ExternalTaskService;
            DecisionService     = processEngineConfiguration.DecisionService;

            DatabaseSchemaUpdate            = processEngineConfiguration.DatabaseSchemaUpdate;
            JobExecutor                     = processEngineConfiguration.JobExecutor;
            commandExecutor                 = processEngineConfiguration.CommandExecutorTxRequired;
            CommandExecutorSchemaOperations = processEngineConfiguration.CommandExecutorSchemaOperations;
            //SessionFactories = processEngineConfiguration.SessionFactories;
            HistoryLevel = processEngineConfiguration.HistoryLevel;
            TransactionContextFactory = processEngineConfiguration.TransactionContextFactory;
            Log.LogDebug("使用的TransactionContextFactory:", TransactionContextFactory.GetType().Name.ToString());
            //TODO 数据库初始化入口
            //ExecuteSchemaOperations();

            if (ReferenceEquals(Name, null))
            {
                Name = ProcessEngines.NameDefault;
                Log.ProcessEngineCreated(ProcessEngines.NameDefault);
            }
            else
            {
                Log.ProcessEngineCreated(Name);
            }

            ProcessEngines.RegisterProcessEngine(this);

            if (JobExecutor != null)
            {
                JobExecutor.RegisterProcessEngine(this);
            }

            if (processEngineConfiguration.MetricsEnabled)
            {
                var reporterId        = processEngineConfiguration.MetricsReporterIdProvider.ProvideId(this);
                var dbMetricsReporter = processEngineConfiguration.DbMetricsReporter;
                dbMetricsReporter.ReporterId = reporterId;

                if (processEngineConfiguration.DbMetricsReporterActivate)
                {
                    dbMetricsReporter.Start();
                }
            }
        }
Exemple #3
0
        protected internal virtual void FireHistoricIncidentEvent(HistoryEventTypes eventType)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = context.Impl.Context.ProcessEngineConfiguration;

            IHistoryLevel historyLevel = processEngineConfiguration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(eventType, this))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper(this, eventType));
            }
        }
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        //ORIGINAL LINE: public void completeHistoricBatch(final org.camunda.bpm.engine.impl.batch.BatchEntity batch)
        public virtual void CompleteHistoricBatch(BatchEntity batch)
        {
            ProcessEngineConfigurationImpl configuration = context.Impl.Context.ProcessEngineConfiguration;

            IHistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.BatchEnd, batch))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper2(this, batch));
            }
        }
Exemple #5
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public void createHistoricTask(final TaskEntity task)
        public virtual void CreateHistoricTask(TaskEntity task)
        {
            ProcessEngineConfigurationImpl configuration = context.Impl.Context.ProcessEngineConfiguration;

            IHistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.TaskInstanceCreate, task))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper3(this, task));
            }
        }
        protected internal virtual void InitExecutionListeners(IHistoryEventProducer historyEventProducer,
                                                               IHistoryLevel historyLevel)
        {
            ProcessInstanceStartListener = new ProcessInstanceStartListener(historyEventProducer, historyLevel);
            ProcessInstanceEndListener   = new ProcessInstanceEndListener(historyEventProducer, historyLevel);

            ActivityInstanceStartListener = new ActivityInstanceStartListener(historyEventProducer, historyLevel);
            ActivityInstanceEndListener   = new ActivityInstanceEndListener(historyEventProducer, historyLevel);

            UserTaskAssignmentHandler = new ActivityInstanceUpdateListener(historyEventProducer, historyLevel);
            UserTaskIdHandler         = UserTaskAssignmentHandler;
        }
Exemple #7
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public void markTaskInstanceEnded(String taskId, final String deleteReason)
        public virtual void MarkTaskInstanceEnded(string taskId, string deleteReason)
        {
            ProcessEngineConfigurationImpl configuration = context.Impl.Context.ProcessEngineConfiguration;

            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final TaskEntity taskEntity = org.camunda.bpm.engine.impl.context.Context.getCommandContext().getDbEntityManager().selectById(TaskEntity.class, taskId);
            //TaskEntity taskEntity = context.Impl.Context.CommandContext.DbEntityManager.SelectById< TaskEntity>(typeof(TaskEntity), taskId);
            TaskEntity    taskEntity   = taskManager.FindTaskById(taskId);
            IHistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.TaskInstanceComplete, taskEntity))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper2(this, deleteReason, taskEntity));
            }
        }
        //public void CheckHistoryLevel(DbEntityManager entityManager)
        //{
        //    var processEngineConfiguration = context.Impl.Context.ProcessEngineConfiguration;


        //    var databaseHistoryLevel =
        //        new DetermineHistoryLevelCmd(processEngineConfiguration.HistoryLevels).Execute(context.Impl.Context.CommandContext);
        //    DetermineAutoHistoryLevel(processEngineConfiguration, databaseHistoryLevel);

        //    var configuredHistoryLevel = processEngineConfiguration.HistoryLevel;

        //    if (databaseHistoryLevel == null)
        //    {
        //        Log.NoHistoryLevelPropertyFound();
        //        //DbCreateHistoryLevel(entityManager);
        //    }
        //    else
        //    {
        //        if (!((int?) configuredHistoryLevel.Id).Equals(databaseHistoryLevel.Id))
        //            throw new ProcessEngineException("historyLevel mismatch: configuration says " +
        //                                             configuredHistoryLevel + " and database says " +
        //                                             databaseHistoryLevel);
        //    }
        //}

        protected internal void DetermineAutoHistoryLevel(ProcessEngineConfigurationImpl engineConfiguration,
                                                          IHistoryLevel databaseHistoryLevel)
        {
            var configuredHistoryLevel = engineConfiguration.HistoryLevel;

            if ((configuredHistoryLevel == null) &&
                ProcessEngineConfiguration.HistoryAuto.Equals(engineConfiguration.History))
            {
                if (databaseHistoryLevel != null)
                {
                    engineConfiguration.HistoryLevel = databaseHistoryLevel;
                }
                else
                {
                    engineConfiguration.HistoryLevel = engineConfiguration.DefaultHistoryLevel;
                }
            }
        }
            public virtual object Execute(CommandContext commandContext)
            {
                IHistoryLevel historyLevel = ESS.FW.Bpm.Engine.context.Impl.Context.ProcessEngineConfiguration.HistoryLevel;

                if (historyLevel.Equals(HistoryLevelFields.HistoryLevelFull))
                {
                    commandContext.HistoricJobLogManager.deleteHistoricJobLogsByHandlerType(TimerSuspendProcessDefinitionHandler.TYPE);
                    IList <IHistoricIncident> incidents =
                        ESS.FW.Bpm.Engine.context.Impl.Context.ProcessEngineConfiguration.HistoryService.CreateHistoricIncidentQuery()
                        .ToList();
                    ; foreach (IHistoricIncident incident in incidents)
                    {
                        commandContext.HistoricIncidentManager
                        .Delete((HistoricIncidentEntity)incident);
                    }
                }

                return(null);
            }
Exemple #10
0
 public HistoryTaskListener(IHistoryEventProducer historyEventProducer, IHistoryLevel historyLevel)
 {
     EventProducer     = historyEventProducer;
     this.HistoryLevel = historyLevel;
 }
 public virtual void CreatingHistoryLevelPropertyInDatabase(IHistoryLevel historyLevel)
 {
     LogInfo("065", "Creating historyLevel property in database for level: {0}", historyLevel);
 }
 public ProcessInstanceUpdateListener(IHistoryEventProducer historyEventProducer, IHistoryLevel historyLevel)
     : base(historyEventProducer, historyLevel)
 {
 }
 public CaseInstanceCreateListener(ICmmnHistoryEventProducer historyEventProducer, IHistoryLevel historyLevel)
     : base(historyEventProducer, historyLevel)
 {
 }
        public virtual object Execute(CommandContext commandContext)
        {
            var configuration = commandContext.ProcessEngineConfiguration;

            //check that the new process definition is just another version of the same
            //process definition that the process instance is using

            IExecutionManager executionManager = commandContext.ExecutionManager;
            ExecutionEntity   processInstance  = executionManager.FindExecutionById(_processInstanceId);

            if (processInstance == null)
            {
                throw new ProcessEngineException("No process instance found for id = '" + _processInstanceId + "'.");
            }
            else if (!processInstance.IsProcessInstanceExecution)
            {
                throw new ProcessEngineException("A process instance id is required, but the provided id " + "'" + _processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.ProcessInstanceId + "'. " + "Please invoke the " + this.GetType().Name + " with a root execution id.");
            }
            ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.ProcessDefinition;

            DeploymentCache         deploymentCache = configuration.DeploymentCache;
            ProcessDefinitionEntity currentProcessDefinition;

            if (currentProcessDefinitionImpl is ProcessDefinitionEntity)
            {
                currentProcessDefinition = (ProcessDefinitionEntity)currentProcessDefinitionImpl;
            }
            else
            {
                currentProcessDefinition = deploymentCache.FindDeployedProcessDefinitionById(currentProcessDefinitionImpl.Id);
            }

            ProcessDefinitionEntity newProcessDefinition = deploymentCache.FindDeployedProcessDefinitionByKeyVersionAndTenantId(currentProcessDefinition.Key, _processDefinitionVersion, currentProcessDefinition.TenantId);

            ValidateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);

            IHistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.ProcessInstanceUpdate, processInstance))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClass(this, processInstance));
            }

            // switch all sub-executions of the process instance to the new process definition version
            IList <ExecutionEntity> childExecutions = executionManager.FindExecutionsByProcessInstanceId(_processInstanceId);

            foreach (ExecutionEntity executionEntity in childExecutions)
            {
                ValidateAndSwitchVersionOfExecution(commandContext, executionEntity, newProcessDefinition);
            }

            // switch all jobs to the new process definition version
            IList <JobEntity>           jobs = commandContext.JobManager.FindJobsByProcessInstanceId(_processInstanceId);
            IList <JobDefinitionEntity> currentJobDefinitions    = commandContext.JobDefinitionManager.FindByProcessDefinitionId(currentProcessDefinition.Id);
            IList <JobDefinitionEntity> newVersionJobDefinitions = commandContext.JobDefinitionManager.FindByProcessDefinitionId(newProcessDefinition.Id);

            IDictionary <string, string> jobDefinitionMapping = GetJobDefinitionMapping(currentJobDefinitions, newVersionJobDefinitions);

            foreach (JobEntity jobEntity in jobs)
            {
                SwitchVersionOfJob(jobEntity, newProcessDefinition, jobDefinitionMapping);
            }

            // switch all incidents to the new process definition version
            IList <IncidentEntity> incidents = commandContext.IncidentManager.FindIncidentsByProcessInstance(_processInstanceId);

            foreach (IncidentEntity incidentEntity in incidents)
            {
                SwitchVersionOfIncident(commandContext, incidentEntity, newProcessDefinition);
            }

            // add an entry to the op log
            PropertyChange change = new PropertyChange("processDefinitionVersion", currentProcessDefinition.Version, _processDefinitionVersion);

            commandContext.OperationLogManager.LogProcessInstanceOperation(UserOperationLogEntryFields.OperationTypeModifyProcessInstance, _processInstanceId, null, null, new List <PropertyChange>()
            {
                change
            });
            return(null);
        }
Exemple #15
0
 public HistoryCaseExecutionListener(ICmmnHistoryEventProducer historyEventProducer, IHistoryLevel historyLevel)
 {
     EventProducer     = historyEventProducer;
     this.HistoryLevel = historyLevel;
 }
 public ActivityInstanceStartListener(IHistoryEventProducer historyEventProducer, IHistoryLevel historyLevel)
     : base(historyEventProducer, historyLevel)
 {
 }
 public HistoryParseListener(IHistoryLevel historyLevel, IHistoryEventProducer historyEventProducer)
 {
     this.HistoryLevel = historyLevel;
     InitExecutionListeners(historyEventProducer, historyLevel);
 }
 public HistoryDecisionEvaluationListener(IDmnHistoryEventProducer historyEventProducer,
                                          IHistoryLevel historyLevel)
 {
     EventProducer     = historyEventProducer;
     this.HistoryLevel = historyLevel;
 }
 public CaseActivityInstanceEndListener(ICmmnHistoryEventProducer historyEventProducer,
                                        IHistoryLevel historyLevel)
     : base(historyEventProducer, historyLevel)
 {
 }
        public virtual DmnEngineConfigurationBuilder HistoryLevel(IHistoryLevel historyLevel)
        {
            HistoryLevelRenamed = historyLevel;

            return(this);
        }