private void CompletedJobsCallback(InvokeOperation <IEnumerable <JobBase> > io) { List <JobBase> completedJobArray = new List <JobBase>(); if (io.Value != null) { completedJobArray = new List <JobBase>(io.Value); } foreach (JobBase jobItem in completedJobArray) { if (jobItem.Code == monitoringJobCode) { UpdateCurrentJob(jobItem); } else { } var jobFound = CompletedJobs.FirstOrDefault(x => x.Code == jobItem.Code); if (jobFound != null) { //update job info UpdateExistingJob(jobFound, jobItem); } else { //insert job info CompletedJobs.Add(CloneJob(jobItem)); } } //Remove jobs from queue that don't exist in Array var c = from aItem in CompletedJobs from bItem in completedJobArray.Where(bItem => aItem.Code == bItem.Code).DefaultIfEmpty() where bItem == null select aItem; CompletedJobs.RemoveAll(x => c.Contains(x)); }
/// <summary> /// Moves the provided <see cref="GeolocationBatchUpdateJob"/> from executing to completed /// </summary> /// <param name="job">The <see cref="GeolocationBatchUpdateJob"/> to move</param> private void MoveExecutingToCompleted(GeolocationBatchUpdateJob job) { ExecutingJobs.Remove(job); CompletedJobs.Add(job); Buffer.Remove(job.Id); }