Add converting beam shear analysis from DTOs

This commit is contained in:
Evgeny Redikultsev
2025-06-15 21:11:02 +05:00
parent 4845a35ba5
commit 87996cf37b
48 changed files with 992 additions and 105 deletions

View File

@@ -0,0 +1,62 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using StructureHelperCommon.Services;
namespace DataAccess.DTOs
{
public class BeamShearActionFromDTOConvertStrategy : ConvertStrategy<BeamShearAction, BeamShearActionDTO>
{
private IUpdateStrategy<IBeamShearAction> updateStrategy;
private IConvertStrategy<FactoredForceTuple, FactoredForceTupleDTO> factoredTupleConvertStrategy;
private IConvertStrategy<BeamShearAxisAction, BeamShearAxisActionDTO> axisActionConvertStrategy;
public BeamShearActionFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger)
{
}
public override BeamShearAction GetNewItem(BeamShearActionDTO source)
{
ChildClass = this;
CheckObjects(source);
InitializeStrategies();
GetNewAction(source);
return NewItem;
}
private void CheckObjects(BeamShearActionDTO source)
{
CheckObject.IsNull(source);
CheckObject.IsNull(source.ExternalForce);
CheckObject.IsNull(source.SupportAction);
}
private void GetNewAction(BeamShearActionDTO source)
{
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
if (source.ExternalForce is not FactoredForceTupleDTO forceTupleDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ExternalForce));
}
NewItem.ExternalForce = factoredTupleConvertStrategy.Convert(forceTupleDTO);
if (source.SupportAction is not BeamShearAxisActionDTO axisActionDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ExternalForce));
}
NewItem.SupportAction = axisActionConvertStrategy.Convert(axisActionDTO);
}
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearActionUpdateStrategy();
factoredTupleConvertStrategy ??= new DictionaryConvertStrategy<FactoredForceTuple, FactoredForceTupleDTO>
(this, new FactoredForceTupleFromDTOConvertStrategy(this));
axisActionConvertStrategy ??= new DictionaryConvertStrategy<BeamShearAxisAction, BeamShearAxisActionDTO>
(this, new BeamShearAxisActionFromDTOConvertStrategy(this));
}
}
}

View File

@@ -5,17 +5,17 @@ using StructureHelperCommon.Models.Forces.BeamShearActions;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {
public class BeamShearActionConvertStrategy : ConvertStrategy<BeamShearActionDTO, IBeamShearAction> public class BeamShearActionToDTOConvertStrategy : ConvertStrategy<BeamShearActionDTO, IBeamShearAction>
{ {
private IUpdateStrategy<IBeamShearAction> updateStrategy; private IUpdateStrategy<IBeamShearAction> updateStrategy;
private IConvertStrategy<FactoredForceTupleDTO, IFactoredForceTuple> factoredTupleConvertStrategy; private IConvertStrategy<FactoredForceTupleDTO, IFactoredForceTuple> factoredTupleConvertStrategy;
private IConvertStrategy<BeamShearAxisActionDTO, IBeamShearAxisAction> axisActionConvertStrategy; private IConvertStrategy<BeamShearAxisActionDTO, IBeamShearAxisAction> axisActionConvertStrategy;
public BeamShearActionConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy) public BeamShearActionToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{ {
} }
public BeamShearActionConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) public BeamShearActionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger) : base(referenceDictionary, traceLogger)
{ {
} }

View File

@@ -0,0 +1,67 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using StructureHelperCommon.Services;
namespace DataAccess.DTOs
{
internal class BeamShearAxisActionFromDTOConvertStrategy : ConvertStrategy<BeamShearAxisAction, BeamShearAxisActionDTO>
{
private IUpdateStrategy<IBeamShearAxisAction> updateStrategy;
private IConvertStrategy<FactoredForceTuple, FactoredForceTupleDTO> factoredTupleConvertStrategy;
private IConvertStrategy<IBeamSpanLoad, IBeamSpanLoad> spanLoadConvertLogic;
public BeamShearAxisActionFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override BeamShearAxisAction GetNewItem(BeamShearAxisActionDTO source)
{
CheckObject.IsNull(source);
CheckObject.IsNull(source.SupportForce);
CheckObject.IsNull(source.ShearLoads);
InitializeStrategies();
GetNewAction(source);
return NewItem;
}
private void GetNewAction(BeamShearAxisActionDTO source)
{
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
if (source.SupportForce is not FactoredForceTupleDTO factoredForceTupleDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.SupportForce));
}
NewItem.SupportForce = factoredTupleConvertStrategy.Convert(factoredForceTupleDTO);
List<IBeamSpanLoad> beamSpanLoads = GetSpanLoads(source.ShearLoads);
NewItem.ShearLoads.Clear();
NewItem.ShearLoads.AddRange(beamSpanLoads);
}
private List<IBeamSpanLoad> GetSpanLoads(IEnumerable<IBeamSpanLoad> shearLoads)
{
List<IBeamSpanLoad> beamSpanLoads = new();
foreach (var spanLoad in shearLoads)
{
beamSpanLoads.Add(ProcessSpanLoad(spanLoad));
}
return beamSpanLoads;
}
private IBeamSpanLoad ProcessSpanLoad(IBeamSpanLoad spanLoad)
{
return spanLoadConvertLogic.Convert(spanLoad);
}
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearAxisActionUpdateStrategy();
factoredTupleConvertStrategy ??= new DictionaryConvertStrategy<FactoredForceTuple, FactoredForceTupleDTO>
(this, new FactoredForceTupleFromDTOConvertStrategy(this));
spanLoadConvertLogic ??= new DictionaryConvertStrategy<IBeamSpanLoad, IBeamSpanLoad>
(this, new BeamSpanLoadFromDTOConvertStrategy(this));
}
}
}

