diff --git a/DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs index 266aefc..2b7ce1a 100644 --- a/DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs @@ -16,6 +16,8 @@ namespace DataAccess.DTOs.Converters { private const string Message = "Analysis type is"; private IConvertStrategy convertCrossSectionNdmAnalysisStrategy = new CrossSectionNdmAnalysisToDTOConvertStrategy(); + private DictionaryConvertStrategy convertLogic; + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } @@ -45,12 +47,7 @@ namespace DataAccess.DTOs.Converters 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 - }; + convertLogic = new DictionaryConvertStrategy(this, convertCrossSectionNdmAnalysisStrategy); CrossSectionNdmAnalysisDTO crossSectionNdmAnalysisDTO = convertLogic.Convert(crossSectionNdmAnalysis); return crossSectionNdmAnalysisDTO; } diff --git a/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs index 569f0c4..fc3f394 100644 --- a/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs @@ -1,8 +1,11 @@ using DataAccess.DTOs.Converters; using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Analyses; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Materials; using System; @@ -16,14 +19,22 @@ namespace DataAccess.DTOs public class CrossSectionRepositoryToDTOConvertStrategy : IConvertStrategy { private IConvertStrategy materialConvertStrategy; + private IConvertStrategy forceCombinationByFactorConvertStrategy; + private IConvertStrategy forceCombinationListConvertStrategy; - public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy materialConvertStrategy) + public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy materialConvertStrategy, + IConvertStrategy forceCombinationByFactorConvertStrategy, + IConvertStrategy forceCombinationListConvertStrategy) { this.materialConvertStrategy = materialConvertStrategy; + this.forceCombinationByFactorConvertStrategy = forceCombinationByFactorConvertStrategy; + this.forceCombinationListConvertStrategy = forceCombinationListConvertStrategy; } public CrossSectionRepositoryToDTOConvertStrategy() : this( - new HeadMaterialToDTOConvertStrategy()) + new HeadMaterialToDTOConvertStrategy(), + new ForceCombinationByFactorToDTOConvertStrategy(), + new ForceCombinationListToDTOConvertStrategy()) { } @@ -34,15 +45,74 @@ namespace DataAccess.DTOs public CrossSectionRepositoryDTO Convert(ICrossSectionRepository source) { Check(); + try + { + CrossSectionRepositoryDTO newItem = GetNewRepository(source); + return newItem; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + + } + + private CrossSectionRepositoryDTO GetNewRepository(ICrossSectionRepository source) + { CrossSectionRepositoryDTO newItem = new() { Id = source.Id }; + List forceActions = ProcessForceActions(source); List materials = ProcessMaterials(source); + newItem.ForceActions.AddRange(forceActions); newItem.HeadMaterials.AddRange(materials); return newItem; } + private List ProcessForceActions(ICrossSectionRepository source) + { + List forceActions = new(); + foreach (var item in source.ForceActions) + { + if (item is IForceCombinationByFactor forceCombinationByFactor) + { + ForceCombinationByFactorDTO forceCombination = GetForceCombinationByFactor(forceCombinationByFactor); + forceActions.Add(forceCombination); + } + else if (item is IForceCombinationList forceCombinationList) + { + ForceCombinationListDTO forceCombination = GetForceCombinationList(forceCombinationList); + forceActions.Add(forceCombination); + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(item)); + } + } + return forceActions; + } + + private ForceCombinationListDTO GetForceCombinationList(IForceCombinationList forceCombinationList) + { + forceCombinationListConvertStrategy.ReferenceDictionary = ReferenceDictionary; + forceCombinationListConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, forceCombinationListConvertStrategy); + var forceCombination = convertLogic.Convert(forceCombinationList); + return forceCombination; + } + + private ForceCombinationByFactorDTO GetForceCombinationByFactor(IForceCombinationByFactor forceCombinationByFactor) + { + forceCombinationByFactorConvertStrategy.ReferenceDictionary = ReferenceDictionary; + forceCombinationByFactorConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, forceCombinationByFactorConvertStrategy); + var forceCombination = convertLogic.Convert(forceCombinationByFactor); + return forceCombination; + } + private List ProcessMaterials(ICrossSectionRepository source) { materialConvertStrategy.ReferenceDictionary = ReferenceDictionary; @@ -64,9 +134,7 @@ namespace DataAccess.DTOs private void Check() { - var checkLogic = new CheckConvertLogic(); - checkLogic.ConvertStrategy = this; - checkLogic.TraceLogger = TraceLogger; + var checkLogic = new CheckConvertLogic(this); checkLogic.Check(); } } diff --git a/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs index e787a41..738f189 100644 --- a/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs @@ -1,32 +1,32 @@ 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 +namespace DataAccess.DTOs { public class CrossSectionToDTOConvertStrategy : IConvertStrategy { - private IUpdateStrategy updateStrategy; - private IConvertStrategy convertStrategy; + private IUpdateStrategy updateStrategy; //don't use since CrossSection does not have any properties + private IConvertStrategy convertRepositoryStrategy; + private DictionaryConvertStrategy convertLogic; + private ICheckConvertLogic checkLogic; + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } public CrossSectionToDTOConvertStrategy(IUpdateStrategy updateStrategy, - IConvertStrategy convertStrategy) + IConvertStrategy convertRepositoryStrategy, + ICheckConvertLogic checkLogic) { this.updateStrategy = updateStrategy; - this.convertStrategy = convertStrategy; + this.convertRepositoryStrategy = convertRepositoryStrategy; + this.checkLogic = checkLogic; } public CrossSectionToDTOConvertStrategy() : this( new CrossSectionUpdateStrategy(), - new CrossSectionRepositoryToDTOConvertStrategy()) + new CrossSectionRepositoryToDTOConvertStrategy(), + new CheckConvertLogic()) { } @@ -38,21 +38,15 @@ namespace DataAccess.DTOs.Converters { Id = source.Id }; - convertStrategy.ReferenceDictionary = ReferenceDictionary; - convertStrategy.TraceLogger = TraceLogger; - var convertLogic = new DictionaryConvertStrategy() - { - ReferenceDictionary = ReferenceDictionary, - ConvertStrategy = convertStrategy, - TraceLogger = TraceLogger - }; + convertRepositoryStrategy.ReferenceDictionary = ReferenceDictionary; + convertRepositoryStrategy.TraceLogger = TraceLogger; + convertLogic = new DictionaryConvertStrategy(this, convertRepositoryStrategy); 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 index 7d03678..c4902a2 100644 --- a/DataAccess/DTOs/Converters/DateVersionToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/DateVersionToDTOConvertStrategy.cs @@ -9,12 +9,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace DataAccess.DTOs.Converters +namespace DataAccess.DTOs { public class DateVersionToDTOConvertStrategy : IConvertStrategy { private IUpdateStrategy updateStrategy; private IConvertStrategy convertStrategy; + private DictionaryConvertStrategy convertLogic; public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } @@ -44,12 +45,7 @@ namespace DataAccess.DTOs.Converters updateStrategy.Update(newItem, source); convertStrategy.ReferenceDictionary = ReferenceDictionary; convertStrategy.TraceLogger = TraceLogger; - var convertLogic = new DictionaryConvertStrategy() - { - ReferenceDictionary = ReferenceDictionary, - ConvertStrategy = convertStrategy, - TraceLogger = TraceLogger - }; + convertLogic = new DictionaryConvertStrategy(this, convertStrategy); newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion); return newItem; } diff --git a/DataAccess/DTOs/Converters/DesignForceTupleToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/DesignForceTupleToDTOConvertStrategy.cs new file mode 100644 index 0000000..6550252 --- /dev/null +++ b/DataAccess/DTOs/Converters/DesignForceTupleToDTOConvertStrategy.cs @@ -0,0 +1,69 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Forces.Logics; +using StructureHelperCommon.Models.Loggers; +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 DesignForceTupleToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy forceTupleConvertStrategy; + + public DesignForceTupleToDTOConvertStrategy(IUpdateStrategy updateStrategy, + IConvertStrategy forceTupleConvertStrategy) + { + this.updateStrategy = updateStrategy; + this.forceTupleConvertStrategy = forceTupleConvertStrategy; + } + + public DesignForceTupleToDTOConvertStrategy() : this(new DesignForceTupleUpdateStrategy(), + new ForceTupleToDTOConvertStrategy()) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public DesignForceTupleDTO Convert(IDesignForceTuple source) + { + try + { + Check(); + DesignForceTupleDTO designForceTupleDTO = GetNewDesignForceTuple(source); + return designForceTupleDTO; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private DesignForceTupleDTO GetNewDesignForceTuple(IDesignForceTuple source) + { + DesignForceTupleDTO newItem = new() { Id = source.Id }; + updateStrategy.Update(newItem, source); + forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary; + forceTupleConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, forceTupleConvertStrategy); + newItem.ForceTuple = convertLogic.Convert(source.ForceTuple); + return newItem; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(this); + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/ElasticMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ElasticMaterialToDTOConvertStrategy.cs new file mode 100644 index 0000000..d24442e --- /dev/null +++ b/DataAccess/DTOs/Converters/ElasticMaterialToDTOConvertStrategy.cs @@ -0,0 +1,62 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Analyses; +using StructureHelperCommon.Models.Loggers; +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 ElasticMaterialToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private ICheckConvertLogic checkLogic; + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public ElasticMaterialToDTOConvertStrategy( + IUpdateStrategy updateStrategy, + ICheckConvertLogic checkLogic) + { + this.updateStrategy = updateStrategy; + this.checkLogic = checkLogic; + } + + public ElasticMaterialToDTOConvertStrategy() : this ( + new ElasticUpdateStrategy(), + new CheckConvertLogic()) + { + + } + + public ElasticMaterialDTO Convert(IElasticMaterial source) + { + Check(); + try + { + ElasticMaterialDTO newItem = new() { Id = source.Id }; + updateStrategy.Update(newItem, source); + return newItem; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + + } + + private void Check() + { + checkLogic = new CheckConvertLogic(this); + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/FRMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/FRMaterialToDTOConvertStrategy.cs new file mode 100644 index 0000000..1b212cf --- /dev/null +++ b/DataAccess/DTOs/Converters/FRMaterialToDTOConvertStrategy.cs @@ -0,0 +1,48 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Loggers; +using StructureHelperLogics.Models.Materials; + +namespace DataAccess.DTOs +{ + public class FRMaterialToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public FRMaterialToDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public FRMaterialToDTOConvertStrategy() : this (new FRUpdateStrategy()) + { + + } + + public FRMaterialDTO Convert(IFRMaterial source) + { + Check(); + try + { + FRMaterialDTO newItem = new() { Id = source.Id }; + updateStrategy.Update(newItem, source); + return newItem; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(this); + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/ForceCombinationByFactorToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ForceCombinationByFactorToDTOConvertStrategy.cs new file mode 100644 index 0000000..a1ae30b --- /dev/null +++ b/DataAccess/DTOs/Converters/ForceCombinationByFactorToDTOConvertStrategy.cs @@ -0,0 +1,102 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Forces.Logics; +using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + public class ForceCombinationByFactorToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy pointUpdateStrategy; + + private IConvertStrategy forceTupleConvertStrategy; + private IUpdateStrategy baseUpdateStrategy; + + public ForceCombinationByFactorToDTOConvertStrategy(IUpdateStrategy updateStrategy, + IConvertStrategy pointUpdateStrategy, + IConvertStrategy convertStrategy, + IUpdateStrategy baseUpdateStrategy) + { + this.baseUpdateStrategy = baseUpdateStrategy; + this.updateStrategy = updateStrategy; + this.forceTupleConvertStrategy = convertStrategy; + this.pointUpdateStrategy = pointUpdateStrategy; + } + + public ForceCombinationByFactorToDTOConvertStrategy() : this ( + new ForceCombinationByFactorUpdateStrategy(), + new Point2DToDTOConvertStrategy(), + new ForceTupleToDTOConvertStrategy(), + new ForceActionBaseUpdateStrategy()) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public ForceCombinationByFactorDTO Convert(IForceCombinationByFactor source) + { + Check(); + try + { + ForceCombinationByFactorDTO newItem = GetNewForceTuple(source); + TraceLogger.AddMessage($"Force combination by factor, name = {newItem.Name} was converted", TraceLogStatuses.Debug); + return newItem; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + + } + + private ForceCombinationByFactorDTO GetNewForceTuple(IForceCombinationByFactor source) + { + ForceCombinationByFactorDTO newItem = new() { Id = source.Id }; + baseUpdateStrategy.Update(newItem, source); + updateStrategy.Update(newItem, source); + GetNewForcePoint(source, newItem); + GetNewFullSLSForces(source, newItem); + return newItem; + } + + private void GetNewFullSLSForces(IForceCombinationByFactor source, ForceCombinationByFactorDTO newItem) + { + if (source.FullSLSForces is not null) + { + forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary; + forceTupleConvertStrategy.TraceLogger = TraceLogger; + var convertForceTupleLogic = new DictionaryConvertStrategy(this, forceTupleConvertStrategy); + newItem.FullSLSForces = convertForceTupleLogic.Convert(source.FullSLSForces); + } + } + + private void GetNewForcePoint(IForceCombinationByFactor source, ForceCombinationByFactorDTO newItem) + { + if (source.ForcePoint is not null) + { + pointUpdateStrategy.ReferenceDictionary = ReferenceDictionary; + pointUpdateStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, pointUpdateStrategy); + newItem.ForcePoint = convertLogic.Convert(source.ForcePoint); + } + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(this); + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/ForceCombinationListToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ForceCombinationListToDTOConvertStrategy.cs new file mode 100644 index 0000000..73abe66 --- /dev/null +++ b/DataAccess/DTOs/Converters/ForceCombinationListToDTOConvertStrategy.cs @@ -0,0 +1,75 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Loggers; +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 ForceCombinationListToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + private IConvertStrategy convertStrategy; + + public ForceCombinationListToDTOConvertStrategy( + IUpdateStrategy updateStrategy, + IConvertStrategy convertStrategy) + { + this.updateStrategy = updateStrategy; + this.convertStrategy = convertStrategy; + } + + public ForceCombinationListToDTOConvertStrategy() : this ( + new ForceCombinationListUpdateStrategy(), + new DesignForceTupleToDTOConvertStrategy()) + { + + } + + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public ForceCombinationListDTO Convert(IForceCombinationList source) + { + try + { + Check(); + return GetNewForceCombinationList(source); + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private ForceCombinationListDTO GetNewForceCombinationList(IForceCombinationList source) + { + + ForceCombinationListDTO newItem = new() { Id = source.Id}; + updateStrategy.Update(newItem, source); + convertStrategy.ReferenceDictionary = ReferenceDictionary; + convertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, convertStrategy); + newItem.DesignForces.Clear(); + foreach (var item in source.DesignForces) + { + newItem.DesignForces.Add(convertLogic.Convert(item)); + } + return newItem; + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(this); + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/ForceTupleToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ForceTupleToDTOConvertStrategy.cs new file mode 100644 index 0000000..67dd1a0 --- /dev/null +++ b/DataAccess/DTOs/Converters/ForceTupleToDTOConvertStrategy.cs @@ -0,0 +1,53 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Loggers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class ForceTupleToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public ForceTupleToDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public ForceTupleToDTOConvertStrategy() : this(new ForceTupleUpdateStrategy()) + { + + } + + public ForceTupleDTO Convert(IForceTuple source) + { + Check(); + try + { + ForceTupleDTO newItem = new() { Id = source.Id}; + updateStrategy.Update(newItem, source); + return newItem; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private void Check() + { + var checkLogic = new CheckConvertLogic(this); + checkLogic.Check(); + } + } +} diff --git a/DataAccess/DTOs/Converters/HeadMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/HeadMaterialToDTOConvertStrategy.cs index 2991b50..a2682cd 100644 --- a/DataAccess/DTOs/Converters/HeadMaterialToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/HeadMaterialToDTOConvertStrategy.cs @@ -1,6 +1,7 @@ using StructureHelper.Models.Materials; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Materials; using System; @@ -34,6 +35,20 @@ namespace DataAccess.DTOs.Converters public IShiftTraceLogger TraceLogger { get; set; } public HeadMaterialDTO Convert(IHeadMaterial source) + { + try + { + return GetMaterial(source); + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private HeadMaterialDTO GetMaterial(IHeadMaterial source) { TraceLogger?.AddMessage($"Convert material Id={source.Id}, name is {source.Name}"); HeadMaterialDTO newItem = new() @@ -42,12 +57,7 @@ namespace DataAccess.DTOs.Converters }; updateStrategy.Update(newItem, source); convertStrategy.ReferenceDictionary = ReferenceDictionary; - var convertLogic = new DictionaryConvertStrategy() - { - ReferenceDictionary = ReferenceDictionary, - ConvertStrategy = convertStrategy, - TraceLogger = TraceLogger - }; + var convertLogic = new DictionaryConvertStrategy(this, convertStrategy); newItem.HelperMaterial = convertLogic.Convert(source.HelperMaterial); return newItem; } diff --git a/DataAccess/DTOs/Converters/HelperMaterialDTOSafetyFactorUpdateStrategy.cs b/DataAccess/DTOs/Converters/HelperMaterialDTOSafetyFactorUpdateStrategy.cs new file mode 100644 index 0000000..41a53bb --- /dev/null +++ b/DataAccess/DTOs/Converters/HelperMaterialDTOSafetyFactorUpdateStrategy.cs @@ -0,0 +1,76 @@ +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.Converters +{ + public class HelperMaterialDTOSafetyFactorUpdateStrategy : IUpdateStrategy + { + private IUpdateStrategy safetyFactorUpdateStrategy; + private IUpdateStrategy partialFactorUpdateStrategy; + + public HelperMaterialDTOSafetyFactorUpdateStrategy( + IUpdateStrategy safetyFactorUpdateStrategy, + IUpdateStrategy partialFactorUpdateStrategy) + { + this.safetyFactorUpdateStrategy = safetyFactorUpdateStrategy; + this.partialFactorUpdateStrategy = partialFactorUpdateStrategy; + } + + public HelperMaterialDTOSafetyFactorUpdateStrategy() : this( + new MaterialSafetyFactorUpdateStrategy(), + new MaterialPartialFactorUpdateStrategy()) + { + + } + + public void Update(IHelperMaterial targetObject, IHelperMaterial 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/HelperMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs index 270392e..97646e2 100644 --- a/DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/HelperMaterialToDTOConvertStrategy.cs @@ -1,8 +1,11 @@ -using StructureHelperCommon.Infrastructures.Exceptions; +using DataAccess.DTOs.Converters; +using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Loggers; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Materials; +using StructureHelperLogics.Models.Materials.Logics; using System; using System.Collections.Generic; using System.Linq; @@ -15,20 +18,31 @@ namespace DataAccess.DTOs { private LibMaterialToDTOConvertStrategy concreteConvertStrategy; private LibMaterialToDTOConvertStrategy reinforcementConvertStrategy; + private IConvertStrategy elasticConvertStrategy; + private IConvertStrategy frMaterialConvertStrategy; + private IUpdateStrategy safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(); + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } public HelperMaterialToDTOConvertStrategy( LibMaterialToDTOConvertStrategy concreteConvertStrategy, - LibMaterialToDTOConvertStrategy reinforcementConvertStrategy) + LibMaterialToDTOConvertStrategy reinforcementConvertStrategy, + IConvertStrategy elasticConvertStrategy, + IConvertStrategy frMaterialConvertStrategy) { this.concreteConvertStrategy = concreteConvertStrategy; this.reinforcementConvertStrategy = reinforcementConvertStrategy; + this.elasticConvertStrategy = elasticConvertStrategy; + this.frMaterialConvertStrategy = frMaterialConvertStrategy; } public HelperMaterialToDTOConvertStrategy() : this ( new ConcreteLibMaterialToDTOConvertStrategy(), - new ReinforcementLibMaterialToDTOConvertStrategy()) + new ReinforcementLibMaterialToDTOConvertStrategy(), + new ElasticMaterialToDTOConvertStrategy(), + new FRMaterialToDTOConvertStrategy() + ) { } @@ -36,17 +50,37 @@ namespace DataAccess.DTOs public IHelperMaterial Convert(IHelperMaterial source) { Check(); + try + { + IHelperMaterial helperMaterial = GetMaterial(source); + safetyFactorUpdateStrategy.Update(helperMaterial, source); + return helperMaterial; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + } + + private IHelperMaterial GetMaterial(IHelperMaterial source) + { if (source is IConcreteLibMaterial concreteLibMaterial) { - concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary; - concreteConvertStrategy.TraceLogger = TraceLogger; - return concreteConvertStrategy.Convert(concreteLibMaterial); + return ProcessConcrete(concreteLibMaterial); } - if (source is IReinforcementLibMaterial reinforcementMaterial) + else if (source is IReinforcementLibMaterial reinforcementMaterial) { - reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary; - reinforcementConvertStrategy.TraceLogger = TraceLogger; - return reinforcementConvertStrategy.Convert(reinforcementMaterial); + return ProcessReinforcement(reinforcementMaterial); + } + else if (source is IFRMaterial frMaterial) + { + return ProcessFRMaterial(frMaterial); + } + else if (source is IElasticMaterial elasticMaterial) + { + return ProcessElastic(elasticMaterial); } else { @@ -54,11 +88,41 @@ namespace DataAccess.DTOs } } + private IHelperMaterial ProcessFRMaterial(IFRMaterial frMaterial) + { + frMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary; + frMaterialConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, frMaterialConvertStrategy); + return convertLogic.Convert(frMaterial); + } + + private IHelperMaterial ProcessElastic(IElasticMaterial elasticMaterial) + { + elasticConvertStrategy.ReferenceDictionary = ReferenceDictionary; + elasticConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, elasticConvertStrategy); + return convertLogic.Convert(elasticMaterial); + } + + private IHelperMaterial ProcessReinforcement(IReinforcementLibMaterial reinforcementMaterial) + { + reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary; + reinforcementConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, reinforcementConvertStrategy); + return convertLogic.Convert(reinforcementMaterial); + } + + private IHelperMaterial ProcessConcrete(IConcreteLibMaterial concreteLibMaterial) + { + concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary; + concreteConvertStrategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, concreteConvertStrategy); + return convertLogic.Convert(concreteLibMaterial); + } + private void Check() { - var checkLogic = new CheckConvertLogic(); - checkLogic.ConvertStrategy = this; - checkLogic.TraceLogger = TraceLogger; + var checkLogic = new CheckConvertLogic(this); checkLogic.Check(); } } diff --git a/DataAccess/DTOs/Converters/LibMaterialDTOUpdateStrategy.cs b/DataAccess/DTOs/Converters/LibMaterialDTOUpdateStrategy.cs index 5270ac7..5f0a2b7 100644 --- a/DataAccess/DTOs/Converters/LibMaterialDTOUpdateStrategy.cs +++ b/DataAccess/DTOs/Converters/LibMaterialDTOUpdateStrategy.cs @@ -12,64 +12,12 @@ 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 index ff160d3..d4a9b7d 100644 --- a/DataAccess/DTOs/Converters/LibMaterialToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/LibMaterialToDTOConvertStrategy.cs @@ -18,7 +18,7 @@ namespace DataAccess.DTOs { public abstract IUpdateStrategy UpdateStrategy { get; } public abstract T GetMaterialDTO(V source); - private IUpdateStrategy libMaterialUpdateStrategy = new LibMaterialDTOUpdateStrategy(); + //private IUpdateStrategy libMaterialUpdateStrategy = new LibMaterialDTOUpdateStrategy(); public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } @@ -29,7 +29,7 @@ namespace DataAccess.DTOs try { UpdateStrategy.Update(newItem, source); - libMaterialUpdateStrategy.Update(newItem, source); + //libMaterialUpdateStrategy.Update(newItem, source); } catch (Exception ex) { @@ -43,9 +43,7 @@ namespace DataAccess.DTOs private void Check() { - var checkLogic = new CheckConvertLogic(); - checkLogic.ConvertStrategy = this; - checkLogic.TraceLogger = TraceLogger; + var checkLogic = new CheckConvertLogic(this); checkLogic.Check(); } diff --git a/DataAccess/DTOs/Converters/Point2DToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Point2DToDTOConvertStrategy.cs new file mode 100644 index 0000000..4cfd87e --- /dev/null +++ b/DataAccess/DTOs/Converters/Point2DToDTOConvertStrategy.cs @@ -0,0 +1,47 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + public class Point2DToDTOConvertStrategy : IConvertStrategy + { + private IUpdateStrategy updateStrategy; + + public Point2DToDTOConvertStrategy(IUpdateStrategy updateStrategy) + { + this.updateStrategy = updateStrategy; + } + + public Point2DToDTOConvertStrategy() : this (new Point2DUpdateStrategy()) + { + + } + + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary {get; set; } + public IShiftTraceLogger TraceLogger { get; set; } + + public Point2DDTO Convert(IPoint2D source) + { + try + { + Point2DDTO newItem = new() { Id = source.Id }; + updateStrategy.Update(newItem, source); + return newItem; + } + catch (Exception ex) + { + TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug); + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + throw; + } + + } + } +} diff --git a/DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs index 0e9b2c3..5785aeb 100644 --- a/DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs @@ -14,6 +14,7 @@ namespace DataAccess.DTOs { private IUpdateStrategy updateStrategy; private IConvertStrategy convertStrategy; + private DictionaryConvertStrategy convertLogic; public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } @@ -39,12 +40,7 @@ namespace DataAccess.DTOs updateStrategy.Update(newItem, source); convertStrategy.ReferenceDictionary = ReferenceDictionary; convertStrategy.TraceLogger = TraceLogger; - var convertLogic = new DictionaryConvertStrategy() - { - ReferenceDictionary = ReferenceDictionary, - ConvertStrategy = convertStrategy, - TraceLogger = TraceLogger - }; + convertLogic = new DictionaryConvertStrategy(this, convertStrategy); newItem.VisualAnalyses.Clear(); foreach (var item in source.VisualAnalyses) { diff --git a/DataAccess/DTOs/Converters/VersionItemToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/VersionItemToDTOConvertStrategy.cs index c7f3e84..4b42376 100644 --- a/DataAccess/DTOs/Converters/VersionItemToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/VersionItemToDTOConvertStrategy.cs @@ -9,7 +9,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace DataAccess.DTOs.Converters +namespace DataAccess.DTOs { public class VersionItemToDTOConvertStrategy : IConvertStrategy { diff --git a/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs index 1937239..6e141ff 100644 --- a/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/VersionProcessorToDTOConvertStrategy.cs @@ -8,14 +8,26 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace DataAccess.DTOs.Converters +namespace DataAccess.DTOs { public class VersionProcessorToDTOConvertStrategy : IConvertStrategy { - private IConvertStrategy convertStrategy = new DateVersionToDTOConvertStrategy(); + private IConvertStrategy dataVersionConvertStrategy; + private ICheckConvertLogic checkLogic; + + public VersionProcessorToDTOConvertStrategy(IConvertStrategy dataVersionConvertStrategy) + { + this.dataVersionConvertStrategy = dataVersionConvertStrategy; + } + public VersionProcessorToDTOConvertStrategy() : this( new DateVersionToDTOConvertStrategy()) + { + + } + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } + public VersionProcessorDTO Convert(IVersionProcessor source) { Check(); @@ -23,25 +35,18 @@ namespace DataAccess.DTOs.Converters { Id = source.Id }; - convertStrategy.ReferenceDictionary = ReferenceDictionary; - convertStrategy.TraceLogger = TraceLogger; + dataVersionConvertStrategy.ReferenceDictionary = ReferenceDictionary; + dataVersionConvertStrategy.TraceLogger = TraceLogger; foreach (var item in source.Versions) { - var convertLogic = new DictionaryConvertStrategy() - { - ReferenceDictionary = ReferenceDictionary, - ConvertStrategy = convertStrategy, - TraceLogger = TraceLogger - }; + var convertLogic = new DictionaryConvertStrategy(this, dataVersionConvertStrategy); newItem.Versions.Add(convertLogic.Convert(item)); } return newItem; } private void Check() { - var checkLogic = new CheckConvertLogic(); - checkLogic.ConvertStrategy = this; - checkLogic.TraceLogger = TraceLogger; + checkLogic = new CheckConvertLogic(this); checkLogic.Check(); } } diff --git a/DataAccess/DTOs/CrossSectionDTO.cs b/DataAccess/DTOs/CrossSectionDTO.cs index 317fa4d..f14da37 100644 --- a/DataAccess/DTOs/CrossSectionDTO.cs +++ b/DataAccess/DTOs/CrossSectionDTO.cs @@ -15,7 +15,6 @@ namespace DataAccess.DTOs [JsonProperty("SectionRepository")] public ICrossSectionRepository SectionRepository { get; set; } - public object Clone() { throw new NotImplementedException(); diff --git a/DataAccess/DTOs/DesignForceTupleDTO.cs b/DataAccess/DTOs/DesignForceTupleDTO.cs new file mode 100644 index 0000000..36d1f49 --- /dev/null +++ b/DataAccess/DTOs/DesignForceTupleDTO.cs @@ -0,0 +1,29 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Forces; + +namespace DataAccess.DTOs +{ + public class DesignForceTupleDTO : IDesignForceTuple + { + private IUpdateStrategy updateStrategy; + + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("LimitState")] + public LimitStates LimitState { get; set; } + [JsonProperty("CalcTerm")] + public CalcTerms CalcTerm { get; set; } + [JsonProperty("ForceTuple")] + public IForceTuple ForceTuple { get; set; } = new ForceTupleDTO(); + + + public object Clone() + { + DesignForceTupleDTO newItem = new(); + updateStrategy.Update(newItem, this); + return newItem; + } + } +} diff --git a/DataAccess/DTOs/ElasticMaterialDTO.cs b/DataAccess/DTOs/ElasticMaterialDTO.cs index 3ad6e3a..5893095 100644 --- a/DataAccess/DTOs/ElasticMaterialDTO.cs +++ b/DataAccess/DTOs/ElasticMaterialDTO.cs @@ -22,7 +22,7 @@ namespace DataAccess.DTOs [JsonProperty("TensileStrength")] public double TensileStrength { get; set; } [JsonProperty("SafetyFactors")] - public List SafetyFactors { get; } = new(); + public List SafetyFactors { get; set; } = new(); public object Clone() diff --git a/DataAccess/DTOs/FRMaterialDTO.cs b/DataAccess/DTOs/FRMaterialDTO.cs index 47368b3..c061b79 100644 --- a/DataAccess/DTOs/FRMaterialDTO.cs +++ b/DataAccess/DTOs/FRMaterialDTO.cs @@ -28,7 +28,7 @@ namespace DataAccess.DTOs [JsonProperty("TensileStrength")] public double TensileStrength { get; set; } [JsonProperty("SafetyFactors")] - public List SafetyFactors { get; } = new(); + public List SafetyFactors { get; set; } = new(); public object Clone() diff --git a/DataAccess/DTOs/ForceCombinationByFactorDTO.cs b/DataAccess/DTOs/ForceCombinationByFactorDTO.cs new file mode 100644 index 0000000..6133d75 --- /dev/null +++ b/DataAccess/DTOs/ForceCombinationByFactorDTO.cs @@ -0,0 +1,40 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class ForceCombinationByFactorDTO : IForceCombinationByFactor + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Name")] + public string Name { get; set; } + [JsonProperty("FullSLSForces")] + public IForceTuple FullSLSForces { get; set; } = new ForceTupleDTO(); + [JsonProperty("ULSFactor")] + public double ULSFactor { get; set; } + [JsonProperty("LongTermFactor")] + public double LongTermFactor { get; set; } + [JsonProperty("SetInGravityCenter")] + public bool SetInGravityCenter { get; set; } + [JsonProperty("ForcePoint")] + public IPoint2D ForcePoint { get; set; } = new Point2DDTO(); + + + public object Clone() + { + throw new NotImplementedException(); + } + + public IForceCombinationList GetCombinations() + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/ForceCombinationListDTO.cs b/DataAccess/DTOs/ForceCombinationListDTO.cs new file mode 100644 index 0000000..913261d --- /dev/null +++ b/DataAccess/DTOs/ForceCombinationListDTO.cs @@ -0,0 +1,35 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class ForceCombinationListDTO : IForceCombinationList + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Name")] + public string Name { get; set; } + [JsonProperty("SetInGravityCenter")] + public bool SetInGravityCenter { get; set; } + [JsonProperty("ForcePoint")] + public IPoint2D ForcePoint { get; set; } + [JsonProperty("DesignForces")] + public List DesignForces { get; set; } = new(); + + public object Clone() + { + throw new NotImplementedException(); + } + + public IForceCombinationList GetCombinations() + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/ForceTupleDTO.cs b/DataAccess/DTOs/ForceTupleDTO.cs new file mode 100644 index 0000000..3dbe8bd --- /dev/null +++ b/DataAccess/DTOs/ForceTupleDTO.cs @@ -0,0 +1,39 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Models.Forces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class ForceTupleDTO : IForceTuple + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("Mx")] + public double Mx { get; set; } + [JsonProperty("My")] + public double My { get; set; } + [JsonProperty("Nz")] + public double Nz { get; set; } + [JsonProperty("Qx")] + public double Qx { get; set; } + [JsonProperty("Qy")] + public double Qy { get; set; } + [JsonProperty("Mz")] + public double Mz { get; set; } + + + public void Clear() + { + throw new NotImplementedException(); + } + + public object Clone() + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/Point2DDTO.cs b/DataAccess/DTOs/Point2DDTO.cs new file mode 100644 index 0000000..a527dc7 --- /dev/null +++ b/DataAccess/DTOs/Point2DDTO.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Models.Shapes; +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 Point2DDTO : IPoint2D + { + [JsonProperty("Id")] + public Guid Id { get; set; } + [JsonProperty("X")] + public double X { get; set; } + [JsonProperty("Y")] + public double Y { get; set; } + + + public object Clone() + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/TypeBinderListFactory.cs b/DataAccess/DTOs/TypeBinderListFactory.cs index 18f04fe..5a1d55e 100644 --- a/DataAccess/DTOs/TypeBinderListFactory.cs +++ b/DataAccess/DTOs/TypeBinderListFactory.cs @@ -42,13 +42,20 @@ namespace DataAccess.DTOs { (typeof(CrossSectionNdmAnalysisDTO), "CrossSectionNdmAnalysis") }, { (typeof(CrossSectionRepositoryDTO), "CrossSectionRepository") }, { (typeof(DateVersionDTO), "DateVersion") }, + { (typeof(DesignForceTupleDTO), "DesignForceTuple") }, + { (typeof(ElasticMaterialDTO), "ElasticMaterial") }, { (typeof(FileVersionDTO), "FileVersion") }, + { (typeof(ForceCombinationByFactorDTO), "ForceCombinationByFactor") }, + { (typeof(ForceCombinationListDTO), "ForceCombinationList") }, + { (typeof(ForceTupleDTO), "ForceTuple") }, + { (typeof(FRMaterialDTO), "FRMaterial") }, { (typeof(HeadMaterialDTO), "HeadMaterial") }, { (typeof(MaterialSafetyFactorDTO), "MaterialSafetyFactor") }, { (typeof(NdmPrimitiveDTO), "NdmPrimitive") }, { (typeof(IVisualAnalysis), "IVisualAnalysis") }, { (typeof(List), "ListOfICalculator") }, { (typeof(List), "ListOfIDateVersion") }, + { (typeof(List), "ListOfIDesignForceTuple") }, { (typeof(List), "ListOfIForceAction") }, { (typeof(List), "ListOfIHeadMaterial") }, { (typeof(List), "ListOfMaterialSafetyFactor") }, @@ -56,6 +63,7 @@ namespace DataAccess.DTOs { (typeof(List), "ListOfINdmPrimitive") }, { (typeof(List), "ListOfPartialFactor") }, { (typeof(List), "ListOfIVisualAnalysis") }, + { (typeof(Point2DDTO), "Point2D") }, { (typeof(ProjectDTO), "Project") }, { (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") }, { (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") }, diff --git a/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs b/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs index 7b83503..9644ca6 100644 --- a/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs +++ b/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs @@ -17,11 +17,11 @@ namespace StructureHelper.Infrastructure.UI.DataContexts { get { - return primitive.DiameterByX; + return primitive.Width; } set { - primitive.DiameterByX = value; + primitive.Width = value; RefreshPlacement(); } } diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs index 5c6d4f9..d27516f 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs @@ -100,7 +100,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections { var primitive = new EllipsePrimitive { - DiameterByX = 0.5d + Width = 0.5d }; ndmPrimitive = primitive; viewPrimitive = new CircleViewPrimitive(primitive); diff --git a/StructureHelperCommon/Infrastructures/Enums/CalcTerms.cs b/StructureHelperCommon/Infrastructures/Enums/CalcTerms.cs index f44ee3f..ef26a9c 100644 --- a/StructureHelperCommon/Infrastructures/Enums/CalcTerms.cs +++ b/StructureHelperCommon/Infrastructures/Enums/CalcTerms.cs @@ -2,7 +2,7 @@ { public enum CalcTerms { - ShortTerm, - LongTerm, + ShortTerm = 1, + LongTerm = 2, } } diff --git a/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs index b83d0b3..4d58b44 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/CheckConvertLogic.cs @@ -1,5 +1,6 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Analyses; using StructureHelperCommon.Models.Loggers; using System; using System.Collections.Generic; @@ -9,11 +10,22 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Infrastructures.Interfaces { - public class CheckConvertLogic : ICheckLogic - where T : ISaveable + public class CheckConvertLogic : ICheckConvertLogic where T : ISaveable where V : ISaveable { private string checkResult; + + public CheckConvertLogic(IConvertStrategy source) + { + ConvertStrategy = source; + TraceLogger = source.TraceLogger; + } + + public CheckConvertLogic() + { + + } + public IConvertStrategy ConvertStrategy { get; set; } public string CheckResult => checkResult; diff --git a/StructureHelperCommon/Infrastructures/Interfaces/DictionaryConvertStrategy.cs b/StructureHelperCommon/Infrastructures/Interfaces/DictionaryConvertStrategy.cs index 901346c..ddc95df 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/DictionaryConvertStrategy.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/DictionaryConvertStrategy.cs @@ -18,9 +18,20 @@ namespace StructureHelperCommon.Infrastructures.Interfaces public IConvertStrategy ConvertStrategy { get; set; } public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + public DictionaryConvertStrategy(IBaseConvertStrategy baseConvertStrategy, IConvertStrategy convertStrategy) + { + ReferenceDictionary = baseConvertStrategy.ReferenceDictionary; + TraceLogger = baseConvertStrategy.TraceLogger; + ConvertStrategy = convertStrategy; + } + public DictionaryConvertStrategy() + { + + } + public T Convert(V source) { - ICheckInputData(); + CheckInputData(); T val; var key = (source.Id, typeof(T)); if (ReferenceDictionary.ContainsKey(key)) @@ -38,7 +49,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces } return val; } - private void ICheckInputData() + private void CheckInputData() { if(ReferenceDictionary is null) { @@ -47,6 +58,6 @@ namespace StructureHelperCommon.Infrastructures.Interfaces throw new StructureHelperException(errorString); } } - + } } diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IBaseConvertStrategy.cs b/StructureHelperCommon/Infrastructures/Interfaces/IBaseConvertStrategy.cs new file mode 100644 index 0000000..d7da7fc --- /dev/null +++ b/StructureHelperCommon/Infrastructures/Interfaces/IBaseConvertStrategy.cs @@ -0,0 +1,12 @@ +using StructureHelperCommon.Models; +using System; +using System.Collections.Generic; + +namespace StructureHelperCommon.Infrastructures.Interfaces +{ + public interface IBaseConvertStrategy + { + Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } + IShiftTraceLogger TraceLogger { get; set; } + } +} \ No newline at end of file diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ICheckConvertLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/ICheckConvertLogic.cs new file mode 100644 index 0000000..dacccd3 --- /dev/null +++ b/StructureHelperCommon/Infrastructures/Interfaces/ICheckConvertLogic.cs @@ -0,0 +1,12 @@ +using StructureHelperCommon.Models; + +namespace StructureHelperCommon.Infrastructures.Interfaces +{ + public interface ICheckConvertLogic : ICheckLogic + where T : ISaveable + where V : ISaveable + { + IConvertStrategy ConvertStrategy { get; set; } + IShiftTraceLogger? TraceLogger { get; set; } + } +} \ No newline at end of file diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IConvertStrategy.cs b/StructureHelperCommon/Infrastructures/Interfaces/IConvertStrategy.cs index 43afc4c..d3adaa9 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/IConvertStrategy.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/IConvertStrategy.cs @@ -7,12 +7,10 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Infrastructures.Interfaces { - public interface IConvertStrategy + public interface IConvertStrategy : IBaseConvertStrategy where T :ISaveable where V :ISaveable { - Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } - IShiftTraceLogger TraceLogger { get; set; } T Convert(V source); } } diff --git a/StructureHelperCommon/Models/Forces/DesignForceTuple.cs b/StructureHelperCommon/Models/Forces/DesignForceTuple.cs index 27ff4e6..b7c0636 100644 --- a/StructureHelperCommon/Models/Forces/DesignForceTuple.cs +++ b/StructureHelperCommon/Models/Forces/DesignForceTuple.cs @@ -1,28 +1,33 @@ using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Forces.Logics; +using System; namespace StructureHelperCommon.Models.Forces { public class DesignForceTuple : IDesignForceTuple { + private IUpdateStrategy updateStrategy = new DesignForceTupleUpdateStrategy(); + public Guid Id { get; } + + public LimitStates LimitState { get; set; } public CalcTerms CalcTerm { get; set; } - public IForceTuple ForceTuple { get; set; } + public IForceTuple ForceTuple { get; set; } = new ForceTuple(); - public DesignForceTuple(LimitStates limitState, CalcTerms calcTerm) : this() + public DesignForceTuple(Guid id) { - LimitState = limitState; - CalcTerm = calcTerm; + Id = id; } - public DesignForceTuple() + public DesignForceTuple() : this (Guid.NewGuid()) { - ForceTuple = new ForceTuple(); } public object Clone() { - var newTuple = new DesignForceTuple(this.LimitState, this.CalcTerm); - newTuple.ForceTuple = this.ForceTuple.Clone() as ForceTuple; + var newTuple = new DesignForceTuple(); + updateStrategy.Update(newTuple, this); return newTuple; } } diff --git a/StructureHelperCommon/Models/Forces/Factories/DesignForceFactory.cs b/StructureHelperCommon/Models/Forces/Factories/DesignForceFactory.cs index dd0b830..7d7a81e 100644 --- a/StructureHelperCommon/Models/Forces/Factories/DesignForceFactory.cs +++ b/StructureHelperCommon/Models/Forces/Factories/DesignForceFactory.cs @@ -15,11 +15,11 @@ namespace StructureHelperCommon.Models.Forces { if (forceType == ForceType.Force_zero) { - return new DesignForceTuple(limitState, calcTerm); + return new DesignForceTuple() { LimitState = limitState, CalcTerm = calcTerm }; } else if (forceType == ForceType.Force_Mx50My50Nz100) { - var tuple = new DesignForceTuple(limitState, calcTerm); + var tuple = new DesignForceTuple() { LimitState = limitState, CalcTerm = calcTerm }; var forceTuple = tuple.ForceTuple; forceTuple.Mx = -50e3d; forceTuple.My = -50e3d; diff --git a/StructureHelperCommon/Models/Forces/ForceCombinationList.cs b/StructureHelperCommon/Models/Forces/ForceCombinationList.cs index a2f9d22..04a0dca 100644 --- a/StructureHelperCommon/Models/Forces/ForceCombinationList.cs +++ b/StructureHelperCommon/Models/Forces/ForceCombinationList.cs @@ -32,10 +32,26 @@ namespace StructureHelperCommon.Models.Forces ForcePoint = new Point2D() { X = 0, Y = 0 }; DesignForces = new List { - new DesignForceTuple(LimitStates.ULS, CalcTerms.ShortTerm), - new DesignForceTuple(LimitStates.ULS, CalcTerms.LongTerm), - new DesignForceTuple(LimitStates.SLS, CalcTerms.ShortTerm), - new DesignForceTuple(LimitStates.SLS, CalcTerms.LongTerm) + new DesignForceTuple() + { + LimitState = LimitStates.ULS, + CalcTerm = CalcTerms.ShortTerm + }, + new DesignForceTuple() + { + LimitState = LimitStates.ULS, + CalcTerm = CalcTerms.LongTerm + }, + new DesignForceTuple() + { + LimitState = LimitStates.SLS, + CalcTerm = CalcTerms.ShortTerm + }, + new DesignForceTuple() + { + LimitState = LimitStates.SLS, + CalcTerm = CalcTerms.LongTerm + } }; } public ForceCombinationList() : this (Guid.NewGuid()) { } diff --git a/StructureHelperCommon/Models/Forces/ForceTuple.cs b/StructureHelperCommon/Models/Forces/ForceTuple.cs index ab298b7..93deb91 100644 --- a/StructureHelperCommon/Models/Forces/ForceTuple.cs +++ b/StructureHelperCommon/Models/Forces/ForceTuple.cs @@ -1,5 +1,6 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Services.Forces; +using System; using System.ComponentModel.DataAnnotations; namespace StructureHelperCommon.Models.Forces @@ -9,6 +10,8 @@ namespace StructureHelperCommon.Models.Forces { private readonly IUpdateStrategy updateStrategy = new ForceTupleUpdateStrategy(); /// + public Guid Id { get; } + /// public double Mx { get; set; } /// public double My { get; set; } @@ -21,6 +24,16 @@ namespace StructureHelperCommon.Models.Forces /// public double Mz { get; set; } + public ForceTuple(Guid id) + { + Id = id; + } + + public ForceTuple() : this (Guid.NewGuid()) + { + + } + public void Clear() { Mx = 0d; diff --git a/StructureHelperCommon/Models/Forces/IDesignForceTuple.cs b/StructureHelperCommon/Models/Forces/IDesignForceTuple.cs index e2144d4..1413e5a 100644 --- a/StructureHelperCommon/Models/Forces/IDesignForceTuple.cs +++ b/StructureHelperCommon/Models/Forces/IDesignForceTuple.cs @@ -1,10 +1,11 @@ using System; using System.CodeDom; using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Interfaces; namespace StructureHelperCommon.Models.Forces { - public interface IDesignForceTuple : ICloneable + public interface IDesignForceTuple : ISaveable, ICloneable { LimitStates LimitState { get; set; } CalcTerms CalcTerm { get; set; } diff --git a/StructureHelperCommon/Models/Forces/IForceTuple.cs b/StructureHelperCommon/Models/Forces/IForceTuple.cs index 9acab6b..ea97cb1 100644 --- a/StructureHelperCommon/Models/Forces/IForceTuple.cs +++ b/StructureHelperCommon/Models/Forces/IForceTuple.cs @@ -1,11 +1,12 @@ -using System; +using StructureHelperCommon.Infrastructures.Interfaces; +using System; namespace StructureHelperCommon.Models.Forces { /// /// Interface for generic force for beams /// - public interface IForceTuple : ICloneable + public interface IForceTuple : ISaveable, ICloneable { /// /// Bending moment round about x-axis diff --git a/StructureHelperCommon/Models/Forces/Logics/ActionUpdateStrategy.cs b/StructureHelperCommon/Models/Forces/Logics/ActionUpdateStrategy.cs index 08f4cb5..855bd9c 100644 --- a/StructureHelperCommon/Models/Forces/Logics/ActionUpdateStrategy.cs +++ b/StructureHelperCommon/Models/Forces/Logics/ActionUpdateStrategy.cs @@ -14,9 +14,9 @@ namespace StructureHelperCommon.Models.Forces readonly IUpdateStrategy forceUpdateStrategy = new ForceActionUpdateStrategy(); public void Update(IAction targetObject, IAction sourceObject) { + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } - - CheckObject.CompareTypes(targetObject, sourceObject); targetObject.Name = sourceObject.Name; if (targetObject is IForceAction forceAction) { diff --git a/StructureHelperCommon/Models/Forces/Logics/DesignForceTupleUpdateStrategy.cs b/StructureHelperCommon/Models/Forces/Logics/DesignForceTupleUpdateStrategy.cs new file mode 100644 index 0000000..4914500 --- /dev/null +++ b/StructureHelperCommon/Models/Forces/Logics/DesignForceTupleUpdateStrategy.cs @@ -0,0 +1,38 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Forces.Logics +{ + public class DesignForceTupleUpdateStrategy : IUpdateStrategy + { + private IUpdateStrategy forceTupleUpdateStrategy; + + public DesignForceTupleUpdateStrategy(IUpdateStrategy forceTupleUpdateStrategy) + { + this.forceTupleUpdateStrategy = forceTupleUpdateStrategy; + } + + public DesignForceTupleUpdateStrategy() : this (new ForceTupleUpdateStrategy()) + { + + } + + public void Update(IDesignForceTuple targetObject, IDesignForceTuple sourceObject) + { + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.LimitState = sourceObject.LimitState; + targetObject.CalcTerm = sourceObject.CalcTerm; + if (sourceObject.ForceTuple is not null) + { + forceTupleUpdateStrategy.Update(targetObject.ForceTuple, sourceObject.ForceTuple); + } + } + } +} diff --git a/StructureHelperCommon/Models/Forces/Logics/ForceActionBaseUpdateStrategy.cs b/StructureHelperCommon/Models/Forces/Logics/ForceActionBaseUpdateStrategy.cs new file mode 100644 index 0000000..0403a78 --- /dev/null +++ b/StructureHelperCommon/Models/Forces/Logics/ForceActionBaseUpdateStrategy.cs @@ -0,0 +1,36 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Forces.Logics +{ + public class ForceActionBaseUpdateStrategy : IUpdateStrategy + { + private readonly IUpdateStrategy pointStrategy; + + public ForceActionBaseUpdateStrategy(IUpdateStrategy pointStrategy) + { + this.pointStrategy = pointStrategy; + } + + public ForceActionBaseUpdateStrategy() : this(new Point2DUpdateStrategy()) + { + + } + + public void Update(IForceAction targetObject, IForceAction sourceObject) + { + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.Name = sourceObject.Name; + targetObject.SetInGravityCenter = sourceObject.SetInGravityCenter; + pointStrategy.Update(targetObject.ForcePoint, sourceObject.ForcePoint); + } + } +} diff --git a/StructureHelperCommon/Models/Forces/Logics/ForceActionUpdateStrategy.cs b/StructureHelperCommon/Models/Forces/Logics/ForceActionUpdateStrategy.cs index 4eb209e..f13a345 100644 --- a/StructureHelperCommon/Models/Forces/Logics/ForceActionUpdateStrategy.cs +++ b/StructureHelperCommon/Models/Forces/Logics/ForceActionUpdateStrategy.cs @@ -8,21 +8,45 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models.Forces.Logics; namespace StructureHelperCommon.Models.Forces { public class ForceActionUpdateStrategy : IUpdateStrategy { - private readonly IUpdateStrategy pointStrategy = new Point2DUpdateStrategy(); - private readonly IUpdateStrategy forcePairUpdateStrategy = new ForcePairUpdateStrategy(); - private readonly IUpdateStrategy factorUpdateStrategy = new FactorCombinationUpdateStrategy(); - private readonly IUpdateStrategy forceListUpdateStrategy = new ForceCombinationListUpdateStrategy(); + private readonly IUpdateStrategy forceActionUpdateStrategy; + private readonly IUpdateStrategy forcePairUpdateStrategy; + private readonly IUpdateStrategy factorUpdateStrategy; + private readonly IUpdateStrategy forceListUpdateStrategy; + + public ForceActionUpdateStrategy( + IUpdateStrategy forceActionUpdateStrategy, + IUpdateStrategy forcePairUpdateStrategy, + IUpdateStrategy factorUpdateStrategy, + IUpdateStrategy forceListUpdateStrategy) + { + this.forceActionUpdateStrategy = forceActionUpdateStrategy; + this.forcePairUpdateStrategy = forcePairUpdateStrategy; + this.factorUpdateStrategy = factorUpdateStrategy; + this.forceListUpdateStrategy = forceListUpdateStrategy; + } + + public ForceActionUpdateStrategy() : this( + new ForceActionBaseUpdateStrategy(), + new ForcePairUpdateStrategy(), + new ForceCombinationByFactorUpdateStrategy(), + new ForceCombinationListUpdateStrategy() + ) + { + + } + public void Update(IForceAction targetObject, IForceAction sourceObject) { + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } - CheckObject.CompareTypes(targetObject, sourceObject); - targetObject.SetInGravityCenter = sourceObject.SetInGravityCenter; - pointStrategy.Update(targetObject.ForcePoint, sourceObject.ForcePoint); + forceActionUpdateStrategy.Update(targetObject, sourceObject); UpdateChildProperties(targetObject, sourceObject); } diff --git a/StructureHelperCommon/Models/Forces/Logics/FactorCombinationUpdateStrategy.cs b/StructureHelperCommon/Models/Forces/Logics/ForceCombinationByFactorUpdateStrategy.cs similarity index 69% rename from StructureHelperCommon/Models/Forces/Logics/FactorCombinationUpdateStrategy.cs rename to StructureHelperCommon/Models/Forces/Logics/ForceCombinationByFactorUpdateStrategy.cs index 6e17a50..427cd71 100644 --- a/StructureHelperCommon/Models/Forces/Logics/FactorCombinationUpdateStrategy.cs +++ b/StructureHelperCommon/Models/Forces/Logics/ForceCombinationByFactorUpdateStrategy.cs @@ -8,20 +8,21 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Models.Forces { - public class FactorCombinationUpdateStrategy : IUpdateStrategy + public class ForceCombinationByFactorUpdateStrategy : IUpdateStrategy { private IUpdateStrategy tupleUpdateStrategy; - public FactorCombinationUpdateStrategy(IUpdateStrategy tupleUpdateStrategy) + public ForceCombinationByFactorUpdateStrategy(IUpdateStrategy tupleUpdateStrategy) { this.tupleUpdateStrategy = tupleUpdateStrategy; } - public FactorCombinationUpdateStrategy() : this(new ForceTupleUpdateStrategy()) + public ForceCombinationByFactorUpdateStrategy() : this(new ForceTupleUpdateStrategy()) { } public void Update(IForceCombinationByFactor targetObject, IForceCombinationByFactor sourceObject) { - CheckObject.CompareTypes(targetObject, sourceObject); + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } tupleUpdateStrategy.Update(targetObject.FullSLSForces, sourceObject.FullSLSForces); targetObject.ULSFactor = sourceObject.ULSFactor; diff --git a/StructureHelperCommon/Models/Forces/Logics/ForceCombinationListUpdateStrategy.cs b/StructureHelperCommon/Models/Forces/Logics/ForceCombinationListUpdateStrategy.cs index 429bd5c..67021ce 100644 --- a/StructureHelperCommon/Models/Forces/Logics/ForceCombinationListUpdateStrategy.cs +++ b/StructureHelperCommon/Models/Forces/Logics/ForceCombinationListUpdateStrategy.cs @@ -1,4 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Forces.Logics; using StructureHelperCommon.Services; using System; using System.Collections.Generic; @@ -10,10 +11,22 @@ namespace StructureHelperCommon.Models.Forces { public class ForceCombinationListUpdateStrategy : IUpdateStrategy { + private IUpdateStrategy designForceTupleUpdateStrategy; + + public ForceCombinationListUpdateStrategy(IUpdateStrategy designForceTupleUpdateStrategy) + { + this.designForceTupleUpdateStrategy = designForceTupleUpdateStrategy; + } + + public ForceCombinationListUpdateStrategy() : this (new DesignForceTupleUpdateStrategy()) + { + + } + public void Update(IForceCombinationList targetObject, IForceCombinationList sourceObject) { + CheckObject.IsNull(targetObject, sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } - CheckObject.CompareTypes(targetObject, sourceObject); targetObject.DesignForces.Clear(); foreach (var item in sourceObject.DesignForces) { diff --git a/StructureHelperCommon/Models/Forces/StrainTuple.cs b/StructureHelperCommon/Models/Forces/StrainTuple.cs index 70b1f25..2cf8aa2 100644 --- a/StructureHelperCommon/Models/Forces/StrainTuple.cs +++ b/StructureHelperCommon/Models/Forces/StrainTuple.cs @@ -1,5 +1,6 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Services.Forces; +using System; namespace StructureHelperCommon.Models.Forces { @@ -8,6 +9,8 @@ namespace StructureHelperCommon.Models.Forces { private readonly IUpdateStrategy updateStrategy = new ForceTupleUpdateStrategy(); /// + public Guid Id { get; } + /// public double Mx { get; set; } /// public double My { get; set; } @@ -20,6 +23,16 @@ namespace StructureHelperCommon.Models.Forces /// public double Mz { get; set; } + public StrainTuple(Guid id) + { + Id = id; + } + + public StrainTuple() : this (Guid.NewGuid()) + { + + } + public void Clear() { Mx = 0d; diff --git a/StructureHelperLogics/Models/Materials/ElasticMaterial.cs b/StructureHelperLogics/Models/Materials/ElasticMaterial.cs index 9af1244..e3145fb 100644 --- a/StructureHelperLogics/Models/Materials/ElasticMaterial.cs +++ b/StructureHelperLogics/Models/Materials/ElasticMaterial.cs @@ -16,7 +16,7 @@ namespace StructureHelperLogics.Models.Materials public double Modulus { get; set; } public double CompressiveStrength { get; set; } public double TensileStrength { get; set; } - public List SafetyFactors { get; } = new(); + public List SafetyFactors { get; set; } = new(); public Guid Id { get; } diff --git a/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs b/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs index 5a65a14..380b550 100644 --- a/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs +++ b/StructureHelperLogics/Models/Materials/FRMaterials/FRMaterial.cs @@ -21,7 +21,7 @@ namespace StructureHelperLogics.Models.Materials public double CompressiveStrength { get; set; } public double TensileStrength { get; set; } - public List SafetyFactors { get; } = new(); + public List SafetyFactors { get; set; } = new(); public double ULSConcreteStrength { get; set; } public double SumThickness { get; set; } public double GammaF2 => GetGammaF2(); diff --git a/StructureHelperLogics/Models/Materials/IElasticMaterial.cs b/StructureHelperLogics/Models/Materials/IElasticMaterial.cs index 0448070..28bdf41 100644 --- a/StructureHelperLogics/Models/Materials/IElasticMaterial.cs +++ b/StructureHelperLogics/Models/Materials/IElasticMaterial.cs @@ -12,6 +12,5 @@ namespace StructureHelperLogics.Models.Materials double Modulus { get; set; } double CompressiveStrength { get; set; } double TensileStrength { get; set; } - List SafetyFactors { get; } } } diff --git a/StructureHelperLogics/Models/Materials/IHelperMaterial.cs b/StructureHelperLogics/Models/Materials/IHelperMaterial.cs index 9f0a851..e82cf06 100644 --- a/StructureHelperLogics/Models/Materials/IHelperMaterial.cs +++ b/StructureHelperLogics/Models/Materials/IHelperMaterial.cs @@ -1,6 +1,7 @@ using LoaderCalculator.Data.Materials; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Materials.Libraries; using StructureHelperLogics.Models.Materials; using System; using System.Collections.Generic; @@ -12,5 +13,6 @@ namespace StructureHelperLogics.Models.Materials { IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm); IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm); + List SafetyFactors { get; set; } } } diff --git a/StructureHelperLogics/Models/Materials/ILibMaterial.cs b/StructureHelperLogics/Models/Materials/ILibMaterial.cs index 2674963..05f6c8c 100644 --- a/StructureHelperLogics/Models/Materials/ILibMaterial.cs +++ b/StructureHelperLogics/Models/Materials/ILibMaterial.cs @@ -11,7 +11,6 @@ namespace StructureHelperLogics.Models.Materials public interface ILibMaterial : IHelperMaterial { ILibMaterialEntity MaterialEntity { get; set; } - List SafetyFactors { get; set; } IMaterialLogic MaterialLogic { get; set; } List MaterialLogics { get; } (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm); diff --git a/StructureHelperLogics/Models/Materials/Logics/ElasticUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/ElasticUpdateStrategy.cs index 8dfda6d..b5f2741 100644 --- a/StructureHelperLogics/Models/Materials/Logics/ElasticUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Materials/Logics/ElasticUpdateStrategy.cs @@ -9,11 +9,12 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.Materials { - internal class ElasticUpdateStrategy : IUpdateStrategy + public class ElasticUpdateStrategy : IUpdateStrategy { public void Update(IElasticMaterial targetObject, IElasticMaterial sourceObject) { - CheckObject.CompareTypes(targetObject, sourceObject); + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.Modulus = sourceObject.Modulus; targetObject.CompressiveStrength = sourceObject.CompressiveStrength; diff --git a/StructureHelperLogics/Models/Materials/Logics/FRUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/FRUpdateStrategy.cs index df4bccf..220d58d 100644 --- a/StructureHelperLogics/Models/Materials/Logics/FRUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Materials/Logics/FRUpdateStrategy.cs @@ -9,11 +9,14 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.Materials { - internal class FRUpdateStrategy : IUpdateStrategy + /// + public class FRUpdateStrategy : IUpdateStrategy { + /// public void Update(IFRMaterial targetObject, IFRMaterial sourceObject) { - CheckObject.ReferenceEquals(targetObject, sourceObject); + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.Modulus = sourceObject.Modulus; targetObject.CompressiveStrength = sourceObject.CompressiveStrength; diff --git a/StructureHelperLogics/Models/Materials/Logics/HelperMaterialSafetyFactorsUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/HelperMaterialSafetyFactorsUpdateStrategy.cs new file mode 100644 index 0000000..dfd32ad --- /dev/null +++ b/StructureHelperLogics/Models/Materials/Logics/HelperMaterialSafetyFactorsUpdateStrategy.cs @@ -0,0 +1,33 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Materials.Libraries; +using StructureHelperCommon.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.Materials.Logics +{ + public class HelpermaterialSafetyFactorsUpdateStrategy : IUpdateStrategy + { + public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject) + { + CheckObject.IsNull(sourceObject); + CheckObject.IsNull(targetObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + if (sourceObject.SafetyFactors is not null) + { + if (targetObject.SafetyFactors is null) + { + targetObject.SafetyFactors = new(); + } + targetObject.SafetyFactors.Clear(); + foreach (var item in sourceObject.SafetyFactors) + { + targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor); + } + } + } + } +} diff --git a/StructureHelperLogics/Models/Materials/Logics/HelperMaterialUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/HelperMaterialUpdateStrategy.cs index 3a3c1a5..6cf10f6 100644 --- a/StructureHelperLogics/Models/Materials/Logics/HelperMaterialUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Materials/Logics/HelperMaterialUpdateStrategy.cs @@ -1,6 +1,8 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Materials.Libraries; using StructureHelperCommon.Services; +using StructureHelperLogics.Models.Materials.Logics; using System; using System.Collections.Generic; using System.Linq; @@ -15,6 +17,7 @@ namespace StructureHelperLogics.Models.Materials private IUpdateStrategy frStrategy; private IUpdateStrategy concreteStrategy; private IUpdateStrategy reinforcementStrategy; + private IUpdateStrategy safetyFactorUpdateStrategy = new HelpermaterialSafetyFactorsUpdateStrategy(); public HelperMaterialUpdateStrategy(IUpdateStrategy elasticStrategy, IUpdateStrategy frStrategy, IUpdateStrategy concreteStrategy, @@ -38,6 +41,8 @@ namespace StructureHelperLogics.Models.Materials { CheckObject.IsNull(sourceObject); CheckObject.IsNull(targetObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + safetyFactorUpdateStrategy.Update(targetObject, sourceObject); if (sourceObject is ILibMaterial) { UpdateLibMaterial(targetObject, sourceObject); diff --git a/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs index 7695258..843919d 100644 --- a/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs +++ b/StructureHelperLogics/Models/Materials/Logics/LibMaterialUpdateStrategy.cs @@ -17,18 +17,6 @@ namespace StructureHelperLogics.Models.Materials CheckObject.IsNull(targetObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.MaterialEntity = sourceObject.MaterialEntity; - if (sourceObject.SafetyFactors is not null) - { - if (targetObject.SafetyFactors is null) - { - targetObject.SafetyFactors = new(); - } - targetObject.SafetyFactors.Clear(); - foreach (var item in sourceObject.SafetyFactors) - { - targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor); - } - } targetObject.MaterialLogic = sourceObject.MaterialLogic; } diff --git a/StructureHelperLogics/Models/Templates/CrossSections/RCs/CircleGeometryLogic.cs b/StructureHelperLogics/Models/Templates/CrossSections/RCs/CircleGeometryLogic.cs index 03868b7..e2be21a 100644 --- a/StructureHelperLogics/Models/Templates/CrossSections/RCs/CircleGeometryLogic.cs +++ b/StructureHelperLogics/Models/Templates/CrossSections/RCs/CircleGeometryLogic.cs @@ -35,7 +35,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs var diameter = template.Shape.Diameter; var concreteMaterial = HeadMaterials.ToList()[0]; var primitives = new List(); - concreteBlock = new EllipsePrimitive() { DiameterByX = diameter, Name = "Concrete block"}; + concreteBlock = new EllipsePrimitive() { Width = diameter, Name = "Concrete block"}; concreteBlock.NdmElement.HeadMaterial = concreteMaterial; primitives.Add(concreteBlock); return primitives; diff --git a/StructureHelperLogics/NdmCalculations/Primitives/EllipsePrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/EllipsePrimitive.cs index a1b2e8d..952ddb9 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/EllipsePrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/EllipsePrimitive.cs @@ -23,7 +23,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives /// public IVisualProperty VisualProperty { get; } = new VisualProperty { Opacity = 0.8d }; /// - public double DiameterByX + public double Width { get { @@ -36,7 +36,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives } } /// - public double DiameterByY { get => rectangleShape.Height; set => rectangleShape.Height = value; } + public double Height { get => rectangleShape.Height; set => rectangleShape.Height = value; } /// public ICrossSection? CrossSection { get; set; } /// @@ -46,6 +46,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives /// public IShape Shape => rectangleShape; + public double Angle { get; set; } public EllipsePrimitive(Guid id) { @@ -78,7 +79,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives var dX = Center.X - point.X; var dY = Center.Y - point.Y; var distance = Math.Sqrt(dX * dX + dY * dY); - if (distance > DiameterByX / 2) { return false; } + if (distance > Width / 2) { return false; } return true; } @@ -96,28 +97,28 @@ namespace StructureHelperLogics.NdmCalculations.Primitives newPoint = new NamedAreaPoint { Name = "Left", - Point = new Point2D() { X = Center.X - DiameterByX / 2d, Y = Center.Y}, + Point = new Point2D() { X = Center.X - Width / 2d, Y = Center.Y}, Area = 0d }; points.Add(newPoint); newPoint = new NamedAreaPoint { Name = "Top", - Point = new Point2D() { X = Center.X, Y = Center.Y + DiameterByX / 2d }, + Point = new Point2D() { X = Center.X, Y = Center.Y + Width / 2d }, Area = 0d }; points.Add(newPoint); newPoint = new NamedAreaPoint { Name = "Right", - Point = new Point2D() { X = Center.X + DiameterByX / 2d, Y = Center.Y }, + Point = new Point2D() { X = Center.X + Width / 2d, Y = Center.Y }, Area = 0d }; points.Add(newPoint); newPoint = new NamedAreaPoint { Name = "Bottom", - Point = new Point2D() { X = Center.X, Y = Center.Y - DiameterByX / 2d }, + Point = new Point2D() { X = Center.X, Y = Center.Y - Width / 2d }, Area = 0d }; points.Add(newPoint); diff --git a/StructureHelperLogics/NdmCalculations/Primitives/IEllipsePrimitive.cs b/StructureHelperLogics/NdmCalculations/Primitives/IEllipsePrimitive.cs index 6514816..38a127f 100644 --- a/StructureHelperLogics/NdmCalculations/Primitives/IEllipsePrimitive.cs +++ b/StructureHelperLogics/NdmCalculations/Primitives/IEllipsePrimitive.cs @@ -7,10 +7,9 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Primitives { - public interface IEllipsePrimitive : INdmPrimitive, IHasDivisionSize + public interface IEllipsePrimitive : INdmPrimitive, IHasDivisionSize, IRectangleShape { - double DiameterByX { get; set; } - double DiameterByY { get; set; } + } } diff --git a/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogicOptions.cs b/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogicOptions.cs index a17f673..7c5a944 100644 --- a/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogicOptions.cs +++ b/StructureHelperLogics/NdmCalculations/Triangulations/CircleTriangulationLogicOptions.cs @@ -29,7 +29,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations { Center = primitive.Center.Clone() as Point2D; //to do change to ellipse - Circle = new CircleShape() { Diameter = primitive.DiameterByX }; + Circle = new CircleShape() { Diameter = primitive.Width }; NdmMaxSize = primitive.DivisionSize.NdmMaxSize; NdmMinDivision = primitive.DivisionSize.NdmMinDivision; HeadMaterial = primitive.NdmElement.HeadMaterial; diff --git a/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs b/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs index ef73b4e..d0b5106 100644 --- a/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs +++ b/StructureHelperTests/UnitTests/Ndms/Triangulations/RectangleTriangulationTest.cs @@ -120,7 +120,7 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations mainBlock.VisualProperty.ZIndex = 0; var opening = new EllipsePrimitive() { - DiameterByX = 0.3d + Width = 0.3d }; opening.DivisionSize.ClearUnderlying = true; opening.NdmElement.HeadMaterial = material; @@ -155,7 +155,7 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations //Arrange ProgramSetting.NatSystem = NatSystems.RU; var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40); - var mainBlock = new EllipsePrimitive() { DiameterByX = diameter}; + var mainBlock = new EllipsePrimitive() { Width = diameter}; mainBlock.NdmElement.HeadMaterial = material; mainBlock.Center.X = centerX; mainBlock.Center.Y = centerY;