Пример #1
0
        private void ActiveJobsCallBack(InvokeOperation <IEnumerable <JobBase> > io)
        {
            List <JobBase> activeJobArray = new List <JobBase>();

            if (io.Value != null)
            {
                activeJobArray = new List <JobBase>(io.Value);
            }
            foreach (JobBase jobItem in activeJobArray)
            {
                if (jobItem.Code == monitoringJobCode)
                {
                    UpdateCurrentJob(jobItem);
                }
                else
                {
                }
                var jobFound = JobQueue.FirstOrDefault(x => x.Code == jobItem.Code);
                if (jobFound != null)
                {
                    //update job info
                    UpdateExistingJob(jobFound, jobItem);
                }
                else
                {
                    //insert job info
                    JobQueue.Add(CloneJob(jobItem));
                }
            }
            //Remove jobs from queue that don't exist in Array
            var c = from aItem in JobQueue
                    from bItem in activeJobArray.Where(bItem => aItem.Code == bItem.Code).DefaultIfEmpty()
                    where bItem == null
                    select aItem;

            JobQueue.RemoveAll(x => c.Contains(x));
        }