View File

@@ -0,0 +1,46 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
internal class BeamShearCalculatorFromDTOConvertStrategy : ConvertStrategy<BeamShearCalculator, BeamShearCalculatorDTO>
{
private IUpdateStrategy<IBeamShearCalculator> updateStrategy;
private IConvertStrategy<BeamShearCalculatorInputData, BeamShearCalculatorInputDataDTO> inputDataConvertStrategy;
public BeamShearCalculatorFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger)
{
}
public override BeamShearCalculator GetNewItem(BeamShearCalculatorDTO source)
{
CheckObject.IsNull(source);
CheckObject.IsNull(source.InputData);
GetNewCalculator(source);
return NewItem;
}
private void GetNewCalculator(BeamShearCalculatorDTO source)
{
if (source.InputData is not BeamShearCalculatorInputDataDTO inputDataDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.InputData));
}
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.InputData = inputDataConvertStrategy.Convert(inputDataDTO);
}
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearCalculatorUpdateStrategy();
inputDataConvertStrategy = new DictionaryConvertStrategy<BeamShearCalculatorInputData, BeamShearCalculatorInputDataDTO>
(this, new BeamShearCalculatorInputDataFromDTOConvertStrategy(this));
}
}
}

View File

@@ -0,0 +1,36 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
internal class BeamShearCalculatorInputDataFromDTOConvertStrategy : ConvertStrategy<BeamShearCalculatorInputData, BeamShearCalculatorInputDataDTO>
{
private IUpdateStrategy<IBeamShearCalculatorInputData> updateStrategy;
private IUpdateStrategy<IHasBeamShearActions> actionUpdateStrategy;
private IUpdateStrategy<IHasBeamShearSections> sectionUpdateStrategy;
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
public BeamShearCalculatorInputDataFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override BeamShearCalculatorInputData GetNewItem(BeamShearCalculatorInputDataDTO source)
{
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
actionUpdateStrategy.Update(NewItem, source);
sectionUpdateStrategy.Update(NewItem, source);
stirrupUpdateStrategy.Update(NewItem, source);
return NewItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearCalculatorInputDataUpdateStrategy();
actionUpdateStrategy ??= new HasBeamShearActionsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
sectionUpdateStrategy ??= new HasBeamShearSectionsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
stirrupUpdateStrategy ??= new HasStirrupsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
}
}
}

View File

@@ -42,9 +42,9 @@ namespace DataAccess.DTOs
private void InitializeStrategies() private void InitializeStrategies()
{ {
actionUpdateStrategy ??= new HasBeamShearActionToDTOConvertStrategy(ReferenceDictionary, TraceLogger); actionUpdateStrategy ??= new HasBeamShearActionsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
sectionUpdateStrategy ??= new HasBeamShearSectionToDTOConvertStrategy(ReferenceDictionary, TraceLogger); sectionUpdateStrategy ??= new HasBeamShearSectionsToDTORenameStrategy(ReferenceDictionary, TraceLogger);
stirrupUpdateStrategy ??= new HasStirrupToDTOConvertStrategy(ReferenceDictionary, TraceLogger); stirrupUpdateStrategy ??= new HasStirrupsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
} }
} }
} }

View File

@@ -0,0 +1,38 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class BeamShearFromDTOConvertStrategy : ConvertStrategy<BeamShear, BeamShearDTO>
{
private IUpdateStrategy<IBeamShear> updateStrategy;
public BeamShearFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override BeamShear GetNewItem(BeamShearDTO source)
{
ChildClass = this;
CheckObject.IsNull(source);
CheckObject.IsNull(source.Repository);
GetNewBeamShear(source);
return NewItem;
}
private void GetNewBeamShear(IBeamShear source)
{
if (source.Repository is not BeamShearRepositoryDTO repositoryDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.Repository));
}
updateStrategy ??= new BeamShearUpdateStrategy();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
BeamShearRepositoryFromDTOConvertStrategy convertStrategy = new(this);
NewItem.Repository = convertStrategy.Convert(repositoryDTO);
}
}
}

View File

@@ -0,0 +1,43 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class BeamShearRepositoryFromDTOConvertStrategy : ConvertStrategy<BeamShearRepository, BeamShearRepositoryDTO>
{
private IUpdateStrategy<IHasBeamShearActions> actionUpdateStrategy;
private IUpdateStrategy<IHasBeamShearSections> sectionUpdateStrategy;
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
private IUpdateStrategy<IHasCalculators> calculatorUpdateStrategy;
public BeamShearRepositoryFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override BeamShearRepository GetNewItem(BeamShearRepositoryDTO source)
{
ChildClass = this;
GetNewRepository(source);
return NewItem;
}
private void GetNewRepository(BeamShearRepositoryDTO source)
{
InitializeStrategies();
NewItem = new(source.Id);
actionUpdateStrategy.Update(NewItem, source);
sectionUpdateStrategy.Update(NewItem, source);
stirrupUpdateStrategy.Update(NewItem, source);
calculatorUpdateStrategy.Update(NewItem, source);
}
private void InitializeStrategies()
{
actionUpdateStrategy ??= new HasBeamShearActionsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
sectionUpdateStrategy ??= new HasBeamShearSectionsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
stirrupUpdateStrategy ??= new HasStirrupsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
calculatorUpdateStrategy ??= new HasBeamShearCalculatorsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
}
}
}

View File

