Index: Application/Riskeer/src/Application.Riskeer.API/Application.Riskeer.API.csproj
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Application.Riskeer.API.csproj (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Application.Riskeer.API.csproj (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/ErrorHandling/RiskeerApiException.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/ErrorHandling/RiskeerApiException.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/ErrorHandling/RiskeerApiException.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,16 @@
+using System;
+using Application.Riskeer.API.Implementation;
+
+namespace Application.Riskeer.API.ErrorHandling {
+ public class RiskeerApiException : Exception
+ {
+ public RiskeerApiException(RiskeerApiExceptionType type, string msg, Exception innerException = null) : base(msg, innerException)
+ {
+ Type = type;
+ }
+
+ public RiskeerApiException(RiskeerApiExceptionType type, Exception innerException = null) : this(type,type.GetMessage(), innerException) {}
+
+ public RiskeerApiExceptionType Type { get; }
+ }
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/ErrorHandling/RiskeerApiExceptionType.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/ErrorHandling/RiskeerApiExceptionType.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/ErrorHandling/RiskeerApiExceptionType.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,13 @@
+namespace Application.Riskeer.API.ErrorHandling {
+ public enum RiskeerApiExceptionType
+ {
+ InvalidRiskeerFile,
+ InvalidFilePath,
+ CouldNotConnectToFile,
+ EmptyRiskeerProject,
+ FileAlreadyExists,
+ ReferenceLineNotFound,
+ NoProjectSpecified,
+ AssessmentSectionNotFound
+ }
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/ErrorHandling/RiskeerApiExceptionTypeExtensions.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/ErrorHandling/RiskeerApiExceptionTypeExtensions.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/ErrorHandling/RiskeerApiExceptionTypeExtensions.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Application.Riskeer.API.Implementation;
+
+namespace Application.Riskeer.API.ErrorHandling
+{
+ public static class RiskeerApiExceptionTypeExtensions
+ {
+ public static string GetMessage(this RiskeerApiExceptionType type)
+ {
+ switch (type)
+ {
+ case RiskeerApiExceptionType.InvalidRiskeerFile:
+ return "No valid Riskeer file";
+ default:
+ return "Unknown exception";
+ }
+ }
+ }
+}
Index: Application/Riskeer/src/Application.Riskeer.API/Implementation/AssessmentSectionApi.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Implementation/AssessmentSectionApi.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Implementation/AssessmentSectionApi.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,24 @@
+using Application.Riskeer.API.Interfaces;
+using Riskeer.Integration.Data;
+
+namespace Application.Riskeer.API.Implementation {
+ public class AssessmentSectionApi : IAssessmentSectionApi
+ {
+ internal readonly AssessmentSection AssessmentSection;
+
+ public AssessmentSectionApi(AssessmentSection assessmentSection)
+ {
+ this.AssessmentSection = assessmentSection;
+ }
+
+ public string Name
+ {
+ get => AssessmentSection.Name;
+ set
+ {
+ AssessmentSection.Name = value;
+ AssessmentSection.NotifyObservers();
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/Implementation/AssessmentSectionHandler.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Implementation/AssessmentSectionHandler.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Implementation/AssessmentSectionHandler.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,291 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Application.Riskeer.API.ErrorHandling;
+using Application.Riskeer.API.Interfaces;
+using Core.Common.Base;
+using Core.Common.Base.IO;
+using Core.Common.IO.Exceptions;
+using Core.Common.IO.Readers;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.IO.HydraRing;
+using Riskeer.Common.IO.ReferenceLines;
+using Riskeer.Common.Service;
+using Riskeer.HydraRing.IO.HydraulicBoundaryDatabase;
+using Riskeer.HydraRing.IO.HydraulicLocationConfigurationDatabase;
+using Riskeer.Integration.IO.Exporters;
+using Riskeer.Integration.Service;
+
+namespace Application.Riskeer.API.Implementation
+{
+ public class AssessmentSectionHandler : IAssessmentSectionHandler
+ {
+ public IAssessmentSectionApi FindAssessmentSection(IProjectApi project, string name)
+ {
+ var projectApi = project as ProjectApi;
+ if (projectApi == null)
+ {
+ throw new RiskeerApiException(RiskeerApiExceptionType.NoProjectSpecified);
+ }
+
+ IAssessmentSectionApi assessmentSection = projectApi.AssessmentSectionsDictionary.Values.FirstOrDefault(p => p.Name == name);
+ if (assessmentSection == null)
+ {
+ throw new RiskeerApiException(RiskeerApiExceptionType.AssessmentSectionNotFound);
+ }
+
+ return assessmentSection;
+ }
+
+ public void ImportReferenceLine(IAssessmentSectionApi assessmentSectionApi, string shapeFileLocation)
+ {
+ AssessmentSectionApi sectionApi = GetAssessmentSectionApi(assessmentSectionApi);
+
+ ReadResult readResult = ReadReferenceLine(shapeFileLocation);
+ if (readResult.CriticalErrorOccurred)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+
+ var originalReferenceLine = sectionApi.AssessmentSection.ReferenceLine;
+ if (originalReferenceLine == null)
+ {
+ throw new ArgumentNullException(nameof(originalReferenceLine));
+ }
+
+ var newReferenceLine = readResult.Items.First();
+ if (newReferenceLine == null)
+ {
+ throw new ArgumentNullException(nameof(newReferenceLine));
+ }
+
+ ClearResults results = RiskeerDataSynchronizationService.ClearReferenceLineDependentData(sectionApi.AssessmentSection);
+ originalReferenceLine.SetGeometry(newReferenceLine.Points);
+ foreach (IObservable observable in results.ChangedObjects)
+ {
+ observable.NotifyObservers();
+ }
+ }
+
+ private static AssessmentSectionApi GetAssessmentSectionApi(IAssessmentSectionApi assessmentSectionApi)
+ {
+ var sectionApi = assessmentSectionApi as AssessmentSectionApi;
+ if (sectionApi == null)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+
+ return sectionApi;
+ }
+
+ private ReadResult ReadReferenceLine(string filePath)
+ {
+ try
+ {
+ return new ReadResult(false)
+ {
+ Items = new[]
+ {
+ new ReferenceLineReader().ReadReferenceLine(filePath)
+ }
+ };
+ }
+ catch (ArgumentException e)
+ {
+ //return HandleCriticalFileReadError(e);
+ }
+ catch (CriticalFileReadException e)
+ {
+ //TODO: return HandleCriticalFileReadError(e);
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+
+
+ public void ExportReferenceLine(IAssessmentSectionApi assessmentSectionApi, string destinationFilePath)
+ {
+ AssessmentSectionApi sectionApi = GetAssessmentSectionApi(assessmentSectionApi);
+ var exporter = new ReferenceLineExporter(sectionApi.AssessmentSection.ReferenceLine,sectionApi.AssessmentSection.Id,destinationFilePath);
+ exporter.Export();
+ }
+
+ public void CoupleToHydraulicDatabase(IAssessmentSectionApi assessmentSectionApi, string databaseFileLocation)
+ {
+ var readHydraulicBoundaryDatabaseResult = ReadHydraulicBoundaryDatabaseFile(databaseFileLocation);
+ if (readHydraulicBoundaryDatabaseResult.CriticalErrorOccurred)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+
+ ReadHydraulicBoundaryDatabase readHydraulicBoundaryDatabase = readHydraulicBoundaryDatabaseResult.Items.Single();
+
+ string hlcdFilePath = Path.Combine(Path.GetDirectoryName(databaseFileLocation), "hlcd.sqlite");
+
+ ReadResult readHydraulicLocationConfigurationDatabaseResult = ReadHydraulicLocationConfigurationDatabase(
+ hlcdFilePath, readHydraulicBoundaryDatabase.TrackId);
+
+ if (readHydraulicLocationConfigurationDatabaseResult.CriticalErrorOccurred)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+
+ ReadHydraulicLocationConfigurationDatabase readHydraulicLocationConfigurationDatabase = readHydraulicLocationConfigurationDatabaseResult.Items.Single();
+ IEnumerable hydraulicLocationConfigurationDatabaseSettings =
+ readHydraulicLocationConfigurationDatabase.ReadHydraulicLocationConfigurationDatabaseSettings;
+ if (hydraulicLocationConfigurationDatabaseSettings != null && hydraulicLocationConfigurationDatabaseSettings.Count() != 1)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+
+ if (readHydraulicLocationConfigurationDatabase.UsePreprocessorClosure
+ && !File.Exists(HydraulicBoundaryDatabaseHelper.GetPreprocessorClosureFilePath(hlcdFilePath)))
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+
+ ReadResult> readExcludedLocationsResult = ReadExcludedLocations(databaseFileLocation);
+
+ if (readExcludedLocationsResult.CriticalErrorOccurred)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+
+ //HydraulicBoundaryDatabaseImporter.AddHydraulicBoundaryDatabaseToDataModel
+ throw new NotImplementedException();
+ }
+
+ private void AddHydraulicBoundaryDatabaseToDataModel(ReadHydraulicBoundaryDatabase readHydraulicBoundaryDatabase,
+ ReadHydraulicLocationConfigurationDatabase readHydraulicLocationConfigurationDatabase,
+ IEnumerable excludedLocationIds)
+ {
+ changedObservables.AddRange(updateHandler.Update(ImportTarget, readHydraulicBoundaryDatabase, readHydraulicLocationConfigurationDatabase,
+ excludedLocationIds, FilePath, GetHlcdFilePath()));
+ }
+
+ private ReadResult> ReadExcludedLocations(string filePath)
+ {
+ string settingsFilePath = HydraulicBoundaryDatabaseHelper.GetHydraulicBoundarySettingsDatabase(filePath);
+ try
+ {
+ using (var reader = new HydraRingSettingsDatabaseReader(settingsFilePath))
+ {
+ return ReadExcludedLocations(reader);
+ }
+ }
+ catch (CriticalFileReadException e)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+ }
+
+ private ReadResult> ReadExcludedLocations(HydraRingSettingsDatabaseReader reader)
+ {
+ try
+ {
+ return new ReadResult>(false)
+ {
+ Items = new[]
+ {
+ reader.ReadExcludedLocations().ToArray()
+ }
+ };
+ }
+ catch (CriticalFileReadException e)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+ }
+
+ private ReadResult ReadHydraulicLocationConfigurationDatabase(string hlcdFilePath, long trackId)
+ {
+ try
+ {
+ using (var reader = new HydraulicLocationConfigurationDatabaseReader(hlcdFilePath))
+ {
+ return ReadHydraulicLocationConfigurationDatabase(trackId, reader);
+ }
+ }
+ catch (CriticalFileReadException)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+ }
+
+ private ReadResult ReadHydraulicLocationConfigurationDatabase(long trackId, HydraulicLocationConfigurationDatabaseReader reader)
+ {
+ try
+ {
+ return new ReadResult(false)
+ {
+ Items = new[]
+ {
+ reader.Read(trackId)
+ }
+ };
+ }
+ catch (Exception e) when (e is CriticalFileReadException || e is LineParseException)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+ }
+
+ private static ReadResult ReadHydraulicBoundaryDatabaseFile(string databaseFileLocation)
+ {
+ try
+ {
+ using (var reader = new HydraulicBoundaryDatabaseReader(databaseFileLocation))
+ {
+ return new ReadResult(false)
+ {
+ Items = new[]
+ {
+ reader.Read()
+ }
+ };
+ }
+ }
+ catch (Exception e) when (e is CriticalFileReadException || e is LineParseException)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ //return HandleCriticalFileReadError(e);
+ }
+ }
+
+ public void ExportAssemblyResults(IAssessmentSectionApi assessmentSectionApi, string filePath)
+ {
+ var section = (assessmentSectionApi as AssessmentSectionApi)?.AssessmentSection;
+ if (section == null)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+ var exporter = new AssemblyExporter(section,filePath);
+ }
+
+ public void ExportHydraulicBoundaryConditions(IAssessmentSectionApi assessmentSectionApi, string filePath)
+ {
+ var section = (assessmentSectionApi as AssessmentSectionApi)?.AssessmentSection;
+ if (section == null)
+ {
+ // TODO:
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile);
+ }
+ var exporter = new HydraulicBoundaryLocationsExporter(section,filePath);
+ exporter.Export();
+ }
+ }
+}
Index: Application/Riskeer/src/Application.Riskeer.API/Implementation/AssessmentSectionHelper.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Implementation/AssessmentSectionHelper.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Implementation/AssessmentSectionHelper.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,78 @@
+using System.Linq;
+using Core.Common.Base.Data;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Contribution;
+using Riskeer.Common.IO;
+using Riskeer.Integration.Data;
+
+namespace Application.Riskeer.API.Implementation
+{
+ internal static class AssessmentSectionHelper {
+
+ internal static AssessmentSection CreateAssessmentSection(ReferenceLineMeta meta,
+ double lowerLimitNorm,
+ double signalingNorm,
+ NormType normativeNorm)
+ {
+ AssessmentSection assessmentSection;
+ var reader = new AssessmentSectionSettingsReader();
+ var settings = reader.ReadSettings();
+ AssessmentSectionSettings settingOfSelectedAssessmentSection = settings.FirstOrDefault(s => s.AssessmentSectionId == meta.AssessmentSectionId);
+ if (settingOfSelectedAssessmentSection == null)
+ {
+ //log.Warn(Resources.AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_No_settings_found_for_AssessmentSection);
+ assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike, lowerLimitNorm, signalingNorm);
+ }
+ else
+ {
+ assessmentSection = settingOfSelectedAssessmentSection.IsDune
+ ? CreateDuneAssessmentSection(lowerLimitNorm,
+ signalingNorm,
+ settingOfSelectedAssessmentSection.N)
+ : CreateDikeAssessmentSection(lowerLimitNorm,
+ signalingNorm,
+ settingOfSelectedAssessmentSection.N);
+ }
+
+ assessmentSection.Name = string.Format(global::Riskeer.Integration.Data.Properties.Resources.AssessmentSection_Id_0, meta.AssessmentSectionId);
+ assessmentSection.Id = meta.AssessmentSectionId;
+
+ if (!meta.ReferenceLine.Points.Any())
+ {
+ //log.Warn(Resources.AssessmentSectionFromFileCommandHandler_CreateAssessmentSection_Importing_ReferenceLineFailed);
+ }
+ else
+ {
+ assessmentSection.ReferenceLine.SetGeometry(meta.ReferenceLine.Points);
+ }
+
+ assessmentSection.FailureMechanismContribution.NormativeNorm = normativeNorm;
+
+ return assessmentSection;
+ }
+
+ private static AssessmentSection CreateDikeAssessmentSection(double lowerLimitNorm, double signalingNorm, int n)
+ {
+ AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike, lowerLimitNorm, signalingNorm);
+ SetFailureMechanismsValueN(assessmentSection, n);
+ return assessmentSection;
+ }
+
+ private static AssessmentSection CreateDuneAssessmentSection(double lowerLimitNorm, double signalingNorm, int n)
+ {
+ var duneAssessmentSection = new AssessmentSection(AssessmentSectionComposition.Dune,
+ lowerLimitNorm,
+ signalingNorm);
+ SetFailureMechanismsValueN(duneAssessmentSection, n);
+ return duneAssessmentSection;
+ }
+
+ private static void SetFailureMechanismsValueN(AssessmentSection assessmentSection, int n)
+ {
+ var roundedN = (RoundedDouble)n;
+ assessmentSection.GrassCoverErosionInwards.GeneralInput.N = roundedN;
+ assessmentSection.GrassCoverErosionOutwards.GeneralInput.N = roundedN;
+ assessmentSection.HeightStructures.GeneralInput.N = roundedN;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/Implementation/ProjectApi.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Implementation/ProjectApi.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Implementation/ProjectApi.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using Application.Riskeer.API.Interfaces;
+using Core.Common.Base.Data;
+using Riskeer.Integration.Data;
+
+namespace Application.Riskeer.API.Implementation {
+ public class ProjectApi : IProjectApi
+ {
+ internal readonly RiskeerProject RiskeerProject;
+ internal readonly Dictionary AssessmentSectionsDictionary = new Dictionary();
+
+ public ProjectApi(RiskeerProject openedProject)
+ {
+ RiskeerProject = openedProject;
+ foreach (var assessmentSection in RiskeerProject.AssessmentSections)
+ {
+ AssessmentSectionsDictionary[assessmentSection] = new AssessmentSectionApi(assessmentSection);
+ }
+ }
+
+ }
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/Implementation/ProjectHandler.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Implementation/ProjectHandler.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Implementation/ProjectHandler.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,110 @@
+using Application.Riskeer.API.Interfaces;
+using System;
+using System.IO;
+using System.Linq;
+using Application.Riskeer.API.ErrorHandling;
+using Core.Common.Base.Storage;
+using Riskeer.Common.Data.Contribution;
+using Riskeer.Common.IO.ReferenceLines;
+using Riskeer.Integration.Data;
+using Riskeer.Integration.Forms;
+using Riskeer.Storage.Core;
+
+namespace Application.Riskeer.API.Implementation
+{
+ public class ProjectHandler : IProjectHandler
+ {
+ private readonly IStoreProject storage;
+
+ public ProjectHandler()
+ {
+ storage = new StorageSqLite();
+ }
+
+ public ProjectApi OpenProject(string fileLocation)
+ {
+ // TODO: Check file location
+ // TODO: Check version and migration etc.
+ try
+ {
+ return new ProjectApi(storage.LoadProject(fileLocation) as RiskeerProject);
+ }
+ catch (ArgumentException e)
+ {
+ throw new RiskeerApiException(RiskeerApiExceptionType.InvalidFilePath, e);
+ }
+ catch (CouldNotConnectException e)
+ {
+ throw new RiskeerApiException(RiskeerApiExceptionType.CouldNotConnectToFile, e);
+ }
+ catch (StorageValidationException e)
+ {
+ // bij uitlezen connectie, validatie Riskeer versie gegeven bestand
+ throw new RiskeerApiException(RiskeerApiExceptionType.InvalidRiskeerFile, e);
+ }
+ catch (StorageException e)
+ {
+ throw new RiskeerApiException(RiskeerApiExceptionType.InvalidRiskeerFile, e);
+ }
+ catch
+ {
+ throw new RiskeerApiException(RiskeerApiExceptionType.InvalidRiskeerFile);
+ }
+ }
+
+ public void SaveProject(ProjectApi project, string filePath, bool overwrite = false)
+ {
+ var riskeerProject = project?.RiskeerProject;
+ if (riskeerProject == null)
+ {
+ throw new RiskeerApiException(RiskeerApiExceptionType.EmptyRiskeerProject);
+ }
+
+ // TODO: Check destination location for right extension etc.
+
+ if (File.Exists(filePath) && !overwrite)
+ {
+ throw new RiskeerApiException(RiskeerApiExceptionType.FileAlreadyExists);
+ }
+
+ storage.StageProject(riskeerProject);
+ try
+ {
+ storage.SaveProjectAs(filePath);
+ }
+ catch (InvalidOperationException e)
+ {
+ // Staging failed
+ }
+ catch (StorageException e)
+ {
+ // Invalid file or error writing file
+ }
+ }
+
+ public IAssessmentSectionApi AddAssessmentSection(ProjectApi project, string sectionId, bool useLowerBoundaryNorm)
+ {
+ // TODO: This introduces a reference to a Forms project. This is not necessary if RiskeerSettingsHelper is placed in another (data?) project
+ var referenceLineMetas = new ReferenceLineMetaImporter(RiskeerSettingsHelper.GetCommonDocumentsRiskeerShapeFileDirectory())
+ .GetReferenceLineMetas();
+
+ var meta = referenceLineMetas.FirstOrDefault(r => r.AssessmentSectionId == sectionId);
+ if (meta == null)
+ {
+ throw new RiskeerApiException(RiskeerApiExceptionType.ReferenceLineNotFound);
+ }
+
+ double metaLowerLimitValue = 1.0/meta.LowerLimitValue;
+ double metaSignalingValue = 1.0 / meta.SignalingValue ?? metaLowerLimitValue;
+
+ AssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSection(meta,
+ metaLowerLimitValue,
+ metaSignalingValue,
+ useLowerBoundaryNorm ? NormType.LowerLimit : NormType.Signaling);
+ project.RiskeerProject.AssessmentSections.Add(assessmentSection);
+ project.RiskeerProject.NotifyObservers();
+
+ return new AssessmentSectionApi(assessmentSection);
+ }
+ }
+}
Index: Application/Riskeer/src/Application.Riskeer.API/Interfaces/IAssessmentSectionApi.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Interfaces/IAssessmentSectionApi.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Interfaces/IAssessmentSectionApi.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,5 @@
+namespace Application.Riskeer.API.Interfaces {
+ public interface IAssessmentSectionApi {
+ string Name { get; set; }
+ }
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/Interfaces/IAssessmentSectionHandler.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Interfaces/IAssessmentSectionHandler.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Interfaces/IAssessmentSectionHandler.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,16 @@
+namespace Application.Riskeer.API.Interfaces {
+ public interface IAssessmentSectionHandler
+ {
+ IAssessmentSectionApi FindAssessmentSection(IProjectApi project, string name);
+
+ void ImportReferenceLine(IAssessmentSectionApi assessmentSectionApi, string shapeFileLocation);
+
+ void ExportReferenceLine(IAssessmentSectionApi assessmentSectionApi, string destinationFilePath);
+
+ void CoupleToHydraulicDatabase(IAssessmentSectionApi assessmentSectionApi, string databaseFileLocation);
+
+ void ExportAssemblyResults(IAssessmentSectionApi assessmentSectionApi, string filePath);
+
+ void ExportHydraulicBoundaryConditions(IAssessmentSectionApi assessmentSectionApi, string filePath);
+ }
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/Interfaces/ICalculationApi.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Interfaces/ICalculationApi.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Interfaces/ICalculationApi.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,3 @@
+namespace Application.Riskeer.API.Interfaces {
+ public interface ICalculationApi {}
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/Interfaces/ICalculationHandler.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Interfaces/ICalculationHandler.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Interfaces/ICalculationHandler.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,11 @@
+namespace Application.Riskeer.API.Interfaces
+{
+ public interface ICalculationHandler where TCalculation : ICalculationApi
+ {
+ TCalculation FindCalculation(IFailureMechanismApi failureMechanismApi, string calculationTitle);
+
+ bool PerformCalculation(TCalculation calculation);
+
+ bool ClearOutput(TCalculation calculation);
+ }
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/Interfaces/IFailureMechanismApi.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Interfaces/IFailureMechanismApi.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Interfaces/IFailureMechanismApi.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,3 @@
+namespace Application.Riskeer.API.Interfaces {
+ public interface IFailureMechanismApi {}
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/Interfaces/IFailureMechanismHandler.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Interfaces/IFailureMechanismHandler.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Interfaces/IFailureMechanismHandler.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Application.Riskeer.API.Interfaces
+{
+ public interface IFailureMechanismHandler where TMechanism : IFailureMechanismApi
+ {
+ TMechanism FindFailureMechanism(IProjectApi projectApi);
+
+ bool ImportAssessmentSections(TMechanism mechanism);
+ }
+}
Index: Application/Riskeer/src/Application.Riskeer.API/Interfaces/IProjectApi.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Interfaces/IProjectApi.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Interfaces/IProjectApi.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,3 @@
+namespace Application.Riskeer.API.Interfaces {
+ public interface IProjectApi {}
+}
\ No newline at end of file
Index: Application/Riskeer/src/Application.Riskeer.API/Interfaces/IProjectHandler.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Interfaces/IProjectHandler.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Interfaces/IProjectHandler.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,14 @@
+using Application.Riskeer.API.Implementation;
+
+namespace Application.Riskeer.API.Interfaces
+{
+ public interface IProjectHandler
+ {
+ ProjectApi OpenProject(string fileLocation);
+
+ void SaveProject(ProjectApi project, string filePath, bool overwrite = false);
+
+ // Lateron
+ IAssessmentSectionApi AddAssessmentSection(ProjectApi project, string sectionId, bool useLowerBoundaryNorm);
+ }
+}
Index: Application/Riskeer/src/Application.Riskeer.API/Properties/AssemblyInfo.cs
===================================================================
diff -u
--- Application/Riskeer/src/Application.Riskeer.API/Properties/AssemblyInfo.cs (revision 0)
+++ Application/Riskeer/src/Application.Riskeer.API/Properties/AssemblyInfo.cs (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Application.Riskeer.API")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Application.Riskeer.API")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("35b774c4-c690-4547-ac43-6d7c0c4bf5fd")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Index: Riskeer.sln
===================================================================
diff -u -rcede2ff3709ca6a522ec5744dcf49a0cbb3f660c -r65d01cee2747c87c84fac01b3a25574c06485559
--- Riskeer.sln (.../Riskeer.sln) (revision cede2ff3709ca6a522ec5744dcf49a0cbb3f660c)
+++ Riskeer.sln (.../Riskeer.sln) (revision 65d01cee2747c87c84fac01b3a25574c06485559)
@@ -1726,6 +1726,11 @@
{C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC}
EndProjectSection
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application.Riskeer.API", "Application\Riskeer\src\Application.Riskeer.API\Application.Riskeer.API.csproj", "{35B774C4-C690-4547-AC43-6D7C0C4BF5FD}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C90B77DA-E421-43CC-B82E-529651BC21AC} = {C90B77DA-E421-43CC-B82E-529651BC21AC}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
@@ -3506,6 +3511,12 @@
{073EE964-974D-442E-801F-F4FCD6D303F5}.Release|x86.Build.0 = Release|x86
{073EE964-974D-442E-801F-F4FCD6D303F5}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86
{073EE964-974D-442E-801F-F4FCD6D303F5}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86
+ {35B774C4-C690-4547-AC43-6D7C0C4BF5FD}.Debug|x86.ActiveCfg = Debug|x86
+ {35B774C4-C690-4547-AC43-6D7C0C4BF5FD}.Debug|x86.Build.0 = Debug|x86
+ {35B774C4-C690-4547-AC43-6D7C0C4BF5FD}.Release|x86.ActiveCfg = Release|x86
+ {35B774C4-C690-4547-AC43-6D7C0C4BF5FD}.Release|x86.Build.0 = Release|x86
+ {35B774C4-C690-4547-AC43-6D7C0C4BF5FD}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86
+ {35B774C4-C690-4547-AC43-6D7C0C4BF5FD}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -3879,6 +3890,7 @@
{FE63A65E-C5AF-456D-A786-912F9B7E26A1} = {8BE49C65-DD09-4890-82B1-5216BF13E757}
{D0C7032E-5730-46D1-A06F-7C4F06BA590A} = {F73AF5D7-DDD9-4A48-A171-037817B59056}
{073EE964-974D-442E-801F-F4FCD6D303F5} = {F73AF5D7-DDD9-4A48-A171-037817B59056}
+ {35B774C4-C690-4547-AC43-6D7C0C4BF5FD} = {39EB5D07-C076-484C-9621-B34C4E5BF64C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {039D31AA-B517-4354-B8CD-0B2B826D0B1F}