Ejemplo n.º 1
0
 /// <summary>
 /// Imports <see cref="FailureMechanismSection"/> data for a given enumeration of <see cref="IFailureMechanism{T}"/>.
 /// </summary>
 /// <param name="assessmentSection">The <see cref="AssessmentSection"/> that contains the <see cref="IFailureMechanism{T}"/> instances.</param>
 /// <param name="targetFailureMechanisms">The <see cref="IFailureMechanism{T}"/> instances to import on.</param>
 /// <remarks>
 /// <para>This will import the same 283 failure mechanism sections on all failure mechanisms.</para>
 /// <para>Does not import using <see cref="FileImportActivity"/>.</para>
 /// </remarks>
 public static void ImportFailureMechanismSections(AssessmentSection assessmentSection, IEnumerable <IFailureMechanism <FailureMechanismSectionResult> > targetFailureMechanisms)
 {
     using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly,
                                                                            true,
                                                                            "traject_6-3_vakken.shp",
                                                                            "traject_6-3_vakken.dbf",
                                                                            "traject_6-3_vakken.prj",
                                                                            "traject_6-3_vakken.shx"))
     {
         IFailureMechanism <FailureMechanismSectionResult>[] failureMechanisms = targetFailureMechanisms.ToArray();
         for (var i = 0; i < failureMechanisms.Length; i++)
         {
             IFailureMechanism <FailureMechanismSectionResult> failureMechanism = failureMechanisms[i];
             if (i == 0)
             {
                 string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath,
                                                "traject_6-3_vakken.shp");
                 var importer = new FailureMechanismSectionsImporter(
                     failureMechanism, assessmentSection.ReferenceLine, filePath,
                     new FailureMechanismSectionReplaceStrategy(failureMechanism),
                     new ImportMessageProvider());
                 importer.Import();
             }
             else
             {
                 // Copy same FailureMechanismSection instances to other failure mechanisms
                 FailureMechanismTestHelper.SetSections(failureMechanism, failureMechanisms[0].Sections.Select(DeepCloneSection).ToArray());
             }
         }
     }
 }
Ejemplo n.º 2
0
        public void EmbeddedResourceFileWriter_ValidEmbeddedResources_FilesPreservedAccordingToFlagRemoveFilesOnDispose(bool removeFilesOnDispose)
        {
            // Setup
            string targetFolderPath;

            // Call
            using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(GetType().Assembly, removeFilesOnDispose, "EmbeddedResource1.txt", "EmbeddedResource2.txt"))
            {
                targetFolderPath = embeddedResourceFileWriter.TargetFolderPath;
            }

            // Assert
            try
            {
                Assert.AreEqual(!removeFilesOnDispose, File.Exists(Path.Combine(targetFolderPath, "EmbeddedResource1.txt")));
                Assert.AreEqual(!removeFilesOnDispose, File.Exists(Path.Combine(targetFolderPath, "EmbeddedResource2.txt")));
            }
            finally
            {
                // Cleanup
                if (!removeFilesOnDispose)
                {
                    DirectoryHelper.TryDelete(targetFolderPath);
                }
            }
        }