@@ -51,10 +51,10 @@ namespace DataAccess.DTOs
private void InitializeStrategies() private void InitializeStrategies()
{ {
actionUpdateStrategy ??= new HasBeamShearActionToDTOConvertStrategy(ReferenceDictionary, TraceLogger); actionUpdateStrategy ??= new HasBeamShearActionsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
sectionUpdateStrategy ??= new HasBeamShearSectionToDTOConvertStrategy(ReferenceDictionary, TraceLogger); sectionUpdateStrategy ??= new HasBeamShearSectionsToDTORenameStrategy(ReferenceDictionary, TraceLogger);
stirrupUpdateStrategy ??= new HasStirrupToDTOConvertStrategy(ReferenceDictionary, TraceLogger); stirrupUpdateStrategy ??= new HasStirrupsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
calculatorUpdateStrategy ??= new HasBeamShearCalculatorToDTOConvertStrategy(ReferenceDictionary, TraceLogger); calculatorUpdateStrategy ??= new HasBeamShearCalculatorsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
} }
} }
} }

View File

@@ -0,0 +1,51 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.BeamShears;
using StructureHelperLogics.Models.Materials;
namespace DataAccess.DTOs
{
public class BeamShearSectionFromDTOConvertStrategy : ConvertStrategy<BeamShearSection, BeamShearSectionDTO>
{
private IUpdateStrategy<IBeamShearSection> updateStrategy;
private IConvertStrategy<IShape, IShape> shapeConvertStrategy;
private IConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO> concreteConvertStrategy;
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy;
public BeamShearSectionFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
{
}
public override BeamShearSection GetNewItem(BeamShearSectionDTO source)
{
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.Shape = shapeConvertStrategy.Convert(source.Shape);
if (source.Material is not ConcreteLibMaterialDTO concreteDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.Material));
}
NewItem.Material = concreteConvertStrategy.Convert(concreteDTO);
safetyFactorUpdateStrategy.Update(NewItem.Material, concreteDTO);
return NewItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new BeamShearSectionUpdateStrategy();
shapeConvertStrategy = new DictionaryConvertStrategy<IShape, IShape>
(this, new ShapeFromDTOConvertStrategy(this));
concreteConvertStrategy = new ConcreteLibMaterialFromDTOConvertStrategy()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorsFromDTOLogic());
}
}
}

View File

@@ -3,6 +3,7 @@ using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Materials; using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.BeamShears; using StructureHelperLogics.Models.BeamShears;
using StructureHelperLogics.Models.Materials;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {
@@ -10,7 +11,7 @@ namespace DataAccess.DTOs
{ {
private IUpdateStrategy<IBeamShearSection> updateStrategy; private IUpdateStrategy<IBeamShearSection> updateStrategy;
private IConvertStrategy<IShape, IShape> shapeConvertStrategy; private IConvertStrategy<IShape, IShape> shapeConvertStrategy;
private ConcreteLibMaterialToDTOConvertStrategy concreteConvertStrategy; private IConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy;
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy; private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy;
public BeamShearSectionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) public BeamShearSectionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)

View File

@@ -0,0 +1,46 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Services;
namespace DataAccess.DTOs
{
internal class BeamSpanLoadFromDTOConvertStrategy : ConvertStrategy<IBeamSpanLoad, IBeamSpanLoad>
{
public BeamSpanLoadFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override IBeamSpanLoad GetNewItem(IBeamSpanLoad source)
{
CheckObject.IsNull(source);
if (source is DistributedLoadDTO distributed)
{
ProcessDistributed(distributed);
}
else if (source is ConcentratedForceDTO concentrated)
{
ProcessConcentrated(concentrated);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
}
return NewItem;
}
private void ProcessConcentrated(ConcentratedForceDTO concentrated)
{
var convertLogic = new DictionaryConvertStrategy<ConcentratedForce, ConcentratedForceDTO>
(this, new ConcentratedForceFromDTOConvertStrategy(this));
NewItem = convertLogic.Convert(concentrated);
}
private void ProcessDistributed(DistributedLoadDTO distributed)
{
var convertLogic = new DictionaryConvertStrategy<DistributedLoad, DistributedLoadDTO>
(this, new DistributedLoadFromDTOConvertStrategy(this));
NewItem = convertLogic.Convert(distributed);
}
}
}

View File

@@ -0,0 +1,45 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
namespace DataAccess.DTOs
{
internal class ConcentratedForceFromDTOConvertStrategy : ConvertStrategy<ConcentratedForce, ConcentratedForceDTO>
{
private IUpdateStrategy<IConcentratedForce> updateStrategy;
private IConvertStrategy<ForceTuple, ForceTupleDTO> tupleConvertStrategy;
private IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationConvertStrategy;
public ConcentratedForceFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override ConcentratedForce GetNewItem(ConcentratedForceDTO source)
{
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
if (source.ForceValue is not ForceTupleDTO forceTupleDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ForceValue));
}
NewItem.ForceValue = tupleConvertStrategy.Convert(forceTupleDTO);
if (source.CombinationProperty is not FactoredCombinationPropertyDTO combinationPropertyDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.CombinationProperty));
}
NewItem.CombinationProperty = combinationConvertStrategy.Convert(combinationPropertyDTO);
return NewItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new ConcentratedForceUpdateStrategy();
tupleConvertStrategy = new DictionaryConvertStrategy<ForceTuple, ForceTupleDTO>
(this, new ForceTupleFromDTOConvertStrategy(ReferenceDictionary, TraceLogger));
combinationConvertStrategy = new DictionaryConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO>
(this, new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger));
}
}
}

View File

