private void DownloadMissingFiles_FromReport(IEnumerable <DemFileReport> report, DEMDataSet dataSet) { // Generate metadata files if missing foreach (var file in report.Where(r => r.IsMetadataGenerated == false && r.IsExistingLocally == true)) { _IRasterService.GenerateFileMetadata(file.LocalName, dataSet.FileFormat, false); } List <DemFileReport> filesToDownload = new List <DemFileReport>(report.Where(kvp => kvp.IsExistingLocally == false)); if (filesToDownload.Count == 0) { _logger?.LogTrace("No missing file(s)."); } else { _logger?.LogInformation($"Downloading {filesToDownload.Count} missing file(s)."); try { Parallel.ForEach(filesToDownload, file => { _IRasterService.DownloadRasterFile(file, dataSet); } ); _IRasterService.GenerateDirectoryMetadata(dataSet, false, false); _IRasterService.LoadManifestMetadata(dataSet, true); } catch (AggregateException ex) { _logger?.LogError(ex, $"Error downloading missing files. Check internet connection or retry later. {ex.GetInnerMostException().Message}"); throw; } } }