diff --git a/DataAccess/DTOs/ConcreteLibMaterialDTO.cs b/DataAccess/DTOs/ConcreteLibMaterialDTO.cs new file mode 100644 index 0000000..778634d --- /dev/null +++ b/DataAccess/DTOs/ConcreteLibMaterialDTO.cs @@ -0,0 +1,80 @@ +using LoaderCalculator.Data.Materials; +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Settings; +using StructureHelperCommon.Models.Materials; +using StructureHelperCommon.Models.Materials.Libraries; +using StructureHelperLogics.Models.Materials; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class ConcreteLibMaterialDTO : IConcreteLibMaterial + { + const MaterialTypes materialType = MaterialTypes.Concrete; + + [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("MaterialEntityId")] + public Guid MaterialEntityId + { + get => MaterialEntity.Id; + set + { + MaterialEntity = ProgramSetting.MaterialRepository.Repository.Single(x => x.Id == value); + } + } + [JsonIgnore] + public ILibMaterialEntity MaterialEntity { get; set; } + [JsonProperty("SafetyFactors")] + public List SafetyFactors { get; set; } = new(); + [JsonProperty("TensionForULS")] + public bool TensionForULS { get; set; } + [JsonProperty("TensionForSLS")] + public bool TensionForSLS { get; set; } + [JsonProperty("MaterialLogicId")] + public Guid MaterialLogicId + { + get => MaterialLogic.Id; + set + { + MaterialLogic = MaterialLogics.Single(x => x.Id == value); + } + } + [JsonIgnore] + public IMaterialLogic MaterialLogic { get; set; } + [JsonIgnore] + public List MaterialLogics { get; } = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList(); + + 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..2f66a14 --- /dev/null +++ b/DataAccess/DTOs/Converters/ConcreteLibMaterialToDTOConvertStrategy.cs @@ -0,0 +1,24 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +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 ConcreteLibMaterialToDTOConvertStrategy : LibMaterialToDTOConvertStrategy + { + public override IUpdateStrategy UpdateStrategy { get; } = new ConcreteLibUpdateStrategy(); + + public override ConcreteLibMaterialDTO GetMaterialDTO(IConcreteLibMaterial source) + { + ConcreteLibMaterialDTO newItem = new() + { + Id = source.Id + }; + return newItem; + } + } +} 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..2991b50 --- /dev/null +++ b/DataAccess/DTOs/Converters/HeadMaterialToDTOConvertStrategy.cs @@ -0,0 +1,55 @@ +using StructureHelper.Models.Materials; +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 HeadMaterialToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy convertStrategy; + + public HeadMaterialToDTOConvertStrategy(IUpdateStrategy updateStrategy, + IConvertStrategy convertStrategy) + { + this.updateStrategy = updateStrategy; + this.convertStrategy = convertStrategy; + } + + public HeadMaterialToDTOConvertStrategy() : this ( + new HeadMaterialUpdateStrategy(), + new HelperMaterialToDTOConvertStrategy()) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public HeadMaterialDTO Convert(IHeadMaterial source) + { + TraceLogger?.AddMessage($"Convert material Id={source.Id}, name is {source.Name}"); + HeadMaterialDTO newItem = new() + { + Id = source.Id + }; + updateStrategy.Update(newItem, source); + convertStrategy.ReferenceDictionary = ReferenceDictionary; + var convertLogic = new DictionaryConvertStrategy() + { + ReferenceDictionary = ReferenceDictionary, + ConvertStrategy = convertStrategy, + TraceLogger = TraceLogger + }; + newItem.HelperMaterial = convertLogic.Convert(source.HelperMaterial); + return newItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs new file mode 100644 index 0000000..270392e --- /dev/null +++ b/DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs @@ -0,0 +1,65 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +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 +{ + internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy + { + private LibMaterialToDTOConvertStrategy concreteConvertStrategy; + private LibMaterialToDTOConvertStrategy reinforcementConvertStrategy; + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public HelperMaterialToDTOConvertStrategy( + LibMaterialToDTOConvertStrategy concreteConvertStrategy, + LibMaterialToDTOConvertStrategy reinforcementConvertStrategy) + { + this.concreteConvertStrategy = concreteConvertStrategy; + this.reinforcementConvertStrategy = reinforcementConvertStrategy; + } + + public HelperMaterialToDTOConvertStrategy() : this ( + new ConcreteLibMaterialToDTOConvertStrategy(), + new ReinforcementLibMaterialToDTOConvertStrategy()) + { + + } + + public IHelperMaterial Convert(IHelperMaterial source) + { + Check(); + if (source is IConcreteLibMaterial concreteLibMaterial) + { + concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary; + concreteConvertStrategy.TraceLogger = TraceLogger; + return concreteConvertStrategy.Convert(concreteLibMaterial); + } + if (source is IReinforcementLibMaterial reinforcementMaterial) + { + reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary; + reinforcementConvertStrategy.TraceLogger = TraceLogger; + return reinforcementConvertStrategy.Convert(reinforcementMaterial); + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source)); + } + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/LibMaterialDTOUpdateStrategy.cs b/DataAccess/DTOs/Converters/LibMaterialDTOUpdateStrategy.cs new file mode 100644 index 0000000..5270ac7 --- /dev/null +++ b/DataAccess/DTOs/Converters/LibMaterialDTOUpdateStrategy.cs @@ -0,0 +1,75 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Materials.Libraries; +using StructureHelperCommon.Services; +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 LibMaterialDTOUpdateStrategy : IUpdateStrategy + { + private IUpdateStrategy safetyFactorUpdateStrategy; + private IUpdateStrategy partialFactorUpdateStrategy; + + public LibMaterialDTOUpdateStrategy(IUpdateStrategy safetyFactorUpdateStrategy, + IUpdateStrategy partialFactorUpdateStrategy) + { + this.safetyFactorUpdateStrategy = safetyFactorUpdateStrategy; + this.partialFactorUpdateStrategy = partialFactorUpdateStrategy; + } + + public LibMaterialDTOUpdateStrategy() : this (new MaterialSafetyFactorUpdateStrategy(), + new MaterialPartialFactorUpdateStrategy()) + { + + } + + /// + public void Update(ILibMaterial targetObject, ILibMaterial sourceObject) + { + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + if (sourceObject.SafetyFactors is not null) + { + targetObject.SafetyFactors.Clear(); + foreach (var safetyFactor in sourceObject.SafetyFactors) + { + MaterialSafetyFactorDTO newSafetyFactor = GetNewSafetyFactorByOld(safetyFactor); + targetObject.SafetyFactors.Add(newSafetyFactor); + } + } + } + + private MaterialSafetyFactorDTO GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor) + { + MaterialSafetyFactorDTO newSafetyFactor = new() + { + Id = safetyFactor.Id + }; + safetyFactorUpdateStrategy.Update(newSafetyFactor, safetyFactor); + newSafetyFactor.PartialFactors.Clear(); + foreach (var partialFactor in safetyFactor.PartialFactors) + { + MaterialPartialFactorDTO newPartialFactor = GetNewPartialFactorByOld(partialFactor); + newSafetyFactor.PartialFactors.Add(newPartialFactor); + } + + return newSafetyFactor; + } + + private MaterialPartialFactorDTO GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor) + { + MaterialPartialFactorDTO newPartialFactor = new() + { + Id = partialFactor.Id + }; + partialFactorUpdateStrategy.Update(newPartialFactor, partialFactor); + return newPartialFactor; + } + } +} diff --git a/DataAccess/DTOs/Converters/LibMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/LibMaterialToDTOConvertStrategy.cs new file mode 100644 index 0000000..ff160d3 --- /dev/null +++ b/DataAccess/DTOs/Converters/LibMaterialToDTOConvertStrategy.cs @@ -0,0 +1,53 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Loggers; +using StructureHelperLogics.Models.CrossSections; +using StructureHelperLogics.Models.Materials; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public abstract class LibMaterialToDTOConvertStrategy : IConvertStrategy + where T : V + where V : ILibMaterial + { + public abstract IUpdateStrategy UpdateStrategy { get; } + public abstract T GetMaterialDTO(V source); + private IUpdateStrategy libMaterialUpdateStrategy = new LibMaterialDTOUpdateStrategy(); + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public T Convert(V source) + { + Check(); + T newItem = GetMaterialDTO(source); + try + { + UpdateStrategy.Update(newItem, source); + libMaterialUpdateStrategy.Update(newItem, source); + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + return newItem; + } + + + private void Check() + { + var checkLogic = new CheckConvertLogic(); + checkLogic.ConvertStrategy = this; + checkLogic.TraceLogger = TraceLogger; + checkLogic.Check(); + } + + } +} diff --git a/DataAccess/DTOs/Converters/MaterialSafetyFactorToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/MaterialSafetyFactorToDTOConvertStrategy.cs new file mode 100644 index 0000000..4c9252e --- /dev/null +++ b/DataAccess/DTOs/Converters/MaterialSafetyFactorToDTOConvertStrategy.cs @@ -0,0 +1,28 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Materials.Libraries; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class MaterialSafetyFactorToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public MaterialSafetyFactorToDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public MaterialSafetyFactorDTO Convert(IMaterialSafetyFactor source) + { + throw new NotImplementedException(); + } + } +} 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/ReinforcementLibMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ReinforcementLibMaterialToDTOConvertStrategy.cs new file mode 100644 index 0000000..f92fcc3 --- /dev/null +++ b/DataAccess/DTOs/Converters/ReinforcementLibMaterialToDTOConvertStrategy.cs @@ -0,0 +1,24 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +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 ReinforcementLibMaterialToDTOConvertStrategy : LibMaterialToDTOConvertStrategy + { + public override IUpdateStrategy UpdateStrategy { get; } = new ReinforcementLibUpdateStrategy(); + + public override ReinforcementLibMaterialDTO GetMaterialDTO(IReinforcementLibMaterial source) + { + ReinforcementLibMaterialDTO newItem = new() + { + Id = source.Id + }; + return newItem; + } + } +} 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/ElasticMaterialDTO.cs b/DataAccess/DTOs/ElasticMaterialDTO.cs new file mode 100644 index 0000000..3ad6e3a --- /dev/null +++ b/DataAccess/DTOs/ElasticMaterialDTO.cs @@ -0,0 +1,43 @@ +using LoaderCalculator.Data.Materials; +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Enums; +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 ElasticMaterialDTO : IElasticMaterial + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Modulus")] + public double Modulus { get; set; } + [JsonProperty("CompressiveStrength")] + public double CompressiveStrength { get; set; } + [JsonProperty("TensileStrength")] + public double TensileStrength { get; set; } + [JsonProperty("SafetyFactors")] + public List SafetyFactors { get; } = new(); + + + 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/FRMaterialDTO.cs b/DataAccess/DTOs/FRMaterialDTO.cs new file mode 100644 index 0000000..47368b3 --- /dev/null +++ b/DataAccess/DTOs/FRMaterialDTO.cs @@ -0,0 +1,49 @@ +using LoaderCalculator.Data.Materials; +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Enums; +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 FRMaterialDTO : IFRMaterial + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("ULSConcreteStrength")] + public double ULSConcreteStrength { get; set; } + [JsonProperty("SunThickness")] + public double SumThickness { get; set; } + [JsonIgnore] + public double GammaF2 { get; } + [JsonProperty("Modulus")] + public double Modulus { get; set; } + [JsonProperty("CompressiveStrength")] + public double CompressiveStrength { get; set; } + [JsonProperty("TensileStrength")] + public double TensileStrength { get; set; } + [JsonProperty("SafetyFactors")] + public List SafetyFactors { get; } = new(); + + + 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/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/MaterialPartialFactorDTO.cs b/DataAccess/DTOs/MaterialPartialFactorDTO.cs new file mode 100644 index 0000000..902f144 --- /dev/null +++ b/DataAccess/DTOs/MaterialPartialFactorDTO.cs @@ -0,0 +1,24 @@ +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models.Materials.Libraries; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class MaterialPartialFactorDTO : IMaterialPartialFactor + { + public Guid Id { get; set; } + public double FactorValue { get; set; } + public StressStates StressState { get; set; } + public CalcTerms CalcTerm { get; set; } + public LimitStates LimitState { get; set; } + + public object Clone() + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/MaterialSafetyFactorDTO.cs b/DataAccess/DTOs/MaterialSafetyFactorDTO.cs new file mode 100644 index 0000000..0657fab --- /dev/null +++ b/DataAccess/DTOs/MaterialSafetyFactorDTO.cs @@ -0,0 +1,36 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models.Materials.Libraries; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class MaterialSafetyFactorDTO : IMaterialSafetyFactor + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Name")] + public string Name { get; set; } = string.Empty; + [JsonProperty("Take")] + public bool Take { get; set; } + [JsonProperty("Description")] + public string Description { get; set; } = string.Empty; + [JsonProperty("PartialFactors")] + public List PartialFactors { get; } = new(); + + + public object Clone() + { + throw new NotImplementedException(); + } + + public double GetFactor(StressStates stressState, CalcTerms calcTerm, LimitStates limitStates) + { + 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/ReinforcementLibMaterialDTO.cs b/DataAccess/DTOs/ReinforcementLibMaterialDTO.cs new file mode 100644 index 0000000..d6de36a --- /dev/null +++ b/DataAccess/DTOs/ReinforcementLibMaterialDTO.cs @@ -0,0 +1,70 @@ +using LoaderCalculator.Data.Materials; +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Settings; +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 ReinforcementLibMaterialDTO : IReinforcementLibMaterial + { + const MaterialTypes materialType = MaterialTypes.Reinforcement; + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("MaterialEntityId")] + public Guid MaterialEntityId + { + get => MaterialEntity.Id; + set + { + MaterialEntity = ProgramSetting.MaterialRepository.Repository.Single(x => x.Id == value); + } + } + [JsonIgnore] + public ILibMaterialEntity MaterialEntity { get; set; } + [JsonProperty("SafetyFactors")] + public List SafetyFactors { get; set; } = new(); + [JsonProperty("MaterialLogicId")] + public Guid MaterialLogicId + { + get => MaterialLogic.Id; + set + { + MaterialLogic = MaterialLogics.Single(x => x.Id == value); + } + } + [JsonIgnore] + public IMaterialLogic MaterialLogic { get; set; } + + [JsonIgnore] + public List MaterialLogics { get; } = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList(); + + + 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/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..18f04fe --- /dev/null +++ b/DataAccess/DTOs/TypeBinderListFactory.cs @@ -0,0 +1,67 @@ +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models.Analyses; +using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Materials.Libraries; +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(MaterialSafetyFactorDTO), "MaterialSafetyFactor") }, + { (typeof(NdmPrimitiveDTO), "NdmPrimitive") }, + { (typeof(IVisualAnalysis), "IVisualAnalysis") }, + { (typeof(List), "ListOfICalculator") }, + { (typeof(List), "ListOfIDateVersion") }, + { (typeof(List), "ListOfIForceAction") }, + { (typeof(List), "ListOfIHeadMaterial") }, + { (typeof(List), "ListOfMaterialSafetyFactor") }, + { (typeof(List), "ListOfMaterialPartialFactor") }, + { (typeof(List), "ListOfINdmPrimitive") }, + { (typeof(List), "ListOfPartialFactor") }, + { (typeof(List), "ListOfIVisualAnalysis") }, + { (typeof(ProjectDTO), "Project") }, + { (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") }, + { (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") }, + { (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 51ccba7..2c1a9e3 100644 --- a/StructureHelper/Windows/MainWindow/Analyses/VisualAnalysis.cs +++ b/StructureHelper/Windows/MainWindow/Analyses/VisualAnalysis.cs @@ -33,7 +33,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); } @@ -60,9 +60,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/Materials/ConcreteCurveLogic.cs b/StructureHelperCommon/Models/Materials/ConcreteCurveLogic.cs index 8031064..9745f4b 100644 --- a/StructureHelperCommon/Models/Materials/ConcreteCurveLogic.cs +++ b/StructureHelperCommon/Models/Materials/ConcreteCurveLogic.cs @@ -2,6 +2,7 @@ using LoaderCalculator.Data.Materials.MaterialBuilders; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; +using System; namespace StructureHelperCommon.Models.Materials { @@ -12,6 +13,7 @@ namespace StructureHelperCommon.Models.Materials private ConcreteLogicOptions options; + public Guid Id { get; private set; } public string Name { get; set; } public IMaterialLogicOptions Options { @@ -29,6 +31,11 @@ namespace StructureHelperCommon.Models.Materials public MaterialTypes MaterialType { get; set; } public DiagramType DiagramType { get; set; } + public ConcreteCurveLogic(Guid id) + { + Id = id; + } + public IMaterial GetLoaderMaterial() { GetLoaderOptions(); diff --git a/StructureHelperCommon/Models/Materials/Factories/MaterialLogicsFactory.cs b/StructureHelperCommon/Models/Materials/Factories/MaterialLogicsFactory.cs index a9912ff..a736738 100644 --- a/StructureHelperCommon/Models/Materials/Factories/MaterialLogicsFactory.cs +++ b/StructureHelperCommon/Models/Materials/Factories/MaterialLogicsFactory.cs @@ -15,9 +15,24 @@ namespace StructureHelperCommon.Models.Materials { var items = new List() { - new ReinforcementByBuilderLogic() { MaterialType = MaterialTypes.Reinforcement, Name="Bilinear", DiagramType = DiagramType.Bilinear}, - new ReinforcementByBuilderLogic() { MaterialType = MaterialTypes.Reinforcement, Name="Triplelinear", DiagramType = DiagramType.TripleLinear}, - new ConcreteCurveLogic() { MaterialType = MaterialTypes.Concrete, Name = "Curve", DiagramType = DiagramType.Curve}, + new ReinforcementByBuilderLogic(Guid.Parse("54c4fe40-8f82-4995-8930-81e65e97edb9")) + { + MaterialType = MaterialTypes.Reinforcement, + Name="Bilinear", + DiagramType = DiagramType.Bilinear + }, + new ReinforcementByBuilderLogic(Guid.Parse("c658b71d-13b1-458c-a1b0-c93d1324acad")) + { + MaterialType = MaterialTypes.Reinforcement, + Name="Triplelinear", + DiagramType = DiagramType.TripleLinear + }, + new ConcreteCurveLogic(Guid.Parse("b97e8168-76a1-4e24-ae98-9aa38edd1e9a")) + { + MaterialType = MaterialTypes.Concrete, + Name = "Curve", + DiagramType = DiagramType.Curve + }, }; return items; } diff --git a/StructureHelperCommon/Models/Materials/IMaterialLogic.cs b/StructureHelperCommon/Models/Materials/IMaterialLogic.cs index 71e77f8..9c8008d 100644 --- a/StructureHelperCommon/Models/Materials/IMaterialLogic.cs +++ b/StructureHelperCommon/Models/Materials/IMaterialLogic.cs @@ -1,6 +1,7 @@ using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Materials.MaterialBuilders; using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Interfaces; using System; using System.Collections.Generic; using System.Linq; @@ -9,7 +10,7 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Models.Materials { - public interface IMaterialLogic + public interface IMaterialLogic : ISaveable { string Name { get; set; } IMaterialLogicOptions Options { get; set; } diff --git a/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialPartialFactorUpdateStrategy.cs b/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialPartialFactorUpdateStrategy.cs index d1747cd..6abab67 100644 --- a/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialPartialFactorUpdateStrategy.cs +++ b/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialPartialFactorUpdateStrategy.cs @@ -1,4 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; using System; using System.Collections.Generic; using System.Linq; @@ -7,10 +8,12 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Models.Materials.Libraries { - internal class MaterialPartialFactorUpdateStrategy : IUpdateStrategy + public class MaterialPartialFactorUpdateStrategy : IUpdateStrategy { public void Update(IMaterialPartialFactor targetObject, IMaterialPartialFactor sourceObject) { + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.LimitState = sourceObject.LimitState; targetObject.StressState = sourceObject.StressState; diff --git a/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialSafetyFactorUpdateStrategy.cs b/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialSafetyFactorUpdateStrategy.cs index ae363de..77ae6c3 100644 --- a/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialSafetyFactorUpdateStrategy.cs +++ b/StructureHelperCommon/Models/Materials/Libraries/Logics/MaterialSafetyFactorUpdateStrategy.cs @@ -1,4 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; using System; using System.Collections.Generic; using System.Linq; @@ -7,10 +8,12 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Models.Materials.Libraries { - internal class MaterialSafetyFactorUpdateStrategy : IUpdateStrategy + public class MaterialSafetyFactorUpdateStrategy : IUpdateStrategy { public void Update(IMaterialSafetyFactor targetObject, IMaterialSafetyFactor sourceObject) { + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.Name = sourceObject.Name; targetObject.Take = sourceObject.Take; diff --git a/StructureHelperCommon/Models/Materials/Libraries/MaterialPartialFactor.cs b/StructureHelperCommon/Models/Materials/Libraries/MaterialPartialFactor.cs index 960a412..ece4de6 100644 --- a/StructureHelperCommon/Models/Materials/Libraries/MaterialPartialFactor.cs +++ b/StructureHelperCommon/Models/Materials/Libraries/MaterialPartialFactor.cs @@ -1,5 +1,6 @@ using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; using System; namespace StructureHelperCommon.Models.Materials.Libraries @@ -7,16 +8,18 @@ namespace StructureHelperCommon.Models.Materials.Libraries public class MaterialPartialFactor : IMaterialPartialFactor { private double factorValue; + private IUpdateStrategy updateStrategy = new MaterialPartialFactorUpdateStrategy(); + public Guid Id { get; } - public StressStates StressState { get; set; } - public CalcTerms CalcTerm { get; set; } - public LimitStates LimitState { get; set; } + public StressStates StressState { get; set; } = StressStates.Compression; + public CalcTerms CalcTerm { get; set; } = CalcTerms.LongTerm; + public LimitStates LimitState { get; set; } = LimitStates.ULS; public double FactorValue { get => factorValue; set { - if (value < 0 ) + if (value < 0) { throw new StructureHelperException(ErrorStrings.FactorMustBeGraterThanZero); } @@ -28,9 +31,6 @@ namespace StructureHelperCommon.Models.Materials.Libraries public MaterialPartialFactor(Guid id) { Id = id; - StressState = StressStates.Compression; - LimitState = LimitStates.ULS; - CalcTerm = CalcTerms.LongTerm; FactorValue = 1d; } @@ -40,7 +40,6 @@ namespace StructureHelperCommon.Models.Materials.Libraries public object Clone() { var newItem = new MaterialPartialFactor(); - var updateStrategy = new MaterialPartialFactorUpdateStrategy(); updateStrategy.Update(newItem, this); return newItem; } diff --git a/StructureHelperCommon/Models/Materials/ReinforcementByBuilderLogic.cs b/StructureHelperCommon/Models/Materials/ReinforcementByBuilderLogic.cs index ac246ee..70dd8fb 100644 --- a/StructureHelperCommon/Models/Materials/ReinforcementByBuilderLogic.cs +++ b/StructureHelperCommon/Models/Materials/ReinforcementByBuilderLogic.cs @@ -3,6 +3,7 @@ using LoaderCalculator.Data.Materials.MaterialBuilders; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Services; +using System; namespace StructureHelperCommon.Models.Materials { @@ -12,6 +13,7 @@ namespace StructureHelperCommon.Models.Materials private ReinforcementOptions materialOptions; private IMaterialOptionLogic optionLogic; + public Guid Id { get; private set; } public string Name { get; set; } public DiagramType DiagramType { get; set; } public IMaterialLogicOptions Options @@ -26,6 +28,10 @@ namespace StructureHelperCommon.Models.Materials public MaterialTypes MaterialType { get; set; } + public ReinforcementByBuilderLogic(Guid id) + { + Id = id; + } public IMaterial GetLoaderMaterial() { GetLoaderOptions(); 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..c6075c7 100644 --- a/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs +++ b/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs @@ -1,6 +1,7 @@ using LoaderCalculator.Data.Materials; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Models.Materials; using StructureHelperCommon.Models.Materials.Libraries; @@ -18,6 +19,10 @@ namespace StructureHelperLogics.Models.Materials private IMaterialOptionLogic optionLogic; private IFactorLogic factorLogic => new FactorLogic(SafetyFactors); private LMLogic.ITrueStrengthLogic strengthLogic; + private IUpdateStrategy updateStrategy = new ConcreteLibUpdateStrategy(); + + /// + public Guid Id { get; } /// public ILibMaterialEntity MaterialEntity { get; set; } /// @@ -38,8 +43,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,12 +56,16 @@ namespace StructureHelperLogics.Models.Materials RelativeHumidity = 0.55d; MinAge = 0d; MaxAge = maxAge; - } + } + + public ConcreteLibMaterial() : this (Guid.NewGuid()) + { + + } public object Clone() { var newItem = new ConcreteLibMaterial(); - var updateStrategy = new ConcreteLibUpdateStrategy(); updateStrategy.Update(newItem, this); return newItem; } 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/ConcreteLibUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/ConcreteLibUpdateStrategy.cs index d7baf4d..5e5e721 100644 --- a/StructureHelperLogics/Models/Materials/Logics/ConcreteLibUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Materials/Logics/ConcreteLibUpdateStrategy.cs @@ -21,12 +21,15 @@ namespace StructureHelperLogics.Models.Materials } public void Update(IConcreteLibMaterial targetObject, IConcreteLibMaterial sourceObject) { - CheckObject.CompareTypes(targetObject, sourceObject); + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } libUpdateStrategy.Update(targetObject, sourceObject); targetObject.TensionForULS = sourceObject.TensionForULS; targetObject.TensionForSLS = sourceObject.TensionForSLS; targetObject.RelativeHumidity = sourceObject.RelativeHumidity; + targetObject.MinAge = sourceObject.MinAge; + targetObject.MaxAge = sourceObject.MaxAge; } } } diff --git a/StructureHelperLogics/Models/Materials/Logics/HeadMaterialUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/HeadMaterialUpdateStrategy.cs new file mode 100644 index 0000000..53feb86 --- /dev/null +++ b/StructureHelperLogics/Models/Materials/Logics/HeadMaterialUpdateStrategy.cs @@ -0,0 +1,30 @@ +using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; + +namespace StructureHelperLogics.Models.Materials +{ + public class HeadMaterialUpdateStrategy : IUpdateStrategy + { + private IUpdateStrategy helperMaterialUpdateStrategy; + + public HeadMaterialUpdateStrategy(IUpdateStrategy helperMaterialUpdateStrategy) + { + this.helperMaterialUpdateStrategy = helperMaterialUpdateStrategy; + } + public HeadMaterialUpdateStrategy() : this(new HelperMaterialUpdateStrategy()) { } + + public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject) + { + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.Name = sourceObject.Name; + targetObject.Color = sourceObject.Color; + targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial; + helperMaterialUpdateStrategy.Update(targetObject.HelperMaterial, sourceObject.HelperMaterial); + } + + + } +} diff --git a/StructureHelperLogics/Models/Materials/Logics/MaterialUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/HelperMaterialUpdateStrategy.cs similarity index 68% rename from StructureHelperLogics/Models/Materials/Logics/MaterialUpdateStrategy.cs rename to StructureHelperLogics/Models/Materials/Logics/HelperMaterialUpdateStrategy.cs index 360ef8e..3a3c1a5 100644 --- a/StructureHelperLogics/Models/Materials/Logics/MaterialUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Materials/Logics/HelperMaterialUpdateStrategy.cs @@ -1,17 +1,21 @@ -using StructureHelper.Models.Materials; -using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace StructureHelperLogics.Models.Materials { - public class MaterialUpdateStrategy : IUpdateStrategy + public class HelperMaterialUpdateStrategy : IUpdateStrategy { private IUpdateStrategy elasticStrategy; private IUpdateStrategy frStrategy; private IUpdateStrategy concreteStrategy; private IUpdateStrategy reinforcementStrategy; - public MaterialUpdateStrategy(IUpdateStrategy elasticStrategy, + public HelperMaterialUpdateStrategy(IUpdateStrategy elasticStrategy, IUpdateStrategy frStrategy, IUpdateStrategy concreteStrategy, IUpdateStrategy reinforcementStrategy @@ -20,28 +24,20 @@ namespace StructureHelperLogics.Models.Materials this.elasticStrategy = elasticStrategy; this.frStrategy = frStrategy; this.concreteStrategy = concreteStrategy; - this.reinforcementStrategy= reinforcementStrategy; + this.reinforcementStrategy = reinforcementStrategy; } - public MaterialUpdateStrategy() : this( + public HelperMaterialUpdateStrategy() : this( new ElasticUpdateStrategy(), new FRUpdateStrategy(), new ConcreteLibUpdateStrategy(), new ReinforcementLibUpdateStrategy() - ) { } + ) + { } - public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject) + public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject) { - CheckObject.CompareTypes(targetObject, sourceObject); - if (ReferenceEquals(targetObject, sourceObject)) { return; } - targetObject.Name = sourceObject.Name; - targetObject.Color = sourceObject.Color; - targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial; - UpdateHelperMaterial(targetObject.HelperMaterial, sourceObject.HelperMaterial); - } - - private void UpdateHelperMaterial(IHelperMaterial targetObject, IHelperMaterial sourceObject) - { - CheckObject.CompareTypes(targetObject, sourceObject); + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); if (sourceObject is ILibMaterial) { UpdateLibMaterial(targetObject, sourceObject); diff --git a/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs index b4281e1..7695258 100644 --- a/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs @@ -13,11 +13,16 @@ namespace StructureHelperLogics.Models.Materials { public void Update(ILibMaterial targetObject, ILibMaterial sourceObject) { - CheckObject.CompareTypes(targetObject, sourceObject); + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.MaterialEntity = sourceObject.MaterialEntity; - if (targetObject.SafetyFactors is not null & sourceObject.SafetyFactors is not null) + if (sourceObject.SafetyFactors is not null) { + if (targetObject.SafetyFactors is null) + { + targetObject.SafetyFactors = new(); + } targetObject.SafetyFactors.Clear(); foreach (var item in sourceObject.SafetyFactors) { diff --git a/StructureHelperLogics/Models/Materials/Logics/ReinforcementLibUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/ReinforcementLibUpdateStrategy.cs index 3b1934e..90dbd59 100644 --- a/StructureHelperLogics/Models/Materials/Logics/ReinforcementLibUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Materials/Logics/ReinforcementLibUpdateStrategy.cs @@ -21,7 +21,8 @@ namespace StructureHelperLogics.Models.Materials } public void Update(IReinforcementLibMaterial targetObject, IReinforcementLibMaterial sourceObject) { - CheckObject.CompareTypes(targetObject, sourceObject); + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } libUpdateStrategy.Update(targetObject, sourceObject); } 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;