@@ -0,0 +1,45 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
namespace DataAccess.DTOs
{
internal class DistributedLoadFromDTOConvertStrategy : ConvertStrategy<DistributedLoad, DistributedLoadDTO>
{
private IUpdateStrategy<IDistributedLoad> updateStrategy;
private IConvertStrategy<ForceTuple, ForceTupleDTO> tupleConvertStrategy;
private IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationConvertStrategy;
public DistributedLoadFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override DistributedLoad GetNewItem(DistributedLoadDTO source)
{
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
if (source.LoadValue is not ForceTupleDTO forceTupleDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.LoadValue));
}
NewItem.LoadValue = tupleConvertStrategy.Convert(forceTupleDTO);
if (source.CombinationProperty is not FactoredCombinationPropertyDTO combinationPropertyDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.CombinationProperty));
}
NewItem.CombinationProperty = combinationConvertStrategy.Convert(combinationPropertyDTO);
return NewItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new DistributedLoadUpdateStrategy();
tupleConvertStrategy = new DictionaryConvertStrategy<ForceTuple, ForceTupleDTO>
(this, new ForceTupleFromDTOConvertStrategy(ReferenceDictionary, TraceLogger));
combinationConvertStrategy = new DictionaryConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO>
(this, new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger));
}
}
}

View File

@@ -0,0 +1,55 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using StructureHelperCommon.Services;
namespace DataAccess.DTOs
{
public class HasBeamShearActionsFromDTOUpdateStrategy : IUpdateStrategy<IHasBeamShearActions>
{
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
private IShiftTraceLogger traceLogger;
private IConvertStrategy<BeamShearAction, BeamShearActionDTO> convertStrategy;
public HasBeamShearActionsFromDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{
this.referenceDictionary = referenceDictionary;
this.traceLogger = traceLogger;
}
public void Update(IHasBeamShearActions targetObject, IHasBeamShearActions sourceObject)
{
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.IsNull(sourceObject.Actions);
CheckObject.IsNull(targetObject.Actions);
targetObject.Actions.Clear();
foreach (var action in sourceObject.Actions)
{
targetObject.Actions.Add(ProcessAction(action));
}
}
private IBeamShearAction ProcessAction(IBeamShearAction action)
{
if (action is not BeamShearActionDTO actionDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(action));
}
InitializeStrategies();
var newAction = convertStrategy.Convert(actionDTO);
return newAction;
}
private void InitializeStrategies()
{
convertStrategy ??= new DictionaryConvertStrategy<BeamShearAction, BeamShearActionDTO>(
referenceDictionary, traceLogger,
new BeamShearActionFromDTOConvertStrategy(referenceDictionary, traceLogger));
}
}
}

View File

@@ -5,15 +5,15 @@ using StructureHelperCommon.Services;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {
public class HasBeamShearActionToDTOConvertStrategy : IUpdateStrategy<IHasBeamShearActions> public class HasBeamShearActionsToDTOUpdateStrategy : IUpdateStrategy<IHasBeamShearActions>
{ {
private Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get;} private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
private IShiftTraceLogger TraceLogger { get;} private IShiftTraceLogger traceLogger;
public HasBeamShearActionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) public HasBeamShearActionsToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{ {
ReferenceDictionary = referenceDictionary; this.referenceDictionary = referenceDictionary;
TraceLogger = traceLogger; this.traceLogger = traceLogger;
} }
public void Update(IHasBeamShearActions targetObject, IHasBeamShearActions sourceObject) public void Update(IHasBeamShearActions targetObject, IHasBeamShearActions sourceObject)
@@ -27,9 +27,9 @@ namespace DataAccess.DTOs
foreach (var action in sourceObject.Actions) foreach (var action in sourceObject.Actions)
{ {
var convertStrategy = new DictionaryConvertStrategy<BeamShearActionDTO, IBeamShearAction>( var convertStrategy = new DictionaryConvertStrategy<BeamShearActionDTO, IBeamShearAction>(
ReferenceDictionary, referenceDictionary,
TraceLogger, traceLogger,
new BeamShearActionConvertStrategy(ReferenceDictionary, TraceLogger)); new BeamShearActionToDTOConvertStrategy(referenceDictionary, traceLogger));
var newAction = convertStrategy.Convert(action); var newAction = convertStrategy.Convert(action);
targetObject.Actions.Add(newAction); targetObject.Actions.Add(newAction);
} }

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
{
internal class HasBeamShearCalculatorsFromDTOUpdateStrategy : IUpdateStrategy<IHasCalculators>
{
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
private IShiftTraceLogger traceLogger;
public HasBeamShearCalculatorsFromDTOUpdateStrategy(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 BeamShearCalculatorDTO shearCalculator)
{
return ProcessShearCalculator(shearCalculator);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(calculator));
}
}
private ICalculator ProcessShearCalculator(BeamShearCalculatorDTO shearCalculator)
{
traceLogger?.AddMessage("Calcultor is beam shear calculator", TraceLogStatuses.Debug);
var convertStrategy = new DictionaryConvertStrategy<BeamShearCalculator, BeamShearCalculatorDTO>
(referenceDictionary, traceLogger, new BeamShearCalculatorFromDTOConvertStrategy(referenceDictionary, traceLogger));
return convertStrategy.Convert(shearCalculator);
}
}
}

View File

