From 58b6e0eb8b205f29e8dc4b47a3f6a325fde66573 Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Sat, 28 Sep 2024 20:46:42 +0500 Subject: [PATCH] Add cross-section convert strategies --- DataAccess/DTOs/ConcreteLibMaterialDTO.cs | 59 +++++++++++++++ .../AnalysisToDTOConvertStrategy.cs | 66 +++++++++++++++++ ...ConcreteLibMaterialToDTOConvertStrategy.cs | 33 +++++++++ ...sSectionNdmAnalysisToDTOConvertStrategy.cs | 64 ++++++++++++++++ ...ssSectionRepositoryToDTOConvertStrategy.cs | 73 +++++++++++++++++++ .../CrossSectionToDTOConvertStrategy.cs | 61 ++++++++++++++++ .../DateVersionToDTOConvertStrategy.cs | 65 +++++++++++++++++ .../HeadMaterialToDTOConvertStrategy.cs | 37 ++++++++++ .../HelperMaterialToDTOConvertStrategy.cs | 31 ++++++++ .../Converters/ProjectToDTOConvertStrategy.cs | 22 +++++- .../VersionItemToDTOConvertStrategy.cs | 63 ++++++++++++++++ .../VersionProcessorToDTOConvertStrategy.cs | 48 ++++++++++++ .../VisualAnalysisToDTOConvertStrategy.cs | 35 ++++++++- DataAccess/DTOs/CrossSectionDTO.cs | 9 ++- DataAccess/DTOs/CrossSectionNdmAnalysisDTO.cs | 28 +++++++ DataAccess/DTOs/CrossSectionRepositoryDTO.cs | 29 ++++++++ DataAccess/DTOs/DateVersionDTO.cs | 22 ++++++ DataAccess/DTOs/HeadMaterialDTO.cs | 44 +++++++++++ DataAccess/DTOs/ProjectDTO.cs | 11 --- DataAccess/DTOs/TypeBinder.cs | 42 +++++++++++ DataAccess/DTOs/TypeBinderListFactory.cs | 60 +++++++++++++++ DataAccess/DTOs/VersionProcessorDTO.cs | 30 ++++++++ DataAccess/DataAccess.csproj | 6 ++ DataAccess/Infrastructures/FileSaveLogic.cs | 44 +++++++---- .../Services/Settings/GlobalRepository.cs | 2 +- .../MainWindow/Analyses/VisualAnalysis.cs | 8 +- .../MainWindow/CrossSectionViewModel.cs | 22 +++--- .../ViewModels/Forces/ActionsViewModel.cs | 2 +- .../Materials/MaterialsViewModel.cs | 2 +- .../AnalysisViewModelLogic.cs | 2 +- .../PrimitiveViewModelLogic.cs | 2 +- .../Interfaces/CheckConvertLogic.cs | 46 ++++++++++++ .../Interfaces/DictionaryConvertStrategy.cs | 1 + .../Models/Analyses/DateVersion.cs | 12 ++- .../Models/Analyses/IDateVersion.cs | 4 +- .../Models/Analyses/VersionProcessor.cs | 4 +- .../Models/Calculators/IHasCalculators.cs | 13 ++++ .../Models/Loggers/LoggerStrings.cs | 2 +- .../Sections/Logics/RcAccEccentricityLogic.cs | 2 +- .../Logics/RcEccentricityAxisLogic.cs | 2 +- .../Sections/Logics/RcEccentricityLogic.cs | 2 +- .../Analyses/CrossSectionNdmAnalysis.cs | 2 +- .../CrossSectionNdmAnalysisUpdateStrategy.cs | 12 +-- .../Analyses/ICrossSectionNdmAnalysis.cs | 8 ++ .../Models/CrossSections/CrossSection.cs | 11 ++- .../CrossSections/CrossSectionRepository.cs | 20 ++--- .../CrossSectionUpdateStrategy.cs | 18 ++++- .../CrossSections/ICrossSectionRepository.cs | 15 +--- .../Models/Materials/ConcreteLibMaterial.cs | 13 +++- .../Models/Materials/ElasticMaterial.cs | 13 +++- .../Materials/FRMaterials/FRMaterial.cs | 41 ++++++----- .../Models/Materials/HeadMaterial.cs | 5 +- .../Models/Materials/IHeadMaterial.cs | 5 -- .../Models/Materials/IHelperMaterial.cs | 3 +- .../Models/Materials/LibMaterial.cs | 2 + ...ategy.cs => HeadMaterialUpdateStrategy.cs} | 9 ++- .../Materials/ReinforcementLibMaterial.cs | 15 +++- .../CrossSections/RCs/SectionTemplate.cs | 2 +- .../Analyses/ByForces/ForceCalculator.cs | 2 +- .../Analyses/ByForces/ForceCalculatorLogic.cs | 2 +- .../Buckling/ConcreteBucklingCalculator.cs | 2 +- .../Buckling/DeltaELogicSP63.cs | 2 +- .../Buckling/EilerCriticalForceLogic.cs | 2 +- .../Buckling/ForceTupleBucklingLogic.cs | 2 +- .../NdmCalculations/Buckling/PhiLogicSP63.cs | 2 +- .../Buckling/ProcessEccentricity.cs | 2 +- .../CheckCrackCalculatorInputDataLogic.cs | 2 +- .../Cracking/CrackCalculator.cs | 2 +- .../Cracking/CrackWidthCalculationLogic.cs | 2 +- .../Cracking/CrackWidthLogicSP63.cs | 2 +- .../CrackedSectionTriangulationLogic.cs | 8 +- .../Cracking/EquivalentDiameterLogic.cs | 2 +- .../Cracking/GetTupleInputDatasLogic.cs | 2 +- .../Cracking/LengthBetweenCracksLogicSP63.cs | 2 +- .../Cracking/RebarCrackCalculator.cs | 2 +- .../SofteningLogics/ExpSofteningLogic.cs | 2 +- .../RebarStressSofteningLogic.cs | 2 +- .../Cracking/TensileConcreteAreaLogicSP63.cs | 2 +- .../Cracking/TensionRebarAreaByStrainLogic.cs | 2 +- .../TensionRebarAreaSimpleSumLogic.cs | 2 +- .../Cracking/TupleCrackCalculator.cs | 2 +- .../CheckPrimitivesForMeshingLogic.cs | 2 +- .../NdmPrimitives/MeshCrackedConcreteLogic.cs | 2 +- .../NdmPrimitives/MeshElasticLogic.cs | 2 +- .../NdmPrimitives/MeshHasDivisionLogic.cs | 2 +- .../NdmPrimitives/MeshPrimitiveLogic.cs | 2 +- .../TriangulatePrimitiveLogic.cs | 2 +- .../StructureHelperLogics.csproj | 4 + .../ForceCalculatorTests/RCSectionsTest.cs | 6 +- 89 files changed, 1204 insertions(+), 174 deletions(-) create mode 100644 DataAccess/DTOs/ConcreteLibMaterialDTO.cs create mode 100644 DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/ConcreteLibMaterialToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/CrossSectionNdmAnalysisToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/DateVersionToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/HeadMaterialToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/VersionItemToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs create mode 100644 DataAccess/DTOs/CrossSectionNdmAnalysisDTO.cs create mode 100644 DataAccess/DTOs/CrossSectionRepositoryDTO.cs create mode 100644 DataAccess/DTOs/DateVersionDTO.cs create mode 100644 DataAccess/DTOs/HeadMaterialDTO.cs create mode 100644 DataAccess/DTOs/TypeBinder.cs create mode 100644 DataAccess/DTOs/TypeBinderListFactory.cs create mode 100644 DataAccess/DTOs/VersionProcessorDTO.cs create mode 100644 StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs create mode 100644 StructureHelperCommon/Models/Calculators/IHasCalculators.cs create mode 100644 StructureHelperLogics/Models/Analyses/ICrossSectionNdmAnalysis.cs rename StructureHelperLogics/Models/Materials/Logics/{MaterialUpdateStrategy.cs => HeadMaterialUpdateStrategy.cs} (91%) diff --git a/DataAccess/DTOs/ConcreteLibMaterialDTO.cs b/DataAccess/DTOs/ConcreteLibMaterialDTO.cs new file mode 100644 index 0000000..9149740 --- /dev/null +++ b/DataAccess/DTOs/ConcreteLibMaterialDTO.cs @@ -0,0 +1,59 @@ +using LoaderCalculator.Data.Materials; +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models.Materials; +using StructureHelperCommon.Models.Materials.Libraries; +using StructureHelperLogics.Models.Materials; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class ConcreteLibMaterialDTO : IConcreteLibMaterial + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("RelativeHumidity")] + public double RelativeHumidity { get; set; } + [JsonProperty("MinAge")] + public double MinAge { get; set; } + [JsonProperty("MaxAge")] + public double MaxAge { get; set; } + [JsonProperty("MaterialEntity")] + public ILibMaterialEntity MaterialEntity { get; set; } + [JsonProperty("SafetyFactors")] + public List SafetyFactors { get; set; } + [JsonProperty("TensionForULS")] + public bool TensionForULS { get; set; } + [JsonProperty("TensionForSLS")] + public bool TensionForSLS { get; set; } + + + public IMaterialLogic MaterialLogic { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + + public List MaterialLogics => throw new NotImplementedException(); + + public object Clone() + { + throw new NotImplementedException(); + } + + public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) + { + throw new NotImplementedException(); + } + + public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) + { + throw new NotImplementedException(); + } + + public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm) + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs new file mode 100644 index 0000000..266aefc --- /dev/null +++ b/DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs @@ -0,0 +1,66 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Analyses; +using StructureHelperLogic.Models.Analyses; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip; + +namespace DataAccess.DTOs.Converters +{ + public class AnalysisToDTOConvertStrategy : IConvertStrategy + { + private const string Message = "Analysis type is"; + private IConvertStrategy convertCrossSectionNdmAnalysisStrategy = new CrossSectionNdmAnalysisToDTOConvertStrategy(); + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public IAnalysis Convert(IAnalysis source) + { + Check(); + IAnalysis analysis; + if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis) + { + analysis = GetCrossSectionNdmAnalysisDTO(crossSectionNdmAnalysis); + } + else + { + string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source); + TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); + throw new StructureHelperException(errorString); + } + foreach (var item in source.VersionProcessor.Versions) + { + + } + return analysis; + } + + private CrossSectionNdmAnalysisDTO GetCrossSectionNdmAnalysisDTO(ICrossSectionNdmAnalysis crossSectionNdmAnalysis) + { + TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug); + convertCrossSectionNdmAnalysisStrategy.ReferenceDictionary = ReferenceDictionary; + convertCrossSectionNdmAnalysisStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy() + { + ReferenceDictionary = ReferenceDictionary, + ConvertStrategy = convertCrossSectionNdmAnalysisStrategy, + TraceLogger = TraceLogger + }; + CrossSectionNdmAnalysisDTO crossSectionNdmAnalysisDTO = convertLogic.Convert(crossSectionNdmAnalysis); + return crossSectionNdmAnalysisDTO; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/ConcreteLibMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ConcreteLibMaterialToDTOConvertStrategy.cs new file mode 100644 index 0000000..65692b0 --- /dev/null +++ b/DataAccess/DTOs/Converters/ConcreteLibMaterialToDTOConvertStrategy.cs @@ -0,0 +1,33 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperLogics.Models.CrossSections; +using StructureHelperLogics.Models.Materials; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + public class ConcreteLibMaterialToDTOConvertStrategy : IConvertStrategy + { + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public ConcreteLibMaterialDTO Convert(IConcreteLibMaterial source) + { + Check(); + + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + + } +} diff --git a/DataAccess/DTOs/Converters/CrossSectionNdmAnalysisToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionNdmAnalysisToDTOConvertStrategy.cs new file mode 100644 index 0000000..f7be3a2 --- /dev/null +++ b/DataAccess/DTOs/Converters/CrossSectionNdmAnalysisToDTOConvertStrategy.cs @@ -0,0 +1,64 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Analyses; +using StructureHelperLogic.Models.Analyses; +using StructureHelperLogics.Models.Analyses; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + internal class CrossSectionNdmAnalysisToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy convertStrategy; + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public CrossSectionNdmAnalysisToDTOConvertStrategy( + IUpdateStrategy updateStrategy, + IConvertStrategy convertStrategy, + IShiftTraceLogger traceLogger) + { + this.updateStrategy = updateStrategy; + this.convertStrategy = convertStrategy; + this.TraceLogger = traceLogger; + } + + public CrossSectionNdmAnalysisToDTOConvertStrategy() : this(new CrossSectionNdmAnalysisUpdateStrategy(), + new VersionProcessorToDTOConvertStrategy(), + null) + { + + } + + public CrossSectionNdmAnalysisDTO Convert(ICrossSectionNdmAnalysis source) + { + Check(); + CrossSectionNdmAnalysisDTO newItem = new(); + newItem.Id = source.Id; + updateStrategy.Update(newItem, source); + convertStrategy.ReferenceDictionary = ReferenceDictionary; + convertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy() + { + ReferenceDictionary = ReferenceDictionary, + ConvertStrategy = convertStrategy, + TraceLogger = TraceLogger + }; + newItem.VersionProcessor = convertLogic.Convert(source.VersionProcessor); + return newItem; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs new file mode 100644 index 0000000..569f0c4 --- /dev/null +++ b/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs @@ -0,0 +1,73 @@ +using DataAccess.DTOs.Converters; +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Analyses; +using StructureHelperLogics.Models.CrossSections; +using StructureHelperLogics.Models.Materials; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class CrossSectionRepositoryToDTOConvertStrategy : IConvertStrategy + { + private IConvertStrategy materialConvertStrategy; + + public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy materialConvertStrategy) + { + this.materialConvertStrategy = materialConvertStrategy; + } + + public CrossSectionRepositoryToDTOConvertStrategy() : this( + new HeadMaterialToDTOConvertStrategy()) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public CrossSectionRepositoryDTO Convert(ICrossSectionRepository source) + { + Check(); + CrossSectionRepositoryDTO newItem = new() + { + Id = source.Id + }; + List materials = ProcessMaterials(source); + newItem.HeadMaterials.AddRange(materials); + return newItem; + } + + private List ProcessMaterials(ICrossSectionRepository source) + { + materialConvertStrategy.ReferenceDictionary = ReferenceDictionary; + materialConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy() + { + ReferenceDictionary = ReferenceDictionary, + ConvertStrategy = materialConvertStrategy, + TraceLogger = TraceLogger + }; + List materials = new(); + foreach (var item in source.HeadMaterials) + { + materials.Add(convertLogic.Convert(item)); + } + + return materials; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs new file mode 100644 index 0000000..e787a41 --- /dev/null +++ b/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs @@ -0,0 +1,61 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Analyses; +using StructureHelperLogics.Models.CrossSections; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + public class CrossSectionToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy convertStrategy; + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public CrossSectionToDTOConvertStrategy(IUpdateStrategy updateStrategy, + IConvertStrategy convertStrategy) + { + this.updateStrategy = updateStrategy; + this.convertStrategy = convertStrategy; + } + + public CrossSectionToDTOConvertStrategy() : this( + new CrossSectionUpdateStrategy(), + new CrossSectionRepositoryToDTOConvertStrategy()) + { + + } + + public CrossSectionDTO Convert(ICrossSection source) + { + Check(); + CrossSectionDTO newItem = new() + { + Id = source.Id + }; + convertStrategy.ReferenceDictionary = ReferenceDictionary; + convertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy() + { + ReferenceDictionary = ReferenceDictionary, + ConvertStrategy = convertStrategy, + TraceLogger = TraceLogger + }; + newItem.SectionRepository = convertLogic.Convert(source.SectionRepository); + return newItem; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/DateVersionToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/DateVersionToDTOConvertStrategy.cs new file mode 100644 index 0000000..7d03678 --- /dev/null +++ b/DataAccess/DTOs/Converters/DateVersionToDTOConvertStrategy.cs @@ -0,0 +1,65 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Analyses; +using StructureHelperLogic.Models.Analyses; +using StructureHelperLogics.Models.CrossSections; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + public class DateVersionToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy convertStrategy; + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public DateVersionToDTOConvertStrategy( + IUpdateStrategy updateStrategy, + IConvertStrategy convertStrategy) + { + this.updateStrategy = updateStrategy; + this.convertStrategy = convertStrategy; + } + + public DateVersionToDTOConvertStrategy() : this ( + new DateVersionUpdateStrategy(), + new VersionItemToDTOConvertStrategy()) + { + + } + + public DateVersionDTO Convert(IDateVersion source) + { + Check(); + DateVersionDTO newItem = new() + { + Id = source.Id + }; + updateStrategy.Update(newItem, source); + convertStrategy.ReferenceDictionary = ReferenceDictionary; + convertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy() + { + ReferenceDictionary = ReferenceDictionary, + ConvertStrategy = convertStrategy, + TraceLogger = TraceLogger + }; + newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion); + return newItem; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/HeadMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/HeadMaterialToDTOConvertStrategy.cs new file mode 100644 index 0000000..50af73a --- /dev/null +++ b/DataAccess/DTOs/Converters/HeadMaterialToDTOConvertStrategy.cs @@ -0,0 +1,37 @@ +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperLogics.Models.Materials; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + public class HeadMaterialToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + + public HeadMaterialToDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public HeadMaterialToDTOConvertStrategy() : this (new HeadMaterialUpdateStrategy()) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public HeadMaterialDTO Convert(IHeadMaterial source) + { + HeadMaterialDTO newItem = new() { Id = source.Id}; + updateStrategy.Update(newItem, source); + return newItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs new file mode 100644 index 0000000..5e93b93 --- /dev/null +++ b/DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs @@ -0,0 +1,31 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperLogics.Models.CrossSections; +using StructureHelperLogics.Models.Materials; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy + { + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public IHelperMaterial Convert(IHelperMaterial source) + { + Check(); + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs index b95294b..0e9b2c3 100644 --- a/DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs @@ -31,21 +31,35 @@ namespace DataAccess.DTOs public ProjectDTO Convert(IProject source) { - ProjectDTO projectDTO = new(source.Id); - updateStrategy.Update(projectDTO, source); + Check(); + ProjectDTO newItem = new() + { + Id = source.Id + }; + updateStrategy.Update(newItem, source); convertStrategy.ReferenceDictionary = ReferenceDictionary; + convertStrategy.TraceLogger = TraceLogger; var convertLogic = new DictionaryConvertStrategy() { ReferenceDictionary = ReferenceDictionary, ConvertStrategy = convertStrategy, TraceLogger = TraceLogger }; + newItem.VisualAnalyses.Clear(); foreach (var item in source.VisualAnalyses) { var newVisualAnalysis = convertLogic.Convert(item); - projectDTO.VisualAnalyses.Add(newVisualAnalysis); + newItem.VisualAnalyses.Add(newVisualAnalysis); } - return projectDTO; + return newItem; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); } } } diff --git a/DataAccess/DTOs/Converters/VersionItemToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/VersionItemToDTOConvertStrategy.cs new file mode 100644 index 0000000..c7f3e84 --- /dev/null +++ b/DataAccess/DTOs/Converters/VersionItemToDTOConvertStrategy.cs @@ -0,0 +1,63 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperLogics.Models.CrossSections; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DataAccess.DTOs.Converters +{ + public class VersionItemToDTOConvertStrategy : IConvertStrategy + { + private const string Message = "Analysis type is"; + private IConvertStrategy crossSectionConvertStrategy = new CrossSectionToDTOConvertStrategy(); + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + + public ISaveable Convert(ISaveable source) + { + Check(); + ISaveable saveable; + if (source is ICrossSection crossSection) + { + saveable = ProcessCrossSection(crossSection); + } + else + { + string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source); + TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); + throw new StructureHelperException(errorString); + } + return saveable; + } + + private ISaveable ProcessCrossSection(ICrossSection crossSection) + { + TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug); + ISaveable saveable; + crossSectionConvertStrategy.ReferenceDictionary = ReferenceDictionary; + crossSectionConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy() + { + ReferenceDictionary = ReferenceDictionary, + ConvertStrategy = crossSectionConvertStrategy, + TraceLogger = TraceLogger + }; + saveable = convertLogic.Convert(crossSection); + return saveable; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs new file mode 100644 index 0000000..1937239 --- /dev/null +++ b/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs @@ -0,0 +1,48 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Analyses; +using StructureHelperLogics.Models.CrossSections; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + public class VersionProcessorToDTOConvertStrategy : IConvertStrategy + { + private IConvertStrategy convertStrategy = new DateVersionToDTOConvertStrategy(); + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public VersionProcessorDTO Convert(IVersionProcessor source) + { + Check(); + VersionProcessorDTO newItem = new() + { + Id = source.Id + }; + convertStrategy.ReferenceDictionary = ReferenceDictionary; + convertStrategy.TraceLogger = TraceLogger; + foreach (var item in source.Versions) + { + var convertLogic = new DictionaryConvertStrategy() + { + ReferenceDictionary = ReferenceDictionary, + ConvertStrategy = convertStrategy, + TraceLogger = TraceLogger + }; + newItem.Versions.Add(convertLogic.Convert(item)); + } + return newItem; + } + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/VisualAnalysisToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/VisualAnalysisToDTOConvertStrategy.cs index a1fd3c3..c1be1ad 100644 --- a/DataAccess/DTOs/Converters/VisualAnalysisToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/VisualAnalysisToDTOConvertStrategy.cs @@ -1,9 +1,13 @@ -using StructureHelperCommon.Infrastructures.Interfaces; +using DataAccess.DTOs.Converters; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Analyses; +using StructureHelperCommon.Models.Projects; +using StructureHelperLogic.Models.Analyses; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; @@ -11,16 +15,45 @@ namespace DataAccess.DTOs { internal class VisualAnalysisToDTOConvertStrategy : IConvertStrategy { + private IConvertStrategy convertStrategy; public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } + public VisualAnalysisToDTOConvertStrategy(IConvertStrategy convertStrategy) + { + this.convertStrategy = convertStrategy; + } + + public VisualAnalysisToDTOConvertStrategy() : this(new AnalysisToDTOConvertStrategy()) + { + + } + public VisualAnalysisDTO Convert(IVisualAnalysis source) { + Check(); VisualAnalysisDTO visualAnalysisDTO = new() { Id = source.Id }; + convertStrategy.ReferenceDictionary = ReferenceDictionary; + convertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy() + { + ReferenceDictionary = ReferenceDictionary, + ConvertStrategy = convertStrategy, + TraceLogger = TraceLogger + }; + visualAnalysisDTO.Analysis = convertLogic.Convert(source.Analysis); return visualAnalysisDTO; } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } } } diff --git a/DataAccess/DTOs/CrossSectionDTO.cs b/DataAccess/DTOs/CrossSectionDTO.cs index f590e54..317fa4d 100644 --- a/DataAccess/DTOs/CrossSectionDTO.cs +++ b/DataAccess/DTOs/CrossSectionDTO.cs @@ -1,4 +1,5 @@ -using StructureHelperLogics.Models.CrossSections; +using Newtonsoft.Json; +using StructureHelperLogics.Models.CrossSections; using System; using System.Collections.Generic; using System.Linq; @@ -9,9 +10,11 @@ namespace DataAccess.DTOs { public class CrossSectionDTO : ICrossSection { - public ICrossSectionRepository SectionRepository { get; } - + [JsonProperty("Id")] public Guid Id { get; set; } + [JsonProperty("SectionRepository")] + public ICrossSectionRepository SectionRepository { get; set; } + public object Clone() { diff --git a/DataAccess/DTOs/CrossSectionNdmAnalysisDTO.cs b/DataAccess/DTOs/CrossSectionNdmAnalysisDTO.cs new file mode 100644 index 0000000..18a0f51 --- /dev/null +++ b/DataAccess/DTOs/CrossSectionNdmAnalysisDTO.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Models.Analyses; +using StructureHelperLogic.Models.Analyses; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class CrossSectionNdmAnalysisDTO : ICrossSectionNdmAnalysis + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Name")] + public string Name { get; set; } + [JsonProperty("Tags")] + public string Tags { get; set; } + [JsonProperty("VersionProcessor")] + public IVersionProcessor VersionProcessor { get; set; } = new VersionProcessorDTO(); + + public object Clone() + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/CrossSectionRepositoryDTO.cs b/DataAccess/DTOs/CrossSectionRepositoryDTO.cs new file mode 100644 index 0000000..1b92eef --- /dev/null +++ b/DataAccess/DTOs/CrossSectionRepositoryDTO.cs @@ -0,0 +1,29 @@ +using Newtonsoft.Json; +using StructureHelper.Models.Materials; +using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Forces; +using StructureHelperLogics.Models.CrossSections; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class CrossSectionRepositoryDTO : ICrossSectionRepository + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("HeadMaterials")] + public List HeadMaterials { get; } = new(); + [JsonProperty("ForceActions")] + public List ForceActions { get; } = new(); + [JsonProperty("Primitives")] + public List Primitives { get; } = new(); + [JsonProperty("Calculators")] + public List Calculators { get; } = new(); + + } +} diff --git a/DataAccess/DTOs/DateVersionDTO.cs b/DataAccess/DTOs/DateVersionDTO.cs new file mode 100644 index 0000000..76ee7b4 --- /dev/null +++ b/DataAccess/DTOs/DateVersionDTO.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Analyses; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class DateVersionDTO : IDateVersion + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("DateTime")] + public DateTime DateTime { get; set; } + [JsonProperty("AnalysisVersion")] + public ISaveable AnalysisVersion { get; set; } + + } +} diff --git a/DataAccess/DTOs/HeadMaterialDTO.cs b/DataAccess/DTOs/HeadMaterialDTO.cs new file mode 100644 index 0000000..a0e9969 --- /dev/null +++ b/DataAccess/DTOs/HeadMaterialDTO.cs @@ -0,0 +1,44 @@ +using LoaderCalculator.Data.Materials; +using Newtonsoft.Json; +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperLogics.Models.Materials; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace DataAccess.DTOs +{ + public class HeadMaterialDTO : IHeadMaterial + { + + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Name")] + public string Name { get; set; } + [JsonProperty("Color")] + public Color Color { get; set; } + [JsonProperty("HelperMaterial")] + public IHelperMaterial HelperMaterial { get; set; } + + + public object Clone() + { + throw new NotImplementedException(); + } + + public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) + { + throw new NotImplementedException(); + } + + public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/ProjectDTO.cs b/DataAccess/DTOs/ProjectDTO.cs index d5f6172..de7a259 100644 --- a/DataAccess/DTOs/ProjectDTO.cs +++ b/DataAccess/DTOs/ProjectDTO.cs @@ -25,16 +25,5 @@ namespace DataAccess.DTOs [JsonIgnore] public string FileName { get; set; } - - public ProjectDTO(Guid id) - { - Id = id; - } - - public ProjectDTO() : this (Guid.NewGuid()) - { - - } - } } diff --git a/DataAccess/DTOs/TypeBinder.cs b/DataAccess/DTOs/TypeBinder.cs new file mode 100644 index 0000000..0143810 --- /dev/null +++ b/DataAccess/DTOs/TypeBinder.cs @@ -0,0 +1,42 @@ +using Newtonsoft.Json.Serialization; +using StructureHelperCommon.Models; +using StructureHelperLogics.Models.CrossSections; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class TypeBinder : ISerializationBinder + { + private List<(Type type, string name)> typesNames; + public static IShiftTraceLogger TraceLogger; + public TypeBinder(List<(Type type, string name)> typesNames, IShiftTraceLogger traceLogger = null) + { + this.typesNames = typesNames; + TraceLogger = traceLogger; + } + + public void BindToName(Type serializedType, out string? assemblyName, out string? typeName) + { + assemblyName = null; + if (typesNames.Any(x => x.type == serializedType)) + { + typeName = typesNames.Single(x => x.type == serializedType).name; + } + else + { + typeName = serializedType.FullName; + } + } + + public Type BindToType(string? assemblyName, string typeName) + { + return typesNames.SingleOrDefault(x => x.name == typeName).type; + + } + + } +} diff --git a/DataAccess/DTOs/TypeBinderListFactory.cs b/DataAccess/DTOs/TypeBinderListFactory.cs new file mode 100644 index 0000000..3ce25fb --- /dev/null +++ b/DataAccess/DTOs/TypeBinderListFactory.cs @@ -0,0 +1,60 @@ +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models.Analyses; +using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Forces; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + internal enum TypeFileVersion + { + version_v1 + } + internal static class TypeBinderListFactory + { + public static List<(Type type, string name)> GetTypeNameList(TypeFileVersion fileVersion) + { + if (fileVersion == TypeFileVersion.version_v1) + { + List<(Type type, string name)> typesNames = GetVersionV1(); + return typesNames; + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(fileVersion)); + } + } + + private static List<(Type type, string name)> GetVersionV1() + { + return new List<(Type type, string name)> + { + { (typeof(CirclePrimitiveDTO), "CircleNdmPrimitive") }, + { (typeof(ConcreteLibMaterialDTO), "ConcreteLibMaterial") }, + { (typeof(CrossSectionDTO), "CrossSection") }, + { (typeof(CrossSectionNdmAnalysisDTO), "CrossSectionNdmAnalysis") }, + { (typeof(CrossSectionRepositoryDTO), "CrossSectionRepository") }, + { (typeof(DateVersionDTO), "DateVersion") }, + { (typeof(FileVersionDTO), "FileVersion") }, + { (typeof(HeadMaterialDTO), "HeadMaterial") }, + { (typeof(NdmPrimitiveDTO), "NdmPrimitive") }, + { (typeof(IVisualAnalysis), "IVisualAnalysis") }, + { (typeof(List), "ListOfICalculator") }, + { (typeof(List), "ListOfIDateVersion") }, + { (typeof(List), "ListOfIForceAction") }, + { (typeof(List), "ListOfIHeadMaterial") }, + { (typeof(List), "ListOfINdmPrimitive") }, + { (typeof(List), "ListOfIVisualAnalysis") }, + { (typeof(ProjectDTO), "Project") }, + { (typeof(VersionProcessorDTO), "VersionProcessor") }, + { (typeof(VisualAnalysisDTO), "VisualAnalysis") }, + }; + } + } +} diff --git a/DataAccess/DTOs/VersionProcessorDTO.cs b/DataAccess/DTOs/VersionProcessorDTO.cs new file mode 100644 index 0000000..22487fd --- /dev/null +++ b/DataAccess/DTOs/VersionProcessorDTO.cs @@ -0,0 +1,30 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Analyses; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class VersionProcessorDTO : IVersionProcessor + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Versions")] + public List Versions { get; } = new(); + + public void AddVersion(ISaveable newItem) + { + throw new NotImplementedException(); + } + + public IDateVersion GetCurrentVersion() + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DataAccess.csproj b/DataAccess/DataAccess.csproj index 36deaff..191fcfe 100644 --- a/DataAccess/DataAccess.csproj +++ b/DataAccess/DataAccess.csproj @@ -19,4 +19,10 @@ + + + ..\StructureHelper\Libraries\LoaderCalculator.dll + + + diff --git a/DataAccess/Infrastructures/FileSaveLogic.cs b/DataAccess/Infrastructures/FileSaveLogic.cs index 7b6617b..60001a9 100644 --- a/DataAccess/Infrastructures/FileSaveLogic.cs +++ b/DataAccess/Infrastructures/FileSaveLogic.cs @@ -48,22 +48,31 @@ namespace DataAccess.Infrastructures private void SaveToFile(IProject project) { - version = ProgramSetting.GetCurrentFileVersion(); - refDictinary = new Dictionary<(Guid id, Type type), ISaveable>(); - FileVersionDTO versionDTO = GetVersionDTO(); - var versionString = Serialize(versionDTO, TraceLogger); - SaveStringToFile(project, versionString); - refDictinary = new Dictionary<(Guid id, Type type), ISaveable>(); - ProjectDTO projectDTO = GetProjectDTO(project); - var projectString = Serialize(projectDTO, TraceLogger); - SaveStringToFile(project, projectString); + try + { + version = ProgramSetting.GetCurrentFileVersion(); + refDictinary = new Dictionary<(Guid id, Type type), ISaveable>(); + FileVersionDTO versionDTO = GetVersionDTO(); + var versionString = Serialize(versionDTO, TraceLogger); + File.Delete(project.FullFileName); + SaveStringToFile(project, versionString); + refDictinary = new Dictionary<(Guid id, Type type), ISaveable>(); + ProjectDTO projectDTO = GetProjectDTO(project); + var projectString = Serialize(projectDTO, TraceLogger); + SaveStringToFile(project, projectString); + } + catch (Exception ex) + { + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + } + } private void SaveStringToFile(IProject project, string versionString) { try { - File.WriteAllText(project.FullFileName, versionString); + File.AppendAllText(project.FullFileName, versionString); TraceLogger?.AddMessage($"File {project.FullFileName} was saved successfully", TraceLogStatuses.Service); } catch (Exception ex) @@ -107,14 +116,17 @@ namespace DataAccess.Infrastructures private static string Serialize(object obj, IShiftTraceLogger logger) { + List<(Type type, string name)> typesNames = TypeBinderListFactory.GetTypeNameList(TypeFileVersion.version_v1); + TypeBinder typeBinder = new(typesNames); var settings = new JsonSerializerSettings - { + { Converters = new List - { - // Add other converters if needed - new FileVersionDTOJsonConverter(logger), // Add the specific converter - new ProjectDTOJsonConverter(logger) - }, + { + // Add other converters if needed + new FileVersionDTOJsonConverter(logger), // Add the specific converter + new ProjectDTOJsonConverter(logger) + }, + SerializationBinder = typeBinder, Formatting = Formatting.Indented, PreserveReferencesHandling = PreserveReferencesHandling.All, MissingMemberHandling = MissingMemberHandling.Ignore, diff --git a/StructureHelper/Services/Settings/GlobalRepository.cs b/StructureHelper/Services/Settings/GlobalRepository.cs index 6f4cbdb..e0ef821 100644 --- a/StructureHelper/Services/Settings/GlobalRepository.cs +++ b/StructureHelper/Services/Settings/GlobalRepository.cs @@ -20,7 +20,7 @@ namespace StructureHelper.Services.Settings { get { - materials ??= new ListRepository(new MaterialUpdateStrategy()); + materials ??= new ListRepository(new HeadMaterialUpdateStrategy()); return materials; } } diff --git a/StructureHelper/Windows/MainWindow/Analyses/VisualAnalysis.cs b/StructureHelper/Windows/MainWindow/Analyses/VisualAnalysis.cs index 51baf27..67e32be 100644 --- a/StructureHelper/Windows/MainWindow/Analyses/VisualAnalysis.cs +++ b/StructureHelper/Windows/MainWindow/Analyses/VisualAnalysis.cs @@ -31,7 +31,7 @@ namespace StructureHelper.Windows.MainWindow.Analyses { throw new StructureHelperException(ErrorStrings.NullReference); } - if (version.Item is ICrossSection crossSection) + if (version.AnalysisVersion is ICrossSection crossSection) { ProcessCrossSection(crossSection); } @@ -49,9 +49,9 @@ namespace StructureHelper.Windows.MainWindow.Analyses public object Clone() { - var newAnalysis = Analysis.Clone() as IAnalysis; - VisualAnalysis newItem = new(newAnalysis); - return newItem; + var newAnalysis = Analysis.Clone() as IAnalysis; + VisualAnalysis newItem = new(newAnalysis); + return newItem; } } } diff --git a/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs index e381169..a166ab5 100644 --- a/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs +++ b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs @@ -284,21 +284,21 @@ namespace StructureHelper.Windows.MainWindow repository.HeadMaterials.AddRange(newRepository.HeadMaterials); repository.Primitives.AddRange(newRepository.Primitives); repository.ForceActions.AddRange(newRepository.ForceActions); - repository.CalculatorsList.AddRange(newRepository.CalculatorsList); + repository.Calculators.AddRange(newRepository.Calculators); OnPropertyChanged(nameof(HeadMaterials)); CombinationsLogic.AddItems(newRepository.ForceActions); - CalculatorsLogic.AddItems(newRepository.CalculatorsList); + CalculatorsLogic.AddItems(newRepository.Calculators); var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(newRepository.Primitives); PrimitiveLogic.Refresh(); - foreach (var item in newRepository.HeadMaterials) - { - GlobalRepository.Materials.Create(item); - } - foreach (var item in newRepository.ForceActions) - { - GlobalRepository.Actions.Create(item); - } - return primitives; + foreach (var item in newRepository.HeadMaterials) + { + GlobalRepository.Materials.Create(item); + } + foreach (var item in newRepository.ForceActions) + { + GlobalRepository.Actions.Create(item); + } + return primitives; } } diff --git a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs index 3b295bd..8f623d4 100644 --- a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs +++ b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs @@ -92,7 +92,7 @@ namespace StructureHelper.Windows.ViewModels.Forces private bool DeleteAction() { bool result = true; - var calcRepository = repository.CalculatorsList; + var calcRepository = repository.Calculators; foreach (var calc in calcRepository) { if (calc is ForceCalculator forceCalculator) diff --git a/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs index 47c231a..1e4bb33 100644 --- a/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs +++ b/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs @@ -73,7 +73,7 @@ namespace StructureHelper.Windows.ViewModels.Materials } else { - var updateStrategy = new MaterialUpdateStrategy(); + var updateStrategy = new HeadMaterialUpdateStrategy(); updateStrategy.Update(SelectedItem, copyObject); } base.EditMethod(parameter); diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs index ad52840..5bffae7 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs @@ -245,7 +245,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections } } - public AnalysisViewModelLogic(ICrossSectionRepository sectionRepository) : base(sectionRepository.CalculatorsList) + public AnalysisViewModelLogic(ICrossSectionRepository sectionRepository) : base(sectionRepository.Calculators) { repository = sectionRepository; } diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs index 4e0a163..5c6d4f9 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs @@ -134,7 +134,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections { var ndmPrimitive = SelectedItem.GetNdmPrimitive(); repository.Primitives.Remove(ndmPrimitive); - foreach (var calc in repository.CalculatorsList) + foreach (var calc in repository.Calculators) { if (calc is ForceCalculator forceCalculator) { diff --git a/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs new file mode 100644 index 0000000..b83d0b3 --- /dev/null +++ b/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs @@ -0,0 +1,46 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Loggers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Infrastructures.Interfaces +{ + public class CheckConvertLogic : ICheckLogic + where T : ISaveable + where V : ISaveable + { + private string checkResult; + public IConvertStrategy ConvertStrategy { get; set; } + + public string CheckResult => checkResult; + + public IShiftTraceLogger? TraceLogger { get; set; } + + public bool Check() + { + checkResult = string.Empty; + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(ConvertStrategy), TraceLogStatuses.Service); + if (ConvertStrategy is null) + { + string errorString = ErrorStrings.ParameterIsNull + ": Convert Strategy"; + checkResult += "\n" + errorString; + TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); + throw new StructureHelperException(errorString); + } + if (ConvertStrategy.ReferenceDictionary is null) + { + string errorString = ErrorStrings.ParameterIsNull + ": Reference Dictionary"; + checkResult += "\n" + errorString; + TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); + throw new StructureHelperException(errorString); + } + TraceLogger?.AddMessage("Checking of convert strategy is ok", TraceLogStatuses.Debug); + return true; + } + } +} diff --git a/StructureHelperCommon/Infrastructures/Interfaces/DictionaryConvertStrategy.cs b/StructureHelperCommon/Infrastructures/Interfaces/DictionaryConvertStrategy.cs index 710e0c2..901346c 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/DictionaryConvertStrategy.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/DictionaryConvertStrategy.cs @@ -17,6 +17,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces public IShiftTraceLogger? TraceLogger { get; set; } public IConvertStrategy ConvertStrategy { get; set; } public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public T Convert(V source) { ICheckInputData(); diff --git a/StructureHelperCommon/Models/Analyses/DateVersion.cs b/StructureHelperCommon/Models/Analyses/DateVersion.cs index f6593eb..45978ca 100644 --- a/StructureHelperCommon/Models/Analyses/DateVersion.cs +++ b/StructureHelperCommon/Models/Analyses/DateVersion.cs @@ -9,8 +9,18 @@ namespace StructureHelperCommon.Models.Analyses { public class DateVersion : IDateVersion { + public Guid Id { get; } public DateTime DateTime { get; set; } + public ISaveable AnalysisVersion { get; set; } - public ISaveable Item { get; set; } + public DateVersion(Guid id) + { + Id = id; + } + + public DateVersion() : this (Guid.NewGuid()) + { + + } } } diff --git a/StructureHelperCommon/Models/Analyses/IDateVersion.cs b/StructureHelperCommon/Models/Analyses/IDateVersion.cs index 9ddd63d..8766f61 100644 --- a/StructureHelperCommon/Models/Analyses/IDateVersion.cs +++ b/StructureHelperCommon/Models/Analyses/IDateVersion.cs @@ -7,9 +7,9 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Models.Analyses { - public interface IDateVersion + public interface IDateVersion : ISaveable { DateTime DateTime { get; set; } - ISaveable Item { get; set; } + ISaveable AnalysisVersion { get; set; } } } diff --git a/StructureHelperCommon/Models/Analyses/VersionProcessor.cs b/StructureHelperCommon/Models/Analyses/VersionProcessor.cs index c2819f7..c7d9d89 100644 --- a/StructureHelperCommon/Models/Analyses/VersionProcessor.cs +++ b/StructureHelperCommon/Models/Analyses/VersionProcessor.cs @@ -19,7 +19,7 @@ namespace StructureHelperCommon.Models.Analyses Id = id; Versions = new(); } - public VersionProcessor() : this (new Guid()) + public VersionProcessor() : this (Guid.NewGuid()) { } @@ -34,7 +34,7 @@ namespace StructureHelperCommon.Models.Analyses var version = new DateVersion() { DateTime = DateTime.Now, - Item = newItem + AnalysisVersion = newItem }; AddVersion(version); } diff --git a/StructureHelperCommon/Models/Calculators/IHasCalculators.cs b/StructureHelperCommon/Models/Calculators/IHasCalculators.cs new file mode 100644 index 0000000..35e32cf --- /dev/null +++ b/StructureHelperCommon/Models/Calculators/IHasCalculators.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Calculators +{ + public interface IHasCalculators + { + List Calculators { get; } + } +} diff --git a/StructureHelperCommon/Models/Loggers/LoggerStrings.cs b/StructureHelperCommon/Models/Loggers/LoggerStrings.cs index 1f6e3b0..9040575 100644 --- a/StructureHelperCommon/Models/Loggers/LoggerStrings.cs +++ b/StructureHelperCommon/Models/Loggers/LoggerStrings.cs @@ -15,6 +15,6 @@ namespace StructureHelperCommon.Models.Loggers public static string Summary => "Summary"; public static string Maximum => "Maximum"; public static string Minimum => "Minimum"; - public static string CalculatorType(object obj) => string.Format("Calculator type: {0}", obj.GetType()); + public static string LogicType(object obj) => string.Format("Logic type: {0}", obj.GetType()); } } diff --git a/StructureHelperCommon/Models/Sections/Logics/RcAccEccentricityLogic.cs b/StructureHelperCommon/Models/Sections/Logics/RcAccEccentricityLogic.cs index 5db7f39..20ce91d 100644 --- a/StructureHelperCommon/Models/Sections/Logics/RcAccEccentricityLogic.cs +++ b/StructureHelperCommon/Models/Sections/Logics/RcAccEccentricityLogic.cs @@ -40,7 +40,7 @@ namespace StructureHelperCommon.Models.Sections.Logics public (double ex, double ey) GetValue() { eccentricityLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50); - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(string.Format(accEccMessage, "x")); eccentricityLogic.Length = Length; eccentricityLogic.Size = SizeX; diff --git a/StructureHelperCommon/Models/Sections/Logics/RcEccentricityAxisLogic.cs b/StructureHelperCommon/Models/Sections/Logics/RcEccentricityAxisLogic.cs index 30e581e..5066d9e 100644 --- a/StructureHelperCommon/Models/Sections/Logics/RcEccentricityAxisLogic.cs +++ b/StructureHelperCommon/Models/Sections/Logics/RcEccentricityAxisLogic.cs @@ -30,7 +30,7 @@ namespace StructureHelperCommon.Models.Sections.Logics } public double GetValue() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); var lengthEccetricity = Length / lengthFactor; TraceLogger?.AddMessage(string.Format("Length of member = {0}(m)", Length)); TraceLogger?.AddMessage(string.Format("Accidental eccentricity by length e,a = {0}(m) / {1} = {2}(m)", Length, lengthFactor, lengthEccetricity)); diff --git a/StructureHelperCommon/Models/Sections/Logics/RcEccentricityLogic.cs b/StructureHelperCommon/Models/Sections/Logics/RcEccentricityLogic.cs index 1743674..b0c6b90 100644 --- a/StructureHelperCommon/Models/Sections/Logics/RcEccentricityLogic.cs +++ b/StructureHelperCommon/Models/Sections/Logics/RcEccentricityLogic.cs @@ -51,7 +51,7 @@ namespace StructureHelperCommon.Models.Sections public IForceTuple GetValue() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); if (InputForceTuple is null) { string errorString = ErrorStrings.NullReference + $": {nameof(InputForceTuple)}"; diff --git a/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysis.cs b/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysis.cs index 77f9db8..bba9a0c 100644 --- a/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysis.cs +++ b/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysis.cs @@ -4,7 +4,7 @@ using StructureHelperLogics.Models.CrossSections; namespace StructureHelperLogic.Models.Analyses { - public class CrossSectionNdmAnalysis : IAnalysis + public class CrossSectionNdmAnalysis : ICrossSectionNdmAnalysis { private CrossSectionNdmAnalysisUpdateStrategy updateStrategy = new(); public Guid Id { get; private set; } diff --git a/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysisUpdateStrategy.cs b/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysisUpdateStrategy.cs index f2ff3f4..e719680 100644 --- a/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysisUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysisUpdateStrategy.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.Analyses { - public class CrossSectionNdmAnalysisUpdateStrategy : IUpdateStrategy + public class CrossSectionNdmAnalysisUpdateStrategy : IUpdateStrategy { private IUpdateStrategy analysisUpdateStrategy; private IUpdateStrategy crossSectionUpdateStrategy; @@ -35,7 +35,7 @@ namespace StructureHelperLogics.Models.Analyses } - public void Update(CrossSectionNdmAnalysis targetObject, CrossSectionNdmAnalysis sourceObject) + public void Update(ICrossSectionNdmAnalysis targetObject, ICrossSectionNdmAnalysis sourceObject) { CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject); CheckObject.IsNull(targetObject, ErrorStrings.TargetObject); @@ -44,24 +44,24 @@ namespace StructureHelperLogics.Models.Analyses targetObject.VersionProcessor.Versions.Clear(); foreach (var version in sourceObject.VersionProcessor.Versions) { - if (version.Item is ICrossSection crossSection) + if (version.AnalysisVersion is ICrossSection crossSection) { updateVersion(targetObject, version, crossSection); } else { - throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version.Item)); + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version.AnalysisVersion)); } } } - private void updateVersion(CrossSectionNdmAnalysis targetObject, IDateVersion version, ICrossSection crossSection) + private void updateVersion(ICrossSectionNdmAnalysis targetObject, IDateVersion version, ICrossSection crossSection) { DateVersion newVersion = new(); dateUpdateStrategy.Update(newVersion, version); CrossSection newCrossection = new(); crossSectionUpdateStrategy.Update(newCrossection, crossSection); - newVersion.Item = newCrossection; + newVersion.AnalysisVersion = newCrossection; targetObject.VersionProcessor.Versions.Add(newVersion); } } diff --git a/StructureHelperLogics/Models/Analyses/ICrossSectionNdmAnalysis.cs b/StructureHelperLogics/Models/Analyses/ICrossSectionNdmAnalysis.cs new file mode 100644 index 0000000..77eef59 --- /dev/null +++ b/StructureHelperLogics/Models/Analyses/ICrossSectionNdmAnalysis.cs @@ -0,0 +1,8 @@ +using StructureHelperCommon.Models.Analyses; + +namespace StructureHelperLogic.Models.Analyses +{ + public interface ICrossSectionNdmAnalysis : IAnalysis + { + } +} \ No newline at end of file diff --git a/StructureHelperLogics/Models/CrossSections/CrossSection.cs b/StructureHelperLogics/Models/CrossSections/CrossSection.cs index adcafa2..494de31 100644 --- a/StructureHelperLogics/Models/CrossSections/CrossSection.cs +++ b/StructureHelperLogics/Models/CrossSections/CrossSection.cs @@ -8,13 +8,18 @@ namespace StructureHelperLogics.Models.CrossSections { public class CrossSection : ICrossSection { - public ICrossSectionRepository SectionRepository { get; private set; } + public ICrossSectionRepository SectionRepository { get; private set; } = new CrossSectionRepository(); public Guid Id { get; private set; } - public CrossSection() + public CrossSection(Guid id) { - SectionRepository = new CrossSectionRepository(); + Id = id; + } + + public CrossSection() : this(Guid.NewGuid()) + { + } public object Clone() diff --git a/StructureHelperLogics/Models/CrossSections/CrossSectionRepository.cs b/StructureHelperLogics/Models/CrossSections/CrossSectionRepository.cs index 0197496..9fd1367 100644 --- a/StructureHelperLogics/Models/CrossSections/CrossSectionRepository.cs +++ b/StructureHelperLogics/Models/CrossSections/CrossSectionRepository.cs @@ -14,17 +14,19 @@ namespace StructureHelperLogics.Models.CrossSections { public class CrossSectionRepository : ICrossSectionRepository { - public List ForceActions { get; private set; } - public List HeadMaterials { get; private set; } - public List Primitives { get; } - public List CalculatorsList { get; private set; } + public Guid Id { get; } + public List ForceActions { get; private set; } = new(); + public List HeadMaterials { get; private set; } = new(); + public List Primitives { get; } = new(); + public List Calculators { get; private set; } = new(); - public CrossSectionRepository() + public CrossSectionRepository(Guid id) + { + Id = id; + } + + public CrossSectionRepository() : this(Guid.NewGuid()) { - ForceActions = new List(); - HeadMaterials = new List(); - Primitives = new List(); - CalculatorsList = new List(); } } } diff --git a/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs b/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs index bfbd28f..66fedeb 100644 --- a/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs +++ b/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs @@ -1,6 +1,7 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Services; using StructureHelperLogics.NdmCalculations.Primitives; +using StructureHelperLogics.NdmCalculations.Primitives.Logics; using System; using System.Collections.Generic; using System.Linq; @@ -11,18 +12,29 @@ namespace StructureHelperLogics.Models.CrossSections { public class CrossSectionUpdateStrategy : IUpdateStrategy { + private IUpdateStrategy repositoryUpdateStrategy; - public CrossSectionUpdateStrategy() + public CrossSectionUpdateStrategy(IUpdateStrategy repositoryUpdateStrategy) { + this.repositoryUpdateStrategy = repositoryUpdateStrategy; + } + public CrossSectionUpdateStrategy() : this ( + new CrossSectionRepositoryUpdateStrategy() + ) + { + } public void Update(ICrossSection targetObject, ICrossSection sourceObject) { CheckObject.IsNull(targetObject, sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } - - + targetObject.SectionRepository.Calculators.Clear(); + targetObject.SectionRepository.Primitives.Clear(); + targetObject.SectionRepository.ForceActions.Clear(); + targetObject.SectionRepository.HeadMaterials.Clear(); + repositoryUpdateStrategy.Update(targetObject.SectionRepository, sourceObject.SectionRepository); } } } diff --git a/StructureHelperLogics/Models/CrossSections/ICrossSectionRepository.cs b/StructureHelperLogics/Models/CrossSections/ICrossSectionRepository.cs index bed4a93..d5cea79 100644 --- a/StructureHelperLogics/Models/CrossSections/ICrossSectionRepository.cs +++ b/StructureHelperLogics/Models/CrossSections/ICrossSectionRepository.cs @@ -1,22 +1,13 @@ -using StructureHelper.Models.Materials; -using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; using StructureHelperLogics.Models.Materials; -using StructureHelperLogics.Models.Primitives; -using StructureHelperLogics.NdmCalculations.Analyses; using StructureHelperLogics.NdmCalculations.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.Models.CrossSections { - public interface ICrossSectionRepository : IHasHeadMaterials, IHasPrimitives, IHasForceCombinations + public interface ICrossSectionRepository : ISaveable, IHasHeadMaterials, IHasPrimitives, IHasForceCombinations, IHasCalculators { - List ForceActions { get; } - List CalculatorsList { get; } + } } diff --git a/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs b/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs index c15e1bd..074b1c7 100644 --- a/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs +++ b/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs @@ -18,6 +18,9 @@ namespace StructureHelperLogics.Models.Materials private IMaterialOptionLogic optionLogic; private IFactorLogic factorLogic => new FactorLogic(SafetyFactors); private LMLogic.ITrueStrengthLogic strengthLogic; + + /// + public Guid Id { get; } /// public ILibMaterialEntity MaterialEntity { get; set; } /// @@ -38,8 +41,9 @@ namespace StructureHelperLogics.Models.Materials public List MaterialLogics => materialLogics; - public ConcreteLibMaterial() + public ConcreteLibMaterial(Guid id) { + Id = id; materialLogics = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList(); MaterialLogic = materialLogics.First(); SafetyFactors = new List(); @@ -50,7 +54,12 @@ namespace StructureHelperLogics.Models.Materials RelativeHumidity = 0.55d; MinAge = 0d; MaxAge = maxAge; - } + } + + public ConcreteLibMaterial() : this (Guid.NewGuid()) + { + + } public object Clone() { diff --git a/StructureHelperLogics/Models/Materials/ElasticMaterial.cs b/StructureHelperLogics/Models/Materials/ElasticMaterial.cs index 48373fd..9af1244 100644 --- a/StructureHelperLogics/Models/Materials/ElasticMaterial.cs +++ b/StructureHelperLogics/Models/Materials/ElasticMaterial.cs @@ -16,11 +16,18 @@ namespace StructureHelperLogics.Models.Materials public double Modulus { get; set; } public double CompressiveStrength { get; set; } public double TensileStrength { get; set; } - public List SafetyFactors { get; } + public List SafetyFactors { get; } = new(); - public ElasticMaterial() + public Guid Id { get; } + + public ElasticMaterial(Guid id) { - SafetyFactors = new List(); + Id = id; + } + + public ElasticMaterial() : this(Guid.NewGuid()) + { + } public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) diff --git a/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs b/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs index 5ccbeb0..5a65a14 100644 --- a/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs +++ b/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs @@ -15,43 +15,34 @@ namespace StructureHelperLogics.Models.Materials { private IElasticMaterialLogic elasticMaterialLogic => new ElasticMaterialLogic(); private MaterialTypes materialType; - IUpdateStrategy fRUpdateStrategy = new FRUpdateStrategy(); + IUpdateStrategy updateStrategy = new FRUpdateStrategy(); + public Guid Id { get; } public double Modulus{ get; set; } public double CompressiveStrength { get; set; } public double TensileStrength { get; set; } - public List SafetyFactors { get; } + public List SafetyFactors { get; } = new(); public double ULSConcreteStrength { get; set; } public double SumThickness { get; set; } public double GammaF2 => GetGammaF2(); - private double GetGammaF2() + public FRMaterial(MaterialTypes materialType, Guid id) { - const double gammaF2Max = 0.9d; - double gammaF2; - IFactorLogic factorLogic = new FactorLogic(SafetyFactors); - var factors = factorLogic.GetTotalFactor(LimitStates.ULS, CalcTerms.ShortTerm); - var rf = TensileStrength * factors.Tensile; - var epsUlt = rf / Modulus; - gammaF2 = 0.4d / epsUlt * Math.Sqrt(ULSConcreteStrength / (Modulus * SumThickness * 1e3d)); - gammaF2 = Math.Min(gammaF2, gammaF2Max); - return gammaF2; - } - - public FRMaterial(MaterialTypes materialType) - { - + Id = id; ULSConcreteStrength = 14e6d; SumThickness = 0.175e-3d; - SafetyFactors = new List(); this.materialType = materialType; SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultFRSafetyFactors(ProgramSetting.FRCodeType, this.materialType)); } + public FRMaterial(MaterialTypes materialType) : this (materialType, Guid.NewGuid()) + { + + } + public object Clone() { var newItem = new FRMaterial(this.materialType); - var updateStrategy = fRUpdateStrategy; updateStrategy.Update(newItem, this); return newItem; } @@ -71,5 +62,17 @@ namespace StructureHelperLogics.Models.Materials { return GetLoaderMaterial(limitState, calcTerm); } + private double GetGammaF2() + { + const double gammaF2Max = 0.9d; + double gammaF2; + IFactorLogic factorLogic = new FactorLogic(SafetyFactors); + var factors = factorLogic.GetTotalFactor(LimitStates.ULS, CalcTerms.ShortTerm); + var rf = TensileStrength * factors.Tensile; + var epsUlt = rf / Modulus; + gammaF2 = 0.4d / epsUlt * Math.Sqrt(ULSConcreteStrength / (Modulus * SumThickness * 1e3d)); + gammaF2 = Math.Min(gammaF2, gammaF2Max); + return gammaF2; + } } } diff --git a/StructureHelperLogics/Models/Materials/HeadMaterial.cs b/StructureHelperLogics/Models/Materials/HeadMaterial.cs index 6e9b568..6584393 100644 --- a/StructureHelperLogics/Models/Materials/HeadMaterial.cs +++ b/StructureHelperLogics/Models/Materials/HeadMaterial.cs @@ -16,6 +16,7 @@ namespace StructureHelper.Models.Materials { public class HeadMaterial : IHeadMaterial, INotifyPropertyChanged { + private HeadMaterialUpdateStrategy updateStrategy = new HeadMaterialUpdateStrategy(); private Color color; public Guid Id { get; } @@ -31,6 +32,7 @@ namespace StructureHelper.Models.Materials } public IHelperMaterial HelperMaterial {get; set;} + public HeadMaterial(Guid id) { Id = id; @@ -51,8 +53,7 @@ namespace StructureHelper.Models.Materials public object Clone() { var newItem = new HeadMaterial(); - newItem.HelperMaterial = this.HelperMaterial.Clone() as IHelperMaterial; - var updateStrategy = new MaterialUpdateStrategy(); + newItem.HelperMaterial = HelperMaterial.Clone() as IHelperMaterial; updateStrategy.Update(newItem, this); return newItem; } diff --git a/StructureHelperLogics/Models/Materials/IHeadMaterial.cs b/StructureHelperLogics/Models/Materials/IHeadMaterial.cs index ee4639d..6701d05 100644 --- a/StructureHelperLogics/Models/Materials/IHeadMaterial.cs +++ b/StructureHelperLogics/Models/Materials/IHeadMaterial.cs @@ -2,11 +2,6 @@ using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperLogics.Models.Materials; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Media; namespace StructureHelper.Models.Materials diff --git a/StructureHelperLogics/Models/Materials/IHelperMaterial.cs b/StructureHelperLogics/Models/Materials/IHelperMaterial.cs index bcfdfe6..9f0a851 100644 --- a/StructureHelperLogics/Models/Materials/IHelperMaterial.cs +++ b/StructureHelperLogics/Models/Materials/IHelperMaterial.cs @@ -1,5 +1,6 @@ using LoaderCalculator.Data.Materials; using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperLogics.Models.Materials; using System; using System.Collections.Generic; @@ -7,7 +8,7 @@ using System.Text; namespace StructureHelperLogics.Models.Materials { - public interface IHelperMaterial : ICloneable + public interface IHelperMaterial : ISaveable, ICloneable { IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm); IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm); diff --git a/StructureHelperLogics/Models/Materials/LibMaterial.cs b/StructureHelperLogics/Models/Materials/LibMaterial.cs index 8c42218..54645c3 100644 --- a/StructureHelperLogics/Models/Materials/LibMaterial.cs +++ b/StructureHelperLogics/Models/Materials/LibMaterial.cs @@ -28,6 +28,8 @@ namespace StructureHelperLogics.Models.Materials public List MaterialLogics => throw new NotImplementedException(); + public Guid Id => throw new NotImplementedException(); + public LibMaterial(MaterialTypes materialType, CodeTypes codeType, string name, double mainStrength) { this.MaterialType = materialType; diff --git a/StructureHelperLogics/Models/Materials/Logics/MaterialUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/HeadMaterialUpdateStrategy.cs similarity index 91% rename from StructureHelperLogics/Models/Materials/Logics/MaterialUpdateStrategy.cs rename to StructureHelperLogics/Models/Materials/Logics/HeadMaterialUpdateStrategy.cs index 360ef8e..aa2a9a1 100644 --- a/StructureHelperLogics/Models/Materials/Logics/MaterialUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Materials/Logics/HeadMaterialUpdateStrategy.cs @@ -5,13 +5,13 @@ using StructureHelperCommon.Services; namespace StructureHelperLogics.Models.Materials { - public class MaterialUpdateStrategy : IUpdateStrategy + public class HeadMaterialUpdateStrategy : IUpdateStrategy { private IUpdateStrategy elasticStrategy; private IUpdateStrategy frStrategy; private IUpdateStrategy concreteStrategy; private IUpdateStrategy reinforcementStrategy; - public MaterialUpdateStrategy(IUpdateStrategy elasticStrategy, + public HeadMaterialUpdateStrategy(IUpdateStrategy elasticStrategy, IUpdateStrategy frStrategy, IUpdateStrategy concreteStrategy, IUpdateStrategy reinforcementStrategy @@ -22,7 +22,7 @@ namespace StructureHelperLogics.Models.Materials this.concreteStrategy = concreteStrategy; this.reinforcementStrategy= reinforcementStrategy; } - public MaterialUpdateStrategy() : this( + public HeadMaterialUpdateStrategy() : this( new ElasticUpdateStrategy(), new FRUpdateStrategy(), new ConcreteLibUpdateStrategy(), @@ -31,7 +31,8 @@ namespace StructureHelperLogics.Models.Materials public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject) { - CheckObject.CompareTypes(targetObject, sourceObject); + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.Name = sourceObject.Name; targetObject.Color = sourceObject.Color; diff --git a/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs b/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs index bc0dcc6..ebd5be8 100644 --- a/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs +++ b/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs @@ -22,16 +22,23 @@ namespace StructureHelperLogics.Models.Materials private LoaderMaterialLogics.ITrueStrengthLogic strengthLogic; private readonly List materialLogics; + public Guid Id { get; } public ILibMaterialEntity MaterialEntity { get; set; } - public List SafetyFactors { get; set; } + public List SafetyFactors { get; set; } = new(); public IMaterialLogic MaterialLogic { get; set; } - public List MaterialLogics => materialLogics; - public ReinforcementLibMaterial() + + + public ReinforcementLibMaterial(Guid id) { + Id = id; materialLogics = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList(); MaterialLogic = materialLogics.First(); - SafetyFactors = new List(); + } + + public ReinforcementLibMaterial() : this (Guid.NewGuid()) + { + } public object Clone() diff --git a/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs b/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs index 8df2207..0a7291b 100644 --- a/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs +++ b/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs @@ -51,7 +51,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs calculators = calculatorLogic.GetNdmCalculators(); AddAllForcesToCalculators(); AddAllPrimitivesToCalculator(); - repository.CalculatorsList.AddRange(calculators); + repository.Calculators.AddRange(calculators); return section; } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs index f971989..cedb759 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs @@ -40,7 +40,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces public void Run() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); checkInputDataLogic.InputData = InputData; checkInputDataLogic.TraceLogger = TraceLogger; if (checkInputDataLogic.Check() != true) diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorLogic.cs index dc43b52..85b0499 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorLogic.cs @@ -25,7 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces public ForcesResults GetForcesResults() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); GetCombinations(); CalculateResult(); return result; diff --git a/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs b/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs index 2442ded..67f1fdd 100644 --- a/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Buckling/ConcreteBucklingCalculator.cs @@ -67,7 +67,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling public void Run() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.MethodBasedOn + "SP63.13330.2018"); var checkResult = CheckInputData(); if (checkResult != "") diff --git a/StructureHelperLogics/NdmCalculations/Buckling/DeltaELogicSP63.cs b/StructureHelperLogics/NdmCalculations/Buckling/DeltaELogicSP63.cs index 3f5b8fb..80924ee 100644 --- a/StructureHelperLogics/NdmCalculations/Buckling/DeltaELogicSP63.cs +++ b/StructureHelperLogics/NdmCalculations/Buckling/DeltaELogicSP63.cs @@ -31,7 +31,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling public double GetDeltaE() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(string.Format("Eccentricity e = {0}", eccentricity)); TraceLogger?.AddMessage(string.Format("Height h = {0}", size)); var deltaE = Math.Abs(eccentricity) / size; diff --git a/StructureHelperLogics/NdmCalculations/Buckling/EilerCriticalForceLogic.cs b/StructureHelperLogics/NdmCalculations/Buckling/EilerCriticalForceLogic.cs index fcd9aa6..f5e7b48 100644 --- a/StructureHelperLogics/NdmCalculations/Buckling/EilerCriticalForceLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Buckling/EilerCriticalForceLogic.cs @@ -26,7 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling public double GetEtaFactor() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); if (LongitudinalForce >= 0d) return 1d; var Ncr = GetCriticalForce(); if (LongitudinalForce <= Ncr) diff --git a/StructureHelperLogics/NdmCalculations/Buckling/ForceTupleBucklingLogic.cs b/StructureHelperLogics/NdmCalculations/Buckling/ForceTupleBucklingLogic.cs index e3e0d09..cf0ab85 100644 --- a/StructureHelperLogics/NdmCalculations/Buckling/ForceTupleBucklingLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Buckling/ForceTupleBucklingLogic.cs @@ -31,7 +31,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling public GenericResult GetForceTupleByBuckling() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); var tuple = bucklingInputData.ForceTuple.Clone() as IForceTuple; diff --git a/StructureHelperLogics/NdmCalculations/Buckling/PhiLogicSP63.cs b/StructureHelperLogics/NdmCalculations/Buckling/PhiLogicSP63.cs index fa7b072..9ba7234 100644 --- a/StructureHelperLogics/NdmCalculations/Buckling/PhiLogicSP63.cs +++ b/StructureHelperLogics/NdmCalculations/Buckling/PhiLogicSP63.cs @@ -29,7 +29,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling public double GetPhil() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); var distance = Math.Sqrt(point.X * point.X + point.Y * point.Y); string distMessage = string.Format("Distance = Sqrt(dX ^2 + dY^2) = Sqrt(({0})^2 + ({1})^2) = {2}, m", point.X, point.Y, distance); TraceLogger?.AddMessage(distMessage); diff --git a/StructureHelperLogics/NdmCalculations/Buckling/ProcessEccentricity.cs b/StructureHelperLogics/NdmCalculations/Buckling/ProcessEccentricity.cs index 8932242..2c6e69c 100644 --- a/StructureHelperLogics/NdmCalculations/Buckling/ProcessEccentricity.cs +++ b/StructureHelperLogics/NdmCalculations/Buckling/ProcessEccentricity.cs @@ -45,7 +45,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling public IForceTuple GetValue() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage("Get eccentricity taking into account accidental eccentricity"); TraceLogger?.AddMessage(string.Format("Cross-section size along x-axis dx = {0}, along y-axis dy = {1}", sizeX, sizeY)); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CheckLogics/CheckCrackCalculatorInputDataLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/CheckLogics/CheckCrackCalculatorInputDataLogic.cs index 2515742..bb3c702 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CheckLogics/CheckCrackCalculatorInputDataLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CheckLogics/CheckCrackCalculatorInputDataLogic.cs @@ -42,7 +42,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public bool Check() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); result = true; CheckResult = string.Empty; CheckPrimitives(); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs index 442c718..a117853 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs @@ -64,7 +64,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking { PrepareNewResult(); CheckInputData(); - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); try { ProcessCalculations(); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculationLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculationLogic.cs index faab256..aac2f9d 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthCalculationLogic.cs @@ -54,7 +54,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public void Run() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); PrepareNewResult(); ProcessCrackWidthCalculation(); } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthLogicSP63.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthLogicSP63.cs index 9c6cf87..e3291d6 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthLogicSP63.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackWidthLogicSP63.cs @@ -33,7 +33,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public double GetCrackWidth() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); CheckOptions(); TraceLogger?.AddMessage("Method of crack width calculation based on SP 63.13330.2018"); TraceInputData(); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs index d25128a..cb69a93 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs @@ -43,7 +43,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking /// public List GetNdmCollection() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug); triangulateLogic = new TriangulatePrimitiveLogic() { @@ -57,7 +57,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking /// public List GetCrackedNdmCollection() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug); triangulateLogic = new TriangulatePrimitiveLogic(new MeshCrackedConcreteLogic()) { @@ -72,7 +72,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking /// public List GetRebarPrimitives() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug); List rebarPrimitives = new(); foreach (var item in NdmPrimitives) @@ -90,7 +90,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking /// public List GetElasticNdmCollection() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug); triangulateLogic = new TriangulatePrimitiveLogic(new MeshElasticLogic()) { diff --git a/StructureHelperLogics/NdmCalculations/Cracking/EquivalentDiameterLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/EquivalentDiameterLogic.cs index 5e1515f..b2055cb 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/EquivalentDiameterLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/EquivalentDiameterLogic.cs @@ -17,7 +17,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public double GetAverageDiameter() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); Check(); var rebarArea = Rebars .Sum(x => x.Area); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/GetTupleInputDatasLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/GetTupleInputDatasLogic.cs index 730ca1a..1a29510 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/GetTupleInputDatasLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/GetTupleInputDatasLogic.cs @@ -33,7 +33,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public List GetTupleInputDatas() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); List resultList = new(); CheckInputData(); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/LengthBetweenCracksLogicSP63.cs b/StructureHelperLogics/NdmCalculations/Cracking/LengthBetweenCracksLogicSP63.cs index f57433d..09acaf9 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/LengthBetweenCracksLogicSP63.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/LengthBetweenCracksLogicSP63.cs @@ -52,7 +52,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking /// public double GetLength() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); IEnumerable rebars = GetRebars(); double rebarArea = GetRebarArea(rebars); double rebarDiameter = GetAverageDiameter(rebars); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/RebarCrackCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/RebarCrackCalculator.cs index ad2cacc..69ee50f 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/RebarCrackCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/RebarCrackCalculator.cs @@ -41,7 +41,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public void Run() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage($"Rebar primitive {InputData.RebarPrimitive.Name}"); PrepareNewResult(); if (CheckInputData() != true) diff --git a/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/ExpSofteningLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/ExpSofteningLogic.cs index 026776b..d55f077 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/ExpSofteningLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/ExpSofteningLogic.cs @@ -65,7 +65,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking /// public double GetSofteningFactor() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage($"Logic of calculation of psi_s factor based on exponential softening model"); TraceLogger?.AddMessage($"psi_s = 1 - BettaFactor * ForceRatio ^ PowerFactor"); TraceLogger?.AddMessage($"But not less than psi_s_min = {PsiSMin}"); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/RebarStressSofteningLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/RebarStressSofteningLogic.cs index 675001e..60370af 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/RebarStressSofteningLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/SofteningLogics/RebarStressSofteningLogic.cs @@ -69,7 +69,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public double GetSofteningFactor() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); if (IsResultActual == false) { GetRebarAndConcreteNdms(); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/TensileConcreteAreaLogicSP63.cs b/StructureHelperLogics/NdmCalculations/Cracking/TensileConcreteAreaLogicSP63.cs index 72996f3..0b7e9b1 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/TensileConcreteAreaLogicSP63.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/TensileConcreteAreaLogicSP63.cs @@ -26,7 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public double GetTensileArea() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); var rebarCollection = NdmCollection .Where(x => x is RebarNdm & stressLogic.GetSectionStrain(StrainMatrix, x) > 0d); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/TensionRebarAreaByStrainLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/TensionRebarAreaByStrainLogic.cs index c6df88d..538c129 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/TensionRebarAreaByStrainLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/TensionRebarAreaByStrainLogic.cs @@ -29,7 +29,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking } public double GetTensionRebarArea() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage("Method of obtaining of summary area of rebars in tension based on areas which are proportional by maximum strain"); var rebars = Rebars .Where(x => stressLogic.GetSectionStrain(StrainMatrix, x) > 0d); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/TensionRebarAreaSimpleSumLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/TensionRebarAreaSimpleSumLogic.cs index d446c3a..2ea3d4f 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/TensionRebarAreaSimpleSumLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/TensionRebarAreaSimpleSumLogic.cs @@ -32,7 +32,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking } public double GetTensionRebarArea() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage("Method of obtaining of summary area of rebars in tension based on ordinary summarizing of areas"); var rebars = Rebars .Where(x => stressLogic.GetSectionStrain(StrainMatrix, x) > 0d); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/TupleCrackCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/TupleCrackCalculator.cs index fdc4567..a4d94d8 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/TupleCrackCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/TupleCrackCalculator.cs @@ -62,7 +62,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public void Run() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); PrepareNewResult(); try diff --git a/StructureHelperLogics/Services/NdmPrimitives/CheckPrimitivesForMeshingLogic.cs b/StructureHelperLogics/Services/NdmPrimitives/CheckPrimitivesForMeshingLogic.cs index 92c9087..3e75fee 100644 --- a/StructureHelperLogics/Services/NdmPrimitives/CheckPrimitivesForMeshingLogic.cs +++ b/StructureHelperLogics/Services/NdmPrimitives/CheckPrimitivesForMeshingLogic.cs @@ -18,7 +18,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives public bool Check() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); if (!Primitives.Any()) { string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Count of primitive must be greater than zero"); diff --git a/StructureHelperLogics/Services/NdmPrimitives/MeshCrackedConcreteLogic.cs b/StructureHelperLogics/Services/NdmPrimitives/MeshCrackedConcreteLogic.cs index 456e04d..67a3788 100644 --- a/StructureHelperLogics/Services/NdmPrimitives/MeshCrackedConcreteLogic.cs +++ b/StructureHelperLogics/Services/NdmPrimitives/MeshCrackedConcreteLogic.cs @@ -27,7 +27,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives List IMeshPrimitiveLogic.MeshPrimitive() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); CheckPrimitive(); List ndmCollection = new(); if (Primitive.NdmElement.HeadMaterial.HelperMaterial is ICrackedMaterial) diff --git a/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs b/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs index e99425b..77bda68 100644 --- a/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs +++ b/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs @@ -23,7 +23,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives public List MeshPrimitive() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); CheckInputData(); List ndms = new(); regularMeshLogic = new MeshPrimitiveLogic() diff --git a/StructureHelperLogics/Services/NdmPrimitives/MeshHasDivisionLogic.cs b/StructureHelperLogics/Services/NdmPrimitives/MeshHasDivisionLogic.cs index d465670..7729b1b 100644 --- a/StructureHelperLogics/Services/NdmPrimitives/MeshHasDivisionLogic.cs +++ b/StructureHelperLogics/Services/NdmPrimitives/MeshHasDivisionLogic.cs @@ -26,7 +26,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives public void MeshHasDivision() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); CheckInputData(); if (Primitive is IHasDivisionSize hasDivision) { diff --git a/StructureHelperLogics/Services/NdmPrimitives/MeshPrimitiveLogic.cs b/StructureHelperLogics/Services/NdmPrimitives/MeshPrimitiveLogic.cs index 7790dc0..45dbfa8 100644 --- a/StructureHelperLogics/Services/NdmPrimitives/MeshPrimitiveLogic.cs +++ b/StructureHelperLogics/Services/NdmPrimitives/MeshPrimitiveLogic.cs @@ -23,7 +23,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives public List MeshPrimitive() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); List ndmCollection = new(); var itemNdms = Primitive.GetNdms(TriangulationOptions); ndmCollection.AddRange(itemNdms); diff --git a/StructureHelperLogics/Services/NdmPrimitives/TriangulatePrimitiveLogic.cs b/StructureHelperLogics/Services/NdmPrimitives/TriangulatePrimitiveLogic.cs index 6c2314e..db1cbf8 100644 --- a/StructureHelperLogics/Services/NdmPrimitives/TriangulatePrimitiveLogic.cs +++ b/StructureHelperLogics/Services/NdmPrimitives/TriangulatePrimitiveLogic.cs @@ -33,7 +33,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives public List GetNdms() { - TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service); CheckPrimitives(); ndmCollection = new List(); SetLogics(); diff --git a/StructureHelperLogics/StructureHelperLogics.csproj b/StructureHelperLogics/StructureHelperLogics.csproj index c221750..7c6c612 100644 --- a/StructureHelperLogics/StructureHelperLogics.csproj +++ b/StructureHelperLogics/StructureHelperLogics.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs b/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs index c996aa1..3433514 100644 --- a/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs +++ b/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs @@ -23,7 +23,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT HeightCount = heightCount }; var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); - var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator; + var calculator = newSection.SectionRepository.Calculators[0] as ForceCalculator; calculator.InputData.CompressedMember.Buckling = isBuckling; //Act calculator.Run(); @@ -48,7 +48,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT //Arrange var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount }; var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); - var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator; + var calculator = newSection.SectionRepository.Calculators[0] as ForceCalculator; calculator.InputData.CompressedMember.Buckling = isBuckling; //Act calculator.Run(); @@ -65,7 +65,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT //Arrange var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount }; var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); - var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator; + var calculator = newSection.SectionRepository.Calculators[0] as ForceCalculator; calculator.InputData.CompressedMember.Buckling = false; calculator.Run(); var ndmPrimitives = newSection.SectionRepository.Primitives;