Add beam shear converting to DTO

This commit is contained in:
Evgeny Redikultsev
2025-06-08 15:49:17 +05:00
parent 3dab65e3bd
commit 0d7f47653b
150 changed files with 710 additions and 259 deletions

View File

@@ -36,13 +36,13 @@ namespace DataAccess.DTOs
private void GetNewBeamAction(IBeamShearAction source)
{
TraceLogger?.AddMessage($"Converting of beam shear action Id = {source.Id} has been started", TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Beam shear action converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.ExternalForce = factoredTupleConvertStrategy.Convert(source.ExternalForce);
NewItem.SupportAction = axisActionConvertStrategy.Convert(source.SupportAction);
TraceLogger?.AddMessage($"Converting of beam shear action Id = {NewItem.Id} has been finished", TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Beam shear action converting Id = {NewItem.Id} has been finished", TraceLogStatuses.Debug);
}
private void InitializeStrategies()

View File

@@ -0,0 +1,50 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class BeamShearCalculatorInputDataToDTOConvertStrategy : ConvertStrategy<BeamShearCalculatorInputDataDTO, IBeamShearCalculatorInputData>
{
private IUpdateStrategy<IHasBeamShearActions> actionUpdateStrategy;
private IUpdateStrategy<IHasBeamShearSections> sectionUpdateStrategy;
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
public BeamShearCalculatorInputDataToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override BeamShearCalculatorInputDataDTO GetNewItem(IBeamShearCalculatorInputData source)
{
try
{
GetNewInputData(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewInputData(IBeamShearCalculatorInputData source)
{
TraceLogger?.AddMessage($"Input data converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
InitializeStrategies();
NewItem = new(source.Id);
actionUpdateStrategy.Update(NewItem, source);
sectionUpdateStrategy.Update(NewItem, source);
stirrupUpdateStrategy.Update(NewItem, source);
TraceLogger?.AddMessage($"Input data converting Id = {NewItem.Id} has been finished", TraceLogStatuses.Debug);
}
private void InitializeStrategies()
{
actionUpdateStrategy ??= new HasBeamShearActionToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
sectionUpdateStrategy ??= new HasBeamShearSectionToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
stirrupUpdateStrategy ??= new HasStirrupToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
}
}
}

View File

@@ -0,0 +1,48 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class BeamShearCalculatorToDTOConvertStrategy : ConvertStrategy<BeamShearCalculatorDTO, IBeamShearCalculator>
{
private IUpdateStrategy<IBeamShearCalculator> updateStrategy;
private IConvertStrategy<BeamShearCalculatorInputDataDTO, IBeamShearCalculatorInputData> inputDataConvertStrategy;
public BeamShearCalculatorToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger)
{
}
public override BeamShearCalculatorDTO GetNewItem(IBeamShearCalculator source)
{
try
{
GetNewCalculator(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewCalculator(IBeamShearCalculator source)
{
TraceLogger?.AddMessage($"Beam shear calculator converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.InputData = inputDataConvertStrategy.Convert(source.InputData);
TraceLogger?.AddMessage($"Beam shear calculator converting Id = {NewItem.Id} has been finished successfully", TraceLogStatuses.Debug);
}
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearCalculatorUpdateStrategy();
inputDataConvertStrategy = new DictionaryConvertStrategy<BeamShearCalculatorInputDataDTO, IBeamShearCalculatorInputData>
(this, new BeamShearCalculatorInputDataToDTOConvertStrategy(this));
}
}
}

View File

@@ -1,6 +1,7 @@
using DataAccess.DTOs.Converters;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using StructureHelperLogics.Models.BeamShears;
@@ -14,6 +15,8 @@ namespace DataAccess.DTOs
{
private IUpdateStrategy<IHasBeamShearActions> actionUpdateStrategy;
private IUpdateStrategy<IHasBeamShearSections> sectionUpdateStrategy;
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
private IUpdateStrategy<IHasCalculators> calculatorUpdateStrategy;
public BeamShearRepositoryToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
{
@@ -40,6 +43,8 @@ namespace DataAccess.DTOs
NewItem = new(source.Id);
actionUpdateStrategy.Update(NewItem, source);
sectionUpdateStrategy.Update(NewItem, source);
stirrupUpdateStrategy.Update(NewItem, source);
calculatorUpdateStrategy.Update(NewItem, source);
TraceLogger?.AddMessage($"Converting of beam shear repository Id = {NewItem.Id} has been finished", TraceLogStatuses.Service);
}
@@ -47,7 +52,9 @@ namespace DataAccess.DTOs
private void InitializeStrategies()
{
actionUpdateStrategy ??= new HasBeamShearActionToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
sectionUpdateStrategy ??= new HasBeamShearSectionConvertStrategy(ReferenceDictionary, TraceLogger);
sectionUpdateStrategy ??= new HasBeamShearSectionToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
stirrupUpdateStrategy ??= new HasStirrupToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
calculatorUpdateStrategy ??= new HasBeamShearCalculatorToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
}
}
}

View File

@@ -0,0 +1,58 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class BeamShearSectionToDTOConvertStrategy : ConvertStrategy<BeamShearSectionDTO, IBeamShearSection>
{
private IUpdateStrategy<IBeamShearSection> updateStrategy;
private IConvertStrategy<IShape, IShape> shapeConvertStrategy;
private ConcreteLibMaterialToDTOConvertStrategy concreteConvertStrategy;
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy;
public BeamShearSectionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger)
{
}
public override BeamShearSectionDTO GetNewItem(IBeamShearSection source)
{
try
{
GetNewSection(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewSection(IBeamShearSection source)
{
TraceLogger?.AddMessage($"Beam shear section converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.Shape = shapeConvertStrategy.Convert(source.Shape);
NewItem.Material = concreteConvertStrategy.Convert(source.Material);
safetyFactorUpdateStrategy.Update(NewItem.Material, source.Material);
TraceLogger?.AddMessage($"Beam shear section converting Id = {NewItem.Id} has been finished succesfully", TraceLogStatuses.Debug);
}
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearSectionUpdateStrategy();
shapeConvertStrategy = new DictionaryConvertStrategy<IShape, IShape>
(this, new ShapeToDTOConvertStrategy(this));
concreteConvertStrategy = new ConcreteLibMaterialToDTOConvertStrategy()
{ ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger};
safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic());
}
}
}

View File

@@ -1,13 +1,7 @@
using DataAccess.DTOs.DTOEntities;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
@@ -29,7 +23,6 @@ namespace DataAccess.DTOs
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewBeamAction(IBeamSpanLoad source)

View File

@@ -2,11 +2,6 @@
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{

View File

@@ -0,0 +1,64 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class HasBeamShearCalculatorToDTOConvertStrategy : IUpdateStrategy<IHasCalculators>
{
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
private IShiftTraceLogger traceLogger;
public HasBeamShearCalculatorToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{
this.referenceDictionary = referenceDictionary;
this.traceLogger = traceLogger;
}
public void Update(IHasCalculators targetObject, IHasCalculators sourceObject)
{
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.IsNull(sourceObject.Calculators);
CheckObject.IsNull(targetObject.Calculators);
targetObject.Calculators.Clear();
List<ICalculator> calculators = GetCalculators(sourceObject.Calculators);
targetObject.Calculators.AddRange(calculators);
}
private List<ICalculator> GetCalculators(IEnumerable<ICalculator> sourceCalculators)
{
List<ICalculator> calculators = new();
foreach (var calculator in sourceCalculators)
{
ICalculator newCalculator = ProcessCalculator(calculator);
calculators.Add(newCalculator);
}
return calculators;
}
private ICalculator ProcessCalculator(ICalculator calculator)
{
if (calculator is IBeamShearCalculator shearCalculator)
{
return ProcessShearCalculator(shearCalculator);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(calculator));
}
}
private ICalculator ProcessShearCalculator(IBeamShearCalculator shearCalculator)
{
traceLogger?.AddMessage("Calcultor is beam shear calculator", TraceLogStatuses.Debug);
var convertStrategy = new DictionaryConvertStrategy<BeamShearCalculatorDTO, IBeamShearCalculator>
(referenceDictionary, traceLogger, new BeamShearCalculatorToDTOConvertStrategy(referenceDictionary, traceLogger));
return convertStrategy.Convert(shearCalculator);
}
}
}

View File

@@ -5,11 +5,13 @@ using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class HasBeamShearSectionConvertStrategy : IUpdateStrategy<IHasBeamShearSections>
public class HasBeamShearSectionToDTOConvertStrategy : IUpdateStrategy<IHasBeamShearSections>
{
private IConvertStrategy<BeamShearSectionDTO, IBeamShearSection> convertStrategy;
private Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; }
private IShiftTraceLogger TraceLogger { get; }
public HasBeamShearSectionConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
public HasBeamShearSectionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{
ReferenceDictionary = referenceDictionary;
TraceLogger = traceLogger;
@@ -22,7 +24,19 @@ namespace DataAccess.DTOs
if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.IsNull(sourceObject.Sections);
CheckObject.IsNull(targetObject.Sections);
InitializeStrategies();
targetObject.Sections.Clear();
foreach (var section in sourceObject.Sections)
{
var newSection = convertStrategy.Convert(section);
targetObject.Sections.Add(newSection);
}
}
private void InitializeStrategies()
{
convertStrategy = new DictionaryConvertStrategy<BeamShearSectionDTO, IBeamShearSection>
(ReferenceDictionary, TraceLogger, new BeamShearSectionToDTOConvertStrategy(ReferenceDictionary, TraceLogger));
}
}
}

View File

@@ -0,0 +1,84 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.BeamShears;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace DataAccess.DTOs
{
public class HasStirrupToDTOConvertStrategy : IUpdateStrategy<IHasStirrups>
{
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
private IShiftTraceLogger traceLogger;
public HasStirrupToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{
this.referenceDictionary = referenceDictionary;
this.traceLogger = traceLogger;
}
public void Update(IHasStirrups targetObject, IHasStirrups sourceObject)
{
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.IsNull(sourceObject.Stirrups);
CheckObject.IsNull(targetObject.Stirrups);
targetObject.Stirrups.Clear();
List<IStirrup> stirrups = GetStirrups(sourceObject.Stirrups);
targetObject.Stirrups.AddRange(stirrups);
}
private List<IStirrup> GetStirrups(IEnumerable<IStirrup> sourceStirrups)
{
List<IStirrup> stirrups = new();
foreach (var stirrup in sourceStirrups)
{
IStirrup newItem = ProcessStirrup(stirrup);
stirrups.Add(newItem);
}
return stirrups;
}
private IStirrup ProcessStirrup(IStirrup stirrup)
{
IStirrup newItem;
if (stirrup is IStirrupByRebar rebar)
{
newItem = ProcessRebar(rebar);
}
else if (stirrup is IStirrupByDensity density)
{
newItem = ProcessDensity(density);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrup));
}
return newItem;
}
private IStirrup ProcessDensity(IStirrupByDensity density)
{
traceLogger?.AddMessage("Stirrup is stirrup by density");
var convertStrategy = new DictionaryConvertStrategy<StirrupByDensityDTO, IStirrupByDensity>
(referenceDictionary, traceLogger, new StirrupByDensityToDTOConvertStrategy(referenceDictionary, traceLogger));
return convertStrategy.Convert(density);
}
private StirrupByRebarDTO ProcessRebar(IStirrupByRebar rebar)
{
traceLogger?.AddMessage("Stirrup is stirrup by rebar");
var convertStrategy = new DictionaryConvertStrategy<StirrupByRebarDTO, IStirrupByRebar>
(referenceDictionary, traceLogger, new StirrupByRebarToDTOConvertStrategy(referenceDictionary, traceLogger));
return convertStrategy.Convert(rebar);
}
}
}