@@ -7,12 +7,12 @@ using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {
public class HasBeamShearCalculatorToDTOConvertStrategy : IUpdateStrategy<IHasCalculators> public class HasBeamShearCalculatorsToDTOUpdateStrategy : IUpdateStrategy<IHasCalculators>
{ {
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary; private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
private IShiftTraceLogger traceLogger; private IShiftTraceLogger traceLogger;
public HasBeamShearCalculatorToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) public HasBeamShearCalculatorsToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{ {
this.referenceDictionary = referenceDictionary; this.referenceDictionary = referenceDictionary;
this.traceLogger = traceLogger; this.traceLogger = traceLogger;

View File

@@ -0,0 +1,51 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
public class HasBeamShearSectionsFromDTOUpdateStrategy : IUpdateStrategy<IHasBeamShearSections>
{
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
private IShiftTraceLogger traceLogger;
private IConvertStrategy<BeamShearSection, BeamShearSectionDTO> convertStrategy;
public HasBeamShearSectionsFromDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{
this.referenceDictionary = referenceDictionary;
this.traceLogger = traceLogger;
}
public void Update(IHasBeamShearSections targetObject, IHasBeamShearSections sourceObject)
{
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.IsNull(sourceObject.Sections);
CheckObject.IsNull(targetObject.Sections);
targetObject.Sections.Clear();
foreach (var section in sourceObject.Sections)
{
targetObject.Sections.Add(ProcessSection(section));
}
}
private IBeamShearSection ProcessSection(IBeamShearSection section)
{
if (section is not BeamShearSectionDTO sectionDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(section));
}
InitializeStrategies();
return convertStrategy.Convert(sectionDTO);
}
private void InitializeStrategies()
{
convertStrategy ??= new DictionaryConvertStrategy<BeamShearSection, BeamShearSectionDTO>
(referenceDictionary, traceLogger, new BeamShearSectionFromDTOConvertStrategy(referenceDictionary, traceLogger));
}
}
}

View File

@@ -5,13 +5,13 @@ using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {
public class HasBeamShearSectionToDTOConvertStrategy : IUpdateStrategy<IHasBeamShearSections> public class HasBeamShearSectionsToDTORenameStrategy : IUpdateStrategy<IHasBeamShearSections>
{ {
private IConvertStrategy<BeamShearSectionDTO, IBeamShearSection> convertStrategy; private IConvertStrategy<BeamShearSectionDTO, IBeamShearSection> convertStrategy;
private Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; } private Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; }
private IShiftTraceLogger TraceLogger { get; } private IShiftTraceLogger TraceLogger { get; }
public HasBeamShearSectionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) public HasBeamShearSectionsToDTORenameStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{ {
ReferenceDictionary = referenceDictionary; ReferenceDictionary = referenceDictionary;
TraceLogger = traceLogger; TraceLogger = traceLogger;

View File

@@ -0,0 +1,78 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
internal class HasStirrupsFromDTOUpdateStrategy : IUpdateStrategy<IHasStirrups>
{
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
private IShiftTraceLogger traceLogger;
public HasStirrupsFromDTOUpdateStrategy(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 StirrupByRebarDTO rebar)
{
newItem = ProcessRebar(rebar);
}
else if (stirrup is StirrupByDensityDTO density)
{
newItem = ProcessDensity(density);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrup));
}
return newItem;
}
private StirrupByDensity ProcessDensity(StirrupByDensityDTO density)
{
traceLogger?.AddMessage("Stirrup is stirrup by density");
var convertStrategy = new DictionaryConvertStrategy<StirrupByDensity, StirrupByDensityDTO>
(referenceDictionary, traceLogger, new StirrupByDensityFromDTOConvertStrategy(referenceDictionary, traceLogger));
return convertStrategy.Convert(density);
}
private StirrupByRebar ProcessRebar(StirrupByRebarDTO rebar)
{
traceLogger?.AddMessage("Stirrup is stirrup by rebar");
var convertStrategy = new DictionaryConvertStrategy<StirrupByRebar, StirrupByRebarDTO>
(referenceDictionary, traceLogger, new StirrupByRebarFromDTOConvertStrategy(referenceDictionary, traceLogger));
return convertStrategy.Convert(rebar);
}
}
}

View File

@@ -3,21 +3,15 @@ using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Services; using StructureHelperCommon.Services;
using StructureHelperLogics.Models.BeamShears; 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 namespace DataAccess.DTOs
{ {
public class HasStirrupToDTOConvertStrategy : IUpdateStrategy<IHasStirrups> public class HasStirrupsToDTOUpdateStrategy : IUpdateStrategy<IHasStirrups>
{ {
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary; private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
private IShiftTraceLogger traceLogger; private IShiftTraceLogger traceLogger;
public HasStirrupToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) public HasStirrupsToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{ {
this.referenceDictionary = referenceDictionary; this.referenceDictionary = referenceDictionary;
this.traceLogger = traceLogger; this.traceLogger = traceLogger;

View File

@@ -0,0 +1,24 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.BeamShears;
namespace DataAccess.DTOs
{
internal class StirrupByDensityFromDTOConvertStrategy : ConvertStrategy<StirrupByDensity, StirrupByDensityDTO>
{
private IUpdateStrategy<IStirrupByDensity> updateStrategy;
public StirrupByDensityFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger)
{
}
public override StirrupByDensity GetNewItem(StirrupByDensityDTO source)
{
updateStrategy ??= new StirrupByDensityUpdateStrategy();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
return NewItem;
}
}
}

View File

@@ -0,0 +1,45 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.BeamShears;
using StructureHelperLogics.Models.Materials;
namespace DataAccess.DTOs
{
internal class StirrupByRebarFromDTOConvertStrategy : ConvertStrategy<StirrupByRebar, StirrupByRebarDTO>
{
private IUpdateStrategy<IStirrupByRebar> updateStrategy;
private IConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO> reinforcementConvertStrategy;
private HelperMaterialDTOSafetyFactorUpdateStrategy safetyFactorUpdateStrategy;
public StirrupByRebarFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger)
{
}
public override StirrupByRebar GetNewItem(StirrupByRebarDTO source)
{
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
if (source.Material is not ReinforcementLibMaterialDTO reinforcement)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.Material));
}
NewItem.Material = reinforcementConvertStrategy.Convert(reinforcement);
safetyFactorUpdateStrategy.Update(NewItem.Material, source.Material);
return NewItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new StirrupByRebarUpdateStrategy();
reinforcementConvertStrategy = new ReinforcementLibMaterialFromDTOConvertStrategy()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorsFromDTOLogic());
}
}
}

