Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Deltares.Dam.Tests.csproj
===================================================================
diff -u -r4217 -r4285
--- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Deltares.Dam.Tests.csproj (.../Deltares.Dam.Tests.csproj) (revision 4217)
+++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/Deltares.Dam.Tests.csproj (.../Deltares.Dam.Tests.csproj) (revision 4285)
@@ -44,6 +44,12 @@
..\..\..\lib\DotSpatial\DotSpatial.Topology.dll
+
+ ..\..\..\lib\DamEngine\DGeoSuite.Common.dll
+
+
+ ..\..\..\lib\DamEngine\DGeoSuite.Components.Persistence.dll
+
@@ -492,6 +498,12 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Deltares.Dam.Data.csproj
===================================================================
diff -u -r4278 -r4285
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Deltares.Dam.Data.csproj (.../Deltares.Dam.Data.csproj) (revision 4278)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Deltares.Dam.Data.csproj (.../Deltares.Dam.Data.csproj) (revision 4285)
@@ -16,12 +16,10 @@
False
..\..\..\lib\Authorization\x86\Deltares.Authorization.dll
-
- False
+
..\..\..\lib\DamEngine\Deltares.DamEngine.Data.dll
-
- False
+
..\..\..\lib\DamEngine\Deltares.DamEngine.Io.dll
@@ -107,6 +105,7 @@
+
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/StiImporter/SoilProfile2DImporter.cs
===================================================================
diff -u -r4201 -r4285
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/StiImporter/SoilProfile2DImporter.cs (.../SoilProfile2DImporter.cs) (revision 4201)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/StiImporter/SoilProfile2DImporter.cs (.../SoilProfile2DImporter.cs) (revision 4285)
@@ -23,6 +23,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using Deltares.Dam.StixFileReader;
using Deltares.Geotechnics.Soils;
using Deltares.Standard.Language;
@@ -64,8 +65,7 @@
}
// Extract all soil profile 2D from a segment
- IEnumerable soilProfiles = segment.SoilProfileProbabilities
- .Where(sp => sp.SoilProfileType == SoilProfileType.SoilGeometryStiFile);
+ IEnumerable soilProfiles = segment.SoilProfileProbabilities.Where(sp => sp.SoilProfileType == SoilProfileType.SoilGeometryStiFile);
var importedSoilProfiles = new List();
foreach (SoilGeometryProbability profile in soilProfiles)
@@ -96,19 +96,46 @@
{
string soilProfileFileName = HasStiFileExtension(soilProfileName) ? soilProfileName : $"{soilProfileName}.sti";
string filePath = Path.Combine(soilProfileDirectory, soilProfileFileName);
- try
+ if (File.Exists(filePath))
{
- var reader = new StiFileReader();
- SoilProfile2D readSoilProfile = reader.ReadSoilProfile(filePath);
- readSoilProfile.Name = soilProfileName;
+ soilProfileFileName = HasStiFileExtension(soilProfileName) ? soilProfileName : $"{soilProfileName}.sti";
+ filePath = Path.Combine(soilProfileDirectory, soilProfileFileName);
+ try
+ {
+ var reader = new StiFileReader();
+ SoilProfile2D readSoilProfile = reader.ReadSoilProfile(filePath);
+ readSoilProfile.Name = soilProfileName;
- return readSoilProfile;
+ return readSoilProfile;
+ }
+ catch (StiFileReadException e)
+ {
+ string messageFormat = LocalizationManager.GetTranslatedText(typeof(SoilProfile2DImporter), "ImportSoilProfileErrorReadFailed");
+ throw new SoilProfileImporterException(string.Format(messageFormat, soilProfileName, e.Message), e);
+ }
}
- catch (StiFileReadException e)
+
+ soilProfileFileName = StixFileReaderHelper.FetchFileNameWithStixExtension(soilProfileName);
+ filePath = Path.Combine(soilProfileDirectory, soilProfileFileName);
+ if (File.Exists(filePath))
{
- string messageFormat = LocalizationManager.GetTranslatedText(typeof(SoilProfile2DImporter), "ImportSoilProfileErrorReadFailed");
- throw new SoilProfileImporterException(string.Format(messageFormat, soilProfileName, e.Message), e);
+ filePath = Path.Combine(soilProfileDirectory, soilProfileFileName);
+ try
+ {
+ var reader = new StixFileReader.StixFileReader();
+ SoilProfile2D readSoilProfile = reader.ReadSoilProfile(filePath);
+
+ return readSoilProfile;
+ }
+ catch (StixFileReadException e)
+ {
+ string messageFormat = LocalizationManager.GetTranslatedText(typeof(SoilProfile2DImporter), "ImportSoilProfileErrorReadFailed");
+ throw new SoilProfileImporterException(string.Format(messageFormat, soilProfileName, e.Message), e);
+ }
}
+
+ string message = LocalizationManager.GetTranslatedText(typeof(SoilProfile2DImporter), "ImportSoilProfileErrorReadFailed");
+ throw new SoilProfileImporterException(string.Format(message, soilProfileName, string.Empty));
}
private static bool HasStiFileExtension(string profileName)
Index: DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/StiImporter/SoilProfile2DImporterTest.cs
===================================================================
diff -u -r4209 -r4285
--- DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/StiImporter/SoilProfile2DImporterTest.cs (.../SoilProfile2DImporterTest.cs) (revision 4209)
+++ DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/StiImporter/SoilProfile2DImporterTest.cs (.../SoilProfile2DImporterTest.cs) (revision 4285)
@@ -206,14 +206,8 @@
"Muck"
});
- // Call
- TestDelegate call = () => SoilProfile2DImporter.Import(TestDataFolder, segment, availableSoils);
-
- // Assert
- var exception = Assert.Throws(call);
- Exception innerException = exception.InnerException;
- Assert.That(innerException, Is.Not.Null);
- Assert.That(exception.Message, Is.EqualTo($"Could not import soil profile '{invalidSoilProfileName}': {innerException.Message}."));
+ Assert.That(() => SoilProfile2DImporter.Import(TestDataFolder, segment, availableSoils),
+ Throws.TypeOf().With.Message.Contains($"Could not import soil profile '{invalidSoilProfileName}': "));
}
private static Segment CreateSegmentWithProfiles(IEnumerable soilProfileNames)