protected internal virtual bool DoInsert(ITimerJobEntity jobEntity, bool fireCreateEvent) { // add link to execution if (jobEntity.ExecutionId is object) { IExecutionEntity execution = ExecutionEntityManager.FindById <IExecutionEntity>(jobEntity.ExecutionId); if (execution != null) { execution.TimerJobs.Add(jobEntity); // Inherit tenant if (if applicable) if (execution.TenantId is object) { jobEntity.TenantId = execution.TenantId; } if (IsExecutionRelatedEntityCountEnabled(execution)) { ICountingExecutionEntity countingExecutionEntity = (ICountingExecutionEntity)execution; countingExecutionEntity.TimerJobCount += 1; } } else { // In case the job has an executionId, but the Execution is not found, // it means that for example for a boundary timer event on a user task, // the task has been completed and the Execution and job have been removed. return(false); } } base.Insert(jobEntity, fireCreateEvent); return(true); }
public override void Insert(IDeadLetterJobEntity jobEntity, bool fireCreateEvent) { // add link to execution if (!(jobEntity.ExecutionId is null)) { IExecutionEntity execution = ExecutionEntityManager.FindById <IExecutionEntity>(jobEntity.ExecutionId); // Inherit tenant if (if applicable) if (!(execution.TenantId is null)) { jobEntity.TenantId = execution.TenantId; } if (ExecutionRelatedEntityCountEnabledGlobally) { ICountingExecutionEntity countingExecutionEntity = (ICountingExecutionEntity)execution; if (IsExecutionRelatedEntityCountEnabled(countingExecutionEntity)) { countingExecutionEntity.DeadLetterJobCount += 1; } } } base.Insert(jobEntity, fireCreateEvent); }
public override void Insert(ICommentEntity commentEntity) { if (HistoryManager.HistoryEnabled == false) { return; } CheckHistoryEnabled(); Insert(commentEntity, false); IComment comment = commentEntity; if (EventDispatcher.Enabled) { // Forced to fetch the process-instance to associate the right // process definition string processDefinitionId = null; string processInstanceId = comment.ProcessInstanceId; if (comment.ProcessInstanceId is object) { IExecutionEntity process = ExecutionEntityManager.FindById <IExecutionEntity>(comment.ProcessInstanceId); if (process != null) { processDefinitionId = process.ProcessDefinitionId; } } EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_CREATED, commentEntity, processInstanceId, processInstanceId, processDefinitionId)); EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, commentEntity, processInstanceId, processInstanceId, processDefinitionId)); } }
protected internal virtual void deleteProcessInstancesForProcessDefinitions(IList <IProcessDefinition> processDefinitions) { foreach (IProcessDefinition processDefinition in processDefinitions) { ExecutionEntityManager.DeleteProcessInstancesByProcessDefinition(processDefinition.Id, "deleted deployment", true); } }
public override void Delete(IVariableInstanceEntity entity, bool fireDeleteEvent) { base.Delete(entity, false); IByteArrayRef byteArrayRef = entity.ByteArrayRef; if (byteArrayRef != null) { byteArrayRef.Delete(); } entity.Deleted = true; if (!(entity.ExecutionId is null) && ExecutionRelatedEntityCountEnabledGlobally) { ICountingExecutionEntity executionEntity = ExecutionEntityManager.FindById <ICountingExecutionEntity>(entity.ExecutionId); if (IsExecutionRelatedEntityCountEnabled(executionEntity)) { executionEntity.VariableCount -= 1; } } IActivitiEventDispatcher eventDispatcher = EventDispatcher; if (fireDeleteEvent && eventDispatcher.Enabled) { eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_DELETED, entity)); eventDispatcher.DispatchEvent(CreateVariableDeleteEvent(entity)); } }
protected internal virtual bool DoInsert(IJobEntity jobEntity, bool fireCreateEvent) { // add link to execution if (jobEntity.ExecutionId is object) { IExecutionEntity execution = ExecutionEntityManager.FindById <IExecutionEntity>(jobEntity.ExecutionId); if (execution != null) { execution.Jobs.Add(jobEntity); // Inherit tenant if (if applicable) if (execution.TenantId is object) { jobEntity.TenantId = execution.TenantId; } if (IsExecutionRelatedEntityCountEnabled(execution)) { ICountingExecutionEntity countingExecutionEntity = (ICountingExecutionEntity)execution; countingExecutionEntity.JobCount += 1; } } else { return(false); } } base.Insert(jobEntity, fireCreateEvent); return(true); }
public override void Delete(ICommentEntity commentEntity) { CheckHistoryEnabled(); Delete(commentEntity, false); IComment comment = commentEntity; if (EventDispatcher.Enabled) { // Forced to fetch the process-instance to associate the right // process definition string processDefinitionId = null; string processInstanceId = comment.ProcessInstanceId; if (!(comment.ProcessInstanceId is null)) { IExecutionEntity process = ExecutionEntityManager.FindById <IExecutionEntity>(comment.ProcessInstanceId); if (process != null) { processDefinitionId = process.ProcessDefinitionId; } } EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_DELETED, commentEntity, processInstanceId, processInstanceId, processDefinitionId)); } }
/// <summary> /// Removes the job's execution's reference to this job, if the job has an associated execution. /// Subclasses may override to provide custom implementations. /// </summary> protected internal virtual void RemoveExecutionLink(IJobEntity jobEntity) { if (jobEntity.ExecutionId is object) { IExecutionEntity execution = ExecutionEntityManager.FindById <IExecutionEntity>(jobEntity.ExecutionId); if (execution != null) { execution.Jobs.Remove(jobEntity); } } }
public override void Delete(IJobEntity entity, bool fireDeleteEvent) { if (entity.ExecutionId is object && ExecutionRelatedEntityCountEnabledGlobally) { ICountingExecutionEntity executionEntity = ExecutionEntityManager.FindById <ICountingExecutionEntity>(entity.ExecutionId); if (IsExecutionRelatedEntityCountEnabled(executionEntity)) { executionEntity.JobCount -= 1; } } base.Delete(entity, fireDeleteEvent); }
public override void Insert(IVariableInstanceEntity entity, bool fireCreateEvent) { base.Insert(entity, fireCreateEvent); if (!(entity.ExecutionId is null) && ExecutionRelatedEntityCountEnabledGlobally) { ICountingExecutionEntity executionEntity = ExecutionEntityManager.FindById <ICountingExecutionEntity>(entity.ExecutionId); if (IsExecutionRelatedEntityCountEnabled(executionEntity)) { executionEntity.VariableCount += 1; } } }
public override void Insert(IIdentityLinkEntity entity, bool fireCreateEvent) { base.Insert(entity, fireCreateEvent); HistoryManager.RecordIdentityLinkCreated(entity); if (!(entity.ProcessInstanceId is null) && ExecutionRelatedEntityCountEnabledGlobally) { ICountingExecutionEntity executionEntity = (ICountingExecutionEntity)ExecutionEntityManager.FindById <ICountingExecutionEntity>(entity.ProcessInstanceId); if (IsExecutionRelatedEntityCountEnabled(executionEntity)) { executionEntity.IdentityLinkCount += 1; } } }
/// <summary> /// /// </summary> /// <param name="jobEntity"></param> protected internal virtual void ExecuteJobHandler(IJobEntity jobEntity) { IExecutionEntity execution = null; if (!(jobEntity.ExecutionId is null)) { execution = ExecutionEntityManager.FindById <ExecutionEntityImpl>(jobEntity.ExecutionId); } IDictionary <string, IJobHandler> jobHandlers = processEngineConfiguration.JobHandlers; IJobHandler jobHandler = jobHandlers[jobEntity.JobHandlerType]; jobHandler.Execute(jobEntity, jobEntity.JobHandlerConfiguration, execution, CommandContext); }
protected internal virtual IActivitiVariableEvent CreateVariableDeleteEvent(IVariableInstanceEntity variableInstance) { string processDefinitionId = null; if (!(variableInstance.ProcessInstanceId is null)) { IExecutionEntity executionEntity = ExecutionEntityManager.FindById <IExecutionEntity>(variableInstance.ProcessInstanceId); if (executionEntity != null) { processDefinitionId = executionEntity.ProcessDefinitionId; } } return(ActivitiEventBuilder.CreateVariableEvent(ActivitiEventType.VARIABLE_DELETED, variableInstance.Name, null, variableInstance.Type, variableInstance.TaskId, variableInstance.ExecutionId, variableInstance.ProcessInstanceId, processDefinitionId)); }
/// <summary> /// /// </summary> /// <param name="timerEntity"></param> protected internal virtual void ExecuteTimerJob(IJobEntity timerEntity) { ITimerJobEntityManager timerJobEntityManager = processEngineConfiguration.TimerJobEntityManager; IVariableScope variableScope = null; if (!(timerEntity.ExecutionId is null)) { variableScope = ExecutionEntityManager.FindById <VariableScopeImpl>(timerEntity.ExecutionId); } if (variableScope == null) { variableScope = NoExecutionVariableScope.SharedInstance; } // set endDate if it was set to the definition RestoreExtraData(timerEntity, variableScope); if (timerEntity.Duedate != null && !IsValidTime(timerEntity, timerEntity.Duedate.GetValueOrDefault(DateTime.Now), variableScope)) { if (logger.IsEnabled(LogLevel.Debug)) { logger.LogDebug($"Timer {timerEntity.Id} fired. but the dueDate is after the endDate. Deleting timer."); } processEngineConfiguration.JobEntityManager.Delete(timerEntity); return; } ExecuteJobHandler(timerEntity); processEngineConfiguration.JobEntityManager.Delete(timerEntity); if (logger.IsEnabled(LogLevel.Debug)) { logger.LogDebug($"Timer {timerEntity.Id} fired. Deleting timer."); } if (!(timerEntity.Repeat is null)) { ITimerJobEntity newTimerJobEntity = timerJobEntityManager.CreateAndCalculateNextTimer(timerEntity, variableScope); if (newTimerJobEntity != null) { ScheduleTimerJob(newTimerJobEntity); } } }
public override void Delete(IDeadLetterJobEntity jobEntity) { base.Delete(jobEntity); DeleteExceptionByteArrayRef(jobEntity); if (!(jobEntity.ExecutionId is null) && ExecutionRelatedEntityCountEnabledGlobally) { ICountingExecutionEntity executionEntity = ExecutionEntityManager.FindById <ICountingExecutionEntity>(jobEntity.ExecutionId); if (IsExecutionRelatedEntityCountEnabled(executionEntity)) { executionEntity.DeadLetterJobCount -= 1; } } // Send event if (EventDispatcher.Enabled) { EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_DELETED, this)); } }
public virtual void DeleteIdentityLink(IIdentityLinkEntity identityLink, bool cascadeHistory) { Delete(identityLink, false); if (cascadeHistory) { HistoryManager.DeleteHistoricIdentityLink(identityLink.Id); } if (identityLink.ProcessInstanceId is object && ExecutionRelatedEntityCountEnabledGlobally) { ICountingExecutionEntity executionEntity = (ICountingExecutionEntity)ExecutionEntityManager.FindById <ICountingExecutionEntity>(identityLink.ProcessInstanceId); if (IsExecutionRelatedEntityCountEnabled(executionEntity)) { executionEntity.IdentityLinkCount -= 1; } } if (EventDispatcher.Enabled) { EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_DELETED, identityLink)); } }
public override void Insert(ISuspendedJobEntity jobEntity, bool fireCreateEvent) { // add link to execution if (jobEntity.ExecutionId is object) { IExecutionEntity execution = ExecutionEntityManager.FindById <IExecutionEntity>(jobEntity.ExecutionId); // Inherit tenant if (if applicable) if (execution.TenantId is object) { jobEntity.TenantId = execution.TenantId; } if (IsExecutionRelatedEntityCountEnabled(execution)) { ICountingExecutionEntity countingExecutionEntity = (ICountingExecutionEntity)execution; countingExecutionEntity.SuspendedJobCount += 1; } } base.Insert(jobEntity, fireCreateEvent); }
public override void Insert(IIdentityLinkEntity entity, bool fireCreateEvent) { //当审核登记设置为Audit时候,再记录identity link,否则会抛出外键异常 if (HistoryManager.IsHistoryLevelAtLeast(HistoryLevel.AUDIT)) { base.Insert(entity, fireCreateEvent); HistoryManager.RecordIdentityLinkCreated(entity); if (entity.ProcessInstanceId is object && ExecutionRelatedEntityCountEnabledGlobally) { ICountingExecutionEntity executionEntity = (ICountingExecutionEntity)ExecutionEntityManager.FindById <ICountingExecutionEntity>(entity.ProcessInstanceId); if (IsExecutionRelatedEntityCountEnabled(executionEntity)) { executionEntity.IdentityLinkCount += 1; } } } }