View File

@@ -6,7 +6,7 @@ namespace DataAccess.DTOs
{ {
public class StirrupByRebarToDTOConvertStrategy : ConvertStrategy<StirrupByRebarDTO, IStirrupByRebar> public class StirrupByRebarToDTOConvertStrategy : ConvertStrategy<StirrupByRebarDTO, IStirrupByRebar>
{ {
private StirrupByRebarUpdateStrategy updateStrategy; private IUpdateStrategy<IStirrupByRebar> updateStrategy;
private ReinforcementLibMaterialToDTOConvertStrategy reinforcementConvertStrategy; private ReinforcementLibMaterialToDTOConvertStrategy reinforcementConvertStrategy;
private HelperMaterialDTOSafetyFactorUpdateStrategy safetyFactorUpdateStrategy; private HelperMaterialDTOSafetyFactorUpdateStrategy safetyFactorUpdateStrategy;

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics; using StructureHelperCommon.Models.Forces.Logics;
@@ -7,6 +8,11 @@ namespace DataAccess.DTOs
public class FactoredCombinationPropertyFromDTOConvertStrategy : ConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> public class FactoredCombinationPropertyFromDTOConvertStrategy : ConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO>
{ {
private IUpdateStrategy<IFactoredCombinationProperty> updateStrategy; private IUpdateStrategy<IFactoredCombinationProperty> updateStrategy;
public FactoredCombinationPropertyFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
{
}
public override FactoredCombinationProperty GetNewItem(FactoredCombinationPropertyDTO source) public override FactoredCombinationProperty GetNewItem(FactoredCombinationPropertyDTO source)
{ {
InitializeStrategies(); InitializeStrategies();

View File

@@ -0,0 +1,59 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Services;
namespace DataAccess.DTOs
{
public class FactoredForceTupleFromDTOConvertStrategy : ConvertStrategy<FactoredForceTuple, FactoredForceTupleDTO>
{
private IConvertStrategy<ForceTuple, ForceTupleDTO> tupleConvertStrategy;
private IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationConvertStrategy;
public FactoredForceTupleFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy)
: base(baseConvertStrategy)
{
}
public override FactoredForceTuple GetNewItem(FactoredForceTupleDTO source)
{
ChildClass = this;
CheckObjects(source);
InitializeStrategies();
return GetNewFactoredTuple(source);
}
private FactoredForceTuple GetNewFactoredTuple(FactoredForceTupleDTO source)
{
if (source.ForceTuple is not ForceTupleDTO forceTupleDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ForceTuple));
}
if (source.CombinationProperty is not FactoredCombinationPropertyDTO combinationPropertyDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ForceTuple));
}
NewItem = new(source.Id)
{
ForceTuple = tupleConvertStrategy.Convert(forceTupleDTO),
CombinationProperty = combinationConvertStrategy.Convert(combinationPropertyDTO)
};
return NewItem;
}
private static void CheckObjects(FactoredForceTupleDTO source)
{
CheckObject.IsNull(source);
CheckObject.IsNull(source.ForceTuple);
CheckObject.IsNull(source.CombinationProperty);
}
private void InitializeStrategies()
{
tupleConvertStrategy = new DictionaryConvertStrategy<ForceTuple, ForceTupleDTO>
(this, new ForceTupleFromDTOConvertStrategy(ReferenceDictionary, TraceLogger));
combinationConvertStrategy = new DictionaryConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO>
(this, new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger));
}
}
}

View File

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

View File

@@ -105,7 +105,7 @@ namespace DataAccess.DTOs
{ {
updateStrategy ??= new ForceCombinationFromFileUpdateStrategy(); updateStrategy ??= new ForceCombinationFromFileUpdateStrategy();
pointConvertStrategy = new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger}; pointConvertStrategy = new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
combinationPropertyConvertStrategy = new FactoredCombinationPropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger}; combinationPropertyConvertStrategy = new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
fileConvertStrategy ??= new ColumnedFilePropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; fileConvertStrategy ??= new ColumnedFilePropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
} }
} }

View File

@@ -87,7 +87,7 @@ namespace DataAccess.DTOs
updateStrategy ??= new ForceFactoredListUpdateStrategy(); updateStrategy ??= new ForceFactoredListUpdateStrategy();
pointConvertStrategy ??= new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger}; pointConvertStrategy ??= new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
forceTupleConvertStrategy ??= new ForceTupleFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; forceTupleConvertStrategy ??= new ForceTupleFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
} }
} }
} }

View File

