Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Properties/Resources.resx
===================================================================
diff -u -r1514 -r2630
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Properties/Resources.resx (.../Resources.resx) (revision 1514)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Properties/Resources.resx (.../Resources.resx) (revision 2630)
@@ -112,10 +112,10 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Couldn't find the csv data file {0}
@@ -257,5 +257,56 @@
PL1 has not been created
-
+
+
+ The project should contain exactly 1 dike
+
+
+ Location has an invalid name {0}
+
+
+ No calculation type specified
+
+
+ No dike defined in this project
+
+
+ No locations defined in this project
+
+
+ Location '{0}', scenario '{1}' has no river level
+
+
+ Location '{0}', scenario '{1}' has no river level low
+
+
+ No scenarios defined in location
+
+
+ No soilprofiles1D defined in this project
+
+
+ No soils defined in this project
+
+
+ No surfacelines defined in this project
+
+
+ Segment has an invalid name {0}
+
+
+ Soil has an invalid name {0}
+
+
+ Soilprofile has an invalid name {0}
+
+
+ Surfaceline '{0}' has no characteristic points
+
+
+ Surfaceline '{0}' has no points
+
+
+ Surfaceline has an invalid name {0}
+
\ No newline at end of file
Index: DamClients/DamUI/trunk/src/Dam/Tests/DamEngineIo/FillXmlInputFromDamUiTests.cs
===================================================================
diff -u -r2615 -r2630
--- DamClients/DamUI/trunk/src/Dam/Tests/DamEngineIo/FillXmlInputFromDamUiTests.cs (.../FillXmlInputFromDamUiTests.cs) (revision 2615)
+++ DamClients/DamUI/trunk/src/Dam/Tests/DamEngineIo/FillXmlInputFromDamUiTests.cs (.../FillXmlInputFromDamUiTests.cs) (revision 2630)
@@ -614,8 +614,8 @@
scenario.RiverLevel = null;
// When Writing Xml, Then Raise Exception With Clear Message
- var expectedMessage = "Location 'Location 1', scenario '1' has no river level";
- Assert.That(() => FillXmlInputFromDamUi.CreateInput(expectedDamProjectData), Throws.TypeOf(typeof(NullReferenceException)).With.Message.EqualTo(expectedMessage));
+ var expectedMessage = "Location 'Location 1', scenario '1' has no river level" + Environment.NewLine + "Parameter name: value";
+ Assert.That(() => FillXmlInputFromDamUi.CreateInput(expectedDamProjectData), Throws.TypeOf(typeof(ArgumentNullException)).With.Message.EqualTo(expectedMessage));
}
[Test]
@@ -636,7 +636,7 @@
// When Writing Xml, Then Raise Exception With Clear Message in case of Stability Outside
if (expectedMessage != string.Empty)
{
- Assert.That(() => FillXmlInputFromDamUi.CreateInput(expectedDamProjectData), Throws.TypeOf(typeof(NullReferenceException)).With.Message.EqualTo(expectedMessage));
+ Assert.That(() => FillXmlInputFromDamUi.CreateInput(expectedDamProjectData), Throws.TypeOf(typeof(ArgumentNullException)).With.Message.Contains(expectedMessage));
}
else
{
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs
===================================================================
diff -u -r2612 -r2630
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs (.../FillXmlInputFromDamUi.cs) (revision 2612)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamEngineIo/FillXmlInputFromDamUi.cs (.../FillXmlInputFromDamUi.cs) (revision 2630)
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Deltares.Dam.Data.Properties;
using Deltares.Dam.Data.Sensors;
using Deltares.DamEngine.Io;
using Deltares.DamEngine.Io.XmlInput;
@@ -84,7 +85,7 @@
input.Soils = new DamEngine.Io.XmlInput.Soil[dike.SoilList.Soils.Count];
TransferSoils(dike.SoilList.Soils, input.Soils);
TransferAquiferSoils(dike.SoilList.AquiferDictionary, input);
-
+
// Process soilprofiles
if (damProjectData.DamProjectCalculationSpecification.SelectedStabilityKernelType == StabilityKernelType.DamClassicStability)
{
@@ -110,7 +111,6 @@
if (localSegmentSoilProfileProbability.SegmentFailureMechanismType ==
FailureMechanismSystemType.StabilityInside)
{
- //var p2D = localLocations[0].GetSoilSurfaceProfile(FailureMechanismSystemType.StabilityInside, 0, out prob);
var soilSurfaceProfile = new SoilSurfaceProfile();
var soilProfile1D = new Deltares.Geotechnics.Soils.SoilProfile1D();
soilProfile1D.Assign(localSegmentSoilProfileProbability.SoilProfile);
@@ -125,7 +125,6 @@
layer.Soil = dikeSoil;
}
}
-
}
}
i++;
@@ -329,7 +328,7 @@
input.PipingModelType = ConversionHelper.ConvertToInputPipingModelType(damProjectData.DamProjectCalculationSpecification.CurrentSpecification.PipingModelType);
}
- input.StabilityModelTypeSpecified = input.FailureMechanismSystemType ==ConversionHelper.InputFailureMechanismStabilityInside ||
+ input.StabilityModelTypeSpecified = input.FailureMechanismSystemType == ConversionHelper.InputFailureMechanismStabilityInside ||
input.FailureMechanismSystemType == ConversionHelper.InputFailureMechanismStabilityOutside;
if (input.StabilityModelTypeSpecified)
{
@@ -390,116 +389,81 @@
private static void ValidateDamProjectData(DamProjectData damProjectData)
{
- if (damProjectData.WaterBoard == null)
- {
- throw new NullReferenceException("No dike defined in this project");
- }
+ ThrowHelper.ThrowIfArgumentNull(damProjectData.WaterBoard, StringResourceNames.NoDikeDefined);
if (damProjectData.WaterBoard.Dikes == null || damProjectData.WaterBoard.Dikes.Count != 1)
{
- throw new NullReferenceException("The project should contain exactly 1 dike");
+ throw new ArgumentException(Resources.DikeShouldContainExactly1Dike);
}
var dike = damProjectData.WaterBoard.Dikes[0];
- if (dike.Locations == null)
- {
- throw new NullReferenceException("No locations defined in this project");
- }
- if (damProjectData.DamProjectCalculationSpecification.CurrentSpecification == null)
- {
- // This situation should never occur in the UI. Tested because of the check on RiverLevelLow in the code below
- throw new NullReferenceException("No calculation type specified");
- }
+ ThrowHelper.ThrowIfArgumentNull(dike.Locations, StringResourceNames.NoLocationsDefined);
+ // Following situation should never occur in the UI. Tested because of the check on RiverLevelLow in the code below
+ ThrowHelper.ThrowIfArgumentNull(damProjectData.DamProjectCalculationSpecification.CurrentSpecification, StringResourceNames.NoCalculationTypeSpecified);
foreach (Location location in dike.Locations)
{
- if (location.Scenarios == null)
+ ThrowHelper.ThrowIfArgumentNull(location.Scenarios, StringResourceNames.NoScenariosDefinedInLocation);
+ foreach (var scenario in location.Scenarios)
{
- throw new NullReferenceException("No scenarios defined in location");
- }
- else
- {
- foreach (var scenario in location.Scenarios)
+ string errorMessage = string.Format(Resources.NoRiverLevel, location.Name, scenario.LocationScenarioID);
+ ThrowHelper.ThrowIfArgumentNull(scenario.RiverLevel, errorMessage);
+ // In code above is tested that CurrentSpecification exists
+ if (damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismSystemType ==
+ FailureMechanismSystemType.StabilityOutside)
{
- if (scenario.RiverLevel == null)
- {
- throw new NullReferenceException(string.Format("Location '{0}', scenario '{1}' has no river level",
- location.Name, scenario.LocationScenarioID));
- }
- // In code above is tested that CurrentSpecification exists
- if (damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismSystemType ==
- FailureMechanismSystemType.StabilityOutside)
- {
- if (scenario.RiverLevelLow == null)
- {
- throw new NullReferenceException(string.Format("Location '{0}', scenario '{1}' has no river level low",
- location.Name, scenario.LocationScenarioID));
- }
- }
+ errorMessage = string.Format(Resources.NoRiverLevelLow, location.Name, scenario.LocationScenarioID);
+ ThrowHelper.ThrowIfArgumentNull(scenario.RiverLevelLow, errorMessage);
}
}
}
- if (dike.SurfaceLines2 == null)
+
+ ThrowHelper.ThrowIfArgumentNull(dike.SurfaceLines2, StringResourceNames.NoSurfaceLines);
+ foreach (var surfaceLine in dike.SurfaceLines2)
{
- throw new NullReferenceException("No surfacelines defined in this project");
- }
- else
- {
- foreach (var surfaceLine in dike.SurfaceLines2)
+ if ((surfaceLine.CharacteristicPoints == null) || (surfaceLine.CharacteristicPoints.Count < 1))
{
- if ((surfaceLine.CharacteristicPoints == null) || (surfaceLine.CharacteristicPoints.Count < 1))
- {
- throw new NullReferenceException(string.Format("Surfaceline '{0}' has no characteristic points", surfaceLine.Name));
- }
- if ((surfaceLine.Geometry == null) || (surfaceLine.Geometry.Count < 2))
- {
- throw new NullReferenceException(string.Format("Surfaceline '{0}' has no points", surfaceLine.Name));
- }
+ throw new ArgumentException(string.Format(Resources.SurfaceLineHasNoCharacteristicPoints, surfaceLine.Name));
}
+ if ((surfaceLine.Geometry == null) || (surfaceLine.Geometry.Count < 2))
+ {
+ throw new ArgumentException(string.Format(Resources.SurfaceLineHasNoPoints, surfaceLine.Name));
+ }
}
- if (dike.SoilList == null)
- {
- throw new NullReferenceException("No soils defined in this project");
- }
- if (dike.SoilList.Soils == null)
- {
- throw new NullReferenceException("No soils defined in this project");
- }
- if (dike.SoilProfiles == null)
- {
- throw new NullReferenceException("No soilprofiles1D defined in this project");
- }
+ ThrowHelper.ThrowIfArgumentNull(dike.SoilList, StringResourceNames.NoSoilsDefinedInProject);
+ ThrowHelper.ThrowIfArgumentNull(dike.SoilList.Soils, StringResourceNames.NoSoilsDefinedInProject);
+ ThrowHelper.ThrowIfArgumentNull(dike.SoilProfiles, StringResourceNames.NoSoilprofiles1DDefinedInProject);
// Check for invalid Id names
foreach (var location in dike.Locations)
{
if (!IdValidator.IsCorrectName(location.Name))
{
- throw new IdValidatorException(string.Format("Location has an invalid name {0}", location.Name));
+ throw new IdValidatorException(string.Format(Resources.LocationInvalidName, location.Name));
}
}
foreach (var segment in damProjectData.WaterBoard.Segments)
{
if (!IdValidator.IsCorrectName(segment.Name))
{
- throw new IdValidatorException(string.Format("Segment has an invalid name {0}", segment.Name));
+ throw new IdValidatorException(string.Format(Resources.SegmentInvalidName, segment.Name));
}
}
foreach (var surfaceLine2 in dike.SurfaceLines2)
{
if (!IdValidator.IsCorrectName(surfaceLine2.Name))
{
- throw new IdValidatorException(string.Format("Surfaceline has an invalid name {0}", surfaceLine2.Name));
+ throw new IdValidatorException(string.Format(Resources.SurfaceLineInvalidName, surfaceLine2.Name));
}
}
foreach (var soilProfile in dike.SoilProfiles)
{
if (!IdValidator.IsCorrectName(soilProfile.Name))
{
- throw new IdValidatorException(string.Format("Soilprofile has an invalid name {0}", soilProfile.Name));
+ throw new IdValidatorException(string.Format(Resources.SoilProfileInvalidName, soilProfile.Name));
}
}
foreach (var soil in dike.SoilList.Soils)
{
if (!IdValidator.IsCorrectName(soil.Name))
{
- throw new IdValidatorException(string.Format("Soil has an invalid name {0}", soil.Name));
+ throw new IdValidatorException(string.Format(Resources.SoilInvalidName, soil.Name));
}
}
}
@@ -593,7 +557,7 @@
waternetOptions.HeadPl2 = location.HeadPL2 ?? 0.0;
waternetOptions.SlopeDampingFactor = location.SlopeDampingPiezometricHeightPolderSide;
inputLocation.WaternetOptions = waternetOptions;
-
+
inputLocation.DesignScenarios = new LocationDesignScenario[location.Scenarios.Count];
for (int j = 0; j < location.Scenarios.Count; j++)
{
@@ -639,7 +603,7 @@
TrafficLoadSpecified = true,
TrafficLoad = location.TrafficLoad,
TrafficLoadDegreeOfConsolidationSpecified = location.TL_DegreeOfConsolidation.HasValue,
- TrafficLoadDegreeOfConsolidation = location.TL_DegreeOfConsolidation?? 0.0,
+ TrafficLoadDegreeOfConsolidation = location.TL_DegreeOfConsolidation ?? 0.0,
MinimumCircleDepthSpecified = true,
MinimumCircleDepth = location.MinimalCircleDepth
};
@@ -708,10 +672,10 @@
var inputSoilProfile2D = new DamEngine.Io.XmlInput.SoilProfile2D
{
Name = soilProfile2D.Name,
-
+
Layers2D = new SoilProfile2DLayer2D[soilProfile2D.LayerCount]
};
- // AddLayers2D(soilProfile2D, inputSoilProfile2D);
+ // AddLayers2D(soilProfile2D, inputSoilProfile2D);
inputSoilProfiles2D[i] = inputSoilProfile2D;
}
}
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/ThrowHelper.cs
===================================================================
diff -u -r2089 -r2630
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/ThrowHelper.cs (.../ThrowHelper.cs) (revision 2089)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/ThrowHelper.cs (.../ThrowHelper.cs) (revision 2630)
@@ -81,7 +81,15 @@
SurfaceLineNotAssigned,
SoilProfileNotAssigned,
SoilListIsNull,
- PL1NotCreated
+ PL1NotCreated,
+ NoDikeDefined,
+ NoLocationsDefined,
+ NoCalculationTypeSpecified,
+ NoScenariosDefinedInLocation,
+ NoRiverLevel,
+ NoSurfaceLines,
+ NoSoilsDefinedInProject,
+ NoSoilprofiles1DDefinedInProject
}
///
@@ -164,6 +172,12 @@
throw new ArgumentNullException(StringResources.GetString(GetResourceString(resourceNamesName)));
}
+ internal static void ThrowIfArgumentNull(object value, string message)
+ {
+ if (value == null)
+ throw new ArgumentNullException(nameof(value), message);
+ }
+
internal static void ThrowIfStringArgumentNullOrEmpty(string value, StringResourceNames resourceNamesName)
{
if (string.IsNullOrEmpty(value) || value.Trim() == "")
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Properties/Resources.Designer.cs
===================================================================
diff -u -r2089 -r2630
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 2089)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 2630)
@@ -1,25 +1,4 @@
-// Copyright (C) Stichting Deltares 2019. All rights reserved.
-//
-// This file is part of the application DAM - Clients Library.
-//
-// DAM - UI is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-//
-// All names, logos, and references to "Deltares" are registered trademarks of
-// Stichting Deltares and remain full property of Stichting Deltares at all times.
-// All rights reserved.
-
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
@@ -154,6 +133,15 @@
}
///
+ /// Looks up a localized string similar to The project should contain exactly 1 dike.
+ ///
+ internal static string DikeShouldContainExactly1Dike {
+ get {
+ return ResourceManager.GetString("DikeShouldContainExactly1Dike", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Cannot create or add the entity with the the given id because it already exist.
///
internal static string EntityAlreadyExist {
@@ -280,6 +268,15 @@
}
///
+ /// Looks up a localized string similar to Location has an invalid name {0}.
+ ///
+ internal static string LocationInvalidName {
+ get {
+ return ResourceManager.GetString("LocationInvalidName", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Couldn't find the MStab executable at location {0}.
///
internal static string MStabExecutableFileNameNotFound {
@@ -289,6 +286,33 @@
}
///
+ /// Looks up a localized string similar to No calculation type specified.
+ ///
+ internal static string NoCalculationTypeSpecified {
+ get {
+ return ResourceManager.GetString("NoCalculationTypeSpecified", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to No dike defined in this project.
+ ///
+ internal static string NoDikeDefined {
+ get {
+ return ResourceManager.GetString("NoDikeDefined", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to No locations defined in this project.
+ ///
+ internal static string NoLocationsDefined {
+ get {
+ return ResourceManager.GetString("NoLocationsDefined", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Location '{0}' does not exist in the location collection..
///
internal static string NonExistentLocation {
@@ -298,6 +322,33 @@
}
///
+ /// Looks up a localized string similar to Location '{0}', scenario '{1}' has no river level.
+ ///
+ internal static string NoRiverLevel {
+ get {
+ return ResourceManager.GetString("NoRiverLevel", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Location '{0}', scenario '{1}' has no river level low.
+ ///
+ internal static string NoRiverLevelLow {
+ get {
+ return ResourceManager.GetString("NoRiverLevelLow", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to No scenarios defined in location.
+ ///
+ internal static string NoScenariosDefinedInLocation {
+ get {
+ return ResourceManager.GetString("NoScenariosDefinedInLocation", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to No soil profiles have been defined for location '{0}'..
///
internal static string NoSoilProfileDefinedForLocation {
@@ -307,6 +358,33 @@
}
///
+ /// Looks up a localized string similar to No soilprofiles1D defined in this project.
+ ///
+ internal static string NoSoilprofiles1DDefinedInProject {
+ get {
+ return ResourceManager.GetString("NoSoilprofiles1DDefinedInProject", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to No soils defined in this project.
+ ///
+ internal static string NoSoilsDefinedInProject {
+ get {
+ return ResourceManager.GetString("NoSoilsDefinedInProject", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to No surfacelines defined in this project.
+ ///
+ internal static string NoSurfaceLines {
+ get {
+ return ResourceManager.GetString("NoSurfaceLines", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Couldn't parse the file because it has no valid content.
///
internal static string OutputFileHasNoContent {
@@ -388,6 +466,15 @@
}
///
+ /// Looks up a localized string similar to Segment has an invalid name {0}.
+ ///
+ internal static string SegmentInvalidName {
+ get {
+ return ResourceManager.GetString("SegmentInvalidName", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Couldn't find the SlopeW (GeoStudio) executable at location {0}.
///
internal static string SlopeWExecutableFileNameNotFound {
@@ -415,6 +502,15 @@
}
///
+ /// Looks up a localized string similar to Soil has an invalid name {0}.
+ ///
+ internal static string SoilInvalidName {
+ get {
+ return ResourceManager.GetString("SoilInvalidName", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to The soil list is not yet created..
///
internal static string SoilListIsNull {
@@ -433,6 +529,15 @@
}
///
+ /// Looks up a localized string similar to Soilprofile has an invalid name {0}.
+ ///
+ internal static string SoilProfileInvalidName {
+ get {
+ return ResourceManager.GetString("SoilProfileInvalidName", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to The soilprofile is not assigned.
///
internal static string SoilProfileNotAssigned {
@@ -442,6 +547,24 @@
}
///
+ /// Looks up a localized string similar to Surfaceline '{0}' has no characteristic points.
+ ///
+ internal static string SurfaceLineHasNoCharacteristicPoints {
+ get {
+ return ResourceManager.GetString("SurfaceLineHasNoCharacteristicPoints", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Surfaceline '{0}' has no points.
+ ///
+ internal static string SurfaceLineHasNoPoints {
+ get {
+ return ResourceManager.GetString("SurfaceLineHasNoPoints", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to The surface line id argument is null or empty but it is required.
///
internal static string SurfaceLineIdArgumentNullOrEmpty {
@@ -451,6 +574,15 @@
}
///
+ /// Looks up a localized string similar to Surfaceline has an invalid name {0}.
+ ///
+ internal static string SurfaceLineInvalidName {
+ get {
+ return ResourceManager.GetString("SurfaceLineInvalidName", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Surfaceline is not inside soil profile.
///
internal static string SurfacelineIsNotInsideSoilprofile {