Ejemplo n.º 1
0
        public async Task FileLevelErrorReportAsync(
            IEasJobContext easContext,
            IEnumerable <EasCsvRecord> models,
            IEnumerable <ValidationErrorModel> errors,
            CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            var reportOutputFilenames = new List <string>();

            if (!string.IsNullOrWhiteSpace(easContext.ReportOutputFileNames))
            {
                reportOutputFilenames.AddRange(easContext.ReportOutputFileNames.Split('|'));
            }

            foreach (var validationReport in _validationReports)
            {
                var reportsGenerated = await validationReport.GenerateReportAsync(easContext, models, errors, cancellationToken);

                reportOutputFilenames.AddRange(reportsGenerated);
            }

            await _resultReport.GenerateReportAsync(easContext, models, errors, cancellationToken);

            var zipName = _fileNameService.GetZipName(easContext.Ukprn, easContext.JobId, _zipName);

            await _zipService.CreateZipAsync(zipName, reportOutputFilenames, easContext.Container.ToString(), cancellationToken);

            easContext.ReportOutputFileNames = string.Join("|", reportOutputFilenames);
        }