Index: Riskeer/Common/src/Riskeer.Common.IO/HydraRing/HydraulicBoundaryDataHelper.cs
===================================================================
diff -u -r6e3bc0437167a40cf4a79f0f04e31dc61ef4407f -r025572749b152ab165c15dc432113acc16d604b3
--- Riskeer/Common/src/Riskeer.Common.IO/HydraRing/HydraulicBoundaryDataHelper.cs (.../HydraulicBoundaryDataHelper.cs) (revision 6e3bc0437167a40cf4a79f0f04e31dc61ef4407f)
+++ Riskeer/Common/src/Riskeer.Common.IO/HydraRing/HydraulicBoundaryDataHelper.cs (.../HydraulicBoundaryDataHelper.cs) (revision 025572749b152ab165c15dc432113acc16d604b3)
@@ -22,6 +22,7 @@
using System;
using System.Globalization;
using System.IO;
+using System.Linq;
using Core.Common.Base.IO;
using Core.Common.Util;
using Core.Common.Util.Builders;
@@ -109,22 +110,48 @@
///
/// Checks whether the provided version string matches the version string in the provided hydraulic boundary database file.
+ ///
/// The version to check for.
/// The path of the hydraulic boundary database to check.
/// true if the provided version string matches the version string in the provided hydraulic boundary
/// database file, false otherwise.
/// Thrown when no connection could be created with the hydraulic boundary
/// database.
- ///
public static bool IsCorrectVersion(string version, string hrdFilePath)
{
- using (var db = new HydraulicBoundaryDatabaseReader(hrdFilePath))
+ using (var hydraulicBoundaryDatabaseReader = new HydraulicBoundaryDatabaseReader(hrdFilePath))
{
- return version == db.ReadVersion();
+ return version == hydraulicBoundaryDatabaseReader.ReadVersion();
}
}
///
+ /// Checks whether the provided hydraulic boundary database matches the file name that is referred to from the provided
+ /// hydraulic location configuration database.
+ ///
+ /// The path of the hydraulic location configuration database to check.
+ /// The path of the hydraulic boundary database to check.
+ /// true if the hydraulic boundary database matches the file name that is referred to from the hydraulic
+ /// location configuration database, false otherwise.
+ /// Thrown when no connection could be created with the hydraulic location
+ /// configuration database or the hydraulic boundary database.
+ public static bool IsCorrectHrdFile(string hlcdFilePath, string hrdFilePath)
+ {
+ using (var hydraulicLocationConfigurationDatabaseReader = new HydraulicLocationConfigurationDatabaseReader(hlcdFilePath))
+ {
+ ReadHydraulicLocationConfigurationDatabase readHydraulicLocationConfigurationDatabase = hydraulicLocationConfigurationDatabaseReader.Read();
+
+ using (var hydraulicBoundaryDatabaseReader = new HydraulicBoundaryDatabaseReader(hrdFilePath))
+ {
+ ReadHydraulicBoundaryDatabase readHydraulicBoundaryDatabase = hydraulicBoundaryDatabaseReader.Read();
+
+ return readHydraulicLocationConfigurationDatabase.ReadTracks.Any(rt => rt.TrackId == readHydraulicBoundaryDatabase.TrackId
+ && rt.HrdFileName == Path.GetFileName(hrdFilePath));
+ }
+ }
+ }
+
+ ///
/// Gets the file path of the hydraulic boundary settings database.
///
/// The file path of the corresponding hydraulic boundary database.
Index: Riskeer/Common/src/Riskeer.Common.Service/HydraulicBoundaryDataConnectionValidator.cs
===================================================================
diff -u -r6e3bc0437167a40cf4a79f0f04e31dc61ef4407f -r025572749b152ab165c15dc432113acc16d604b3
--- Riskeer/Common/src/Riskeer.Common.Service/HydraulicBoundaryDataConnectionValidator.cs (.../HydraulicBoundaryDataConnectionValidator.cs) (revision 6e3bc0437167a40cf4a79f0f04e31dc61ef4407f)
+++ Riskeer/Common/src/Riskeer.Common.Service/HydraulicBoundaryDataConnectionValidator.cs (.../HydraulicBoundaryDataConnectionValidator.cs) (revision 025572749b152ab165c15dc432113acc16d604b3)
@@ -70,6 +70,11 @@
return string.Format(Resources.Hydraulic_boundary_database_mismatching_version_in_file_0_, hydraulicBoundaryDatabase.FilePath);
}
+ if (!HydraulicBoundaryDataHelper.IsCorrectHrdFile(hydraulicBoundaryData.HydraulicLocationConfigurationDatabase.FilePath, hydraulicBoundaryDatabase.FilePath))
+ {
+ return string.Format(Resources.Hydraulic_location_configuration_database_refers_to_hydraulic_boundary_database_that_does_not_correspond_with_0, hydraulicBoundaryDatabase.FilePath);
+ }
+
return null;
}
}
Index: Riskeer/Common/src/Riskeer.Common.Service/Properties/Resources.Designer.cs
===================================================================
diff -u -r6e3bc0437167a40cf4a79f0f04e31dc61ef4407f -r025572749b152ab165c15dc432113acc16d604b3
--- Riskeer/Common/src/Riskeer.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 6e3bc0437167a40cf4a79f0f04e31dc61ef4407f)
+++ Riskeer/Common/src/Riskeer.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 025572749b152ab165c15dc432113acc16d604b3)
@@ -215,6 +215,16 @@
}
///
+ /// Looks up a localized string similar to Het HLCD bestand verwijst naar een HRD bestand dat niet correspondeert met '{0}'..
+ ///
+ public static string Hydraulic_location_configuration_database_refers_to_hydraulic_boundary_database_that_does_not_correspond_with_0 {
+ get {
+ return ResourceManager.GetString("Hydraulic_location_configuration_database_refers_to_hydraulic_boundary_database_t" +
+ "hat_does_not_correspond_with_0", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to De waarde voor '{0}' moet een concreet getal zijn..
///
public static string NumericInputRule_Value_of_0_must_be_a_valid_number {
Index: Riskeer/Common/src/Riskeer.Common.Service/Properties/Resources.resx
===================================================================
diff -u -re72f1aeba979e2399a54d18cd348e42ba6558899 -r025572749b152ab165c15dc432113acc16d604b3
--- Riskeer/Common/src/Riskeer.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision e72f1aeba979e2399a54d18cd348e42ba6558899)
+++ Riskeer/Common/src/Riskeer.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision 025572749b152ab165c15dc432113acc16d604b3)
@@ -212,4 +212,7 @@
Kan de waterstand niet afleiden op basis van de invoer.
+
+ Het HLCD bestand verwijst naar een HRD bestand dat niet correspondeert met '{0}'.
+
\ No newline at end of file
Index: Riskeer/Common/src/Riskeer.Common.Service/TargetProbabilityCalculationService.cs
===================================================================
diff -u -r6e3bc0437167a40cf4a79f0f04e31dc61ef4407f -r025572749b152ab165c15dc432113acc16d604b3
--- Riskeer/Common/src/Riskeer.Common.Service/TargetProbabilityCalculationService.cs (.../TargetProbabilityCalculationService.cs) (revision 6e3bc0437167a40cf4a79f0f04e31dc61ef4407f)
+++ Riskeer/Common/src/Riskeer.Common.Service/TargetProbabilityCalculationService.cs (.../TargetProbabilityCalculationService.cs) (revision 025572749b152ab165c15dc432113acc16d604b3)
@@ -76,6 +76,17 @@
isValid = false;
}
+ if (isValid && !HydraulicBoundaryDataHelper.IsCorrectHrdFile(calculationSettings.HlcdFilePath, calculationSettings.HrdFilePath))
+ {
+ CalculationServiceHelper.LogMessagesAsError(Resources.Hydraulic_location_configuration_database_refers_to_hydraulic_boundary_database_that_does_not_correspond_with_0,
+ new[]
+ {
+ calculationSettings.HrdFilePath
+ });
+
+ isValid = false;
+ }
+
CalculationServiceHelper.LogValidationEnd();
return isValid;