Beispiel #1
0
        public async Task <IActionResult> RunReport(string reportName, int?year, int?period)
        {
            // if collection period params not specified default to current period
            if (year == null || period == null)
            {
                var currentYearPeriod = await _periodService.GetRecentlyClosedPeriodAsync();

                if (currentYearPeriod?.CollectionYear == null)
                {
                    string errorMessage = $"Call to get current return period failed in request {reportName} collectionYear: {year} collectionPeriod: {period}";
                    _logger.LogError(errorMessage);
                    throw new InvalidOperationException(errorMessage);
                }

                year   = currentYearPeriod.CollectionYear;
                period = currentYearPeriod.PeriodNumber;
            }

            // queue the report job
            var jobId = await _reportsService.RunReport(reportName, year.Value, period.Value, User.Name());

            // display the processing report spinner page while the report is running
            return(RedirectToAction("ProcessingReport", "Reports", new { ReportName = reportName, ReportAction = ReportActions.ProcessingRunReport, CollectionYear = year, CollectionPeriod = period, JobId = jobId }));
        }