Compare commits
142 Commits
master
...
PrimitiveP
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6065460e2b | ||
|
|
3b95fab0b2 | ||
|
|
d81b72d420 | ||
|
|
002be12b2f | ||
|
|
ac34a26c15 | ||
|
|
7e82e5ee9d | ||
|
|
68b15682bb | ||
|
|
01cc3947bc | ||
|
|
f937b9f373 | ||
|
|
681ab17781 | ||
|
|
70bfd065c4 | ||
|
|
7594872a41 | ||
|
|
96e7e9a587 | ||
|
|
f381229a63 | ||
|
|
5daa32a954 | ||
|
|
7ab4909c67 | ||
|
|
215f631bb0 | ||
|
|
f7e60e0bb3 | ||
|
|
43f46b83af | ||
|
|
466b47f447 | ||
|
|
111b60a08d | ||
|
|
b28606003a | ||
|
|
871be6cb46 | ||
|
|
ba0d3e580b | ||
|
|
3dfbb43b73 | ||
|
|
693e0648c4 | ||
|
|
c84dc47134 | ||
|
|
09dcf4e7e9 | ||
|
|
196dc636bb | ||
|
|
ed66da123c | ||
|
|
5bf01bcb09 | ||
|
|
8d4c788a7e | ||
|
|
292e7bac74 | ||
|
|
35fccfaa11 | ||
|
|
c31e56869c | ||
|
|
98c94dc232 | ||
|
|
5e45be35b1 | ||
|
|
738ce5c433 | ||
|
|
b38c19f7bb | ||
|
|
a05138fa8a | ||
|
|
c61069a394 | ||
|
|
3d8ac6f0c4 | ||
|
|
b34618e8a4 | ||
|
|
2f6c35482b | ||
|
|
466c57feef | ||
|
|
6e8f4bcc58 | ||
|
|
ddf075bffd | ||
|
|
efb0fa6e1e | ||
|
|
0addeda339 | ||
|
|
43c78729f0 | ||
|
|
1bc7799d3c | ||
|
|
0975dde696 | ||
|
|
d45d37edb7 | ||
|
|
1ebe1bbcd1 | ||
|
|
4fbb3f3658 | ||
|
|
6168b93f3d | ||
|
|
976b6b5f68 | ||
|
|
22bd35da98 | ||
|
|
87996cf37b | ||
|
|
4845a35ba5 | ||
|
|
0d7f47653b | ||
|
|
3dab65e3bd | ||
|
|
ece04ae406 | ||
|
|
2ab366da55 | ||
|
|
957ab62ece | ||
|
|
34ad25b2ea | ||
|
|
4a6127d7fd | ||
|
|
add2ed8777 | ||
|
|
f127594b5c | ||
|
|
d108c52cac | ||
|
|
b38bad251d | ||
|
|
2269b2ea07 | ||
|
|
cefe30f103 | ||
|
|
a0a25f183a | ||
|
|
15bb7030cc | ||
|
|
aec85e37f5 | ||
|
|
b2027f92dd | ||
|
|
a496f5a80f | ||
|
|
e5d33351e2 | ||
|
|
5302664958 | ||
|
|
382ff6ed36 | ||
|
|
e4a23f5139 | ||
|
|
f60d031f91 | ||
|
|
91ccebf147 | ||
|
|
57bc6141c9 | ||
|
|
3a946a29bc | ||
|
|
bbc6ade283 | ||
|
|
0aded4a631 | ||
|
|
44a7a569aa | ||
|
|
50b173c805 | ||
|
|
f508399846 | ||
|
|
13c3022c2f | ||
|
|
690af15e2a | ||
|
|
932f87f566 | ||
|
|
65253a907b | ||
|
|
ba70e0d214 | ||
|
|
bd0175086a | ||
|
|
921ec22e8a | ||
|
|
f10bcf6350 | ||
|
|
07370e6fc9 | ||
|
|
fb017af47d | ||
|
|
a7dd63ccd4 | ||
|
|
2668b2a0c0 | ||
|
|
2dd8b3f119 | ||
|
|
7e652a8495 | ||
|
|
2cd350d3e8 | ||
|
|
a14433f3cb | ||
|
|
0538c6b53c | ||
|
|
ccaf9a927c | ||
|
|
59b989ca89 | ||
|
|
346378222c | ||
|
|
32243f5448 | ||
|
|
6ec68c6f49 | ||
|
|
28f031764c | ||
|
|
ad4075f601 | ||
|
|
0a2934a1ea | ||
|
|
a8d570713d | ||
|
|
0bf9cf6a0b | ||
|
|
7ea82c9492 | ||
|
|
223e69263f | ||
|
|
b0c24126da | ||
|
|
d3a1992f4d | ||
|
|
d16c0e1f79 | ||
|
|
7e54aa0407 | ||
|
|
2c5c5db43a | ||
|
|
018a989ba6 | ||
|
|
58b6e0eb8b | ||
|
|
c10d6eb94e | ||
|
|
5a9e7c3c4f | ||
|
|
6e0b7b8070 | ||
|
|
408e9f6999 | ||
|
|
2268557672 | ||
|
|
8c030e2271 | ||
|
|
f5deffd237 | ||
|
|
c1b9f80a96 | ||
|
|
45dbd7a1ca | ||
|
|
3eb5aa2b96 | ||
|
|
e7c7211f54 | ||
|
|
35b4000f64 | ||
|
|
732af8bc09 | ||
|
|
09b53ac4e3 | ||
|
|
45a87fe7a6 |
25
DataAccess/DTOs/Converters/AccuracyFromDTOConvertStrategy.cs
Normal file
25
DataAccess/DTOs/Converters/AccuracyFromDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class AccuracyFromDTOConvertStrategy : ConvertStrategy<Accuracy, AccuracyDTO>
|
||||
{
|
||||
private IUpdateStrategy<IAccuracy> updateStrategy;
|
||||
public override Accuracy GetNewItem(AccuracyDTO source)
|
||||
{
|
||||
updateStrategy ??= new AccuracyUpdateStrategy();
|
||||
try
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
DataAccess/DTOs/Converters/AccuracyToDTOConvertStrategy.cs
Normal file
25
DataAccess/DTOs/Converters/AccuracyToDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class AccuracyToDTOConvertStrategy : ConvertStrategy<AccuracyDTO, IAccuracy>
|
||||
{
|
||||
private IUpdateStrategy<IAccuracy> updateStrategy;
|
||||
public override AccuracyDTO GetNewItem(IAccuracy source)
|
||||
{
|
||||
updateStrategy ??= new AccuracyUpdateStrategy();
|
||||
try
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
92
DataAccess/DTOs/Converters/AnalysisFromDTOConvertStrategy.cs
Normal file
92
DataAccess/DTOs/Converters/AnalysisFromDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class AnalysisFromDTOConvertStrategy : ConvertStrategy<IAnalysis, IAnalysis>
|
||||
{
|
||||
private const string AnalysisIs = "Analysis type is";
|
||||
|
||||
private IConvertStrategy<IVersionProcessor, IVersionProcessor> versionProcessorConvertStrategy;
|
||||
|
||||
public AnalysisFromDTOConvertStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
public AnalysisFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override IAnalysis GetNewItem(IAnalysis source)
|
||||
{
|
||||
try
|
||||
{
|
||||
IAnalysis analysis = GetAnalysis(source);
|
||||
return analysis;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private IAnalysis GetAnalysis(IAnalysis source)
|
||||
{
|
||||
if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
||||
{
|
||||
GetCrossSectionNdmAnalysis(crossSectionNdmAnalysis);
|
||||
}
|
||||
else if (source is IBeamShearAnalysis beamShearAnalysis)
|
||||
{
|
||||
GetBeamShearAnalysis(beamShearAnalysis);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
NewItem.VersionProcessor = GetVersionProcessor(source.VersionProcessor);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void GetBeamShearAnalysis(IBeamShearAnalysis beamShearAnalysis)
|
||||
{
|
||||
TraceLogger?.AddMessage(AnalysisIs + " beam shear Analysis", TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage("Beam shear analysis converting has been started", TraceLogStatuses.Debug);
|
||||
var convertStrategy = new DictionaryConvertStrategy<IBeamShearAnalysis, IBeamShearAnalysis>
|
||||
(this, new BeamShearAnalysisFromDTOConvertStrategy(this));
|
||||
NewItem = convertStrategy.Convert(beamShearAnalysis);
|
||||
TraceLogger?.AddMessage("Beam shear analysis converting has been finished succesfully", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
|
||||
private void GetCrossSectionNdmAnalysis(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been started", TraceLogStatuses.Debug);
|
||||
var convertStrategy = new DictionaryConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>
|
||||
(this, new CrossSectionNdmAnalysisFromDTOConvertStrategy(this));
|
||||
NewItem = convertStrategy.Convert(source);
|
||||
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been finished successfully", TraceLogStatuses.Debug);
|
||||
}
|
||||
private IVersionProcessor GetVersionProcessor(IVersionProcessor source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Version processor converting is started", TraceLogStatuses.Service);
|
||||
versionProcessorConvertStrategy ??= new VersionProcessorFromDTOConvertStrategy();
|
||||
versionProcessorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
versionProcessorConvertStrategy.TraceLogger = TraceLogger;
|
||||
IVersionProcessor versionProcessor = versionProcessorConvertStrategy.Convert(source);
|
||||
TraceLogger?.AddMessage("Version processor converting has been finished successfully", TraceLogStatuses.Service);
|
||||
return versionProcessor;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
66
DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs
Normal file
66
DataAccess/DTOs/Converters/AnalysisToDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class AnalysisToDTOConvertStrategy : ConvertStrategy<IAnalysis, IAnalysis>
|
||||
{
|
||||
private const string Message = "Analysis type is";
|
||||
|
||||
private IConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis> crossSectionConvertLogic;
|
||||
private IConvertStrategy<BeamShearAnalysisDTO, IBeamShearAnalysis> beamShearConvertLogic;
|
||||
|
||||
public AnalysisToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override IAnalysis GetNewItem(IAnalysis source)
|
||||
{
|
||||
IAnalysis analysis;
|
||||
if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
||||
{
|
||||
analysis = GetCrossSectionNdmAnalysisDTO(crossSectionNdmAnalysis);
|
||||
}
|
||||
else if (source is IBeamShearAnalysis beamShearAnalysis)
|
||||
{
|
||||
analysis = GetBeamShearAnalysis(beamShearAnalysis);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
foreach (var item in source.VersionProcessor.Versions)
|
||||
{
|
||||
//to do
|
||||
}
|
||||
return analysis;
|
||||
}
|
||||
private BeamShearAnalysisDTO GetBeamShearAnalysis(IBeamShearAnalysis beamShearAnalysis)
|
||||
{
|
||||
TraceLogger?.AddMessage(Message + " Beam Shear Analysis", TraceLogStatuses.Debug);
|
||||
beamShearConvertLogic ??= new DictionaryConvertStrategy<BeamShearAnalysisDTO, IBeamShearAnalysis>
|
||||
(this,
|
||||
new BeamShearAnalysisToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
||||
);
|
||||
BeamShearAnalysisDTO newItem = beamShearConvertLogic.Convert(beamShearAnalysis);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private CrossSectionNdmAnalysisDTO GetCrossSectionNdmAnalysisDTO(ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
||||
{
|
||||
TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
||||
crossSectionConvertLogic ??= new DictionaryConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>
|
||||
(this,
|
||||
new CrossSectionNdmAnalysisToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
||||
);
|
||||
CrossSectionNdmAnalysisDTO newItem = crossSectionConvertLogic.Convert(crossSectionNdmAnalysis);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.ThrowIfNull(source);
|
||||
CheckObject.ThrowIfNull(source.ExternalForce);
|
||||
CheckObject.ThrowIfNull(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.BeamShearActions;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearActionToDTOConvertStrategy : ConvertStrategy<BeamShearActionDTO, IBeamShearAction>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShearAction> updateStrategy;
|
||||
private IConvertStrategy<FactoredForceTupleDTO, IFactoredForceTuple> factoredTupleConvertStrategy;
|
||||
private IConvertStrategy<BeamShearAxisActionDTO, IBeamShearAxisAction> axisActionConvertStrategy;
|
||||
|
||||
public BeamShearActionToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public BeamShearActionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override BeamShearActionDTO GetNewItem(IBeamShearAction source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewBeamAction(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewBeamAction(IBeamShearAction source)
|
||||
{
|
||||
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($"Beam shear action converting Id = {NewItem.Id} has been finished", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearActionUpdateStrategy();
|
||||
factoredTupleConvertStrategy = new DictionaryConvertStrategy<FactoredForceTupleDTO, IFactoredForceTuple>
|
||||
(this, new FactoredForceTupleToDTOConvertStrategy(this));
|
||||
axisActionConvertStrategy = new DictionaryConvertStrategy<BeamShearAxisActionDTO, IBeamShearAxisAction>
|
||||
(this, new BeamShearAxisActionToDTOConvertStrategy(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearAnalysisFromDTOConvertStrategy : ConvertStrategy<IBeamShearAnalysis, IBeamShearAnalysis>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShearAnalysis> updateStrategy;
|
||||
|
||||
public BeamShearAnalysisFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override IBeamShearAnalysis GetNewItem(IBeamShearAnalysis source)
|
||||
{
|
||||
ChildClass = this;
|
||||
GetAnalysis(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void GetAnalysis(IBeamShearAnalysis source)
|
||||
{
|
||||
updateStrategy ??= new BeamShearAnalysisUpdateStrategy();
|
||||
BeamShearAnalysis beamShearAnalysis = new(source.Id);
|
||||
updateStrategy.Update(beamShearAnalysis, source);
|
||||
NewItem = beamShearAnalysis;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearAnalysisToDTOConvertStrategy : ConvertStrategy<BeamShearAnalysisDTO, IBeamShearAnalysis>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShearAnalysis> updateStrategy;
|
||||
private IConvertStrategy<VersionProcessorDTO, IVersionProcessor> convertStrategy;
|
||||
|
||||
public BeamShearAnalysisToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override BeamShearAnalysisDTO GetNewItem(IBeamShearAnalysis source)
|
||||
{
|
||||
updateStrategy ??= new BeamShearAnalysisUpdateStrategy();
|
||||
try
|
||||
{
|
||||
GetNewAnalysis(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewAnalysis(IBeamShearAnalysis source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting beam shear analysis id = {source.Id} has been started");
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.VersionProcessor = convertStrategy.Convert(source.VersionProcessor);
|
||||
TraceLogger?.AddMessage($"Converting beam shear analysis id = {NewItem.Id} has done successfully");
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearAnalysisUpdateStrategy();
|
||||
convertStrategy = new DictionaryConvertStrategy<VersionProcessorDTO, IVersionProcessor>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = new VersionProcessorToDTOConvertStrategy(ReferenceDictionary, TraceLogger),
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.ThrowIfNull(source);
|
||||
CheckObject.ThrowIfNull(source.SupportForce);
|
||||
CheckObject.ThrowIfNull(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.BeamShearActions;
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearAxisActionToDTOConvertStrategy : ConvertStrategy<BeamShearAxisActionDTO, IBeamShearAxisAction>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShearAxisAction> updateStrategy;
|
||||
private IConvertStrategy<FactoredForceTupleDTO, IFactoredForceTuple> factoredTupleConvertStrategy;
|
||||
private IConvertStrategy<IBeamSpanLoad, IBeamSpanLoad> spanLoadConvertStrategy;
|
||||
|
||||
public BeamShearAxisActionToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override BeamShearAxisActionDTO GetNewItem(IBeamShearAxisAction source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewBeamAction(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewBeamAction(IBeamShearAxisAction source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting of beam shear action Id = {source.Id} has been started", TraceLogStatuses.Debug);
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.SupportForce = factoredTupleConvertStrategy.Convert(source.SupportForce);
|
||||
NewItem.ShearLoads.Clear();
|
||||
foreach (var spanLoad in source.ShearLoads)
|
||||
{
|
||||
var newSpanLoad = spanLoadConvertStrategy.Convert(spanLoad);
|
||||
NewItem.ShearLoads.Add(newSpanLoad);
|
||||
}
|
||||
TraceLogger?.AddMessage($"Converting of beam shear action Id = {source.Id} has been finished", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearAxisActionUpdateStrategy();
|
||||
factoredTupleConvertStrategy = new DictionaryConvertStrategy<FactoredForceTupleDTO, IFactoredForceTuple>
|
||||
(this, new FactoredForceTupleToDTOConvertStrategy(this));
|
||||
spanLoadConvertStrategy = new DictionaryConvertStrategy<IBeamSpanLoad, IBeamSpanLoad>
|
||||
(this, new BeamSpanLoadToDTOConvertStrategy(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.ThrowIfNull(source);
|
||||
CheckObject.ThrowIfNull(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using DataAccess.DTOs.Converters.BeamShears;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
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;
|
||||
private IConvertStrategy<BeamShearDesignRangeProperty, BeamShearDesignRangePropertyDTO> designRangeConvertStrategy;
|
||||
|
||||
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);
|
||||
if (source.DesignRangeProperty is BeamShearDesignRangePropertyDTO propertyDTO)
|
||||
{
|
||||
NewItem.DesignRangeProperty = designRangeConvertStrategy.Convert(propertyDTO);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.DesignRangeProperty));
|
||||
}
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearCalculatorInputDataUpdateStrategy();
|
||||
actionUpdateStrategy ??= new HasBeamShearActionsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
sectionUpdateStrategy ??= new HasBeamShearSectionsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
stirrupUpdateStrategy ??= new HasStirrupsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
designRangeConvertStrategy ??= new BeamShearDesignRangePropertyFromDTOConvertStrategy(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearCalculatorInputDataToDTOConvertStrategy : ConvertStrategy<BeamShearCalculatorInputDataDTO, IBeamShearCalculatorInputData>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShearCalculatorInputData> updateStrategy;
|
||||
private IUpdateStrategy<IHasBeamShearActions> actionUpdateStrategy;
|
||||
private IUpdateStrategy<IHasBeamShearSections> sectionUpdateStrategy;
|
||||
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
|
||||
private IConvertStrategy<BeamShearDesignRangePropertyDTO, IBeamShearDesignRangeProperty> designRangeConvertStrategy;
|
||||
|
||||
public BeamShearCalculatorInputDataToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override BeamShearCalculatorInputDataDTO GetNewItem(IBeamShearCalculatorInputData source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
actionUpdateStrategy.Update(NewItem, source);
|
||||
sectionUpdateStrategy.Update(NewItem, source);
|
||||
stirrupUpdateStrategy.Update(NewItem, source);
|
||||
NewItem.DesignRangeProperty = designRangeConvertStrategy.Convert(source.DesignRangeProperty);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearCalculatorInputDataUpdateStrategy();
|
||||
actionUpdateStrategy ??= new HasBeamShearActionsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
sectionUpdateStrategy ??= new HasBeamShearSectionsToDTORenameStrategy(ReferenceDictionary, TraceLogger);
|
||||
stirrupUpdateStrategy ??= new HasStirrupsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
designRangeConvertStrategy ??= new BeamShearDesignRangePropertyToDTOConvertStrategy(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
namespace DataAccess.DTOs.Converters.BeamShears
|
||||
{
|
||||
public class BeamShearDesignRangePropertyFromDTOConvertStrategy : ConvertStrategy<BeamShearDesignRangeProperty, BeamShearDesignRangePropertyDTO>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShearDesignRangeProperty> updateStrategy;
|
||||
|
||||
public BeamShearDesignRangePropertyFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override BeamShearDesignRangeProperty GetNewItem(BeamShearDesignRangePropertyDTO source)
|
||||
{
|
||||
updateStrategy ??= new BeamShearDesignRangePropertyUpdateStrategy();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearDesignRangePropertyToDTOConvertStrategy : ConvertStrategy<BeamShearDesignRangePropertyDTO, IBeamShearDesignRangeProperty>
|
||||
{
|
||||
IUpdateStrategy<IBeamShearDesignRangeProperty>? updateStrategy;
|
||||
|
||||
public BeamShearDesignRangePropertyToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override BeamShearDesignRangePropertyDTO GetNewItem(IBeamShearDesignRangeProperty source)
|
||||
{
|
||||
updateStrategy ??= new BeamShearDesignRangePropertyUpdateStrategy();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.ThrowIfNull(source);
|
||||
CheckObject.ThrowIfNull(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
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;
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearRepositoryToDTOConvertStrategy : ConvertStrategy<BeamShearRepositoryDTO, IBeamShearRepository>
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
public override BeamShearRepositoryDTO GetNewItem(IBeamShearRepository source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewBeamRepository(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewBeamRepository(IBeamShearRepository source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting of beam shear repository 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);
|
||||
calculatorUpdateStrategy.Update(NewItem, source);
|
||||
TraceLogger?.AddMessage($"Converting of beam shear repository Id = {NewItem.Id} has been finished", TraceLogStatuses.Service);
|
||||
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
actionUpdateStrategy ??= new HasBeamShearActionsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
sectionUpdateStrategy ??= new HasBeamShearSectionsToDTORenameStrategy(ReferenceDictionary, TraceLogger);
|
||||
stirrupUpdateStrategy ??= new HasStirrupsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
calculatorUpdateStrategy ??= new HasBeamShearCalculatorsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
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 IConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO> reinforcementConvertStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy;
|
||||
private IUpdateStrategy<IHasVisualProperty> visualUpdateStrategy;
|
||||
|
||||
|
||||
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.ConcreteMaterial is not ConcreteLibMaterialDTO concreteDTO)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ConcreteMaterial));
|
||||
}
|
||||
NewItem.ConcreteMaterial = concreteConvertStrategy.Convert(concreteDTO);
|
||||
safetyFactorUpdateStrategy.Update(NewItem.ConcreteMaterial, concreteDTO);
|
||||
if (source.ReinforcementMaterial is not ReinforcementLibMaterialDTO reinforcement)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.ReinforcementMaterial));
|
||||
}
|
||||
NewItem.ReinforcementMaterial = reinforcementConvertStrategy.Convert(reinforcement);
|
||||
visualUpdateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearSectionUpdateStrategy() { UpdateChildren = false};
|
||||
shapeConvertStrategy = new DictionaryConvertStrategy<IShape, IShape>
|
||||
(this, new ShapeFromDTOConvertStrategy(this));
|
||||
concreteConvertStrategy = new ConcreteLibMaterialFromDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
reinforcementConvertStrategy = new ReinforcementLibMaterialFromDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorsFromDTOLogic());
|
||||
visualUpdateStrategy = new HasVisualPropertyFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearSectionToDTOConvertStrategy : ConvertStrategy<BeamShearSectionDTO, IBeamShearSection>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShearSection> updateStrategy;
|
||||
private IConvertStrategy<IShape, IShape> shapeConvertStrategy;
|
||||
private IConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy;
|
||||
private ReinforcementLibMaterialToDTOConvertStrategy reinforcementConvertStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy;
|
||||
private IUpdateStrategy<IHasVisualProperty> visualUpdateStrategy;
|
||||
|
||||
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.ConcreteMaterial = concreteConvertStrategy.Convert(source.ConcreteMaterial);
|
||||
safetyFactorUpdateStrategy.Update(NewItem.ConcreteMaterial, source.ConcreteMaterial);
|
||||
NewItem.ReinforcementMaterial = reinforcementConvertStrategy.Convert(source.ReinforcementMaterial);
|
||||
safetyFactorUpdateStrategy.Update(NewItem.ReinforcementMaterial, source.ReinforcementMaterial);
|
||||
TraceLogger?.AddMessage($"Beam shear section converting Id = {NewItem.Id} has been finished succesfully", TraceLogStatuses.Debug);
|
||||
visualUpdateStrategy.Update(NewItem, source);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearSectionUpdateStrategy() { UpdateChildren = false};
|
||||
shapeConvertStrategy = new DictionaryConvertStrategy<IShape, IShape>
|
||||
(this, new ShapeToDTOConvertStrategy(this));
|
||||
concreteConvertStrategy = new ConcreteLibMaterialToDTOConvertStrategy()
|
||||
{ ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger};
|
||||
reinforcementConvertStrategy = new ReinforcementLibMaterialToDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic());
|
||||
visualUpdateStrategy = new HasVisualPropertyToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearToDTOConvertStrategy : ConvertStrategy<BeamShearDTO, IBeamShear>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShear> updateStrategy;
|
||||
private IConvertStrategy<BeamShearRepositoryDTO, IBeamShearRepository> repositoryConvertStrategy;
|
||||
public BeamShearToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override BeamShearDTO GetNewItem(IBeamShear source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewBeamShear(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewBeamShear(IBeamShear source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting of beam shear Id = {source.Id} has been started");
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.Repository = repositoryConvertStrategy.Convert(source.Repository);
|
||||
TraceLogger?.AddMessage($"Converting of beam shear Id = {NewItem.Id} has been finished successfully");
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearUpdateStrategy();
|
||||
repositoryConvertStrategy = new DictionaryConvertStrategy<BeamShearRepositoryDTO, IBeamShearRepository>(
|
||||
ReferenceDictionary,
|
||||
TraceLogger,
|
||||
new BeamShearRepositoryToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.ThrowIfNull(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamSpanLoadToDTOConvertStrategy : ConvertStrategy<IBeamSpanLoad, IBeamSpanLoad>
|
||||
{
|
||||
public BeamSpanLoadToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override IBeamSpanLoad GetNewItem(IBeamSpanLoad source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewBeamAction(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewBeamAction(IBeamSpanLoad source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting of beam shear action Id = {source.Id} has been started", TraceLogStatuses.Debug);
|
||||
if (source is IDistributedLoad distributedLoad)
|
||||
{
|
||||
ProcessDistributedLoad(distributedLoad);
|
||||
}
|
||||
else if (source is IConcentratedForce concentratedForce)
|
||||
{
|
||||
ProcessConcentratedForce(concentratedForce);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": type of span load");
|
||||
}
|
||||
TraceLogger?.AddMessage($"Converting of beam shear action Id = {source.Id} has been finished", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
private void ProcessConcentratedForce(IConcentratedForce concentratedForce)
|
||||
{
|
||||
var convertStrategy = new DictionaryConvertStrategy<ConcentratedForceDTO, IConcentratedForce>
|
||||
(this, new ConcentratedForceToDTOConvertStrategy(this));
|
||||
ConcentratedForceDTO concentratedForceDTO = convertStrategy.Convert(concentratedForce);
|
||||
NewItem = concentratedForceDTO;
|
||||
}
|
||||
|
||||
private void ProcessDistributedLoad(IDistributedLoad distributedLoad)
|
||||
{
|
||||
var convertStrategy = new DictionaryConvertStrategy<DistributedLoadDTO, IDistributedLoad>
|
||||
(this, new DistributedLoadToDTOConvertStrategy(this));
|
||||
DistributedLoadDTO distributedLoadDTO = convertStrategy.Convert(distributedLoad);
|
||||
NewItem = distributedLoadDTO;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.ThrowIfNull(sourceObject.Actions);
|
||||
CheckObject.ThrowIfNull(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasBeamShearActionsToDTOUpdateStrategy : IUpdateStrategy<IHasBeamShearActions>
|
||||
{
|
||||
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
public HasBeamShearActionsToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
this.referenceDictionary = referenceDictionary;
|
||||
this.traceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasBeamShearActions targetObject, IHasBeamShearActions sourceObject)
|
||||
{
|
||||
CheckObject.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.ThrowIfNull(sourceObject.Actions);
|
||||
CheckObject.ThrowIfNull(targetObject.Actions);
|
||||
targetObject.Actions.Clear();
|
||||
foreach (var action in sourceObject.Actions)
|
||||
{
|
||||
var convertStrategy = new DictionaryConvertStrategy<BeamShearActionDTO, IBeamShearAction>(
|
||||
referenceDictionary,
|
||||
traceLogger,
|
||||
new BeamShearActionToDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
var newAction = convertStrategy.Convert(action);
|
||||
targetObject.Actions.Add(newAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.ThrowIfNull(sourceObject.Calculators);
|
||||
CheckObject.ThrowIfNull(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 HasBeamShearCalculatorsToDTOUpdateStrategy : IUpdateStrategy<IHasCalculators>
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
|
||||
public HasBeamShearCalculatorsToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
this.referenceDictionary = referenceDictionary;
|
||||
this.traceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasCalculators targetObject, IHasCalculators sourceObject)
|
||||
{
|
||||
CheckObject.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.ThrowIfNull(sourceObject.Calculators);
|
||||
CheckObject.ThrowIfNull(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.ThrowIfNull(sourceObject.Sections);
|
||||
CheckObject.ThrowIfNull(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasBeamShearSectionsToDTORenameStrategy : IUpdateStrategy<IHasBeamShearSections>
|
||||
{
|
||||
private IConvertStrategy<BeamShearSectionDTO, IBeamShearSection> convertStrategy;
|
||||
private Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; }
|
||||
private IShiftTraceLogger TraceLogger { get; }
|
||||
|
||||
public HasBeamShearSectionsToDTORenameStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
ReferenceDictionary = referenceDictionary;
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasBeamShearSections targetObject, IHasBeamShearSections sourceObject)
|
||||
{
|
||||
CheckObject.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.ThrowIfNull(sourceObject.Sections);
|
||||
CheckObject.ThrowIfNull(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
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;
|
||||
private IUpdateStrategy<IHasVisualProperty> visualUpdateStrategy;
|
||||
|
||||
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.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.ThrowIfNull(sourceObject.Stirrups);
|
||||
CheckObject.ThrowIfNull(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 if (stirrup is StirrupGroupDTO stirrupGroup)
|
||||
{
|
||||
newItem = ProcessStirrupGroup(stirrupGroup);
|
||||
}
|
||||
else if (stirrup is StirrupByInclinedRebarDTO inclinedRebar)
|
||||
{
|
||||
newItem = ProcessInclinedRebar(inclinedRebar);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrup));
|
||||
}
|
||||
visualUpdateStrategy = new HasVisualPropertyFromDTOUpdateStrategy(referenceDictionary, traceLogger);
|
||||
visualUpdateStrategy.Update(newItem, stirrup);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IStirrup ProcessInclinedRebar(StirrupByInclinedRebarDTO inclinedRebar)
|
||||
{
|
||||
traceLogger?.AddMessage("Stirrup is stirrup by inclined rebar");
|
||||
var convertStrategy = new DictionaryConvertStrategy<StirrupByInclinedRebar, IStirrupByInclinedRebar>
|
||||
(referenceDictionary, traceLogger, new StirrupByInclinedRebarFromDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
return convertStrategy.Convert(inclinedRebar);
|
||||
}
|
||||
|
||||
private IStirrup ProcessStirrupGroup(StirrupGroupDTO stirrupGroup)
|
||||
{
|
||||
traceLogger?.AddMessage("Stirrup is stirrup group");
|
||||
var convertStrategy = new DictionaryConvertStrategy<StirrupGroup, IStirrupGroup>
|
||||
(referenceDictionary, traceLogger, new StirrupGroupFromDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
return convertStrategy.Convert(stirrupGroup);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasStirrupsToDTOUpdateStrategy : IUpdateStrategy<IHasStirrups>
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IUpdateStrategy<IHasVisualProperty> visualUpdateStrategy;
|
||||
|
||||
public HasStirrupsToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
this.referenceDictionary = referenceDictionary;
|
||||
this.traceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasStirrups targetObject, IHasStirrups sourceObject)
|
||||
{
|
||||
CheckObject.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.ThrowIfNull(sourceObject.Stirrups);
|
||||
CheckObject.ThrowIfNull(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)
|
||||
{
|
||||
traceLogger?.AddMessage($"Stirrup Id = {stirrup.Id} has been started", TraceLogStatuses.Debug);
|
||||
IStirrup newItem;
|
||||
if (stirrup is IStirrupByRebar rebar)
|
||||
{
|
||||
newItem = ProcessRebar(rebar);
|
||||
}
|
||||
else if (stirrup is IStirrupGroup group)
|
||||
{
|
||||
newItem = ProcessGroup(group);
|
||||
}
|
||||
else if (stirrup is IStirrupByInclinedRebar inclinatedRebar)
|
||||
{
|
||||
newItem = ProcessInclinatedRebar(inclinatedRebar);
|
||||
}
|
||||
else if (stirrup is IStirrupByDensity density)
|
||||
{
|
||||
newItem = ProcessDensity(density);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrup));
|
||||
}
|
||||
visualUpdateStrategy = new HasVisualPropertyToDTOUpdateStrategy(referenceDictionary, traceLogger);
|
||||
visualUpdateStrategy.Update(newItem, stirrup);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IStirrup ProcessInclinatedRebar(IStirrupByInclinedRebar inclinedRebar)
|
||||
{
|
||||
traceLogger?.AddMessage("Stirrup is inclined rebar");
|
||||
var convertStrategy = new DictionaryConvertStrategy<StirrupByInclinedRebarDTO, IStirrupByInclinedRebar>
|
||||
(referenceDictionary, traceLogger, new StirrupByInclinedRebarToDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
return convertStrategy.Convert(inclinedRebar);
|
||||
}
|
||||
|
||||
private IStirrup ProcessGroup(IStirrupGroup group)
|
||||
{
|
||||
traceLogger?.AddMessage("Stirrup is stirrup group");
|
||||
var convertStrategy = new DictionaryConvertStrategy<StirrupGroupDTO, IStirrupGroup>
|
||||
(referenceDictionary, traceLogger, new StirrupGroupToDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
return convertStrategy.Convert(group);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class StirrupByInclinedRebarFromDTOConvertStrategy : ConvertStrategy<StirrupByInclinedRebar, IStirrupByInclinedRebar>
|
||||
{
|
||||
private IUpdateStrategy<IStirrupByInclinedRebar> updateStrategy;
|
||||
private IConvertStrategy<RebarSection, IRebarSection> rebarSectionConvertStrategy;
|
||||
|
||||
public StirrupByInclinedRebarFromDTOConvertStrategy(
|
||||
Dictionary<(Guid id, Type type), ISaveable> referenceDictionary,
|
||||
IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override StirrupByInclinedRebar GetNewItem(IStirrupByInclinedRebar source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.RebarSection = rebarSectionConvertStrategy.Convert(source.RebarSection);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new StirrupByInclinedRebarUpdateStrategy() { UpdateChildren = false};
|
||||
rebarSectionConvertStrategy ??= new RebarSectionFromDTOConvertStrategy(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
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 StirrupByInclinedRebarToDTOConvertStrategy : ConvertStrategy<StirrupByInclinedRebarDTO, IStirrupByInclinedRebar>
|
||||
{
|
||||
private IUpdateStrategy<IStirrupByInclinedRebar> updateStrategy;
|
||||
private IConvertStrategy<RebarSectionDTO, IRebarSection> rebarConvertStrategy;
|
||||
|
||||
|
||||
public StirrupByInclinedRebarToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override StirrupByInclinedRebarDTO GetNewItem(IStirrupByInclinedRebar source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Stirrup by inclinated rebar converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
|
||||
updateStrategy ??= new StirrupByInclinedRebarUpdateStrategy();
|
||||
rebarConvertStrategy ??= new RebarSectionToDTOConvertStrategy(this);
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.RebarSection = rebarConvertStrategy.Convert(source.RebarSection);
|
||||
TraceLogger?.AddMessage($"Stirrup by inclinated rebar converting Id = {NewItem.Id} has been finished succesfully", TraceLogStatuses.Debug);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 IUpdateStrategy<IStirrupByRebar> 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 rebar 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 rebar 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class StirrupGroupFromDTOConvertStrategy : ConvertStrategy<StirrupGroup, IStirrupGroup>
|
||||
{
|
||||
private IUpdateStrategy<IStirrupGroup> updateStrategy;
|
||||
private IUpdateStrategy<IHasStirrups> hasStirrupsUpdateStrategy;
|
||||
|
||||
public StirrupGroupFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override StirrupGroup GetNewItem(IStirrupGroup source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
hasStirrupsUpdateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new StirrupGroupUpdateStrategy() { UpdateChildren = false};
|
||||
hasStirrupsUpdateStrategy ??= new HasStirrupsFromDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.BeamShears.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
internal class StirrupGroupToDTOConvertStrategy : ConvertStrategy<StirrupGroupDTO, IStirrupGroup>
|
||||
{
|
||||
private IUpdateStrategy<IStirrupGroup> updateStrategy;
|
||||
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
|
||||
|
||||
|
||||
public StirrupGroupToDTOConvertStrategy(
|
||||
Dictionary<(Guid id, Type type), ISaveable> referenceDictionary,
|
||||
IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override StirrupGroupDTO GetNewItem(IStirrupGroup source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
stirrupUpdateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new StirrupGroupUpdateStrategy() { UpdateChildren = false};
|
||||
stirrupUpdateStrategy ??= new HasStirrupsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
}
|
||||
}
|
||||
116
DataAccess/DTOs/Converters/CalculatorToDTOConvertStrategy.cs
Normal file
116
DataAccess/DTOs/Converters/CalculatorToDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CalculatorToDTOConvertStrategy : IConvertStrategy<ICalculator, ICalculator>
|
||||
{
|
||||
private readonly IConvertStrategy<ForceCalculatorDTO, IForceCalculator> forceCalculatorStrategy;
|
||||
private readonly IConvertStrategy<CrackCalculatorDTO, ICrackCalculator> crackCalculatorStrategy;
|
||||
|
||||
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
public CalculatorToDTOConvertStrategy(
|
||||
IConvertStrategy<ForceCalculatorDTO, IForceCalculator> forceCalculatorStrategy,
|
||||
IConvertStrategy<CrackCalculatorDTO, ICrackCalculator> crackCalculatorStrategy)
|
||||
{
|
||||
this.forceCalculatorStrategy = forceCalculatorStrategy;
|
||||
this.crackCalculatorStrategy = crackCalculatorStrategy;
|
||||
}
|
||||
|
||||
public CalculatorToDTOConvertStrategy() : this (
|
||||
new ForceCalculatorToDTOConvertStrategy(),
|
||||
new CrackCalculatorToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ICalculator Convert(ICalculator source)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ProcessCalculators(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ICalculator ProcessCalculators(ICalculator source)
|
||||
{
|
||||
if (source is IForceCalculator forceCalculator)
|
||||
{
|
||||
return ProcessForceCalculator(forceCalculator);
|
||||
}
|
||||
if (source is ICrackCalculator crackCalculator)
|
||||
{
|
||||
return ProcessCrackCalculator(crackCalculator);
|
||||
}
|
||||
if (source is LimitCurvesCalculator limitCalculator)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Current version of StructureHelper does not suppurt saving interaction diagram calculator, {limitCalculator.Name} was ignored");
|
||||
}
|
||||
if (source is IValueDiagramCalculator valueDiagramCalculator)
|
||||
{
|
||||
return ProcessValueDiagramCalcualtor(valueDiagramCalculator);
|
||||
}
|
||||
if (source is CurvatureCalculator curvatureCalculator)
|
||||
{
|
||||
return ProcessCurvatureCalcualtor(curvatureCalculator);
|
||||
}
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
|
||||
private ICalculator ProcessCurvatureCalcualtor(CurvatureCalculator calculator)
|
||||
{
|
||||
var convertStrategy = new CurvatureCalculatorToDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger,
|
||||
};
|
||||
var dictionaryConvertStrategy = new DictionaryConvertStrategy<CurvatureCalculatorDTO, ICurvatureCalculator>(this, convertStrategy);
|
||||
return dictionaryConvertStrategy.Convert(calculator);
|
||||
}
|
||||
|
||||
private ValueDiagramCalculatorDTO ProcessValueDiagramCalcualtor(IValueDiagramCalculator valueDiagramCalculator)
|
||||
{
|
||||
var convertStrategy = new ValueDiagramCalculatorToDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var dictionaryConvertStrategy = new DictionaryConvertStrategy<ValueDiagramCalculatorDTO, IValueDiagramCalculator>(this, convertStrategy);
|
||||
return dictionaryConvertStrategy.Convert(valueDiagramCalculator);
|
||||
}
|
||||
|
||||
private CrackCalculatorDTO ProcessCrackCalculator(ICrackCalculator crackCalculator)
|
||||
{
|
||||
crackCalculatorStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
crackCalculatorStrategy.TraceLogger = TraceLogger;
|
||||
var logic = new DictionaryConvertStrategy<CrackCalculatorDTO, ICrackCalculator>(this, crackCalculatorStrategy);
|
||||
return logic.Convert(crackCalculator);
|
||||
}
|
||||
|
||||
private ForceCalculatorDTO ProcessForceCalculator(IForceCalculator forceCalculator)
|
||||
{
|
||||
forceCalculatorStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceCalculatorStrategy.TraceLogger = TraceLogger;
|
||||
var logic = new DictionaryConvertStrategy<ForceCalculatorDTO, IForceCalculator>(this, forceCalculatorStrategy);
|
||||
return logic.Convert(forceCalculator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CalculatorsFromDTOConvertStrategy : ConvertStrategy<ICalculator, ICalculator>
|
||||
{
|
||||
private const string CalculatorIs = "Calculator is";
|
||||
private IConvertStrategy<ForceCalculator, ForceCalculatorDTO> forceConvertStrategy = new ForceCalculatorFromDTOConvertStrategy();
|
||||
private IConvertStrategy<CrackCalculator, CrackCalculatorDTO> crackConvertStrategy = new CrackCalculatorFromDTOConvertStrategy();
|
||||
|
||||
public override ICalculator GetNewItem(ICalculator source)
|
||||
{
|
||||
NewItem = GetNewCalculator(source);
|
||||
TraceLogger?.AddMessage($"Calculator Id = {NewItem.Id}, Name = {NewItem.Name} has been obtained");
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private ICalculator GetNewCalculator(ICalculator source)
|
||||
{
|
||||
if (source is IForceCalculator forceCalculator)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{CalculatorIs} force calculator");
|
||||
IForceCalculator calculator = GetForcCalculator(forceCalculator);
|
||||
return calculator;
|
||||
}
|
||||
if (source is ICrackCalculator crackCalculator)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{CalculatorIs} crack calculator");
|
||||
ICrackCalculator calculator = GetCrackCalculator(crackCalculator);
|
||||
return calculator;
|
||||
}
|
||||
if (source is ValueDiagramCalculatorDTO valueDiagramCalculator)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{CalculatorIs} value digram calculator");
|
||||
return GetValueDiagramCalculator(valueDiagramCalculator);
|
||||
}
|
||||
if (source is CurvatureCalculatorDTO curvatureCalculator)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{CalculatorIs} curvature calculator");
|
||||
return GetCurvatureCalculator(curvatureCalculator);
|
||||
}
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
|
||||
private CurvatureCalculator GetCurvatureCalculator(CurvatureCalculatorDTO calculator)
|
||||
{
|
||||
var convertStrategy = new CurvatureCalculatorFromDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger,
|
||||
};
|
||||
return convertStrategy.Convert(calculator);
|
||||
}
|
||||
|
||||
private ValueDiagramCalculator GetValueDiagramCalculator(ValueDiagramCalculatorDTO valueDiagramCalculator)
|
||||
{
|
||||
var convertStrategy = new ValueDiagramCalcualtorFromDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger,
|
||||
};
|
||||
return convertStrategy.Convert(valueDiagramCalculator);
|
||||
}
|
||||
|
||||
private ICrackCalculator GetCrackCalculator(ICrackCalculator crackCalculator)
|
||||
{
|
||||
crackConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
crackConvertStrategy.TraceLogger = TraceLogger;
|
||||
CrackCalculator newItem = crackConvertStrategy.Convert(crackCalculator as CrackCalculatorDTO);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IForceCalculator GetForcCalculator(IForceCalculator forceCalculator)
|
||||
{
|
||||
forceConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceConvertStrategy.TraceLogger = TraceLogger;
|
||||
ForceCalculator newItem = forceConvertStrategy.Convert(forceCalculator as ForceCalculatorDTO);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ColumnFilePropertyFromDTOConvertStrategy : ConvertStrategy<ColumnFileProperty, ColumnFilePropertyDTO>
|
||||
{
|
||||
private IUpdateStrategy<IColumnFileProperty> updateStrategy;
|
||||
public override ColumnFileProperty GetNewItem(ColumnFilePropertyDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
updateStrategy ??= new ColumnFilePropertyUpdateStrategy();
|
||||
ColumnFileProperty newItem = new(source.Id, source.Name);
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ColumnFilePropertyToDTOConvertStrategy : ConvertStrategy<ColumnFilePropertyDTO, IColumnFileProperty>
|
||||
{
|
||||
private IUpdateStrategy<IColumnFileProperty> updateStrategy;
|
||||
|
||||
public ColumnFilePropertyToDTOConvertStrategy(IUpdateStrategy<IColumnFileProperty> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ColumnFilePropertyToDTOConvertStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ColumnFilePropertyDTO GetNewItem(IColumnFileProperty source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Column file property Id={source.Id} converting to {typeof(ColumnFilePropertyDTO)} has been started");
|
||||
updateStrategy ??= new ColumnFilePropertyUpdateStrategy();
|
||||
ColumnFilePropertyDTO newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage($"Column file property Id={source.Id} converting to {typeof(ColumnFilePropertyDTO)} has been finished");
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ColumnedFilePropertyFromDTOConvertStrategy : ConvertStrategy<ColumnedFileProperty, ColumnedFilePropertyDTO>
|
||||
{
|
||||
private IUpdateStrategy<IColumnedFileProperty>? updateStrategy;
|
||||
private IConvertStrategy<ColumnFileProperty, ColumnFilePropertyDTO>? columnConvertStrategy;
|
||||
public override ColumnedFileProperty GetNewItem(ColumnedFilePropertyDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting of columned file property Path={source.FilePath} has been started");
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
ColumnedFileProperty newItem = GetFilePropertyBySource(source);
|
||||
TraceLogger?.AddMessage($"Converting of columned file property Path={newItem.FilePath} has been finished successfully");
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(this)} made error: {ex.Message}", TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ColumnedFileProperty GetFilePropertyBySource(ColumnedFilePropertyDTO source)
|
||||
{
|
||||
ColumnedFileProperty newItem = new(source.Id);
|
||||
updateStrategy?.Update(newItem, source);
|
||||
newItem.ColumnProperties.Clear();
|
||||
foreach (var item in source.ColumnProperties)
|
||||
{
|
||||
if (item is ColumnFilePropertyDTO columnPropertyDTO)
|
||||
{
|
||||
ColumnFileProperty columnFileProperty = columnConvertStrategy.Convert(columnPropertyDTO);
|
||||
newItem.ColumnProperties.Add(columnFileProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ExpectedWas(typeof(ColumnFilePropertyDTO), item);
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
}
|
||||
|
||||
return newItem;
|
||||
}
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ColumnedFilePropertyUpdateStrategy();
|
||||
columnConvertStrategy ??= new ColumnFilePropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public class ColumnedFilePropertyToDTOConvertStrategy : ConvertStrategy<ColumnedFilePropertyDTO, IColumnedFileProperty>
|
||||
{
|
||||
private IUpdateStrategy<IColumnedFileProperty>? updateStrategy;
|
||||
private IConvertStrategy<ColumnFilePropertyDTO, IColumnFileProperty>? columnConvertStrategy;
|
||||
|
||||
public override ColumnedFilePropertyDTO GetNewItem(IColumnedFileProperty source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Columned file property Id = {source.Id}, Path = {source.FilePath} converting has been started");
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
ColumnedFilePropertyDTO newItem = GetNewItemBySource(source);
|
||||
TraceLogger?.AddMessage($"Columned file property Id={newItem.Id}, Path = {newItem.FilePath} converting has been finished successfully");
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(this)} made error: {ex.Message}", TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ColumnedFilePropertyDTO GetNewItemBySource(IColumnedFileProperty source)
|
||||
{
|
||||
ColumnedFilePropertyDTO newItem = new(source.Id);
|
||||
updateStrategy?.Update(newItem, source);
|
||||
newItem.ColumnProperties.Clear();
|
||||
foreach (var item in source.ColumnProperties)
|
||||
{
|
||||
ColumnFilePropertyDTO columnFilePropertyDTO = columnConvertStrategy.Convert(item);
|
||||
newItem.ColumnProperties.Add(columnFilePropertyDTO);
|
||||
}
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ColumnedFilePropertyUpdateStrategy();
|
||||
columnConvertStrategy ??= new ColumnFilePropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
}
|
||||
}
|
||||
}
|
||||
8
DataAccess/DTOs/Converters/ConvertDirection.cs
Normal file
8
DataAccess/DTOs/Converters/ConvertDirection.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public enum ConvertDirection
|
||||
{
|
||||
FromDTO,
|
||||
ToDTO
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CurvatureCalculatorFromDTOConvertStrategy : ConvertStrategy<CurvatureCalculator, CurvatureCalculatorDTO>
|
||||
{
|
||||
IUpdateStrategy<ICurvatureCalculator> updateStrategy;
|
||||
IConvertStrategy<CurvatureCalculatorInputData, CurvatureCalculatorInputDataDTO> inputDataConvertStrategy;
|
||||
IUpdateStrategy<ICurvatureCalculator> UpdateStrategy => updateStrategy ??= new CurvatureCalculatorUpdateStrategy() { UpdateChildren = false };
|
||||
IConvertStrategy<CurvatureCalculatorInputData, CurvatureCalculatorInputDataDTO> InputDataConvertStrategy => inputDataConvertStrategy ??= new CurvatureCalculatorInputDataFromDTOConvertStrategy(this);
|
||||
|
||||
public override CurvatureCalculator GetNewItem(CurvatureCalculatorDTO source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
if (source.InputData is not CurvatureCalculatorInputDataDTO inputData)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.InputData) + ": deflection factor");
|
||||
}
|
||||
NewItem.InputData = InputDataConvertStrategy.Convert(inputData);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CurvatureCalculatorInputDataFromDTOConvertStrategy : ConvertStrategy<CurvatureCalculatorInputData, CurvatureCalculatorInputDataDTO>
|
||||
{
|
||||
private IProcessLogic<IHasForcesAndPrimitives> forcesAndPrimitivesProcessLogic;
|
||||
private IUpdateStrategy<ICurvatureCalculatorInputData> updateStrategy;
|
||||
private IConvertStrategy<DeflectionFactor, DeflectionFactorDTO> deflectionConvertStrategy;
|
||||
private IProcessLogic<IHasForcesAndPrimitives> ForcesAndPrimitivesProcessLogic => forcesAndPrimitivesProcessLogic ??= new HasForcesAndPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
private IUpdateStrategy<ICurvatureCalculatorInputData> UpdateStrategy => updateStrategy ??= new CurvatureCalculatorInputDataUpdateStrategy() { UpdateChildren = false };
|
||||
private IConvertStrategy<DeflectionFactor, DeflectionFactorDTO> DeflectionConvertStrategy => deflectionConvertStrategy ??= new DeflectionFactorFromDTOConvertStrategy(this);
|
||||
public CurvatureCalculatorInputDataFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
public override CurvatureCalculatorInputData GetNewItem(CurvatureCalculatorInputDataDTO source)
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
if (source.DeflectionFactor is not DeflectionFactorDTO deflectionFactorDTO)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.DeflectionFactor) + ": deflection factor");
|
||||
}
|
||||
NewItem.DeflectionFactor = DeflectionConvertStrategy.Convert(deflectionFactorDTO);
|
||||
ProcessForcesAndPrimitives(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
|
||||
private void ProcessForcesAndPrimitives(IHasForcesAndPrimitives source)
|
||||
{
|
||||
ForcesAndPrimitivesProcessLogic.Source = source;
|
||||
ForcesAndPrimitivesProcessLogic.Target = NewItem;
|
||||
ForcesAndPrimitivesProcessLogic.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CurvatureCalculatorInputDataToDTOConvertStrategy : ConvertStrategy<CurvatureCalculatorInputDataDTO, ICurvatureCalculatorInputData>
|
||||
{
|
||||
private IProcessLogic<IHasForcesAndPrimitives> actionsProcessLogic;
|
||||
private IUpdateStrategy<ICurvatureCalculatorInputData> updateStrategy;
|
||||
private IConvertStrategy<DeflectionFactorDTO, IDeflectionFactor> deflectionConvertStrategy;
|
||||
|
||||
private IProcessLogic<IHasForcesAndPrimitives> ForceAndPrimitivesLogic => actionsProcessLogic ??= new HasForcesAndPrimitivesProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
private IUpdateStrategy<ICurvatureCalculatorInputData> UpdateStrategy => updateStrategy ??= new CurvatureCalculatorInputDataUpdateStrategy() { UpdateChildren = false};
|
||||
private IConvertStrategy<DeflectionFactorDTO, IDeflectionFactor> DeflectionConvertStrategy => deflectionConvertStrategy ??= new DeflectionFactorToDTOConvertStrategy(this);
|
||||
|
||||
public CurvatureCalculatorInputDataToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override CurvatureCalculatorInputDataDTO GetNewItem(ICurvatureCalculatorInputData source)
|
||||
{
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
NewItem.DeflectionFactor = DeflectionConvertStrategy.Convert(source.DeflectionFactor);
|
||||
ProcessActions(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void ProcessActions(IHasForcesAndPrimitives source)
|
||||
{
|
||||
ForceAndPrimitivesLogic.Source = source;
|
||||
ForceAndPrimitivesLogic.Target = NewItem;
|
||||
ForceAndPrimitivesLogic.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CurvatureCalculatorToDTOConvertStrategy : ConvertStrategy<CurvatureCalculatorDTO, ICurvatureCalculator>
|
||||
{
|
||||
IUpdateStrategy<ICurvatureCalculator> updateStrategy;
|
||||
IConvertStrategy<CurvatureCalculatorInputDataDTO, ICurvatureCalculatorInputData> inputDataConvertStrategy;
|
||||
IUpdateStrategy<ICurvatureCalculator> UpdateStrategy => updateStrategy ??= new CurvatureCalculatorUpdateStrategy() { UpdateChildren = false};
|
||||
IConvertStrategy<CurvatureCalculatorInputDataDTO, ICurvatureCalculatorInputData> InputDataConvertStrategy => inputDataConvertStrategy ??= new CurvatureCalculatorInputDataToDTOConvertStrategy(this);
|
||||
|
||||
|
||||
public override CurvatureCalculatorDTO GetNewItem(ICurvatureCalculator source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
NewItem.InputData = InputDataConvertStrategy.Convert(source.InputData);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DeflectionFactorFromDTOConvertStrategy : ConvertStrategy<DeflectionFactor, DeflectionFactorDTO>
|
||||
{
|
||||
private IUpdateStrategy<IDeflectionFactor> updateStrategy;
|
||||
private IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy;
|
||||
|
||||
public DeflectionFactorFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
private IUpdateStrategy<IDeflectionFactor> UpdateStrategy => updateStrategy ??= new DeflectionFactorUpdateStrategy() { UpdateChildren = false };
|
||||
private IConvertStrategy<ForceTuple, ForceTupleDTO> ForceTupleConvertStrategy => forceTupleConvertStrategy ??= new ForceTupleFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
|
||||
public override DeflectionFactor GetNewItem(DeflectionFactorDTO source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
if (source.DeflectionFactors is not ForceTupleDTO deflectionFactor)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.DeflectionFactors) + ": deflection factor");
|
||||
}
|
||||
NewItem.DeflectionFactors = ForceTupleConvertStrategy.Convert(deflectionFactor);
|
||||
if (source.MaxDeflections is not ForceTupleDTO maxDeflections)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.MaxDeflections) + ": maximum deflections");
|
||||
}
|
||||
NewItem.MaxDeflections = ForceTupleConvertStrategy.Convert(maxDeflections);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DeflectionFactorToDTOConvertStrategy : ConvertStrategy<DeflectionFactorDTO, IDeflectionFactor>
|
||||
{
|
||||
private IUpdateStrategy<IDeflectionFactor> updateStrategy;
|
||||
private IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy;
|
||||
private IUpdateStrategy<IDeflectionFactor> UpdateStrategy => updateStrategy??= new DeflectionFactorUpdateStrategy() { UpdateChildren = false};
|
||||
private IConvertStrategy<ForceTupleDTO, IForceTuple> ForceTupleConvertStrategy => forceTupleConvertStrategy ??= new ForceTupleToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
|
||||
public DeflectionFactorToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
public override DeflectionFactorDTO GetNewItem(IDeflectionFactor source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
UpdateStrategy.Update(NewItem, source);
|
||||
NewItem.DeflectionFactors = ForceTupleConvertStrategy.Convert(source.DeflectionFactors);
|
||||
NewItem.MaxDeflections = ForceTupleConvertStrategy.Convert(source.MaxDeflections);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DateVersionFromDTOConvertStrategy : ConvertStrategy<IDateVersion, IDateVersion>
|
||||
{
|
||||
private IUpdateStrategy<IDateVersion> updateStrategy;
|
||||
private IConvertStrategy<ISaveable, ISaveable> convertStrategy;
|
||||
private IConvertStrategy<ISaveable, ISaveable> convertLogic;
|
||||
|
||||
public override IDateVersion GetNewItem(IDateVersion source)
|
||||
{
|
||||
ChildClass = this;
|
||||
return GetDateVersion(source);
|
||||
}
|
||||
|
||||
private DateVersion GetDateVersion(IDateVersion source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Date version converting is started", TraceLogStatuses.Service);
|
||||
InitializeStrategies();
|
||||
DateVersion newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion);
|
||||
TraceLogger?.AddMessage($"Date version date = {newItem.DateTime} converting has been finished", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new DateVersionUpdateStrategy();
|
||||
convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>
|
||||
(this, new VersionItemFromDTOConvertStrategy(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DateVersionToDTOConvertStrategy : ConvertStrategy<DateVersionDTO, IDateVersion>
|
||||
{
|
||||
private IUpdateStrategy<IDateVersion> updateStrategy;
|
||||
private DictionaryConvertStrategy<ISaveable, ISaveable> convertStrategy;
|
||||
|
||||
public DateVersionToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override DateVersionDTO GetNewItem(IDateVersion source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewDateVersion(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewDateVersion(IDateVersion source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Date version converting is started", TraceLogStatuses.Debug);
|
||||
InitializeStrategies();
|
||||
NewItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.AnalysisVersion = convertStrategy.Convert(source.AnalysisVersion);
|
||||
TraceLogger?.AddMessage("Date version converting has been finished", TraceLogStatuses.Service);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new DateVersionUpdateStrategy();
|
||||
convertStrategy = new DictionaryConvertStrategy<ISaveable, ISaveable>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger,
|
||||
ConvertStrategy = new VersionItemToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DesignForceTupleFromDTOConvertStrategy : ConvertStrategy<DesignForceTuple, DesignForceTupleDTO>
|
||||
{
|
||||
private IUpdateStrategy<IDesignForceTuple> updateStrategy;
|
||||
private IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy;
|
||||
|
||||
public DesignForceTupleFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IDesignForceTuple> updateStrategy,
|
||||
IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
|
||||
}
|
||||
|
||||
public DesignForceTupleFromDTOConvertStrategy() : this(
|
||||
new DesignForceTupleUpdateStrategy(),
|
||||
new ForceTupleFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override DesignForceTuple GetNewItem(DesignForceTupleDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Design force tuple converting has been started");
|
||||
try
|
||||
{
|
||||
DesignForceTuple newItem = GetNewItemBySource(source);
|
||||
TraceLogger?.AddMessage("Design force tuple converting has been finished");
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private DesignForceTuple GetNewItemBySource(DesignForceTupleDTO source)
|
||||
{
|
||||
DesignForceTuple newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceTupleConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ForceTuple, ForceTupleDTO>(this, forceTupleConvertStrategy);
|
||||
newItem.ForceTuple = convertLogic.Convert((ForceTupleDTO)source.ForceTuple);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DesignForceTupleToDTOConvertStrategy : IConvertStrategy<DesignForceTupleDTO, IDesignForceTuple>
|
||||
{
|
||||
private IUpdateStrategy<IDesignForceTuple> updateStrategy;
|
||||
private IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy;
|
||||
|
||||
public DesignForceTupleToDTOConvertStrategy(IUpdateStrategy<IDesignForceTuple> updateStrategy,
|
||||
IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
|
||||
}
|
||||
|
||||
public DesignForceTupleToDTOConvertStrategy() : this(
|
||||
new DesignForceTupleUpdateStrategy(),
|
||||
new ForceTupleToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public DesignForceTupleDTO Convert(IDesignForceTuple source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
DesignForceTupleDTO designForceTupleDTO = GetNewDesignForceTuple(source);
|
||||
return designForceTupleDTO;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private DesignForceTupleDTO GetNewDesignForceTuple(IDesignForceTuple source)
|
||||
{
|
||||
DesignForceTupleDTO newItem = new() { Id = source.Id };
|
||||
updateStrategy.Update(newItem, source);
|
||||
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceTupleConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>(this, forceTupleConvertStrategy);
|
||||
newItem.ForceTuple = convertLogic.Convert(source.ForceTuple);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<DesignForceTupleDTO, IDesignForceTuple>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DivisionSizeFromDTOConvertStrategy : ConvertStrategy<IDivisionSize, IDivisionSize>
|
||||
{
|
||||
IUpdateStrategy<IDivisionSize> updateStrategy;
|
||||
|
||||
public DivisionSizeFromDTOConvertStrategy(IUpdateStrategy<IDivisionSize> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public DivisionSizeFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
updateStrategy = new DivisionSizeUpdateStrategy();
|
||||
}
|
||||
|
||||
public override IDivisionSize GetNewItem(IDivisionSize source)
|
||||
{
|
||||
if (source is not DivisionSizeDTO sourceDTO)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
|
||||
}
|
||||
NewItem = new DivisionSize(source.Id);
|
||||
updateStrategy.Update(NewItem, sourceDTO);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DivisionSizeToDTOConvertStrategy : IConvertStrategy<DivisionSizeDTO, IDivisionSize>
|
||||
{
|
||||
private IUpdateStrategy<IDivisionSize> updateStrategy;
|
||||
|
||||
public DivisionSizeToDTOConvertStrategy(IUpdateStrategy<IDivisionSize> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public DivisionSizeToDTOConvertStrategy() : this (new DivisionSizeUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public DivisionSizeDTO Convert(IDivisionSize source)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetNewDivisionSize(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private DivisionSizeDTO GetNewDivisionSize(IDivisionSize source)
|
||||
{
|
||||
DivisionSizeDTO newItem = new() { Id = source.Id };
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FileVersionFromDTOConvertStrategy : IConvertStrategy<FileVersion, FileVersionDTO>
|
||||
{
|
||||
private IUpdateStrategy<IFileVersion> updateStrategy;
|
||||
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public FileVersionFromDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
public FileVersionFromDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FileVersion Convert(FileVersionDTO source)
|
||||
{
|
||||
FileVersion fileVersion = new(source.Id);
|
||||
updateStrategy.Update(fileVersion, source);
|
||||
return fileVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FileVersionToDTOConvertStrategy : IConvertStrategy<FileVersionDTO, IFileVersion>
|
||||
{
|
||||
private IUpdateStrategy<IFileVersion> updateStrategy;
|
||||
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
|
||||
public FileVersionToDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
public FileVersionToDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FileVersionDTO Convert(IFileVersion source)
|
||||
{
|
||||
FileVersionDTO fileVersion = new(source.Id);
|
||||
updateStrategy.Update(fileVersion, source);
|
||||
return fileVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.BeamShearActions;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ConcentratedForceToDTOConvertStrategy : ConvertStrategy<ConcentratedForceDTO, IConcentratedForce>
|
||||
{
|
||||
private IUpdateStrategy<IConcentratedForce> updateStrategy;
|
||||
private IConvertStrategy<ForceTupleDTO, IForceTuple> tupleConvertStrategy;
|
||||
private IConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty> combinationConvertStrategy;
|
||||
|
||||
public ConcentratedForceToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override ConcentratedForceDTO GetNewItem(IConcentratedForce source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewConcentratedForce(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewConcentratedForce(IConcentratedForce source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Concentrated force converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.ForceValue = tupleConvertStrategy.Convert(source.ForceValue);
|
||||
NewItem.CombinationProperty = combinationConvertStrategy.Convert(source.CombinationProperty);
|
||||
TraceLogger?.AddMessage($"Concentrated force converting Id = {NewItem.Id} has been finished successfully", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ConcentratedForceUpdateStrategy();
|
||||
tupleConvertStrategy = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>
|
||||
(this, new ForceTupleToDTOConvertStrategy(ReferenceDictionary, TraceLogger));
|
||||
combinationConvertStrategy = new DictionaryConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty>
|
||||
(this, new FactoredCombinationPropertyToDTOConvertStrategy(ReferenceDictionary, TraceLogger));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.BeamShearActions;
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DistributedLoadToDTOConvertStrategy : ConvertStrategy<DistributedLoadDTO, IDistributedLoad>
|
||||
{
|
||||
private IUpdateStrategy<IDistributedLoad> updateStrategy;
|
||||
private IConvertStrategy<ForceTupleDTO, IForceTuple> tupleConvertStrategy;
|
||||
private IConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty> combinationConvertStrategy;
|
||||
|
||||
public DistributedLoadToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override DistributedLoadDTO GetNewItem(IDistributedLoad source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewBeamAction(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewBeamAction(IDistributedLoad source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting of beam shear action Id = {source.Id} has been started", TraceLogStatuses.Debug);
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.LoadValue = tupleConvertStrategy.Convert(source.LoadValue);
|
||||
NewItem.CombinationProperty = combinationConvertStrategy.Convert(source.CombinationProperty);
|
||||
TraceLogger?.AddMessage($"Converting of beam shear action Id = {source.Id} has been finished", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new DistributedLoadUpdateStrategy();
|
||||
tupleConvertStrategy = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>
|
||||
(this, new ForceTupleToDTOConvertStrategy(ReferenceDictionary, TraceLogger));
|
||||
combinationConvertStrategy = new DictionaryConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty>
|
||||
(this, new FactoredCombinationPropertyToDTOConvertStrategy(ReferenceDictionary, TraceLogger));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FactoredCombinationPropertyFromDTOConvertStrategy : ConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO>
|
||||
{
|
||||
private IUpdateStrategy<IFactoredCombinationProperty> updateStrategy;
|
||||
|
||||
public FactoredCombinationPropertyFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override FactoredCombinationProperty GetNewItem(FactoredCombinationPropertyDTO source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
TraceLogger.AddMessage($"Force factored combination property Id={source.Id} converting has been started");
|
||||
FactoredCombinationProperty newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger.AddMessage($"Force factored combination property Id={newItem.Id} converting has been finished");
|
||||
return newItem;
|
||||
}
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new FactoredCombinationPropertyUpdateStrategy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FactoredCombinationPropertyToDTOConvertStrategy : ConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty>
|
||||
{
|
||||
private IUpdateStrategy<IFactoredCombinationProperty> updateStrategy;
|
||||
|
||||
public FactoredCombinationPropertyToDTOConvertStrategy(IUpdateStrategy<IFactoredCombinationProperty> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public FactoredCombinationPropertyToDTOConvertStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FactoredCombinationPropertyToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override FactoredCombinationPropertyDTO GetNewItem(IFactoredCombinationProperty source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Force factored combination property Id={source.Id} converting has been started");
|
||||
InitializeStrategies();
|
||||
FactoredCombinationPropertyDTO newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage($"Force factored combination property Id={newItem.Id} converting has been finished");
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new FactoredCombinationPropertyUpdateStrategy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.ThrowIfNull(source);
|
||||
CheckObject.ThrowIfNull(source.ForceTuple);
|
||||
CheckObject.ThrowIfNull(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FactoredForceTupleToDTOConvertStrategy : ConvertStrategy<FactoredForceTupleDTO, IFactoredForceTuple>
|
||||
{
|
||||
private IConvertStrategy<ForceTupleDTO, IForceTuple> tupleConvertStrategy;
|
||||
private IConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty> combinationConvertStrategy;
|
||||
|
||||
public FactoredForceTupleToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override FactoredForceTupleDTO GetNewItem(IFactoredForceTuple source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewFactoredForceTuple(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewFactoredForceTuple(IFactoredForceTuple source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting of factored force tuple Id = {source.Id} has been started", TraceLogStatuses.Debug);
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
NewItem.ForceTuple = tupleConvertStrategy.Convert(source.ForceTuple);
|
||||
NewItem.CombinationProperty = combinationConvertStrategy.Convert(source.CombinationProperty);
|
||||
TraceLogger?.AddMessage($"Converting of factored force tuple Id = {NewItem.Id} has been finished", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
tupleConvertStrategy = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>
|
||||
(this, new ForceTupleToDTOConvertStrategy(ReferenceDictionary, TraceLogger));
|
||||
combinationConvertStrategy = new DictionaryConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty>
|
||||
(this, new FactoredCombinationPropertyToDTOConvertStrategy(ReferenceDictionary, TraceLogger));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceActionFromDTOConvertStrategy : ConvertStrategy<IForceAction, IForceAction>
|
||||
{
|
||||
private IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy;
|
||||
private IConvertStrategy<ForceFactoredList, ForceCombinationByFactorV1_0DTO> factorConvertStrategy_v1_0;
|
||||
private IConvertStrategy<ForceFactoredList, ForceFactoredListDTO> factorConvertStrategy;
|
||||
private IConvertStrategy<ForceCombinationFromFile, ForceCombinationFromFileDTO> fileConvertStrategy;
|
||||
|
||||
public ForceActionFromDTOConvertStrategy(
|
||||
IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy,
|
||||
IConvertStrategy<ForceFactoredList, ForceCombinationByFactorV1_0DTO> factorConvertStrategy_v1_0,
|
||||
IConvertStrategy<ForceFactoredList, ForceFactoredListDTO> factorConvertStrategy,
|
||||
IConvertStrategy<ForceCombinationFromFile, ForceCombinationFromFileDTO> fileConvertStrategy)
|
||||
{
|
||||
this.listConvertStrategy = listConvertStrategy;
|
||||
this.factorConvertStrategy_v1_0 = factorConvertStrategy_v1_0;
|
||||
this.factorConvertStrategy = factorConvertStrategy;
|
||||
this.fileConvertStrategy = fileConvertStrategy;
|
||||
}
|
||||
|
||||
public ForceActionFromDTOConvertStrategy() { }
|
||||
|
||||
public override IForceAction GetNewItem(IForceAction source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
NewItem = GetNewItemBySource(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
listConvertStrategy ??= new ForceCombinationListFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
factorConvertStrategy ??= new ForceFactoredListFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
fileConvertStrategy ??= new ForceCombinationFromFileFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
}
|
||||
private IForceAction GetNewItemBySource(IForceAction source)
|
||||
{
|
||||
if (source is ForceFactoredListDTO combination)
|
||||
{
|
||||
return GetFactoredCombination(combination);
|
||||
}
|
||||
if (source is ForceCombinationListDTO forceList)
|
||||
{
|
||||
return GetForceList(forceList);
|
||||
}
|
||||
if (source is ForceCombinationFromFileDTO fileCombination)
|
||||
{
|
||||
return GetFileCombination(fileCombination);
|
||||
}
|
||||
if (source is ForceCombinationByFactorV1_0DTO combination_v1_0)
|
||||
{
|
||||
return Obsolete_GetForceCombination_V1_0(combination_v1_0);
|
||||
}
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
private ForceCombinationFromFile GetFileCombination(ForceCombinationFromFileDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force action is combination by factors");
|
||||
ForceCombinationFromFile newItem = fileConvertStrategy.Convert(source);
|
||||
return newItem;
|
||||
}
|
||||
private ForceFactoredList Obsolete_GetForceCombination_V1_0(ForceCombinationByFactorV1_0DTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force action is combination by factors version 1.0 (obsolete)", TraceLogStatuses.Warning);
|
||||
factorConvertStrategy_v1_0 ??= new ForceCombinationByFactorV1_0FromDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
ForceFactoredList newItem = factorConvertStrategy_v1_0.Convert(source);
|
||||
return newItem;
|
||||
}
|
||||
private IForceAction GetFactoredCombination(ForceFactoredListDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force action is combination by factors");
|
||||
ForceFactoredList newItem = factorConvertStrategy.Convert(source);
|
||||
return newItem;
|
||||
}
|
||||
private IForceAction GetForceList(ForceCombinationListDTO forceList)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force action is combination by list");
|
||||
ForceCombinationList newItem = listConvertStrategy.Convert(forceList);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceActionToDTOConvertStrategy : ConvertStrategy<IForceAction, IForceAction>
|
||||
{
|
||||
private IConvertStrategy<ForceFactoredListDTO, IForceFactoredList> forceFactoredListConvertStrategy;
|
||||
private IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy;
|
||||
private IConvertStrategy<ForceCombinationFromFileDTO, IForceCombinationFromFile> forceCombinationFromFileConvertStrategy;
|
||||
|
||||
public ForceActionToDTOConvertStrategy(
|
||||
IConvertStrategy<ForceFactoredListDTO, IForceFactoredList> forceFactoredListConvertStrategy,
|
||||
IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy,
|
||||
IConvertStrategy<ForceCombinationFromFileDTO, IForceCombinationFromFile> forceCombinationFromFileConvertStrategy)
|
||||
{
|
||||
this.forceFactoredListConvertStrategy = forceFactoredListConvertStrategy;
|
||||
this.forceCombinationListConvertStrategy = forceCombinationListConvertStrategy;
|
||||
this.forceCombinationFromFileConvertStrategy = forceCombinationFromFileConvertStrategy;
|
||||
}
|
||||
|
||||
public ForceActionToDTOConvertStrategy() { }
|
||||
|
||||
public override IForceAction GetNewItem(IForceAction source)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage($"Force action converting has been started");
|
||||
InitializeStrategies();
|
||||
if (source is IForceFactoredList forceFactoredList)
|
||||
{
|
||||
return GetForceCombinationByFactor(forceFactoredList);
|
||||
}
|
||||
else if (source is IForceCombinationList forceCombinationList)
|
||||
{
|
||||
return GetForceCombinationList(forceCombinationList);
|
||||
}
|
||||
else if (source is IForceCombinationFromFile forceCombinationFile)
|
||||
{
|
||||
return GetForceCombinationFile(forceCombinationFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
}
|
||||
|
||||
private IForceAction GetForceCombinationFile(IForceCombinationFromFile forceCombinationFile)
|
||||
{
|
||||
var convertLogic = new DictionaryConvertStrategy<ForceCombinationFromFileDTO, IForceCombinationFromFile>(this, forceCombinationFromFileConvertStrategy);
|
||||
var forceCombination = convertLogic.Convert(forceCombinationFile);
|
||||
return forceCombination;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
forceFactoredListConvertStrategy ??= new ForceFactoredListToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
forceCombinationListConvertStrategy ??= new ForceCombinationListToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; ;
|
||||
forceCombinationFromFileConvertStrategy ??= new ForceCombinaionFromFileToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; ;
|
||||
}
|
||||
|
||||
private ForceCombinationListDTO GetForceCombinationList(IForceCombinationList forceCombinationList)
|
||||
{
|
||||
var convertLogic = new DictionaryConvertStrategy<ForceCombinationListDTO, IForceCombinationList>(this, forceCombinationListConvertStrategy);
|
||||
var forceCombination = convertLogic.Convert(forceCombinationList);
|
||||
return forceCombination;
|
||||
}
|
||||
|
||||
private ForceFactoredListDTO GetForceCombinationByFactor(IForceFactoredList forceCombinationByFactor)
|
||||
{
|
||||
var convertLogic = new DictionaryConvertStrategy<ForceFactoredListDTO, IForceFactoredList>(this, forceFactoredListConvertStrategy);
|
||||
var forceCombination = convertLogic.Convert(forceCombinationByFactor);
|
||||
return forceCombination;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceCombinaionFromFileToDTOConvertStrategy : ConvertStrategy<ForceCombinationFromFileDTO, IForceCombinationFromFile>
|
||||
{
|
||||
|
||||
private IUpdateStrategy<IForceCombinationFromFile> updateStrategy;
|
||||
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
|
||||
private IConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty> combinationPropertyConvertStrategy;
|
||||
private IConvertStrategy<ColumnedFilePropertyDTO, IColumnedFileProperty> filePropertyConvertStrategy;
|
||||
|
||||
|
||||
|
||||
public override ForceCombinationFromFileDTO GetNewItem(IForceCombinationFromFile source)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger.AddMessage($"Force combination from file, name = {source.Name} converting has been started");
|
||||
InitializeStrategies();
|
||||
ForceCombinationFromFileDTO newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
newItem.ForceFiles.Clear();
|
||||
foreach (var item in source.ForceFiles)
|
||||
{
|
||||
ColumnedFilePropertyDTO columnedFilePropertyDTO = filePropertyConvertStrategy.Convert(item);
|
||||
newItem.ForceFiles.Add(columnedFilePropertyDTO);
|
||||
}
|
||||
SetPoint(source, newItem);
|
||||
SetCombinationProperty(source, newItem);
|
||||
TraceLogger.AddMessage($"Force combination from file, name = {source.Name} converting has been finished successfully");
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ForceCombinationFromFileUpdateStrategy();
|
||||
pointConvertStrategy ??= new Point2DToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
filePropertyConvertStrategy ??= new ColumnedFilePropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
}
|
||||
|
||||
private void SetPoint(IForceCombinationFromFile source, ForceCombinationFromFileDTO newItem)
|
||||
{
|
||||
if (source.ForcePoint is not null)
|
||||
{
|
||||
var convertLogic = new DictionaryConvertStrategy<Point2DDTO, IPoint2D>(this, pointConvertStrategy);
|
||||
newItem.ForcePoint = convertLogic.Convert(source.ForcePoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMessage = ErrorStrings.NullReference + $"File combination {source.Name} Id={source.Id} does not have force point";
|
||||
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
private void SetCombinationProperty(IForceCombinationFromFile source, ForceCombinationFromFileDTO newItem)
|
||||
{
|
||||
if (source.CombinationProperty is not null)
|
||||
{
|
||||
var convertLogic = new DictionaryConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty>(this, combinationPropertyConvertStrategy);
|
||||
newItem.CombinationProperty = convertLogic.Convert(source.CombinationProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMessage = ErrorStrings.NullReference + $"Factored combination {source.Name} Id={source.Id} does not have combination properties";
|
||||
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceCombinationFromFileFromDTOConvertStrategy : ConvertStrategy<ForceCombinationFromFile, ForceCombinationFromFileDTO>
|
||||
{
|
||||
private IUpdateStrategy<IForceCombinationFromFile> updateStrategy;
|
||||
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
|
||||
private IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationPropertyConvertStrategy;
|
||||
private IConvertStrategy<ColumnedFileProperty, ColumnedFilePropertyDTO> fileConvertStrategy;
|
||||
|
||||
public ForceCombinationFromFileFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IForceCombinationFromFile> updateStrategy,
|
||||
IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy,
|
||||
IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationPropertyConvertStrategy,
|
||||
IConvertStrategy<ColumnedFileProperty, ColumnedFilePropertyDTO> fileConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.pointConvertStrategy = pointConvertStrategy;
|
||||
this.combinationPropertyConvertStrategy = combinationPropertyConvertStrategy;
|
||||
this.fileConvertStrategy = fileConvertStrategy;
|
||||
}
|
||||
|
||||
public ForceCombinationFromFileFromDTOConvertStrategy() { }
|
||||
|
||||
public override ForceCombinationFromFile GetNewItem(ForceCombinationFromFileDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Force combination from file Name = {source.Name} converting has been started");
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
ForceCombinationFromFile newItem = GetForceCombination(source);
|
||||
TraceLogger?.AddMessage($"Force combination from file Name = {newItem.Name} converting has been finished successfully");
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(this)} made error: {ex.Message}", TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ForceCombinationFromFile GetForceCombination(ForceCombinationFromFileDTO source)
|
||||
{
|
||||
ForceCombinationFromFile newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
SetForceFiles(source, newItem);
|
||||
SetPoint(source, newItem);
|
||||
SetCombinationProperty(source, newItem);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void SetForceFiles(ForceCombinationFromFileDTO source, ForceCombinationFromFile newItem)
|
||||
{
|
||||
newItem.ForceFiles.Clear();
|
||||
foreach (var item in source.ForceFiles)
|
||||
{
|
||||
if (item is ColumnedFilePropertyDTO filePropertyDTO)
|
||||
{
|
||||
ColumnedFileProperty columnFileProperty = fileConvertStrategy.Convert(filePropertyDTO);
|
||||
newItem.ForceFiles.Add(columnFileProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ExpectedWas(typeof(ColumnFilePropertyDTO), item);
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPoint(IForceAction source, IForceAction newItem)
|
||||
{
|
||||
if (source.ForcePoint is Point2DDTO pointDTO)
|
||||
{
|
||||
newItem.ForcePoint = pointConvertStrategy.Convert(pointDTO);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMessage = ErrorStrings.ExpectedWas(typeof(Point2DDTO), source.ForcePoint);
|
||||
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
private void SetCombinationProperty(IForceFactoredCombination source, IForceFactoredCombination newItem)
|
||||
{
|
||||
if (source.CombinationProperty is FactoredCombinationPropertyDTO factoredPropertyDTO)
|
||||
{
|
||||
newItem.CombinationProperty = combinationPropertyConvertStrategy.Convert(factoredPropertyDTO);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMessage = ErrorStrings.ExpectedWas(typeof(FactoredCombinationPropertyDTO), source.CombinationProperty);
|
||||
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ForceCombinationFromFileUpdateStrategy();
|
||||
pointConvertStrategy = new Point2DFromDTOConvertStrategy(this);
|
||||
combinationPropertyConvertStrategy = new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
fileConvertStrategy ??= new ColumnedFilePropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceCombinationListFromDTOConvertStrategy : ConvertStrategy<ForceCombinationList, ForceCombinationListDTO>
|
||||
{
|
||||
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
|
||||
private IUpdateStrategy<IForceCombinationList> updateStrategy;
|
||||
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
|
||||
private IConvertStrategy<DesignForceTuple, DesignForceTupleDTO> designTupleConvertStrategy;
|
||||
|
||||
public ForceCombinationListFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IForceAction> baseUpdateStrategy,
|
||||
IUpdateStrategy<IForceCombinationList> updateStrategy,
|
||||
IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy,
|
||||
IConvertStrategy<DesignForceTuple, DesignForceTupleDTO> designTupleConvertStrategy)
|
||||
{
|
||||
this.baseUpdateStrategy = baseUpdateStrategy;
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.pointConvertStrategy = pointConvertStrategy;
|
||||
this.designTupleConvertStrategy = designTupleConvertStrategy;
|
||||
}
|
||||
|
||||
public ForceCombinationListFromDTOConvertStrategy() { }
|
||||
|
||||
public override ForceCombinationList GetNewItem(ForceCombinationListDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Force combination list Id = {source.Id}, Name = {source.Name} converting has been started");
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
ForceCombinationList newItem = GetNewItemBySource(source);
|
||||
TraceLogger?.AddMessage($"Force combination list Id = {source.Id}, Name = {source.Name} has been finished successfully");
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ForceCombinationList GetNewItemBySource(ForceCombinationListDTO source)
|
||||
{
|
||||
ForceCombinationList newItem = new(source.Id);
|
||||
baseUpdateStrategy.Update(newItem, source);
|
||||
//updateStrategy.Update(newItem, source);
|
||||
newItem.ForcePoint = pointConvertStrategy.Convert((Point2DDTO)source.ForcePoint);
|
||||
newItem.DesignForces.Clear();
|
||||
foreach (var item in source.DesignForces)
|
||||
{
|
||||
DesignForceTuple newDesignTuple = designTupleConvertStrategy.Convert((DesignForceTupleDTO)item);
|
||||
TraceLogger?.AddMessage($"New Design Tuple Limit state = {newDesignTuple.LimitState}, Calc term = {newDesignTuple.CalcTerm}");
|
||||
TraceLogger?.AddMessage($"Mx = {newDesignTuple.ForceTuple.Mx}, My = {newDesignTuple.ForceTuple.My}, Nz = {newDesignTuple.ForceTuple.Nz}");
|
||||
newItem.DesignForces.Add(newDesignTuple);
|
||||
}
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy();
|
||||
updateStrategy ??= new ForceCombinationListUpdateStrategy();
|
||||
pointConvertStrategy ??= new Point2DFromDTOConvertStrategy(this);
|
||||
designTupleConvertStrategy ??= new DesignForceTupleFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceCombinationListToDTOConvertStrategy : ConvertStrategy<ForceCombinationListDTO, IForceCombinationList>
|
||||
{
|
||||
private IUpdateStrategy<IForceCombinationList> updateStrategy;
|
||||
private IConvertStrategy<DesignForceTupleDTO, IDesignForceTuple> convertStrategy;
|
||||
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
|
||||
private IConvertStrategy<Point2DDTO, IPoint2D> pointUpdateStrategy;
|
||||
|
||||
public ForceCombinationListToDTOConvertStrategy(
|
||||
IUpdateStrategy<IForceCombinationList> updateStrategy,
|
||||
IConvertStrategy<DesignForceTupleDTO, IDesignForceTuple> convertStrategy,
|
||||
IUpdateStrategy<IForceAction> baseUpdateStrategy,
|
||||
IConvertStrategy<Point2DDTO, IPoint2D> pointUpdateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertStrategy = convertStrategy;
|
||||
this.baseUpdateStrategy = baseUpdateStrategy;
|
||||
this.pointUpdateStrategy = pointUpdateStrategy;
|
||||
}
|
||||
|
||||
public ForceCombinationListToDTOConvertStrategy() { }
|
||||
|
||||
public override ForceCombinationListDTO GetNewItem(IForceCombinationList source)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage($"Factored combination list Name: {source.Name} has been started");
|
||||
ForceCombinationListDTO forceCombinationListDTO = GetNewForceCombinationList(source);
|
||||
TraceLogger?.AddMessage($"Factored combination list Name: {source.Name} has been finished");
|
||||
return forceCombinationListDTO;
|
||||
}
|
||||
|
||||
private ForceCombinationListDTO GetNewForceCombinationList(IForceCombinationList source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
ForceCombinationListDTO newItem = new() { Id = source.Id};
|
||||
baseUpdateStrategy.Update(newItem, source);
|
||||
updateStrategy.Update(newItem, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<DesignForceTupleDTO, IDesignForceTuple>(this, convertStrategy);
|
||||
GetNewForcePoint(newItem, source);
|
||||
newItem.DesignForces.Clear();
|
||||
foreach (var item in source.DesignForces)
|
||||
{
|
||||
newItem.DesignForces.Add(convertLogic.Convert(item));
|
||||
}
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ForceCombinationListUpdateStrategy();
|
||||
convertStrategy ??= new DesignForceTupleToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy();
|
||||
pointUpdateStrategy ??= new Point2DToDTOConvertStrategy();
|
||||
}
|
||||
|
||||
private void GetNewForcePoint(ForceCombinationListDTO newItem, IForceCombinationList source)
|
||||
{
|
||||
if (source.ForcePoint is not null)
|
||||
{
|
||||
pointUpdateStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
pointUpdateStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<Point2DDTO, IPoint2D>(this, pointUpdateStrategy);
|
||||
newItem.ForcePoint = convertLogic.Convert(source.ForcePoint);
|
||||
}
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ForceCombinationListDTO, IForceCombinationList>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceFactoredListFromDTOConvertStrategy : ConvertStrategy<ForceFactoredList, ForceFactoredListDTO>
|
||||
{
|
||||
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
|
||||
private IUpdateStrategy<IForceFactoredList> updateStrategy;
|
||||
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
|
||||
private IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy;
|
||||
private IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationPropertyConvertStrategy;
|
||||
|
||||
public ForceFactoredListFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IForceAction> baseUpdateStrategy,
|
||||
IUpdateStrategy<IForceFactoredList> updateStrategy,
|
||||
IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy,
|
||||
IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy,
|
||||
IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationPropertyConvertStrategy)
|
||||
{
|
||||
this.baseUpdateStrategy = baseUpdateStrategy;
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.pointConvertStrategy = pointConvertStrategy;
|
||||
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
|
||||
this.combinationPropertyConvertStrategy = combinationPropertyConvertStrategy;
|
||||
}
|
||||
|
||||
public ForceFactoredListFromDTOConvertStrategy() { }
|
||||
|
||||
public override ForceFactoredList GetNewItem(ForceFactoredListDTO source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
TraceLogger.AddMessage($"Force combination by factor name = {source.Name} converting is starting");
|
||||
ForceFactoredList newItem = new(source.Id);
|
||||
baseUpdateStrategy.Update(newItem, source);
|
||||
updateStrategy.Update(newItem, source);
|
||||
SetPoint(source, newItem);
|
||||
SetCombinationProperty(source, newItem);
|
||||
SetForceTuples(source, newItem);
|
||||
TraceLogger.AddMessage($"Force combination by factor name = {newItem.Name} converting has been finished");
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void SetForceTuples(ForceFactoredListDTO source, ForceFactoredList newItem)
|
||||
{
|
||||
CheckObject.ThrowIfNull(newItem.ForceTuples, nameof(newItem.ForceTuples));
|
||||
newItem.ForceTuples.Clear();
|
||||
foreach (var item in source.ForceTuples)
|
||||
{
|
||||
var newTuple = forceTupleConvertStrategy.Convert((ForceTupleDTO)item);
|
||||
newItem.ForceTuples.Add(newTuple);
|
||||
}
|
||||
}
|
||||
private void SetPoint(ForceFactoredListDTO source, ForceFactoredList newItem)
|
||||
{
|
||||
if (source.ForcePoint is Point2DDTO pointDTO)
|
||||
{
|
||||
newItem.ForcePoint = pointConvertStrategy.Convert(pointDTO);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMessage = ErrorStrings.ExpectedWas(typeof(Point2DDTO), source.ForcePoint);
|
||||
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
private void SetCombinationProperty(ForceFactoredListDTO source, ForceFactoredList newItem)
|
||||
{
|
||||
if (source.CombinationProperty is FactoredCombinationPropertyDTO factoredPropertyDTO)
|
||||
{
|
||||
newItem.CombinationProperty = combinationPropertyConvertStrategy.Convert(factoredPropertyDTO);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMessage = ErrorStrings.ExpectedWas(typeof(FactoredCombinationPropertyDTO), source.CombinationProperty);
|
||||
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy();
|
||||
updateStrategy ??= new ForceFactoredListUpdateStrategy();
|
||||
pointConvertStrategy ??= new Point2DFromDTOConvertStrategy(this);
|
||||
forceTupleConvertStrategy ??= new ForceTupleFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceFactoredListToDTOConvertStrategy : ConvertStrategy<ForceFactoredListDTO, IForceFactoredList>
|
||||
{
|
||||
private IUpdateStrategy<IForceFactoredList> updateStrategy;
|
||||
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
|
||||
private IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy;
|
||||
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
|
||||
private IConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty> combinationPropertyConvertStrategy;
|
||||
|
||||
public ForceFactoredListToDTOConvertStrategy(IUpdateStrategy<IForceFactoredList> updateStrategy,
|
||||
IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy,
|
||||
IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy,
|
||||
IUpdateStrategy<IForceAction> baseUpdateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.pointConvertStrategy = pointConvertStrategy;
|
||||
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
|
||||
this.baseUpdateStrategy = baseUpdateStrategy;
|
||||
}
|
||||
|
||||
public ForceFactoredListToDTOConvertStrategy() { }
|
||||
|
||||
public override ForceFactoredListDTO GetNewItem(IForceFactoredList source)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage($"Force combination by factor, name = {source.Name} converting has been started");
|
||||
InitializeStrategies();
|
||||
ForceFactoredListDTO newItem = GetNewForceTuple(source);
|
||||
TraceLogger?.AddMessage($"Force combination by factor, name = {newItem.Name} converting has been finished successfully");
|
||||
return newItem;
|
||||
|
||||
}
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy();
|
||||
updateStrategy ??= new ForceFactoredListUpdateStrategy();
|
||||
forceTupleConvertStrategy ??= new ForceTupleToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
pointConvertStrategy ??= new Point2DToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
}
|
||||
|
||||
private ForceFactoredListDTO GetNewForceTuple(IForceFactoredList source)
|
||||
{
|
||||
ForceFactoredListDTO newItem = new(source.Id);
|
||||
baseUpdateStrategy.Update(newItem, source);
|
||||
updateStrategy.Update(newItem, source);
|
||||
SetPoint(source, newItem);
|
||||
SetForces(source, newItem);
|
||||
SetCombinationProperty(source, newItem);
|
||||
return newItem;
|
||||
}
|
||||
private void SetForces(IForceFactoredList source, ForceFactoredListDTO newItem)
|
||||
{
|
||||
if (source.ForceTuples is not null)
|
||||
{
|
||||
var convertForceTupleLogic = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>(this, forceTupleConvertStrategy);
|
||||
newItem.ForceTuples.Clear();
|
||||
foreach (var item in source.ForceTuples)
|
||||
{
|
||||
var forceTuple = convertForceTupleLogic.Convert(item);
|
||||
newItem.ForceTuples.Add(forceTuple);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMessage = ErrorStrings.NullReference + $"Factored combination {source.Name} Id={source.Id} does not have list of forces";
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
private void SetPoint(IForceFactoredList source, ForceFactoredListDTO newItem)
|
||||
{
|
||||
if (source.ForcePoint is not null)
|
||||
{
|
||||
var convertLogic = new DictionaryConvertStrategy<Point2DDTO, IPoint2D>(this, pointConvertStrategy);
|
||||
newItem.ForcePoint = convertLogic.Convert(source.ForcePoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMessage = ErrorStrings.NullReference + $"Factored combination {source.Name} Id={source.Id} does not have force point";
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
private void SetCombinationProperty(IForceFactoredList source, ForceFactoredListDTO newItem)
|
||||
{
|
||||
if (source.CombinationProperty is not null)
|
||||
{
|
||||
var convertLogic = new DictionaryConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty>(this, combinationPropertyConvertStrategy);
|
||||
newItem.CombinationProperty = convertLogic.Convert(source.CombinationProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorMessage = ErrorStrings.NullReference + $"Factored combination {source.Name} Id={source.Id} does not have combination properties";
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceTupleFromDTOConvertStrategy : ConvertStrategy<ForceTuple, ForceTupleDTO>
|
||||
{
|
||||
private IUpdateStrategy<IForceTuple> updateStrategy;
|
||||
|
||||
public ForceTupleFromDTOConvertStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
public ForceTupleFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override ForceTuple GetNewItem(ForceTupleDTO source)
|
||||
{
|
||||
updateStrategy ??= new ForceTupleUpdateStrategy();
|
||||
ForceTuple newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceTupleToDTOConvertStrategy : ConvertStrategy<ForceTupleDTO, IForceTuple>
|
||||
{
|
||||
private IUpdateStrategy<IForceTuple> updateStrategy;
|
||||
|
||||
public ForceTupleToDTOConvertStrategy(IUpdateStrategy<IForceTuple> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ForceTupleToDTOConvertStrategy() : this(new ForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ForceTupleToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override ForceTupleDTO GetNewItem(IForceTuple source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewBeamForceTuple(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void GetNewBeamForceTuple(IForceTuple source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting of force tuple Id = {source.Id} has been started", TraceLogStatuses.Debug);
|
||||
updateStrategy ??= new ForceTupleUpdateStrategy();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
TraceLogger?.AddMessage($"Converting of force tuple Id = {source.Id} has been finished", TraceLogStatuses.Debug);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class HasCalculatorsFromDTOUpdateStrategy : IUpdateStrategy<IHasCalculators>
|
||||
{
|
||||
private IConvertStrategy<ICalculator, ICalculator> convertStrategy;
|
||||
|
||||
public HasCalculatorsFromDTOUpdateStrategy(IConvertStrategy<ICalculator, ICalculator> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasCalculators targetObject, IHasCalculators sourceObject)
|
||||
{
|
||||
targetObject.Calculators.Clear();
|
||||
foreach (var item in sourceObject.Calculators)
|
||||
{
|
||||
var newItem = convertStrategy.Convert(item);
|
||||
targetObject.Calculators.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class HasCalculatorsToDTOUpdateStrategy : IUpdateStrategy<IHasCalculators>
|
||||
{
|
||||
private IConvertStrategy<ICalculator, ICalculator> convertStrategy;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public HasCalculatorsToDTOUpdateStrategy(IConvertStrategy<ICalculator, ICalculator> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public HasCalculatorsToDTOUpdateStrategy() : this(new CalculatorToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IHasCalculators targetObject, IHasCalculators sourceObject)
|
||||
{
|
||||
if (sourceObject.Calculators is null)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ParameterIsNull);
|
||||
}
|
||||
targetObject.Calculators.Clear();
|
||||
ProcessCalculators(targetObject, sourceObject);
|
||||
}
|
||||
|
||||
private void ProcessCalculators(IHasCalculators targetObject, IHasCalculators sourceObject)
|
||||
{
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
foreach (var item in sourceObject.Calculators)
|
||||
{
|
||||
ICalculator newItem = convertStrategy.Convert(item);
|
||||
targetObject.Calculators.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasForceActionToDTOUpdateStrategy : IUpdateStrategy<IHasForceActions>
|
||||
{
|
||||
private readonly IConvertStrategy<IForceAction, IForceAction> forceActionStrategy;
|
||||
|
||||
public HasForceActionToDTOUpdateStrategy(IConvertStrategy<IForceAction, IForceAction> forceActionStrategy)
|
||||
{
|
||||
this.forceActionStrategy = forceActionStrategy;
|
||||
}
|
||||
|
||||
public HasForceActionToDTOUpdateStrategy() : this (new ForceActionToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public void Update(IHasForceActions targetObject, IHasForceActions sourceObject)
|
||||
{
|
||||
if (sourceObject.ForceActions is null)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ParameterIsNull);
|
||||
}
|
||||
targetObject.ForceActions.Clear();
|
||||
targetObject.ForceActions.AddRange(ProcessForceActions(sourceObject.ForceActions));
|
||||
}
|
||||
|
||||
private List<IForceAction> ProcessForceActions(List<IForceAction> source)
|
||||
{
|
||||
List<IForceAction> forceActions = new();
|
||||
forceActionStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceActionStrategy.TraceLogger = TraceLogger;
|
||||
foreach (var item in source)
|
||||
{
|
||||
forceActions.Add(forceActionStrategy.Convert(item));
|
||||
}
|
||||
return forceActions;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasForceActionsFromDTOUpdateStrategy : IUpdateStrategy<IHasForceActions>
|
||||
{
|
||||
private readonly IConvertStrategy<IForceAction, IForceAction> convertStrategy;
|
||||
|
||||
public HasForceActionsFromDTOUpdateStrategy(IConvertStrategy<IForceAction, IForceAction> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasForceActions targetObject, IHasForceActions sourceObject)
|
||||
{
|
||||
CheckObject.ThrowIfNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.ForceActions.Clear();
|
||||
foreach (var item in sourceObject.ForceActions)
|
||||
{
|
||||
var newItem = convertStrategy.Convert(item);
|
||||
targetObject.ForceActions.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
66
DataAccess/DTOs/Converters/HasForceActionsProcessLogic.cs
Normal file
66
DataAccess/DTOs/Converters/HasForceActionsProcessLogic.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasForceActionsProcessLogic : IHasForceActionsProcessLogic
|
||||
{
|
||||
private const string convertStarted = " converting is started";
|
||||
private const string convertFinished = " converting has been finished successfully";
|
||||
private IConvertStrategy<IForceAction, IForceAction> convertStrategy;
|
||||
private DictionaryConvertStrategy<IForceAction, IForceAction> convertLogic;
|
||||
private ConvertDirection convertDirection;
|
||||
|
||||
public HasForceActionsProcessLogic(ConvertDirection convertDirection)
|
||||
{
|
||||
this.convertDirection = convertDirection;
|
||||
}
|
||||
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
|
||||
public IHasForceActions Source { get; set; }
|
||||
public IHasForceActions Target { get; set; }
|
||||
public void Process()
|
||||
{
|
||||
TraceLogger?.AddMessage("Actions" + convertStarted);
|
||||
HasForceActionsFromDTOUpdateStrategy updateStrategy = GetUpdateStrategyFactory();
|
||||
updateStrategy.Update(Target, Source);
|
||||
TraceLogger?.AddMessage("Actions" + convertFinished);
|
||||
}
|
||||
|
||||
private HasForceActionsFromDTOUpdateStrategy GetUpdateStrategyFactory()
|
||||
{
|
||||
if (convertDirection == ConvertDirection.FromDTO)
|
||||
{
|
||||
convertStrategy ??= new ForceActionFromDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
}
|
||||
else if (convertDirection == ConvertDirection.ToDTO)
|
||||
{
|
||||
convertStrategy ??= new ForceActionToDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(convertDirection));
|
||||
}
|
||||
convertLogic ??= new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger,
|
||||
ConvertStrategy = convertStrategy
|
||||
};
|
||||
HasForceActionsFromDTOUpdateStrategy updateStrategy = new(convertLogic);
|
||||
return updateStrategy;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasForcesAndPrimitivesProcessLogic : IProcessLogic<IHasForcesAndPrimitives>
|
||||
{
|
||||
private ConvertDirection convertDirection;
|
||||
private IProcessLogic<IHasForceActions> forcesLogic;
|
||||
private IProcessLogic<IHasPrimitives> primitivesLogic;
|
||||
private IProcessLogic<IHasForceActions> ForcesLogic => forcesLogic ??= new HasForceActionsProcessLogic(convertDirection) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
private IProcessLogic<IHasPrimitives> PrimitivesLogic => primitivesLogic ??=new HasPrimitivesProcessLogic(convertDirection) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IHasForcesAndPrimitives Source { get; set; }
|
||||
public IHasForcesAndPrimitives Target { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public HasForcesAndPrimitivesProcessLogic(ConvertDirection convertDirection)
|
||||
{
|
||||
this.convertDirection = convertDirection;
|
||||
}
|
||||
|
||||
public HasForcesAndPrimitivesProcessLogic(
|
||||
ConvertDirection convertDirection,
|
||||
IProcessLogic<IHasForceActions> forcesLogic,
|
||||
IProcessLogic<IHasPrimitives> primitivesLogic)
|
||||
{
|
||||
this.convertDirection = convertDirection;
|
||||
this.forcesLogic = forcesLogic;
|
||||
this.primitivesLogic = primitivesLogic;
|
||||
}
|
||||
|
||||
public void Process()
|
||||
{
|
||||
Check();
|
||||
ProcessForces();
|
||||
ProcessPrimitives();
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
CheckObject.ThrowIfNull(ReferenceDictionary, ": reference dictionary");
|
||||
CheckObject.ThrowIfNull(Source, ": source object");
|
||||
CheckObject.ThrowIfNull(Target, ": target object");
|
||||
}
|
||||
|
||||
private void ProcessPrimitives()
|
||||
{
|
||||
PrimitivesLogic.Source = Source;
|
||||
PrimitivesLogic.Target = Target;
|
||||
PrimitivesLogic.Process();
|
||||
}
|
||||
|
||||
private void ProcessForces()
|
||||
{
|
||||
ForcesLogic.Source = Source;
|
||||
ForcesLogic.Target = Target;
|
||||
ForcesLogic.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasVisualPropertyFromDTOUpdateStrategy : IUpdateStrategy<IHasVisualProperty>
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IConvertStrategy<PrimitiveVisualProperty, PrimitiveVisualPropertyDTO> convertStrategy;
|
||||
|
||||
public HasVisualPropertyFromDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
this.referenceDictionary = referenceDictionary;
|
||||
this.traceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasVisualProperty targetObject, IHasVisualProperty sourceObject)
|
||||
{
|
||||
CheckObject.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
convertStrategy = new DictionaryConvertStrategy<PrimitiveVisualProperty, PrimitiveVisualPropertyDTO>(
|
||||
referenceDictionary,
|
||||
traceLogger,
|
||||
new PrimitiveVisualPropertyFromDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
if (sourceObject.VisualProperty is not PrimitiveVisualPropertyDTO visualProperty)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(sourceObject.VisualProperty));
|
||||
}
|
||||
targetObject.VisualProperty = convertStrategy.Convert(visualProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasVisualPropertyToDTOUpdateStrategy : IUpdateStrategy<IHasVisualProperty>
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IConvertStrategy<PrimitiveVisualPropertyDTO, IPrimitiveVisualProperty> convertStrategy;
|
||||
|
||||
|
||||
public HasVisualPropertyToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
this.referenceDictionary = referenceDictionary;
|
||||
this.traceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasVisualProperty targetObject, IHasVisualProperty sourceObject)
|
||||
{
|
||||
CheckObject.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
convertStrategy = new DictionaryConvertStrategy<PrimitiveVisualPropertyDTO, IPrimitiveVisualProperty>(
|
||||
referenceDictionary,
|
||||
traceLogger,
|
||||
new PrimitiveVisualPropertyToDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
targetObject.VisualProperty = convertStrategy.Convert(sourceObject.VisualProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
DataAccess/DTOs/Converters/IHasForceActionsProcessLogic.cs
Normal file
13
DataAccess/DTOs/Converters/IHasForceActionsProcessLogic.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for antities which have force actions
|
||||
/// </summary>
|
||||
public interface IHasForceActionsProcessLogic : IProcessLogic<IHasForceActions>
|
||||
{
|
||||
}
|
||||
}
|
||||
10
DataAccess/DTOs/Converters/IHasPrimitivesProcessLogic.cs
Normal file
10
DataAccess/DTOs/Converters/IHasPrimitivesProcessLogic.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public interface IHasPrimitivesProcessLogic : IProcessLogic<IHasPrimitives>
|
||||
{
|
||||
}
|
||||
}
|
||||
17
DataAccess/DTOs/Converters/IProcessLogic.cs
Normal file
17
DataAccess/DTOs/Converters/IProcessLogic.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public interface IProcessLogic<T>
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
T Source { get; set; }
|
||||
T Target { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
void Process();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ConcreteLibMaterialFromDTOConvertStrategy : ConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO>
|
||||
{
|
||||
private readonly IUpdateStrategy<IConcreteLibMaterial> updateStrategy;
|
||||
|
||||
public ConcreteLibMaterialFromDTOConvertStrategy(IUpdateStrategy<IConcreteLibMaterial> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ConcreteLibMaterialFromDTOConvertStrategy() : this (new ConcreteLibUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ConcreteLibMaterial GetNewItem(ConcreteLibMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Concrete library material converting is started", TraceLogStatuses.Service);
|
||||
ConcreteLibMaterial newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("Concrete library material converting has been finished successfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ConcreteLibMaterialToDTOConvertStrategy : LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>
|
||||
{
|
||||
|
||||
public override IUpdateStrategy<IConcreteLibMaterial> UpdateStrategy { get; } = new ConcreteLibUpdateStrategy();
|
||||
|
||||
public override ConcreteLibMaterialDTO GetMaterialDTO(IConcreteLibMaterial source)
|
||||
{
|
||||
ConcreteLibMaterialDTO newItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ElasticMaterialFromDTOConvertStrategy : ConvertStrategy<ElasticMaterial, ElasticMaterialDTO>
|
||||
{
|
||||
private readonly IUpdateStrategy<IElasticMaterial> updateStrategy;
|
||||
|
||||
public ElasticMaterialFromDTOConvertStrategy(IUpdateStrategy<IElasticMaterial> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ElasticMaterialFromDTOConvertStrategy() : this (new ElasticUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ElasticMaterial GetNewItem(ElasticMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Elastic material converting is started", TraceLogStatuses.Service);
|
||||
ElasticMaterial newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("Elastic material converting has been finished successfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ElasticMaterialToDTOConvertStrategy : IConvertStrategy<ElasticMaterialDTO, IElasticMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IElasticMaterial> updateStrategy;
|
||||
private ICheckConvertLogic<ElasticMaterialDTO, IElasticMaterial> checkLogic;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ElasticMaterialToDTOConvertStrategy(
|
||||
IUpdateStrategy<IElasticMaterial> updateStrategy,
|
||||
ICheckConvertLogic<ElasticMaterialDTO, IElasticMaterial> checkLogic)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.checkLogic = checkLogic;
|
||||
}
|
||||
|
||||
public ElasticMaterialToDTOConvertStrategy() : this (
|
||||
new ElasticUpdateStrategy(),
|
||||
new CheckConvertLogic<ElasticMaterialDTO, IElasticMaterial>())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ElasticMaterialDTO Convert(IElasticMaterial source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
ElasticMaterialDTO newItem = new() { Id = source.Id };
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
checkLogic = new CheckConvertLogic<ElasticMaterialDTO, IElasticMaterial>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FRMaterialFromDTOConvertStrategy : ConvertStrategy<FRMaterial, FRMaterialDTO>
|
||||
{
|
||||
private IUpdateStrategy<IFRMaterial> updateStrategy;
|
||||
|
||||
public FRMaterialFromDTOConvertStrategy(IUpdateStrategy<IFRMaterial> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public FRMaterialFromDTOConvertStrategy() : this(new FRUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override FRMaterial GetNewItem(FRMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Fiber reinforcement material converting is started", TraceLogStatuses.Service);
|
||||
FRMaterial newItem = new(source.MaterialType, source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("FiberReinforcement material converting has been finished successfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FRMaterialToDTOConvertStrategy : IConvertStrategy<FRMaterialDTO, IFRMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IFRMaterial> updateStrategy;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public FRMaterialToDTOConvertStrategy(IUpdateStrategy<IFRMaterial> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public FRMaterialToDTOConvertStrategy() : this (new FRUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FRMaterialDTO Convert(IFRMaterial source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
FRMaterialDTO newItem = new() { Id = source.Id };
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<FRMaterialDTO, IFRMaterial>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//Copyright (c) 2024 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates copies of materials from source and adds them into target material list
|
||||
/// </summary>
|
||||
public class HasMaterialFromDTOUpdateStrategy : IUpdateStrategy<IHasHeadMaterials>
|
||||
{
|
||||
private readonly IConvertStrategy<IHeadMaterial, IHeadMaterial> convertStrategy;
|
||||
|
||||
public HasMaterialFromDTOUpdateStrategy(IConvertStrategy<IHeadMaterial, IHeadMaterial> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasHeadMaterials targetObject, IHasHeadMaterials sourceObject)
|
||||
{
|
||||
targetObject.HeadMaterials.Clear();
|
||||
foreach (var item in sourceObject.HeadMaterials)
|
||||
{
|
||||
var newItem = convertStrategy.Convert(item);
|
||||
targetObject.HeadMaterials.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HeadMaterialFromDTOConvertStrategy : ConvertStrategy<IHeadMaterial, IHeadMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IHeadMaterial> updateStrategy;
|
||||
private IConvertStrategy<IHelperMaterial, IHelperMaterial> helperMaterialConvertStrategy;
|
||||
|
||||
public HeadMaterialFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IHeadMaterial> updateStrategy,
|
||||
IConvertStrategy<IHelperMaterial, IHelperMaterial> helperMaterialConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.helperMaterialConvertStrategy = helperMaterialConvertStrategy;
|
||||
}
|
||||
|
||||
public HeadMaterialFromDTOConvertStrategy() : this (
|
||||
new HeadMaterialBaseUpdateStrategy(),
|
||||
new HelperMaterialFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
public override IHeadMaterial GetNewItem(IHeadMaterial source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Head material converting is started", TraceLogStatuses.Service);
|
||||
HeadMaterial newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
IHelperMaterial helperMaterial = GetHelperMaterial(source.HelperMaterial);
|
||||
newItem.HelperMaterial = helperMaterial;
|
||||
//GlobalRepository
|
||||
TraceLogger?.AddMessage($"Head material Name = {newItem.Name} converting has been finished successfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IHelperMaterial GetHelperMaterial(IHelperMaterial source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Helper material converting is started", TraceLogStatuses.Service);
|
||||
helperMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
helperMaterialConvertStrategy.TraceLogger = TraceLogger;
|
||||
IHelperMaterial newItem = helperMaterialConvertStrategy.Convert(source);
|
||||
TraceLogger?.AddMessage($"Object of type <<{newItem.GetType()}>> was obtained", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class HeadMaterialToDTOConvertStrategy : IConvertStrategy<HeadMaterialDTO, IHeadMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IHeadMaterial> updateStrategy;
|
||||
private IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy;
|
||||
|
||||
public HeadMaterialToDTOConvertStrategy(IUpdateStrategy<IHeadMaterial> updateStrategy,
|
||||
IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public HeadMaterialToDTOConvertStrategy() : this (
|
||||
new HeadMaterialUpdateStrategy(),
|
||||
new HelperMaterialToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public HeadMaterialDTO Convert(IHeadMaterial source)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetMaterial(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private HeadMaterialDTO GetMaterial(IHeadMaterial source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Convert material Id={source.Id}, name is {source.Name}");
|
||||
HeadMaterialDTO newItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
updateStrategy.Update(newItem, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
var convertLogic = new DictionaryConvertStrategy<IHelperMaterial, IHelperMaterial>(this, convertStrategy);
|
||||
newItem.HelperMaterial = convertLogic.Convert(source.HelperMaterial);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HelperMaterialDTOSafetyFactorUpdateStrategy : IUpdateStrategy<IHelperMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy;
|
||||
private IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy;
|
||||
private IMaterialSafetyFactorDTOLogic factorDTOLogic;
|
||||
|
||||
public HelperMaterialDTOSafetyFactorUpdateStrategy(
|
||||
IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy,
|
||||
IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy)
|
||||
{
|
||||
this.safetyFactorUpdateStrategy = safetyFactorUpdateStrategy;
|
||||
this.partialFactorUpdateStrategy = partialFactorUpdateStrategy;
|
||||
}
|
||||
|
||||
public HelperMaterialDTOSafetyFactorUpdateStrategy(IMaterialSafetyFactorDTOLogic factorDTOLogic) : this(
|
||||
new MaterialSafetyFactorBaseUpdateStrategy(),
|
||||
new MaterialPartialFactorUpdateStrategy())
|
||||
{
|
||||
this.factorDTOLogic = factorDTOLogic;
|
||||
}
|
||||
|
||||
public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||
{
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
CheckObject.ThrowIfNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
if (sourceObject.SafetyFactors is not null)
|
||||
{
|
||||
targetObject.SafetyFactors.Clear();
|
||||
foreach (var safetyFactor in sourceObject.SafetyFactors)
|
||||
{
|
||||
IMaterialSafetyFactor newSafetyFactor = GetNewSafetyFactorByOld(safetyFactor);
|
||||
targetObject.SafetyFactors.Add(newSafetyFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IMaterialSafetyFactor GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor)
|
||||
{
|
||||
IMaterialSafetyFactor newSafetyFactor = factorDTOLogic.GetNewSafetyFactorByOld(safetyFactor);
|
||||
safetyFactorUpdateStrategy.Update(newSafetyFactor, safetyFactor);
|
||||
newSafetyFactor.PartialFactors.Clear();
|
||||
foreach (var partialFactor in safetyFactor.PartialFactors)
|
||||
{
|
||||
IMaterialPartialFactor newPartialFactor = GetNewPartialFactorByOld(partialFactor);
|
||||
newSafetyFactor.PartialFactors.Add(newPartialFactor);
|
||||
}
|
||||
|
||||
return newSafetyFactor;
|
||||
}
|
||||
|
||||
private IMaterialPartialFactor GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor)
|
||||
{
|
||||
IMaterialPartialFactor newPartialFactor = factorDTOLogic.GetNewPartialFactorByOld(partialFactor);
|
||||
partialFactorUpdateStrategy.Update(newPartialFactor, partialFactor);
|
||||
return newPartialFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user