Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rad69743281f3934fee4089cb577e078bcb92b736 --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs (.../AddNewDemoDikeAssessmentSectionCommand.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs (.../AddNewDemoDikeAssessmentSectionCommand.cs) (revision ad69743281f3934fee4089cb577e078bcb92b736) @@ -1,5 +1,5 @@ -using System.Linq; - +using System.IO; +using System.Linq; using Core.Common.Base.Data; using Core.Common.Controls.Commands; using Core.Common.Gui; @@ -9,7 +9,6 @@ using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Plugin.FileImporters; using Ringtoets.Piping.Data; -using Ringtoets.Piping.Data.Probabilistics; using Ringtoets.Piping.Forms.Extensions; using Ringtoets.Piping.Plugin.FileImporter; @@ -69,7 +68,7 @@ "traject_10-1.dbf", "traject_10-1.prj", "traject_10-1.shx")) { var importer = new ReferenceLineImporter(); - importer.Import(new ReferenceLineContext(demoAssessmentSection), temporaryShapeFile.FilePath); + importer.Import(new ReferenceLineContext(demoAssessmentSection), Path.Combine(temporaryShapeFile.TargetFolderPath, "traject_10-1.shp")); } } @@ -79,7 +78,7 @@ { using (var hydraulicBoundaryDatabaseImporter = new HydraulicBoundaryDatabaseImporter()) { - hydraulicBoundaryDatabaseImporter.ValidateAndConnectTo(tempPath.FilePath); + hydraulicBoundaryDatabaseImporter.ValidateAndConnectTo(Path.Combine(tempPath.TargetFolderPath, "HRD_dutchcoastsouth.sqlite")); hydraulicBoundaryDatabaseImporter.Import(new HydraulicBoundaryDatabaseContext(demoAssessmentSection)); } } @@ -94,7 +93,7 @@ foreach (var failureMechanism in demoAssessmentSection.GetFailureMechanisms()) { var context = new FailureMechanismSectionsContext(failureMechanism, demoAssessmentSection); - importer.Import(context, temporaryShapeFile.FilePath); + importer.Import(context, Path.Combine(temporaryShapeFile.TargetFolderPath, "traject_10-1_vakken.shp")); } } } @@ -106,19 +105,19 @@ using (var tempPath = new TemporaryImportFile("DR6_surfacelines.csv", "DR6_surfacelines.krp.csv")) { var surfaceLinesImporter = new PipingSurfaceLinesCsvImporter(); - surfaceLinesImporter.Import(pipingFailureMechanism.SurfaceLines, tempPath.FilePath); + surfaceLinesImporter.Import(pipingFailureMechanism.SurfaceLines, Path.Combine(tempPath.TargetFolderPath, "DR6_surfacelines.csv")); } using (var tempPath = new TemporaryImportFile("DR6.soil")) { var surfaceLinesImporter = new PipingSoilProfilesImporter(); - surfaceLinesImporter.Import(pipingFailureMechanism.SoilProfiles, tempPath.FilePath); + surfaceLinesImporter.Import(pipingFailureMechanism.SoilProfiles, Path.Combine(tempPath.TargetFolderPath, "DR6.soil")); } var calculation = pipingFailureMechanism.CalculationsGroup.GetPipingCalculations().First(); calculation.InputParameters.SetSurfaceLine(pipingFailureMechanism.SurfaceLines.First(sl => sl.Name == "PK001_0001")); calculation.InputParameters.SetSoilProfile(pipingFailureMechanism.SoilProfiles.First(sl => sl.Name == "W1-6_0_1D1")); - calculation.InputParameters.PhreaticLevelExit.Mean = (RoundedDouble)3; + calculation.InputParameters.PhreaticLevelExit.Mean = (RoundedDouble) 3; calculation.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0.0, 0.0) { DesignWaterLevel = 0.0 Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDuneAssessmentSectionCommand.cs =================================================================== diff -u -rfc22f4b149d07797f0526f04ca58595bb9446786 -rad69743281f3934fee4089cb577e078bcb92b736 --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDuneAssessmentSectionCommand.cs (.../AddNewDemoDuneAssessmentSectionCommand.cs) (revision fc22f4b149d07797f0526f04ca58595bb9446786) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDuneAssessmentSectionCommand.cs (.../AddNewDemoDuneAssessmentSectionCommand.cs) (revision ad69743281f3934fee4089cb577e078bcb92b736) @@ -1,9 +1,9 @@ -using Core.Common.Controls.Commands; +using System.IO; +using Core.Common.Controls.Commands; using Core.Common.Gui; using Ringtoets.Common.Data; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Integration.Data; -using Ringtoets.Integration.Data.Placeholders; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Plugin.FileImporters; @@ -62,7 +62,7 @@ "traject_10-1.dbf", "traject_10-1.prj", "traject_10-1.shx")) { var importer = new ReferenceLineImporter(); - importer.Import(new ReferenceLineContext(demoAssessmentSection), temporaryShapeFile.FilePath); + importer.Import(new ReferenceLineContext(demoAssessmentSection), Path.Combine(temporaryShapeFile.TargetFolderPath, "traject_10-1.shp")); } } @@ -72,7 +72,7 @@ { using (var hydraulicBoundaryDatabaseImporter = new HydraulicBoundaryDatabaseImporter()) { - hydraulicBoundaryDatabaseImporter.ValidateAndConnectTo(tempPath.FilePath); + hydraulicBoundaryDatabaseImporter.ValidateAndConnectTo(Path.Combine(tempPath.TargetFolderPath, "HRD_dutchcoastsouth.sqlite")); hydraulicBoundaryDatabaseImporter.Import(new HydraulicBoundaryDatabaseContext(demoAssessmentSection)); } } @@ -87,7 +87,7 @@ foreach (IFailureMechanism failureMechanism in demoAssessmentSection.GetFailureMechanisms()) { var context = new FailureMechanismSectionsContext(failureMechanism, demoAssessmentSection); - importer.Import(context, temporaryShapeFile.FilePath); + importer.Import(context, Path.Combine(temporaryShapeFile.TargetFolderPath, "traject_10-1_vakken.shp")); } } } Index: Demo/Ringtoets/src/Demo.Ringtoets/TemporaryImportFile.cs =================================================================== diff -u -rad2d65c5904706727b1e19341a8b1162645c845a -rad69743281f3934fee4089cb577e078bcb92b736 --- Demo/Ringtoets/src/Demo.Ringtoets/TemporaryImportFile.cs (.../TemporaryImportFile.cs) (revision ad2d65c5904706727b1e19341a8b1162645c845a) +++ Demo/Ringtoets/src/Demo.Ringtoets/TemporaryImportFile.cs (.../TemporaryImportFile.cs) (revision ad69743281f3934fee4089cb577e078bcb92b736) @@ -1,6 +1,5 @@ using System; using System.IO; - using Core.Common.Utils.Reflection; namespace Demo.Ringtoets @@ -11,52 +10,46 @@ /// internal class TemporaryImportFile : IDisposable { - private readonly string tempTargetFolderPath; - private readonly string fullFilePath; + private readonly string targetFolderPath; /// /// Initializes a new instance of the class. /// - /// Name of the file with build action 'Embedded Resource' within this project. - /// Names of extra files required for importing the . - public TemporaryImportFile(string embeddedResourceFileName, params string[] supportFiles) + /// The names of the 'Embedded Resource' files to temporary copy to the file system. + public TemporaryImportFile(params string[] embeddedResourceFileNames) { - tempTargetFolderPath = Path.Combine(Path.GetTempPath(), "demo_traject"); - Directory.CreateDirectory(tempTargetFolderPath); + targetFolderPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - fullFilePath = Path.Combine(tempTargetFolderPath, embeddedResourceFileName); + Directory.CreateDirectory(targetFolderPath); - WriteEmbeddedResourceToTemporaryFile(embeddedResourceFileName, fullFilePath); - - foreach (string supportFile in supportFiles) + foreach (string embeddedResourceFileName in embeddedResourceFileNames) { - var filePath = Path.Combine(tempTargetFolderPath, supportFile); - WriteEmbeddedResourceToTemporaryFile(supportFile, filePath); + WriteEmbeddedResourceToTemporaryFile(embeddedResourceFileName, Path.Combine(targetFolderPath, embeddedResourceFileName)); } } - private void WriteEmbeddedResourceToTemporaryFile(string embeddedResourceFileName, string filePath) + public string TargetFolderPath { - var stream = GetStreamToFileInResource(embeddedResourceFileName); - - var bytes = GetBinaryDataOfStream(stream); - - File.WriteAllBytes(filePath, bytes); - } - - public string FilePath - { get { - return fullFilePath; + return targetFolderPath; } } public void Dispose() { - Directory.Delete(tempTargetFolderPath, true); + Directory.Delete(targetFolderPath, true); } + private void WriteEmbeddedResourceToTemporaryFile(string embeddedResourceFileName, string filePath) + { + var stream = GetStreamToFileInResource(embeddedResourceFileName); + + var bytes = GetBinaryDataOfStream(stream); + + File.WriteAllBytes(filePath, bytes); + } + private Stream GetStreamToFileInResource(string embeddedResourceFileName) { return AssemblyUtils.GetAssemblyResourceStream(GetType().Assembly, embeddedResourceFileName); @@ -66,7 +59,7 @@ { var bytes = new byte[stream.Length]; var reader = new BinaryReader(stream); - reader.Read(bytes, 0, (int)stream.Length); + reader.Read(bytes, 0, (int) stream.Length); return bytes; } }