@@ -1,29 +1,25 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {
public class ForceTupleFromDTOConvertStrategy : ConvertStrategy<ForceTuple, ForceTupleDTO> public class ForceTupleFromDTOConvertStrategy : ConvertStrategy<ForceTuple, ForceTupleDTO>
{ {
private readonly IUpdateStrategy<IForceTuple> updateStrategy; private IUpdateStrategy<IForceTuple> updateStrategy;
public ForceTupleFromDTOConvertStrategy(IUpdateStrategy<IForceTuple> updateStrategy) public ForceTupleFromDTOConvertStrategy()
{ {
this.updateStrategy = updateStrategy;
} }
public ForceTupleFromDTOConvertStrategy() : this(new ForceTupleUpdateStrategy()) public ForceTupleFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
: base(referenceDictionary, traceLogger)
{ {
} }
public override ForceTuple GetNewItem(ForceTupleDTO source) public override ForceTuple GetNewItem(ForceTupleDTO source)
{ {
updateStrategy ??= new ForceTupleUpdateStrategy();
ForceTuple newItem = new(source.Id); ForceTuple newItem = new(source.Id);
updateStrategy.Update(newItem, source); updateStrategy.Update(newItem, source);
return newItem; return newItem;

View File

@@ -1,16 +1,8 @@
using DataAccess.DTOs.Converters; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Materials; using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.Models.Materials; using StructureHelperLogics.Models.Materials;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {

View File

@@ -1,9 +1,4 @@
using StructureHelperCommon.Models.Materials.Libraries; using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {

View File

@@ -1,15 +1,9 @@
using DataAccess.DTOs.Converters; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.WorkPlanes; using StructureHelperCommon.Models.WorkPlanes;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {
@@ -18,15 +12,12 @@ namespace DataAccess.DTOs
private IConvertStrategy<ICrossSectionRepository, ICrossSectionRepository> repositoryConvertStrategy; private IConvertStrategy<ICrossSectionRepository, ICrossSectionRepository> repositoryConvertStrategy;
private IConvertStrategy<WorkPlaneProperty, WorkPlanePropertyDTO> workPlaneConvertStrategy; private IConvertStrategy<WorkPlaneProperty, WorkPlanePropertyDTO> workPlaneConvertStrategy;
public CrossSectionFromDTOConvertStrategy(IConvertStrategy<ICrossSectionRepository, ICrossSectionRepository> repositoryConvertStrategy, public CrossSectionFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger? traceLogger)
IConvertStrategy<WorkPlaneProperty, WorkPlanePropertyDTO> workPlaneConvertStrategy)
{ {
this.repositoryConvertStrategy = repositoryConvertStrategy; ReferenceDictionary = referenceDictionary;
this.workPlaneConvertStrategy = workPlaneConvertStrategy; TraceLogger = traceLogger;
} }
public CrossSectionFromDTOConvertStrategy() { }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; } public IShiftTraceLogger TraceLogger { get; set; }

View File

@@ -0,0 +1,27 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
namespace DataAccess.DTOs
{
internal class RectangleShapeFromDTOConvertStrategy : ConvertStrategy<RectangleShape, RectangleShapeDTO>
{
private IUpdateStrategy<IRectangleShape> updateStrategy;
public RectangleShapeFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override RectangleShape GetNewItem(RectangleShapeDTO source)
{
InitializeStrategies();
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
return NewItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new RectangleShapeUpdateStrategy();
}
}
}

View File

@@ -0,0 +1,30 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
namespace DataAccess.DTOs
{
internal class ShapeFromDTOConvertStrategy : ConvertStrategy<IShape, IShape>
{
private IConvertStrategy<RectangleShape, RectangleShapeDTO> rectangleConvertStrategy;
public ShapeFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
{
}
public override IShape GetNewItem(IShape source)
{
if (source is RectangleShapeDTO rectangleShapeDTO)
{
rectangleConvertStrategy ??= new DictionaryConvertStrategy<RectangleShape, RectangleShapeDTO>
(this, new RectangleShapeFromDTOConvertStrategy(this));
NewItem = rectangleConvertStrategy.Convert(rectangleShapeDTO);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape is unknown");
}
return NewItem;
}
}
}

View File

@@ -1,9 +1,7 @@
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using System.Windows.Forms;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {

View File

@@ -38,22 +38,31 @@ namespace DataAccess.DTOs
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString); throw new StructureHelperException(errorString);
} }
TraceLogger?.AddMessage($"Object of type <<{newItem.GetType()}>> was obtained", TraceLogStatuses.Service); TraceLogger?.AddMessage($"Object of type <<{newItem.GetType()}>> was obtained successfully", TraceLogStatuses.Service);
return newItem; return newItem;
} }
private ISaveable ProcessBeamShear(IBeamShear beamShear) private IBeamShear ProcessBeamShear(IBeamShear source)
{ {
throw new NotImplementedException(); if (source is not BeamShearDTO beamShearDTO)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
}
TraceLogger?.AddMessage(AnalysisIs + " Beam shear", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Beam shear analysis Id = {source.Id} converting has been started", TraceLogStatuses.Service);
var convertLogic = new DictionaryConvertStrategy<BeamShear, BeamShearDTO>
(this,
new BeamShearFromDTOConvertStrategy(this));
IBeamShear newItem = convertLogic.Convert(beamShearDTO);
TraceLogger?.AddMessage($"Beam shear analysis Id = {newItem.Id} converting has been finished successfully", TraceLogStatuses.Service);
return newItem;
} }
private ICrossSection ProcessCrossSection(ICrossSection source) private ICrossSection ProcessCrossSection(ICrossSection source)
{ {
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section", TraceLogStatuses.Service); TraceLogger?.AddMessage(AnalysisIs + " Cross-Section", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Cross-Section converting is started", TraceLogStatuses.Service); TraceLogger?.AddMessage("Cross-Section converting has been started", TraceLogStatuses.Service);
crossSectionConvertStrategy ??= new CrossSectionFromDTOConvertStrategy(); crossSectionConvertStrategy ??= new CrossSectionFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
crossSectionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
crossSectionConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ICrossSection, ICrossSection>(this, crossSectionConvertStrategy); var convertLogic = new DictionaryConvertStrategy<ICrossSection, ICrossSection>(this, crossSectionConvertStrategy);
ICrossSection newItem = convertLogic.Convert(source); ICrossSection newItem = convertLogic.Convert(source);
TraceLogger?.AddMessage("Cross-Section converting has been finished successfully", TraceLogStatuses.Service); TraceLogger?.AddMessage("Cross-Section converting has been finished successfully", TraceLogStatuses.Service);

View File

@@ -1,13 +1,8 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.WorkPlanes; using StructureHelperCommon.Models.WorkPlanes;
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 WorkPlanePropertyFromDTOConvertStrategy : ConvertStrategy<WorkPlaneProperty, WorkPlanePropertyDTO> public class WorkPlanePropertyFromDTOConvertStrategy : ConvertStrategy<WorkPlaneProperty, WorkPlanePropertyDTO>
{ {

View File

@@ -1,10 +1,5 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {
@@ -37,7 +32,7 @@ namespace DataAccess.DTOs
public object Clone() public object Clone()
{ {
throw new NotImplementedException(); return this;
} }
} }
} }

View File

@@ -64,7 +64,7 @@ namespace DataAccess.DTOs
public object Clone() public object Clone()
{ {
throw new NotImplementedException(); return this;
} }
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)

View File

@@ -49,7 +49,7 @@ namespace DataAccess.DTOs
public object Clone() public object Clone()
{ {
throw new NotImplementedException(); return this;
} }
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)

