Beispiel #1
0
        public virtual object Execute(CommandContext commandContext)
        {
            JobEntity jobToDelete = null;

            foreach (var jobId in JobIds)
            {
                jobToDelete = context.Impl.Context.CommandContext.JobManager.FindJobById(jobId);

                if (jobToDelete != null)
                {
                    // When given job doesn't exist, ignore
                    jobToDelete.Delete();

                    if (Cascade)
                    {
                        commandContext.HistoricJobLogManager.DeleteHistoricJobLogByJobId(jobId);
                    }
                }
            }
            return(null);
        }
Beispiel #2
0
        public virtual object Execute(CommandContext commandContext)
        {
            EnsureUtil.EnsureNotNull("jobId", JobId);

            JobEntity job = commandContext.JobManager.FindJobById(JobId);

            EnsureUtil.EnsureNotNull("No job found with id '" + JobId + "'", "job", job);

            foreach (var checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.CheckUpdateJob(job);
            }
            // We need to check if the job was locked, ie acquired by the job acquisition thread
            // This happens if the the job was already acquired, but not yet executed.
            // In that case, we can't allow to delete the job.
            if (!ReferenceEquals(job.LockOwner, null) || job.LockExpirationTime != null)
            {
                throw new ProcessEngineException("Cannot delete job when the job is being executed. Try again later.");
            }

            job.Delete();
            return(null);
        }