public async Task <List <ValidationErrorModel> > ValidateDataAsync(IEasJobContext easJobContext, IReadOnlyDictionary <string, ValidationErrorRule> validationErrorReferenceData, CancellationToken cancellationToken)
        {
            var easCsvRecords = await GetCsvRecords(easJobContext, cancellationToken);

            List <ValidationErrorModel> validationErrorModels = await ValidateAsync(easJobContext, validationErrorReferenceData, easCsvRecords.ToList(), cancellationToken);

            List <EasCsvRecord> validRecords = GetValidRows(easCsvRecords, validationErrorModels);
            var fileDataCache = _fileDataCacheService.BuildFileDataCache(easJobContext.Ukprn, easJobContext.FileReference, easCsvRecords, validRecords, validationErrorModels, false);
            await _fileDataCacheService.PopulateFileDataCacheAsync(fileDataCache, cancellationToken);

            return(validationErrorModels);
        }
Beispiel #2
0
        private async Task GenerateErrorOutputsAsync(IEasJobContext easJobContext, ICollection <ValidationErrorModel> errorModels, IReadOnlyDictionary <string, ValidationErrorRule> validationErrorReferenceData, CancellationToken cancellationToken)
        {
            _logger.LogInfo("File Level validation - Error(s) found.");
            var easCsvRecords = Enumerable.Empty <EasCsvRecord>();

            var errorsToReport = _validationErrorBuilder.BuildFileLevelValidationErrors(errorModels, validationErrorReferenceData);

            await _validationErrorLoggerService.LogValidationErrorsAsync(easJobContext, errorsToReport, cancellationToken);

            await _reportingController.FileLevelErrorReportAsync(easJobContext, easCsvRecords, errorsToReport, cancellationToken);

            var fileDataCache = _fileDataCacheService.BuildFileDataCache(easJobContext.Ukprn, easJobContext.FileReference, easCsvRecords, null, null, true);
            await _fileDataCacheService.PopulateFileDataCacheAsync(fileDataCache, cancellationToken);
        }