public virtual void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { string byteArrayId = configuration.ConfigurationByteArrayId; sbyte[] configurationByteArray = findByteArrayById(byteArrayId, commandContext).Bytes; SetRemovalTimeBatchConfiguration batchConfiguration = readConfiguration(configurationByteArray); foreach (string instanceId in batchConfiguration.Ids) { HistoricProcessInstanceEntity instance = findProcessInstanceById(instanceId, commandContext); if (instance != null) { if (batchConfiguration.Hierarchical && hasHierarchy(instance)) { string rootProcessInstanceId = instance.RootProcessInstanceId; HistoricProcessInstanceEntity rootInstance = findProcessInstanceById(rootProcessInstanceId, commandContext); DateTime removalTime = getOrCalculateRemovalTime(batchConfiguration, rootInstance, commandContext); addRemovalTimeToHierarchy(rootProcessInstanceId, removalTime, commandContext); } else { DateTime removalTime = getOrCalculateRemovalTime(batchConfiguration, instance, commandContext); if (removalTime != instance.RemovalTime) { addRemovalTime(instanceId, removalTime, commandContext); } } } } }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); BatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); bool initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers; commandContext.disableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = true; try { HistoryService historyService = commandContext.ProcessEngineConfiguration.HistoryService; if (batchConfiguration.FailIfNotExists) { historyService.deleteHistoricProcessInstances(batchConfiguration.Ids); } else { historyService.deleteHistoricProcessInstancesIfExists(batchConfiguration.Ids); } } finally { commandContext.enableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions; } commandContext.ByteArrayManager.delete(configurationEntity); }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); UpdateProcessInstancesSuspendStateBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); bool initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers; commandContext.disableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = true; try { if (batchConfiguration.Suspended) { commandContext.ProcessEngineConfiguration.RuntimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(batchConfiguration.Ids).suspend(); } else { commandContext.ProcessEngineConfiguration.RuntimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(batchConfiguration.Ids).activate(); } } finally { commandContext.enableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions; } }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); RestartProcessInstancesBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); bool initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers; commandContext.disableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = true; try { RestartProcessInstanceBuilderImpl builder = (RestartProcessInstanceBuilderImpl)commandContext.ProcessEngineConfiguration.RuntimeService.restartProcessInstances(batchConfiguration.ProcessDefinitionId).processInstanceIds(batchConfiguration.Ids); builder.Instructions = batchConfiguration.Instructions; if (batchConfiguration.InitialVariables) { builder.initialSetOfVariables(); } if (batchConfiguration.SkipCustomListeners) { builder.skipCustomListeners(); } if (batchConfiguration.WithoutBusinessKey) { builder.withoutBusinessKey(); } if (batchConfiguration.SkipIoMappings) { builder.skipIoMappings(); } builder.execute(false); } finally { commandContext.enableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions; } commandContext.ByteArrayManager.delete(configurationEntity); }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); SetRetriesBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); bool initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers; commandContext.disableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = true; try { commandContext.ProcessEngineConfiguration.ManagementService.setJobRetries(batchConfiguration.Ids, batchConfiguration.Retries); } finally { commandContext.enableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions; } commandContext.ByteArrayManager.delete(configurationEntity); }
public virtual void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { string byteArrayId = configuration.ConfigurationByteArrayId; sbyte[] configurationByteArray = findByteArrayById(byteArrayId, commandContext).Bytes; SetRemovalTimeBatchConfiguration batchConfiguration = readConfiguration(configurationByteArray); foreach (string instanceId in batchConfiguration.Ids) { HistoricBatchEntity instance = findBatchById(instanceId, commandContext); if (instance != null) { DateTime removalTime = getOrCalculateRemovalTime(batchConfiguration, instance, commandContext); if (removalTime != instance.RemovalTime) { addRemovalTime(instanceId, removalTime, commandContext); } } } }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); MigrationBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); MigrationPlanExecutionBuilder executionBuilder = commandContext.ProcessEngineConfiguration.RuntimeService.newMigration(batchConfiguration.MigrationPlan).processInstanceIds(batchConfiguration.Ids); if (batchConfiguration.SkipCustomListeners) { executionBuilder.skipCustomListeners(); } if (batchConfiguration.SkipIoMappings) { executionBuilder.skipIoMappings(); } // uses internal API in order to skip writing user operation log (CommandContext#disableUserOperationLog // is not sufficient with legacy engine config setting "restrictUserOperationLogToAuthenticatedUsers" = false) ((MigrationPlanExecutionBuilderImpl)executionBuilder).execute(false); commandContext.ByteArrayManager.delete(configurationEntity); }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); ModificationBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); ModificationBuilderImpl executionBuilder = (ModificationBuilderImpl)commandContext.ProcessEngineConfiguration.RuntimeService.createModification(batchConfiguration.ProcessDefinitionId).processInstanceIds(batchConfiguration.Ids); executionBuilder.Instructions = batchConfiguration.Instructions; if (batchConfiguration.SkipCustomListeners) { executionBuilder.skipCustomListeners(); } if (batchConfiguration.SkipIoMappings) { executionBuilder.skipIoMappings(); } executionBuilder.execute(false); commandContext.ByteArrayManager.delete(configurationEntity); }
public void Execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { throw new System.NotImplementedException(); //ResourceEntity configurationEntity = commandContext.Get(typeof(ResourceEntity), configuration.ConfigurationByteArrayId); //BatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); var initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers; commandContext.DisableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = true; try { //commandContext.ProcessEngineConfiguration.HistoryService.deleteHistoricProcessInstances(batchConfiguration.Ids); } finally { commandContext.EnableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions; } //commandContext.ByteArrayManager.delete(configurationEntity); }