Index: Riskeer/Integration/src/Riskeer.Integration.IO/Importers/HydraulicBoundaryDatabaseImporter.cs =================================================================== diff -u -r91c32d38c4fdff5dcd61e0b7085966edfa486a18 -rad08cefd9ff7b50d8583e53330dbcf716b1049f2 --- Riskeer/Integration/src/Riskeer.Integration.IO/Importers/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision 91c32d38c4fdff5dcd61e0b7085966edfa486a18) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Importers/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision ad08cefd9ff7b50d8583e53330dbcf716b1049f2) @@ -87,15 +87,12 @@ return false; } - ReadResult> readExcludedLocationIdsResult = ReadExcludedLocationIds(); - - if (readExcludedLocationIdsResult.CriticalErrorOccurred || Canceled) + IEnumerable readExcludedLocationIds = TryReadExcludedLocationIds(); + if (readExcludedLocationIds == null) { return false; } - IEnumerable readExcludedLocationIds = readExcludedLocationIdsResult.Items.Single(); - AddHydraulicBoundaryDatabaseToDataModel(readHydraulicBoundaryDatabase, readHydraulicLocationConfigurationDatabase, readExcludedLocationIds); return true; @@ -211,47 +208,52 @@ return readHydraulicLocationConfigurationDatabaseResult.Items.Single(); } - private ReadResult> ReadExcludedLocationIds() + private IEnumerable TryReadExcludedLocationIds() { NotifyProgress(Resources.HydraulicBoundaryDatabaseImporter_ProgressText_Reading_Hrd_settings_file, 3, numberOfSteps); - + + ReadResult> readExcludedLocationIdsResult; + try { using (var reader = new HydraRingSettingsDatabaseReader(HydraulicBoundaryDataHelper.GetHydraulicBoundarySettingsDatabaseFilePath(FilePath))) { - return ReadExcludedLocationIds(reader); + try + { + readExcludedLocationIdsResult = new ReadResult>(false) + { + Items = new[] + { + reader.ReadExcludedLocations().ToArray() + } + }; + } + catch (CriticalFileReadException e) + { + readExcludedLocationIdsResult = HandleCriticalFileReadError>(e.Message); + } } } catch (CriticalFileReadException e) { - return HandleCriticalFileReadError>( + readExcludedLocationIdsResult = HandleCriticalFileReadError>( string.Format(Resources.HydraulicBoundaryDatabaseImporter_Cannot_open_hydraulic_calculation_settings_file_0_, e.Message)); } - } - private ReadResult> ReadExcludedLocationIds(HydraRingSettingsDatabaseReader reader) - { - try + if (readExcludedLocationIdsResult.CriticalErrorOccurred || Canceled) { - return new ReadResult>(false) - { - Items = new[] - { - reader.ReadExcludedLocations().ToArray() - } - }; + return null; } - catch (CriticalFileReadException e) - { - return HandleCriticalFileReadError>(e.Message); - } + + return readExcludedLocationIdsResult.Items.Single(); } private void AddHydraulicBoundaryDatabaseToDataModel(ReadHydraulicBoundaryDatabase readHydraulicBoundaryDatabase, ReadHydraulicLocationConfigurationDatabase readHydraulicLocationConfigurationDatabase, IEnumerable excludedLocationIds) { NotifyProgress(RiskeerCommonIOResources.Importer_ProgressText_Adding_imported_data_to_AssessmentSection, 4, numberOfSteps); + changedObservables.AddRange(updateHandler.Update(ImportTarget, readHydraulicBoundaryDatabase, readHydraulicLocationConfigurationDatabase, excludedLocationIds, FilePath, ImportTarget.HydraulicLocationConfigurationDatabase.FilePath)); }