Ejemplo n.º 3
0
        public void EmbeddedResourceFileWriter_ValidEmbeddedResources_FilesCorrectlyWritten(bool removeFilesOnDispose)
        {
            // Setup
            const string fileName1 = "EmbeddedResource1.txt";
            const string fileName2 = "EmbeddedResource2.txt";

            // Call
            using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(GetType().Assembly, removeFilesOnDispose, fileName1, fileName2))
            {
                // Assert
                string filePath1 = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, fileName1);
                string filePath2 = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, fileName2);

                try
                {
                    Assert.IsTrue(File.Exists(filePath1));
                    Assert.IsTrue(File.Exists(filePath2));
                }
                finally
                {
                    if (File.Exists(filePath1))
                    {
                        File.Delete(filePath1);
                    }

                    if (File.Exists(filePath2))
                    {
                        File.Delete(filePath2);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Imports the <see cref="HydraulicBoundaryDatabase"/> for the given <see cref="AssessmentSection"/>.
        /// </summary>
        /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to import on.</param>
        /// <remarks>This will import 18 Hydraulic boundary locations.</remarks>
        public static void ImportHydraulicBoundaryDatabase(AssessmentSection assessmentSection)
        {
            using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly,
                                                                                   false,
                                                                                   "HRD dutch coast south.sqlite",
                                                                                   "HLCD.sqlite",
                                                                                   "HRD dutch coast south.config.sqlite"))
            {
                string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "HRD dutch coast south.sqlite");

                ImportHydraulicBoundaryDatabase(assessmentSection, filePath);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Imports the <see cref="MacroStabilityInwardsStochasticSoilModel"/> data for the <see cref="MacroStabilityInwardsFailureMechanism"/>
 /// of the given <see cref="IAssessmentSection"/>.
 /// </summary>
 /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to import on.</param>
 /// <remarks>This will import 4 soil models with one profile each.</remarks>
 public static void ImportMacroStabilityInwardsStochasticSoilModels(AssessmentSection assessmentSection)
 {
     using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly,
                                                                            true,
                                                                            "DR6.soil"))
     {
         string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil");
         var    activity = new FileImportActivity(new StochasticSoilModelImporter <MacroStabilityInwardsStochasticSoilModel>(
                                                      assessmentSection.MacroStabilityInwards.StochasticSoilModels,
                                                      filePath,
                                                      new ImportMessageProvider(),
                                                      MacroStabilityInwardsStochasticSoilModelImporterConfigurationFactory.CreateReplaceStrategyConfiguration(assessmentSection.MacroStabilityInwards)),
                                                  "MacroStabilityInwardsStochasticSoilModelImporter");
         activity.Run();
         activity.Finish();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Imports the <see cref="MacroStabilityInwardsSurfaceLine"/> data for the <see cref="MacroStabilityInwardsFailureMechanism"/>
 /// of the given <see cref="IAssessmentSection"/>.
 /// </summary>
 /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to import on.</param>
 /// <remarks>This will import 4 surface lines.</remarks>
 public static void ImportMacroStabilityInwardsSurfaceLines(AssessmentSection assessmentSection)
 {
     using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly,
                                                                            true,
                                                                            "DR6_surfacelines.csv",
                                                                            "DR6_surfacelines.krp.csv"))
     {
         string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_surfacelines.csv");
         var    activity = new FileImportActivity(new SurfaceLinesCsvImporter <MacroStabilityInwardsSurfaceLine>(
                                                      assessmentSection.MacroStabilityInwards.SurfaceLines,
                                                      filePath,
                                                      new ImportMessageProvider(),
                                                      MacroStabilityInwardsSurfaceLinesCsvImporterConfigurationFactory.CreateReplaceStrategyConfiguration(assessmentSection.MacroStabilityInwards, assessmentSection.ReferenceLine)),
                                                  "MacroStabilityInwardsSurfaceLinesCsvImporter");
         activity.Run();
         activity.Finish();
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Imports the <see cref="PipingStochasticSoilModel"/> data for the <see cref="PipingFailureMechanism"/>
 /// of the given <see cref="IAssessmentSection"/> and updates existing data based upon the imported
 /// data.
 /// </summary>
 /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to import on.</param>
 /// <remarks>When data from <see cref="DataImportHelper.ImportPipingStochasticSoilModels"/> is added first,
 /// then calling this method will remove soil model 'PK001_0004_Piping', stochastic soil profile 'W1-6_4_1D1'
 /// and update the probability of stochastic soil profile '6-3_22' (100% to 50%).</remarks>
 public static void UpdatePipingStochasticSoilModels(AssessmentSection assessmentSection)
 {
     using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataUpdateHelper).Assembly,
                                                                            true,
                                                                            "DR6_updated.soil"))
     {
         string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_updated.soil");
         var    activity = new FileImportActivity(
             new StochasticSoilModelImporter <PipingStochasticSoilModel>(
                 assessmentSection.Piping.StochasticSoilModels,
                 filePath,
                 new UpdateMessageProvider(),
                 PipingStochasticSoilModelImporterConfigurationFactory.CreateUpdateStrategyConfiguration(assessmentSection.Piping)),
             "StochasticSoilModelUpdater");
         activity.Run();
         activity.Finish();
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Imports <see cref="FailureMechanismSection"/> data for a given <see cref="IFailureMechanism{T}"/>.
 /// </summary>
 /// <param name="assessmentSection">The <see cref="AssessmentSection"/> that contains the <see cref="IFailureMechanism{T}"/> instance.</param>
 /// <param name="failureMechanism">The <see cref="IFailureMechanism{T}"/> instance to import on.</param>
 /// <remarks>
 /// <para>This will import 283 failure mechanism sections.</para>
 /// <para>Imports using <see cref="FileImportActivity"/>.</para>
 /// </remarks>
 public static void ImportFailureMechanismSections(AssessmentSection assessmentSection, IFailureMechanism <FailureMechanismSectionResult> failureMechanism)
 {
     using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly,
                                                                            true,
                                                                            "traject_6-3_vakken.shp",
                                                                            "traject_6-3_vakken.dbf",
                                                                            "traject_6-3_vakken.prj",
                                                                            "traject_6-3_vakken.shx"))
     {
         string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3_vakken.shp");
         var    activity = new FileImportActivity(new FailureMechanismSectionsImporter(
                                                      failureMechanism, assessmentSection.ReferenceLine, filePath,
                                                      new FailureMechanismSectionReplaceStrategy(failureMechanism),
                                                      new ImportMessageProvider()),
                                                  "FailureMechanismSectionsImporter");
         activity.Run();
         activity.Finish();
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Imports the <see cref="ReferenceLine"/> on the <see cref="AssessmentSection"/>.
 /// </summary>
 /// <param name="assessmentSection">The <see cref="AssessmentSection"/> to import the reference line on.</param>
 public static void ImportReferenceLine(AssessmentSection assessmentSection)
 {
     using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DataImportHelper).Assembly,
                                                                            true,
                                                                            "traject_6-3.shp",
                                                                            "traject_6-3.dbf",
                                                                            "traject_6-3.prj",
                                                                            "traject_6-3.shx"))
     {
         string filePath     = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3.shp");
         var    mocks        = new MockRepository();
         var    viewCommands = mocks.Stub <IViewCommands>();
         mocks.ReplayAll();
         var activity = new FileImportActivity(new ReferenceLineImporter(assessmentSection.ReferenceLine,
                                                                         new ReferenceLineUpdateHandler(assessmentSection, viewCommands),
                                                                         filePath),
                                               "ReferenceLineImporter");
         activity.Run();
         activity.Finish();
         mocks.VerifyAll();
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates an <see cref="IEnumerable{T}"/> of <see cref="ReadDuneLocation"/> based on the line features within the embedded shape file.
        /// </summary>
        /// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ReadDuneLocation"/>.</returns>
        public IEnumerable <ReadDuneLocation> ReadDuneLocations()
        {
            using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(typeof(DuneLocationsReader).Assembly,
                                                                                   true,
                                                                                   "RSPstelsel.shp",
                                                                                   "RSPstelsel.dbf",
                                                                                   "RSPstelsel.cpg",
                                                                                   "RSPstelsel.sbn",
                                                                                   "RSPstelsel.sbx",
                                                                                   "RSPstelsel.shx"))
            {
                string filePath = Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "RSPstelsel.shp");

                var readDuneLocations = new List <ReadDuneLocation>();
                using (var pointShapeReader = new PointShapeFileReader(filePath))
                {
                    FeatureBasedMapData locationsData = pointShapeReader.ReadShapeFile();
                    readDuneLocations.AddRange(CreateDuneLocations(locationsData));
                }

                return(readDuneLocations);
            }
        }