View File

@@ -0,0 +1,44 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class StirrupByDensityToDTOConvertStrategy : ConvertStrategy<StirrupByDensityDTO, IStirrupByDensity>
{
private IUpdateStrategy<IStirrupByDensity> updateStrategy;
public StirrupByDensityToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger)
{
}
public override StirrupByDensityDTO GetNewItem(IStirrupByDensity source)
{
try
{
GetNewStirrup(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewStirrup(IStirrupByDensity source)
{
TraceLogger?.AddMessage($"Stirrup by density converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
TraceLogger?.AddMessage($"Stirrup by density converting Id = {NewItem.Id} has been finished succesfully", TraceLogStatuses.Debug);
}
private void InitializeStrategies()
{
updateStrategy ??= new StirrupByDensityUpdateStrategy();
}
}
}

View File

@@ -0,0 +1,54 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class StirrupByRebarToDTOConvertStrategy : ConvertStrategy<StirrupByRebarDTO, IStirrupByRebar>
{
private StirrupByRebarUpdateStrategy updateStrategy;
private ReinforcementLibMaterialToDTOConvertStrategy reinforcementConvertStrategy;
private HelperMaterialDTOSafetyFactorUpdateStrategy safetyFactorUpdateStrategy;
public StirrupByRebarToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger)
{
}
public override StirrupByRebarDTO GetNewItem(IStirrupByRebar source)
{
try
{
GetNewStirrup(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewStirrup(IStirrupByRebar source)
{
TraceLogger?.AddMessage($"Stirrup by density converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.Material = reinforcementConvertStrategy.Convert(source.Material);
safetyFactorUpdateStrategy.Update(NewItem.Material, source.Material);
TraceLogger?.AddMessage($"Stirrup by density converting Id = {NewItem.Id} has been finished succesfully", TraceLogStatuses.Debug);
}
private void InitializeStrategies()
{
updateStrategy ??= new StirrupByRebarUpdateStrategy();
reinforcementConvertStrategy = new ReinforcementLibMaterialToDTOConvertStrategy()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic());
}
}
}

View File

@@ -1,15 +1,11 @@
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<ConcreteLibMaterialDTO, IConcreteLibMaterial>
{
public override IUpdateStrategy<IConcreteLibMaterial> UpdateStrategy { get; } = new ConcreteLibUpdateStrategy();
public override ConcreteLibMaterialDTO GetMaterialDTO(IConcreteLibMaterial source)

View File

@@ -1,17 +1,9 @@
using DataAccess.DTOs.Converters;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.Models.Materials.Logics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{

View File

@@ -1,11 +1,6 @@
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
{

View File

@@ -40,7 +40,7 @@ namespace DataAccess.DTOs
public EllipseNdmPrimitiveToDTOConvertStrategy() : this(
new EllipsePrimitiveUpdateStrategy(),
new RectangleShapeToDTOConvertStrategy(),
new NdmElementDTOConvertStrategy(),
new NdmElementToDTOConvertStrategy(),
new Point2DToDTOConvertStrategy(),
new VisualPropertyToDTOConvertStrategy(),
new DivisionSizeToDTOConvertStrategy()

View File

@@ -42,7 +42,7 @@ namespace DataAccess.DTOs
private void GetNewItemBySource(IForceCalculator source)
{
NewItem = new() { Id = source.Id};
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.InputData = inputDataConvertStrategy.Convert(source.InputData);
}

View File

@@ -9,13 +9,13 @@ using StructureHelperLogics.NdmCalculations.Primitives.Logics;
namespace DataAccess.DTOs
{
public class NdmElementDTOConvertStrategy : IConvertStrategy<NdmElementDTO, INdmElement>
public class NdmElementToDTOConvertStrategy : IConvertStrategy<NdmElementDTO, INdmElement>
{
private IUpdateStrategy<INdmElement> updateStrategy;
private IConvertStrategy<HeadMaterialDTO, IHeadMaterial> headMaterialConvertStrategy;
private IUpdateStrategy<IForceTuple> forceUpdateStrategy = new ForceTupleUpdateStrategy();
public NdmElementDTOConvertStrategy(
public NdmElementToDTOConvertStrategy(
IUpdateStrategy<INdmElement> updateStrategy,
IConvertStrategy<HeadMaterialDTO, IHeadMaterial> headMaterialConvertStrategy)
{
@@ -23,7 +23,7 @@ namespace DataAccess.DTOs
this.headMaterialConvertStrategy = headMaterialConvertStrategy;
}
public NdmElementDTOConvertStrategy() : this(
public NdmElementToDTOConvertStrategy() : this(
new NdmElementUpdateStrategy(),
new HeadMaterialToDTOConvertStrategy())
{
@@ -50,7 +50,7 @@ namespace DataAccess.DTOs
private NdmElementDTO GenNewNdmElementDTO(INdmElement source)
{
NdmElementDTO newItem = new() { Id = source.Id };
NdmElementDTO newItem = new(source.Id);
updateStrategy.Update(newItem, source);
headMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
headMaterialConvertStrategy.TraceLogger = TraceLogger;

View File

@@ -33,7 +33,7 @@ namespace DataAccess.DTOs
public PointNdmPrimitiveToDTOConvertStrategy() : this(
new PointNdmPrimitiveUpdateStrategy(),
new NdmElementDTOConvertStrategy(),
new NdmElementToDTOConvertStrategy(),
new Point2DToDTOConvertStrategy(),
new VisualPropertyToDTOConvertStrategy()
) { }

View File

@@ -29,7 +29,7 @@ namespace DataAccess.DTOs
public RebarNdmPrimitiveToDTOConvertStrategy() : this(
new RebarNdmPrimitiveUpdateStrategy(),
new NdmElementDTOConvertStrategy(),
new NdmElementToDTOConvertStrategy(),
new Point2DToDTOConvertStrategy(),
new VisualPropertyToDTOConvertStrategy()
) { }

View File

@@ -39,7 +39,7 @@ namespace DataAccess.DTOs.Converters
public RectangleNdmPrimitiveToDTOConvertStrategy() : this(
new RectanglePrimitiveUpdateStrategy(),
new RectangleShapeToDTOConvertStrategy(),
new NdmElementDTOConvertStrategy(),
new NdmElementToDTOConvertStrategy(),
new Point2DToDTOConvertStrategy(),
new VisualPropertyToDTOConvertStrategy(),
new DivisionSizeToDTOConvertStrategy()

View File

@@ -0,0 +1,48 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
namespace DataAccess.DTOs
{
public class RectangleShapeToDTOConvertStrategy : ConvertStrategy<RectangleShapeDTO, IRectangleShape>
{
private IUpdateStrategy<IRectangleShape> updateStrategy;
public RectangleShapeToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public RectangleShapeToDTOConvertStrategy()
{
}
public override RectangleShapeDTO GetNewItem(IRectangleShape source)
{
try
{
GetNewRectangleShape(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewRectangleShape(IRectangleShape source)
{
TraceLogger?.AddMessage($"Rectangle shape converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
TraceLogger?.AddMessage($"Rectangle shape converting Id = {NewItem.Id} has been finished successfully", TraceLogStatuses.Debug);
}
private void InitializeStrategies()
{
updateStrategy ??= new RectangleShapeUpdateStrategy();
}
}
}

View File

@@ -1,31 +0,0 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
namespace DataAccess.DTOs
{
public class RectangleShapeToDTOConvertStrategy : IConvertStrategy<RectangleShapeDTO, IRectangleShape>
{
private IUpdateStrategy<IRectangleShape> updateStrategy;
public RectangleShapeToDTOConvertStrategy(IUpdateStrategy<IRectangleShape> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public RectangleShapeToDTOConvertStrategy() : this (new RectangleShapeUpdateStrategy())
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public RectangleShapeDTO Convert(IRectangleShape source)
{
RectangleShapeDTO newItem = new() { Id = source.Id};
updateStrategy.Update(newItem, source);
return newItem;
}
}
}

View File

@@ -0,0 +1,55 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
using System.Windows.Forms;
namespace DataAccess.DTOs
{
public class ShapeToDTOConvertStrategy : ConvertStrategy<IShape, IShape>
{
private IConvertStrategy<RectangleShapeDTO, IRectangleShape> rectangleConvertStrategy;
public ShapeToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override IShape GetNewItem(IShape source)
{
try
{
GetNewShape(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewShape(IShape source)
{
TraceLogger?.AddMessage($"Shape converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
if (source is IRectangleShape rectangle)
{
ProcessRectangle(rectangle);
}
else
{
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape type";
throw new StructureHelperException(errorString);
}
TraceLogger?.AddMessage($"Shape converting Id = {NewItem.Id} has been has been finished successfully", TraceLogStatuses.Debug);
}
private void ProcessRectangle(IRectangleShape rectangle)
{
TraceLogger?.AddMessage($"Shape is rectangle", TraceLogStatuses.Debug);
rectangleConvertStrategy = new DictionaryConvertStrategy<RectangleShapeDTO, IRectangleShape>
(this, new RectangleShapeToDTOConvertStrategy(this));
NewItem = rectangleConvertStrategy.Convert(rectangle);
}
}
}

View File

@@ -6,16 +6,16 @@ using StructureHelperLogics.Models.BeamShears;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace DataAccess.DTOs.DTOEntities
namespace DataAccess.DTOs
{
internal class BeamShearCalculatorDTO : IBeamShearCalculator
public class BeamShearCalculatorDTO : IBeamShearCalculator
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("Name")]
public string Name { get; set; } = string.Empty;
[JsonProperty("InputData")]
public IBeamShearCalculatorInputData InputData { get; set; }
public IBeamShearCalculatorInputData InputData { get; set; } = new BeamShearCalculatorInputDataDTO(Guid.Empty);
[JsonProperty("ShowTraceData")]
public bool ShowTraceData { get; set; }
[JsonIgnore]

View File

@@ -2,9 +2,9 @@
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs.DTOEntities
namespace DataAccess.DTOs
{
internal class BeamShearCalculatorInputDataDTO : IBeamShearCalculatorInputData
public class BeamShearCalculatorInputDataDTO : IBeamShearCalculatorInputData
{
[JsonProperty("Id")]
public Guid Id { get; }
@@ -14,5 +14,9 @@ namespace DataAccess.DTOs.DTOEntities
public List<IBeamShearSection> Sections { get; } = new();
[JsonProperty("Stirrups")]
public List<IStirrup> Stirrups { get; } = new();
public BeamShearCalculatorInputDataDTO(Guid id)
{
Id = id;
}
}
}

View File

@@ -11,12 +11,12 @@ namespace DataAccess.DTOs
public Guid Id { get; }
[JsonProperty("Actions")]
public List<IBeamShearAction> Actions { get; } = new();
[JsonProperty("Calculators")]
public List<ICalculator> Calculators { get; } = new();
[JsonProperty("Sections")]
public List<IBeamShearSection> Sections { get; } = new();
[JsonProperty("Stirrups")]
public List<IStirrup> Stirrups { get; } = new();
[JsonProperty("Calculators")]
public List<ICalculator> Calculators { get; } = new();
public BeamShearRepositoryDTO(Guid id)
{
Id = id;

View File

@@ -6,7 +6,7 @@ using StructureHelperLogics.Models.Materials;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace DataAccess.DTOs.DTOEntities
namespace DataAccess.DTOs
{
public class BeamShearSectionDTO : IBeamShearSection
{
@@ -15,7 +15,7 @@ namespace DataAccess.DTOs.DTOEntities
[JsonProperty("Name")]
public string? Name { get; set; }
[JsonProperty("Shape")]
public IShape Shape { get; set; }
public IShape Shape { get; set; } = new RectangleShapeDTO(Guid.Empty);
[JsonProperty("Material")]
public IConcreteLibMaterial Material { get; set; }
[JsonProperty("CenterCover")]

View File

@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs.DTOEntities
namespace DataAccess.DTOs
{
public class StirrupByDensityDTO : IStirrupByDensity
{
@@ -14,10 +14,14 @@ namespace DataAccess.DTOs.DTOEntities
[JsonProperty("CompressedGap")]
public double CompressedGap { get; set; }
public StirrupByDensityDTO(Guid id)
{
Id = id;
}
public object Clone()
{
throw new NotImplementedException();
return this;
}
}
}

View File

@@ -2,7 +2,7 @@
using StructureHelperLogics.Models.BeamShears;
using StructureHelperLogics.Models.Materials;
namespace DataAccess.DTOs.DTOEntities
namespace DataAccess.DTOs
{
public class StirrupByRebarDTO : IStirrupByRebar
{

View File

@@ -1,11 +1,6 @@
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
{

View File

@@ -2,11 +2,6 @@
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Cracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
@@ -16,6 +11,8 @@ namespace DataAccess.DTOs
public Guid Id { get;}
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("ShowTraceData")]
public bool ShowTraceData { get; set; } = false;
[JsonProperty("InputData")]
public ICrackCalculatorInputData InputData { get; set; }
[JsonIgnore]

View File

@@ -1,11 +1,6 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.WorkPlanes;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{

Some files were not shown because too many files have changed in this diff Show More