public override void performCleanup() { CommandContext commandContext = Context.CommandContext; HistoryCleanupHelper.prepareNextBatch(this, commandContext); if (size() > 0) { if (historicProcessInstanceIds.Count > 0) { commandContext.HistoricProcessInstanceManager.deleteHistoricProcessInstanceByIds(historicProcessInstanceIds); } if (historicDecisionInstanceIds.Count > 0) { commandContext.HistoricDecisionInstanceManager.deleteHistoricDecisionInstanceByIds(historicDecisionInstanceIds); } if (historicCaseInstanceIds.Count > 0) { commandContext.HistoricCaseInstanceManager.deleteHistoricCaseInstancesByIds(historicCaseInstanceIds); } if (historicBatchIds.Count > 0) { commandContext.HistoricBatchManager.deleteHistoricBatchesByIds(historicBatchIds); } } }
public virtual Void execute(CommandContext commandContext) { if (MetricsEnabled) { reportMetrics(commandContext); } JobEntity jobEntity = commandContext.JobManager.findJobById(jobId); bool rescheduled = false; if (isRescheduleNow) { commandContext.JobManager.reschedule(jobEntity, ClockUtil.CurrentTime); rescheduled = true; cancelCountEmptyRuns(configuration, jobEntity); } else { if (HistoryCleanupHelper.isWithinBatchWindow(ClockUtil.CurrentTime, commandContext.ProcessEngineConfiguration)) { DateTime nextRunDate = configuration.getNextRunWithDelay(ClockUtil.CurrentTime); if (HistoryCleanupHelper.isWithinBatchWindow(nextRunDate, commandContext.ProcessEngineConfiguration)) { commandContext.JobManager.reschedule(jobEntity, nextRunDate); rescheduled = true; incrementCountEmptyRuns(configuration, jobEntity); } } } if (!rescheduled) { if (HistoryCleanupHelper.isBatchWindowConfigured(commandContext)) { rescheduleRegularCall(commandContext, jobEntity); } else { suspendJob(jobEntity); } cancelCountEmptyRuns(configuration, jobEntity); } return(null); }
protected internal virtual bool isWithinBatchWindow(CommandContext commandContext) { return(HistoryCleanupHelper.isWithinBatchWindow(ClockUtil.CurrentTime, commandContext.ProcessEngineConfiguration)); }