View File

@@ -73,13 +73,18 @@ namespace StructureHelperLogics.Models.BeamShears
private void GetSections() private void GetSections()
{ {
actionResults = new(); actionResults = new();
List<IStirrup> stirrups = inputData.Stirrups.ToList();
if (stirrups.Any() == false)
{
stirrups.Add(new StirrupByDensity(Guid.NewGuid()) { StirrupDensity = 0 });
}
foreach (var beamShearAction in inputData.Actions) foreach (var beamShearAction in inputData.Actions)
{ {
foreach (var calcTerm in calcTerms) foreach (var calcTerm in calcTerms)
{ {
foreach (var section in inputData.Sections) foreach (var section in inputData.Sections)
{ {
foreach (var stirrup in inputData.Stirrups) foreach (var stirrup in stirrups)
{ {
List<IInclinedSection> inclinedSections = GetInclinedSections(section); List<IInclinedSection> inclinedSections = GetInclinedSections(section);
List<IBeamShearSectionLogicInputData> sectionInputDatas = GetSectionInputDatas(beamShearAction, calcTerm, section, stirrup, inclinedSections); List<IBeamShearSectionLogicInputData> sectionInputDatas = GetSectionInputDatas(beamShearAction, calcTerm, section, stirrup, inclinedSections);

View File

@@ -12,7 +12,7 @@ namespace StructureHelperLogics.Models.BeamShears
/// <inheritdoc/> /// <inheritdoc/>
public IConcreteLibMaterial Material { get; set; } public IConcreteLibMaterial Material { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public IShape Shape { get; } = new RectangleShape(Guid.NewGuid()) { Height = 0.6, Width = 0.4}; public IShape Shape { get; set; } = new RectangleShape(Guid.NewGuid()) { Height = 0.6, Width = 0.4};
public double CenterCover { get; set; } = 0.05; public double CenterCover { get; set; } = 0.05;

View File

@@ -26,8 +26,8 @@ namespace StructureHelperLogics.Models.BeamShears
private void InitializeStrategies() private void InitializeStrategies()
{ {
repositoryUpdateStrategy ??= new BeamShearRepositoryAddUpdateStrategy();
clearStrategy ??= new BeamShearReporitoryClearStrategy(); clearStrategy ??= new BeamShearReporitoryClearStrategy();
repositoryUpdateStrategy ??= new BeamShearRepositoryAddUpdateStrategy();
} }
} }
} }

View File

@@ -17,7 +17,7 @@ namespace StructureHelperLogics.Models.BeamShears
/// <summary> /// <summary>
/// Shape of cross-section /// Shape of cross-section
/// </summary> /// </summary>
IShape Shape { get; } IShape Shape { get; set; }
/// <summary> /// <summary>
/// Distance from edge of tension zone to center of the nearest reinforcement bar /// Distance from edge of tension zone to center of the nearest reinforcement bar
/// </summary> /// </summary>

View File

@@ -4,7 +4,7 @@ using StructureHelperCommon.Services;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {
internal class BeamShearCalculatorInputDataUpdateStrategy : IUpdateStrategy<IBeamShearCalculatorInputData> public class BeamShearCalculatorInputDataUpdateStrategy : IUpdateStrategy<IBeamShearCalculatorInputData>
{ {
private IUpdateStrategy<IHasBeamShearActions>? hasActionUpdateStrategy; private IUpdateStrategy<IHasBeamShearActions>? hasActionUpdateStrategy;
private IUpdateStrategy<IHasStirrups>? hasStirrupsUpdateStrategy; private IUpdateStrategy<IHasStirrups>? hasStirrupsUpdateStrategy;

View File

@@ -4,6 +4,9 @@ using StructureHelperCommon.Services;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {
/// <summary>
/// Add objects from one repository to another one without deleting previous objects
/// </summary>
public class BeamShearRepositoryAddUpdateStrategy : IUpdateStrategy<IBeamShearRepository> public class BeamShearRepositoryAddUpdateStrategy : IUpdateStrategy<IBeamShearRepository>
{ {
public void Update(IBeamShearRepository targetObject, IBeamShearRepository sourceObject) public void Update(IBeamShearRepository targetObject, IBeamShearRepository sourceObject)