// GET: InformationRadiator public ActionResult Index() { var viewModel = new InformationRadiatorViewModel(); int total = 0; try { var result = _vacancySummaryService.Find(new ApprenticeshipVacancyQuery() { RequestedPage = 1, PageSize = 1, DesiredStatuses = new List <VacancyStatus>() { VacancyStatus.Live } }, out total); if (result != null && result.Count >= 1) { viewModel.DatabaseStatus = InformationRadiatorStatus.Success; } else { viewModel.DatabaseStatus = InformationRadiatorStatus.Warning; } } catch (Exception ex) { _logService.Error("Information radiator failure", ex); viewModel.DatabaseStatus = InformationRadiatorStatus.Exception; } return(View(viewModel)); }
/// <summary> /// This queues up to 1000 vacancies for /// </summary> /// <param name="deadline"></param> public void QueueVacanciesForClosure(DateTime deadline) { var stopwatch = new Stopwatch(); stopwatch.Start(); var query = new ApprenticeshipVacancyQuery() { RequestedPage = 1, DesiredStatuses = new List<VacancyStatus>() { VacancyStatus.Live }, LatestClosingDate = deadline, EditedInRaa = false, PageSize = 1000 }; int resultCount; var eligibleVacancies = _vacancySummaryService.Find(query, out resultCount); var message = string.Format("Querying vacancies about to close took {0}", stopwatch.Elapsed); var counter = 0; foreach (var vacancy in eligibleVacancies) { var eligibleForClosure = new VacancyEligibleForClosure(vacancy.VacancyId); _serviceBus.PublishMessage(eligibleForClosure); counter ++; } stopwatch.Stop(); message += string.Format(". Queuing {0} vacancies for closure took {1}", counter, stopwatch.Elapsed); if (stopwatch.ElapsedMilliseconds > 60000) { _logService.Warn(message); } else { _logService.Info(message); } }