Пример #1
0
        /// <summary>Processes any jobs that have been added.</summary>
        /// <param name="jobManager">The job manager.</param>
        private void ProcessAddedJobs(JobManager jobManager)
        {
            JobsService.Job runningJobDescription = null;

            //If there is no YP job running, then add a new job.  Once a YP job is running don't add any more jobs (regardless of type).
            if (runningJob == null || jobManager.IsJobCompleted(runningJob))
            {
                // Remove completed jobs if nothing is running. Otherwise, completedjobs will
                // grow and grow.
                jobManager.ClearCompletedJobs();
                runningJob = null;

                using (JobsService.JobsClient jobsClient = new JobsService.JobsClient())
                {
                    runningJobDescription = jobsClient.GetNextToRun();
                }

                if (runningJobDescription != null)
                {
                    if (RunnableJobs.ProcessYPJob.IsF4PJob(runningJobDescription.Name) == true)
                        runningJob = new RunnableJobs.ProcessF4PJob(true) { JobName = runningJobDescription.Name };
                    else
                        runningJob = new RunnableJobs.ProcessYPJob(true) { JobName = runningJobDescription.Name };
                    if (runningJob != null)
                        jobManager.AddJob(runningJob);
                }
                else
                {
                    // No jobs to run so wait a bit.
                    Thread.Sleep(15 * 1000); // 15 sec.
                }
            }
        }