Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var viewModel = new DeploymentDashboardViewModel();

            using (var repo = new JobRepository())
            {
                IList <Job> allRunningJobs = repo.GetCurrentlyRunningJobs();
                viewModel.RunningDeployments = allRunningJobs.Select(GetViewModelForJob).ToList();

                IList <Job> pendingJobs = repo.GetPendingJobs();
                viewModel.PendingDeployments = pendingJobs.Select(GetViewModelForJob).ToList();

                IList <Job> completedJobs = repo.GetCompletedJobs(10);
                viewModel.CompletedDeployments = completedJobs.Select(GetViewModelForJob).ToList();
            }

            return(View(viewModel));
        }
        private void TimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            Job         latestJob;
            IList <Job> currentlyRunningJobs;

            using (var jobRepo = new JobRepository())
            {
                currentlyRunningJobs = jobRepo.GetCurrentlyRunningJobs();
                latestJob            = jobRepo.GetOldestUnstartedJob();
            }

            if (currentlyRunningJobs.Count >= MaxRunningJobs)
            {
                Logger.Debug("There are currently {0} running job(s). The max job count is {1}", currentlyRunningJobs.Count, MaxRunningJobs);
                return;
            }

            if (latestJob != null)
            {
                StartRunningJob(latestJob);
            }
        }