public bool TryGetJob(out Job job) { lock (_locker) { job = null; var jobInWork = _jobs.FirstOrDefault(x => !x.InWork && !x.IsArchived); if (jobInWork is null) { JobsInQueue.Reset(); return(false); } jobInWork.Work(); job = jobInWork.Job; if (_jobs.Count(x => !x.InWork && !x.IsArchived) == 0) { JobsInQueue.Reset(); } return(true); } }
public void JobUnWork(Job job) { lock (_locker) { _jobs.FirstOrDefault(x => x.Job.JobName == job.JobName)?.UnWork(); } JobsInQueue.Set(); _logger?.Verbose($"Job {job.JobName} has updated in queue {Name} to {job}"); }
public IHttpActionResult QueryProcessTaskStatus(JobsInQueue jobsInQueue) { var details = jobQueueService.QueryJobsStatus(jobsInQueue.CreatedJobIds); jobsInQueue.CompleteJobIds = details.Where(x => x.ProcessStatus == ProcessStatus.Completed).Select(x => x.Id.ToString()).ToList(); jobsInQueue.ErrorJobIds = details.Where(x => x.ProcessStatus == ProcessStatus.FailToPublish || x.ResultStatus == ResultStatus.Error).Select(x => x.Id.ToString()).ToList(); jobsInQueue.ProcessingJobIds = details.Where(x => x.ProcessStatus == ProcessStatus.Processing).Select(x => x.Id.ToString()).ToList(); jobsInQueue.SuccessJobIds = details.Where(x => x.ResultStatus == ResultStatus.Success).Select(x => x.Id.ToString()).ToList(); return(Ok(jobsInQueue)); }
private void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { JobsInQueue?.Dispose(); } _disposed = true; }
public void UpdateJob(Job job) { if (job is null) { return; } lock (_locker) { _jobs.FirstOrDefault(x => x.Job.JobName == job.JobName)?.Update(job); } JobsInQueue.Set(); }
public void AddLast(Job job) { if (job is null) { _logger?.Warning("Job is null."); return; } lock (_locker) { if (_jobs.Any(x => x.Job.Id == job.Id)) { return; } _jobs.AddLast(new JobInWork(job)); _logger?.Verbose($"Job has added to end of {Name}: {job}."); } JobsInQueue.Set(); }