Add calculators saving

This commit is contained in:
Evgeny Redikultsev
2024-10-19 20:32:25 +05:00
parent d16c0e1f79
commit d3a1992f4d
131 changed files with 1742 additions and 375 deletions

View File

@@ -0,0 +1,85 @@
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.Cracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
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);
}
}
}

View File

@@ -0,0 +1,85 @@
using DataAccess.DTOs.Converters;
using DataAccess.DTOs.DTOEntities;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Cracking;
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 CrackCalculatorToDTOConvertStrategy : IConvertStrategy<CrackCalculatorDTO, ICrackCalculator>
{
private readonly IUpdateStrategy<ICrackCalculator> updateStrategy;
public CrackCalculatorToDTOConvertStrategy(IUpdateStrategy<ICrackCalculator> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public CrackCalculatorToDTOConvertStrategy() : this (new CrackCalculatorUpdateStrategy())
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public CrackCalculatorDTO Convert(ICrackCalculator source)
{
try
{
Check();
return GetNewItem(source);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private CrackCalculatorDTO GetNewItem(ICrackCalculator source)
{
CrackCalculatorDTO newItem = new() { Id = source.Id};
updateStrategy.Update(newItem, source);
ProcessForceActions(newItem.InputData, source.InputData);
ProcessPrimitives(newItem.InputData, source.InputData);
return newItem;
}
private void ProcessPrimitives(IHasPrimitives target, IHasPrimitives source)
{
HasPrimitivesToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private void ProcessForceActions(IHasForceCombinations target, IHasForceCombinations source)
{
HasForceActionToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private void Check()
{
var checkLogic = new CheckConvertLogic<CrackCalculatorDTO, ICrackCalculator>(this);
checkLogic.Check();
}
}
}

View File

@@ -1,9 +1,11 @@
using DataAccess.DTOs.Converters;
using NLog.Targets;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Models.CrossSections;
@@ -20,23 +22,15 @@ namespace DataAccess.DTOs
public class CrossSectionRepositoryToDTOConvertStrategy : IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>
{
private IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy;
private IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor> forceCombinationByFactorConvertStrategy;
private IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy;
private IConvertStrategy<EllipseNdmPrimitiveDTO, IEllipsePrimitive> ellipseConvertStrategy = new EllipsePrimitiveDTOConvertStrategy();
public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy,
IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor> forceCombinationByFactorConvertStrategy,
IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy)
public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy)
{
this.materialConvertStrategy = materialConvertStrategy;
this.forceCombinationByFactorConvertStrategy = forceCombinationByFactorConvertStrategy;
this.forceCombinationListConvertStrategy = forceCombinationListConvertStrategy;
}
public CrossSectionRepositoryToDTOConvertStrategy() : this(
new HeadMaterialToDTOConvertStrategy(),
new ForceCombinationByFactorToDTOConvertStrategy(),
new ForceCombinationListToDTOConvertStrategy())
new HeadMaterialToDTOConvertStrategy())
{
}
@@ -54,11 +48,10 @@ namespace DataAccess.DTOs
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private CrossSectionRepositoryDTO GetNewRepository(ICrossSectionRepository source)
@@ -67,71 +60,42 @@ namespace DataAccess.DTOs
{
Id = source.Id
};
List<IForceAction> forceActions = ProcessForceActions(source);
newItem.ForceActions.AddRange(forceActions);
ProcessForceActions(newItem, source);
List<IHeadMaterial> materials = ProcessMaterials(source);
newItem.HeadMaterials.AddRange(materials);
List<INdmPrimitive> primitives = ProcessPrimitives(source);
newItem.Primitives.AddRange(primitives);
ProcessPrimitives(newItem, source);
ProcessCalculators(newItem, source);
return newItem;
}
private List<INdmPrimitive> ProcessPrimitives(ICrossSectionRepository source)
private void ProcessCalculators(IHasCalculators target, IHasCalculators source)
{
List<INdmPrimitive> primitives = new();
foreach (var item in source.Primitives)
HasCalculatorsToDTOUpdateStrategy updateStrategy = new()
{
if (item is IEllipsePrimitive ellipse)
{
ellipseConvertStrategy.ReferenceDictionary = ReferenceDictionary;
ellipseConvertStrategy.TraceLogger = TraceLogger;
INdmPrimitive ndmPrimitive;
ndmPrimitive = ellipseConvertStrategy.Convert(ellipse);
primitives.Add(ndmPrimitive);
}
}
return primitives;
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private List<IForceAction> ProcessForceActions(ICrossSectionRepository source)
private void ProcessPrimitives(IHasPrimitives target, IHasPrimitives source)
{
List<IForceAction> forceActions = new();
foreach (var item in source.ForceActions)
{
if (item is IForceCombinationByFactor forceCombinationByFactor)
{
ForceCombinationByFactorDTO forceCombination = GetForceCombinationByFactor(forceCombinationByFactor);
forceActions.Add(forceCombination);
}
else if (item is IForceCombinationList forceCombinationList)
{
ForceCombinationListDTO forceCombination = GetForceCombinationList(forceCombinationList);
forceActions.Add(forceCombination);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(item));
}
}
return forceActions;
HasPrimitivesToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private ForceCombinationListDTO GetForceCombinationList(IForceCombinationList forceCombinationList)
private void ProcessForceActions(IHasForceCombinations target, IHasForceCombinations source)
{
forceCombinationListConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceCombinationListConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ForceCombinationListDTO, IForceCombinationList>(this, forceCombinationListConvertStrategy);
var forceCombination = convertLogic.Convert(forceCombinationList);
return forceCombination;
}
private ForceCombinationByFactorDTO GetForceCombinationByFactor(IForceCombinationByFactor forceCombinationByFactor)
{
forceCombinationByFactorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceCombinationByFactorConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor>(this, forceCombinationByFactorConvertStrategy);
var forceCombination = convertLogic.Convert(forceCombinationByFactor);
return forceCombination;
HasForceActionToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private List<IHeadMaterial> ProcessMaterials(ICrossSectionRepository source)

View File

@@ -43,7 +43,7 @@ namespace DataAccess.DTOs.Converters
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}

View File

@@ -12,17 +12,17 @@ using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class EllipsePrimitiveDTOConvertStrategy : IConvertStrategy<EllipseNdmPrimitiveDTO, IEllipsePrimitive>
public class EllipseNdmPrimitiveToDTOConvertStrategy : IConvertStrategy<EllipseNdmPrimitiveDTO, IEllipseNdmPrimitive>
{
private IUpdateStrategy<IEllipsePrimitive> updateStrategy;
private IUpdateStrategy<IEllipseNdmPrimitive> updateStrategy;
private IConvertStrategy<RectangleShapeDTO, IRectangleShape> rectangleShapeConvertStrategy;
private IConvertStrategy<NdmElementDTO, INdmElement> ndmElementConvertStrategy;
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
private IConvertStrategy<VisualPropertyDTO, IVisualProperty> visualPropsConvertStrategy;
private IConvertStrategy<DivisionSizeDTO, IDivisionSize> divisionConvertStrategy;
public EllipsePrimitiveDTOConvertStrategy(
IUpdateStrategy<IEllipsePrimitive> updateStrategy,
public EllipseNdmPrimitiveToDTOConvertStrategy(
IUpdateStrategy<IEllipseNdmPrimitive> updateStrategy,
IConvertStrategy<RectangleShapeDTO, IRectangleShape> rectangleShapeConvertStrategy,
IConvertStrategy<NdmElementDTO, INdmElement> ndmElementConvertStrategy,
IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy,
@@ -37,7 +37,7 @@ namespace DataAccess.DTOs
this.divisionConvertStrategy = divisionConvertStrategy;
}
public EllipsePrimitiveDTOConvertStrategy() : this(
public EllipseNdmPrimitiveToDTOConvertStrategy() : this(
new EllipsePrimitiveUpdateStrategy(),
new RectangleShapeToDTOConvertStrategy(),
new NdmElementDTOConvertStrategy(),
@@ -52,13 +52,13 @@ namespace DataAccess.DTOs
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public EllipseNdmPrimitiveDTO Convert(IEllipsePrimitive source)
public EllipseNdmPrimitiveDTO Convert(IEllipseNdmPrimitive source)
{
try
{
Check();
PrepareStrategies();
return GetNewEllipsePrimitive(source);
return GetNewPrimitive(source);
}
catch (Exception ex)
{
@@ -68,7 +68,7 @@ namespace DataAccess.DTOs
}
}
private EllipseNdmPrimitiveDTO GetNewEllipsePrimitive(IEllipsePrimitive source)
private EllipseNdmPrimitiveDTO GetNewPrimitive(IEllipseNdmPrimitive source)
{
EllipseNdmPrimitiveDTO newItem = new() { Id = source.Id };
updateStrategy.Update(newItem, source);
@@ -98,7 +98,7 @@ namespace DataAccess.DTOs
private void Check()
{
var checkLogic = new CheckConvertLogic<EllipseNdmPrimitiveDTO, IEllipsePrimitive>(this);
var checkLogic = new CheckConvertLogic<EllipseNdmPrimitiveDTO, IEllipseNdmPrimitive>(this);
checkLogic.Check();
}
}

View File

@@ -0,0 +1,83 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
namespace DataAccess.DTOs.Converters
{
public class ForceActionToDTOConvertStrategy : IConvertStrategy<IForceAction, IForceAction>
{
private IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor> forceCombinationByFactorConvertStrategy;
private IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy;
public ForceActionToDTOConvertStrategy(
IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor> forceCombinationByFactorConvertStrategy,
IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy)
{
this.forceCombinationByFactorConvertStrategy = forceCombinationByFactorConvertStrategy;
this.forceCombinationListConvertStrategy = forceCombinationListConvertStrategy;
}
public ForceActionToDTOConvertStrategy() : this(
new ForceCombinationByFactorToDTOConvertStrategy(),
new ForceCombinationListToDTOConvertStrategy())
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public IForceAction Convert(IForceAction source)
{
try
{
return ProcessForceAction(source);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private IForceAction ProcessForceAction(IForceAction source)
{
if (source is IForceCombinationByFactor forceCombinationByFactor)
{
return GetForceCombinationByFactor(forceCombinationByFactor);
}
else if (source is IForceCombinationList forceCombinationList)
{
return GetForceCombinationList(forceCombinationList);
}
else
{
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
}
private ForceCombinationListDTO GetForceCombinationList(IForceCombinationList forceCombinationList)
{
forceCombinationListConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceCombinationListConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ForceCombinationListDTO, IForceCombinationList>(this, forceCombinationListConvertStrategy);
var forceCombination = convertLogic.Convert(forceCombinationList);
return forceCombination;
}
private ForceCombinationByFactorDTO GetForceCombinationByFactor(IForceCombinationByFactor forceCombinationByFactor)
{
forceCombinationByFactorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceCombinationByFactorConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor>(this, forceCombinationByFactorConvertStrategy);
var forceCombination = convertLogic.Convert(forceCombinationByFactor);
return forceCombination;
}
}
}

View File

@@ -0,0 +1,86 @@
using DataAccess.DTOs.Converters;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
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 ForceCalculatorToDTOConvertStrategy : IConvertStrategy<ForceCalculatorDTO, IForceCalculator>
{
private readonly IUpdateStrategy<IForceCalculator> updateStrategy;
public ForceCalculatorToDTOConvertStrategy(IUpdateStrategy<IForceCalculator> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public ForceCalculatorToDTOConvertStrategy() : this (
new ForceCalculatorUpdateStrategy()
)
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ForceCalculatorDTO Convert(IForceCalculator source)
{
try
{
Check();
return GetNewItem(source);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private ForceCalculatorDTO GetNewItem(IForceCalculator source)
{
ForceCalculatorDTO newItem = new() { Id = source.Id};
updateStrategy.Update(newItem, source);
ProcessForceActions(newItem.InputData, source.InputData);
ProcessPrimitives(newItem.InputData, source.InputData);
return newItem;
}
private void ProcessPrimitives(IHasPrimitives target, IHasPrimitives source)
{
HasPrimitivesToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private void ProcessForceActions(IHasForceCombinations target, IHasForceCombinations source)
{
HasForceActionToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private void Check()
{
var checkLogic = new CheckConvertLogic<ForceCalculatorDTO, IForceCalculator>(this);
checkLogic.Check();
}
}
}

View File

@@ -54,7 +54,7 @@ namespace DataAccess.DTOs.Converters
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}

View File

@@ -1,7 +1,9 @@
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 StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
@@ -15,18 +17,26 @@ namespace DataAccess.DTOs.Converters
{
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)
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() : this (
new ForceCombinationListUpdateStrategy(),
new DesignForceTupleToDTOConvertStrategy())
new DesignForceTupleToDTOConvertStrategy(),
new ForceActionBaseUpdateStrategy(),
new Point2DToDTOConvertStrategy())
{
}
@@ -44,7 +54,7 @@ namespace DataAccess.DTOs.Converters
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
@@ -54,10 +64,12 @@ namespace DataAccess.DTOs.Converters
{
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)
{
@@ -66,6 +78,17 @@ namespace DataAccess.DTOs.Converters
return newItem;
}
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);

View File

@@ -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);
}
}
}
}

View File

@@ -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<IHasForceCombinations>
{
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(IHasForceCombinations targetObject, IHasForceCombinations 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;
}
}
}

View File

@@ -0,0 +1,52 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.Converters
{
public class HasPrimitivesToDTOUpdateStrategy : IUpdateStrategy<IHasPrimitives>
{
private IConvertStrategy<INdmPrimitive, INdmPrimitive> convertStrategy;
public HasPrimitivesToDTOUpdateStrategy(IConvertStrategy<INdmPrimitive, INdmPrimitive> primitiveConvertStrategy)
{
this.convertStrategy = primitiveConvertStrategy;
}
public HasPrimitivesToDTOUpdateStrategy() : this(new NdmPrimitiveToDTOConvertStrategy())
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public void Update(IHasPrimitives targetObject, IHasPrimitives sourceObject)
{
if (sourceObject.Primitives is null)
{
throw new StructureHelperException(ErrorStrings.ParameterIsNull);
}
targetObject.Primitives.Clear();
ProcessPrimitives(targetObject, sourceObject);
}
private void ProcessPrimitives(IHasPrimitives targetObject, IHasPrimitives sourceObject)
{
convertStrategy.ReferenceDictionary = ReferenceDictionary;
convertStrategy.TraceLogger = TraceLogger;
foreach (var item in sourceObject.Primitives)
{
INdmPrimitive primtiveDTO = convertStrategy.Convert(item);
targetObject.Primitives.Add(primtiveDTO);
}
}
}
}

View File

@@ -58,7 +58,9 @@ namespace DataAccess.DTOs
var headMaterial = convertLogic.Convert(source.HeadMaterial);
newItem.HeadMaterial = headMaterial;
forceUpdateStrategy.Update(newItem.UsersPrestrain, source.UsersPrestrain);
(newItem.UsersPrestrain as ForceTupleDTO).Id = source.UsersPrestrain.Id;
forceUpdateStrategy.Update(newItem.AutoPrestrain, source.AutoPrestrain);
(newItem.AutoPrestrain as ForceTupleDTO).Id = source.AutoPrestrain.Id;
return newItem;
}

View File

@@ -0,0 +1,97 @@
using DataAccess.DTOs.DTOEntities;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Primitives;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace DataAccess.DTOs.Converters
{
public class NdmPrimitiveToDTOConvertStrategy : IConvertStrategy<INdmPrimitive, INdmPrimitive>
{
private readonly IConvertStrategy<RebarNdmPrimitiveDTO, IRebarNdmPrimitive> rebarConvertStrategy;
private readonly IConvertStrategy<PointNdmPrimitiveDTO, IPointNdmPrimitive> pointConvertStrategy;
private readonly IConvertStrategy<EllipseNdmPrimitiveDTO, IEllipseNdmPrimitive> ellipseConvertStrategy;
private readonly IConvertStrategy<RectangleNdmPrimitiveDTO, IRectangleNdmPrimitive> rectangleConvertStrategy;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public NdmPrimitiveToDTOConvertStrategy(
IConvertStrategy<RebarNdmPrimitiveDTO,IRebarNdmPrimitive> rebarConvertStrategy,
IConvertStrategy<PointNdmPrimitiveDTO, IPointNdmPrimitive> pointConvertStrategy,
IConvertStrategy<EllipseNdmPrimitiveDTO, IEllipseNdmPrimitive> ellipseConvertStrategy,
IConvertStrategy<RectangleNdmPrimitiveDTO, IRectangleNdmPrimitive> rectangleConvertStrategy)
{
this.rebarConvertStrategy = rebarConvertStrategy;
this.pointConvertStrategy = pointConvertStrategy;
this.ellipseConvertStrategy = ellipseConvertStrategy;
this.rectangleConvertStrategy = rectangleConvertStrategy;
}
public NdmPrimitiveToDTOConvertStrategy() : this(
new RebarNdmPrimitiveToDTOConvertStrategy(),
new PointNdmPrimitiveToDTOConvertStrategy(),
new EllipseNdmPrimitiveToDTOConvertStrategy(),
new RectangleNdmPrimitiveToDTOConvertStrategy())
{
}
public INdmPrimitive Convert(INdmPrimitive source)
{
if (source is IRebarNdmPrimitive rebar)
{
return ProcessRebar(rebar);
}
if (source is IPointNdmPrimitive point)
{
return ProcessPoint(point);
}
if (source is IEllipseNdmPrimitive ellipse)
{
return ProcessEllipse(ellipse);
}
if (source is IRectangleNdmPrimitive rectangle)
{
return ProcessRectangle(rectangle);
}
TraceLogger.AddMessage("Object type is unknown", TraceLogStatuses.Error);
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
}
private RebarNdmPrimitiveDTO ProcessRebar(IRebarNdmPrimitive rebar)
{
rebarConvertStrategy.ReferenceDictionary = ReferenceDictionary;
rebarConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<RebarNdmPrimitiveDTO, IRebarNdmPrimitive>(this, rebarConvertStrategy);
return convertLogic.Convert(rebar);
}
private PointNdmPrimitiveDTO ProcessPoint(IPointNdmPrimitive point)
{
pointConvertStrategy.ReferenceDictionary = ReferenceDictionary;
pointConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<PointNdmPrimitiveDTO, IPointNdmPrimitive>(this, pointConvertStrategy);
return convertLogic.Convert(point);
}
private EllipseNdmPrimitiveDTO ProcessEllipse(IEllipseNdmPrimitive ellipse)
{
ellipseConvertStrategy.ReferenceDictionary = ReferenceDictionary;
ellipseConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<EllipseNdmPrimitiveDTO, IEllipseNdmPrimitive>(this, ellipseConvertStrategy);
return convertLogic.Convert(ellipse);
}
private RectangleNdmPrimitiveDTO ProcessRectangle(IRectangleNdmPrimitive rectangle)
{
rectangleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
rectangleConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<RectangleNdmPrimitiveDTO, IRectangleNdmPrimitive>(this, rectangleConvertStrategy);
return convertLogic.Convert(rectangle);
}
}
}

View File

@@ -0,0 +1,88 @@
using DataAccess.DTOs.Converters;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
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 PointNdmPrimitiveToDTOConvertStrategy : IConvertStrategy<PointNdmPrimitiveDTO, IPointNdmPrimitive>
{
private IUpdateStrategy<IPointNdmPrimitive> updateStrategy;
private IConvertStrategy<NdmElementDTO, INdmElement> ndmElementConvertStrategy;
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
private IConvertStrategy<VisualPropertyDTO, IVisualProperty> visualPropsConvertStrategy;
public PointNdmPrimitiveToDTOConvertStrategy(
IUpdateStrategy<IPointNdmPrimitive> updateStrategy,
IConvertStrategy<NdmElementDTO, INdmElement> ndmElementConvertStrategy,
IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy,
IConvertStrategy<VisualPropertyDTO, IVisualProperty> visualPropsConvertStrategy)
{
this.updateStrategy = updateStrategy;
this.ndmElementConvertStrategy = ndmElementConvertStrategy;
this.pointConvertStrategy = pointConvertStrategy;
this.visualPropsConvertStrategy = visualPropsConvertStrategy;
}
public PointNdmPrimitiveToDTOConvertStrategy() : this(
new PointPrimitiveUpdateStrategy(),
new NdmElementDTOConvertStrategy(),
new Point2DToDTOConvertStrategy(),
new VisualPropertyToDTOConvertStrategy()
) { }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public PointNdmPrimitiveDTO Convert(IPointNdmPrimitive source)
{
try
{
Check();
PrepareStrategies();
return GetNewPrimitive(source);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private PointNdmPrimitiveDTO GetNewPrimitive(IPointNdmPrimitive source)
{
PointNdmPrimitiveDTO newItem = new() { Id = source.Id};
updateStrategy.Update(newItem, source);
newItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement);
newItem.Center = pointConvertStrategy.Convert(source.Center);
newItem.VisualProperty = visualPropsConvertStrategy.Convert(source.VisualProperty);
return newItem;
}
private void PrepareStrategies()
{
ndmElementConvertStrategy.ReferenceDictionary =
pointConvertStrategy.ReferenceDictionary =
visualPropsConvertStrategy.ReferenceDictionary =
ReferenceDictionary;
ndmElementConvertStrategy.TraceLogger =
pointConvertStrategy.TraceLogger =
visualPropsConvertStrategy.TraceLogger =
TraceLogger;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<PointNdmPrimitiveDTO, IPointNdmPrimitive>(this);
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,99 @@
using DataAccess.DTOs.Converters;
using DataAccess.DTOs.DTOEntities;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
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 RebarNdmPrimitiveToDTOConvertStrategy : IConvertStrategy<RebarNdmPrimitiveDTO, IRebarNdmPrimitive>
{
private IUpdateStrategy<IRebarNdmPrimitive> updateStrategy;
private IConvertStrategy<NdmElementDTO, INdmElement> ndmElementConvertStrategy;
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
private IConvertStrategy<VisualPropertyDTO, IVisualProperty> visualPropsConvertStrategy;
private IConvertStrategy<INdmPrimitive, INdmPrimitive> hostPrimitiveConvertStrategy;
public RebarNdmPrimitiveToDTOConvertStrategy(
IUpdateStrategy<IRebarNdmPrimitive> updateStrategy,
IConvertStrategy<NdmElementDTO, INdmElement> ndmElementConvertStrategy,
IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy,
IConvertStrategy<VisualPropertyDTO, IVisualProperty> visualPropsConvertStrategy)
{
this.updateStrategy = updateStrategy;
this.ndmElementConvertStrategy = ndmElementConvertStrategy;
this.pointConvertStrategy = pointConvertStrategy;
this.visualPropsConvertStrategy = visualPropsConvertStrategy;
}
public RebarNdmPrimitiveToDTOConvertStrategy() : this(
new RebarNdmPrimitiveUpdateStrategy(),
new NdmElementDTOConvertStrategy(),
new Point2DToDTOConvertStrategy(),
new VisualPropertyToDTOConvertStrategy()
) { }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public RebarNdmPrimitiveDTO Convert(IRebarNdmPrimitive source)
{
try
{
Check();
PrepareStrategies();
return GetNewPrimitive(source);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private RebarNdmPrimitiveDTO GetNewPrimitive(IRebarNdmPrimitive source)
{
RebarNdmPrimitiveDTO newItem = new() { Id = source.Id };
//updateStrategy.Update(newItem, source);
newItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement);
newItem.Center = pointConvertStrategy.Convert(source.Center);
newItem.VisualProperty = visualPropsConvertStrategy.Convert(source.VisualProperty);
if (source.HostPrimitive is not null)
{
hostPrimitiveConvertStrategy = new NdmPrimitiveToDTOConvertStrategy(null, null,
new EllipseNdmPrimitiveToDTOConvertStrategy(),
new RectangleNdmPrimitiveToDTOConvertStrategy());
hostPrimitiveConvertStrategy.ReferenceDictionary = ReferenceDictionary;
hostPrimitiveConvertStrategy.TraceLogger = TraceLogger;
newItem.HostPrimitive = hostPrimitiveConvertStrategy.Convert(source.HostPrimitive);
}
return newItem;
}
private void PrepareStrategies()
{
ndmElementConvertStrategy.ReferenceDictionary =
pointConvertStrategy.ReferenceDictionary =
visualPropsConvertStrategy.ReferenceDictionary =
ReferenceDictionary;
ndmElementConvertStrategy.TraceLogger =
pointConvertStrategy.TraceLogger =
visualPropsConvertStrategy.TraceLogger =
TraceLogger;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<RebarNdmPrimitiveDTO, IRebarNdmPrimitive>(this);
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,104 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
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 RectangleNdmPrimitiveToDTOConvertStrategy : IConvertStrategy<RectangleNdmPrimitiveDTO, IRectangleNdmPrimitive>
{
private IUpdateStrategy<IRectangleNdmPrimitive> updateStrategy;
private IConvertStrategy<RectangleShapeDTO, IRectangleShape> rectangleShapeConvertStrategy;
private IConvertStrategy<NdmElementDTO, INdmElement> ndmElementConvertStrategy;
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
private IConvertStrategy<VisualPropertyDTO, IVisualProperty> visualPropsConvertStrategy;
private IConvertStrategy<DivisionSizeDTO, IDivisionSize> divisionConvertStrategy;
public RectangleNdmPrimitiveToDTOConvertStrategy(
IUpdateStrategy<IRectangleNdmPrimitive> updateStrategy,
IConvertStrategy<RectangleShapeDTO, IRectangleShape> rectangleShapeConvertStrategy,
IConvertStrategy<NdmElementDTO, INdmElement> ndmElementConvertStrategy,
IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy,
IConvertStrategy<VisualPropertyDTO, IVisualProperty> visualPropsConvertStrategy,
IConvertStrategy<DivisionSizeDTO, IDivisionSize> divisionConvertStrategy)
{
this.updateStrategy = updateStrategy;
this.rectangleShapeConvertStrategy = rectangleShapeConvertStrategy;
this.ndmElementConvertStrategy = ndmElementConvertStrategy;
this.pointConvertStrategy = pointConvertStrategy;
this.visualPropsConvertStrategy = visualPropsConvertStrategy;
this.divisionConvertStrategy = divisionConvertStrategy;
}
public RectangleNdmPrimitiveToDTOConvertStrategy() : this(
new RectanglePrimitiveUpdateStrategy(),
new RectangleShapeToDTOConvertStrategy(),
new NdmElementDTOConvertStrategy(),
new Point2DToDTOConvertStrategy(),
new VisualPropertyToDTOConvertStrategy(),
new DivisionSizeToDTOConvertStrategy()
)
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public RectangleNdmPrimitiveDTO Convert(IRectangleNdmPrimitive source)
{
try
{
Check();
PrepareStrategies();
return GetNewPrimitive(source);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private RectangleNdmPrimitiveDTO GetNewPrimitive(IRectangleNdmPrimitive source)
{
RectangleNdmPrimitiveDTO newItem = new() { Id = source.Id };
updateStrategy.Update(newItem, source);
newItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement);
newItem.RectangleShape = rectangleShapeConvertStrategy.Convert(source.Shape as IRectangleShape);
newItem.Center = pointConvertStrategy.Convert(source.Center);
newItem.VisualProperty = visualPropsConvertStrategy.Convert(source.VisualProperty);
newItem.DivisionSize = divisionConvertStrategy.Convert(source.DivisionSize);
return newItem;
}
private void PrepareStrategies()
{
rectangleShapeConvertStrategy.ReferenceDictionary =
ndmElementConvertStrategy.ReferenceDictionary =
pointConvertStrategy.ReferenceDictionary =
visualPropsConvertStrategy.ReferenceDictionary =
divisionConvertStrategy.ReferenceDictionary =
ReferenceDictionary;
rectangleShapeConvertStrategy.TraceLogger =
ndmElementConvertStrategy.TraceLogger =
pointConvertStrategy.TraceLogger =
visualPropsConvertStrategy.TraceLogger =
divisionConvertStrategy.TraceLogger =
TraceLogger;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<RectangleNdmPrimitiveDTO, IRectangleNdmPrimitive>(this);
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,21 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Calculators;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.DTOEntities
{
public class AccuracyDTO : IAccuracy
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("IterationAccuracy")]
public double IterationAccuracy { get; set; }
[JsonProperty("MaxIterationCount")]
public int MaxIterationCount { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Sections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class CompressedMemberDTO : ICompressedMember
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Bucling")]
public bool Buckling { get; set; }
[JsonProperty("GeometryLength")]
public double GeometryLength { get; set; }
[JsonProperty("LengthFactorX")]
public double LengthFactorX { get; set; }
[JsonProperty("DiagramFactorX")]
public double DiagramFactorX { get; set; }
[JsonProperty("LengthFactorY")]
public double LengthFactorY { get; set; }
[JsonProperty("DiagramFactorY")]
public double DiagramFactorY { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,37 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Cracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class CrackCalculatorDTO : ICrackCalculator
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("InputData")]
public ICrackCalculatorInputData InputData { get; set; } = new CrackCalculatorInputDataDTO();
[JsonIgnore]
public IResult Result { get; }
[JsonIgnore]
public IShiftTraceLogger? TraceLogger { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
public void Run()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,20 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace DataAccess.DTOs
{
public class CrackCalculatorInputDataDTO : ICrackCalculatorInputData
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("ForceActions")]
public List<IForceAction> ForceActions { get; set; } = new();
[JsonProperty("ForcePrimitives")]
public List<INdmPrimitive> Primitives { get; set; } = new();
[JsonProperty("UserCrackInputData")]
public IUserCrackInputData UserCrackInputData { get; set; } = new UserCrackInputDataDTO();
}
}

View File

@@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class EllipseNdmPrimitiveDTO : IEllipsePrimitive
public class EllipseNdmPrimitiveDTO : IEllipseNdmPrimitive
{
private IRectangleShape shape = new RectangleShapeDTO();
@@ -36,14 +36,15 @@ namespace DataAccess.DTOs
public IPoint2D Center { get; set; } = new Point2DDTO();
[JsonProperty("DivisionSize")]
public IDivisionSize DivisionSize { get; set; } = new DivisionSizeDTO();
[JsonProperty("RotationAngle")]
public double RotationAngle { get; set; }
[JsonIgnore]
public double Width { get; set; }
[JsonIgnore]
public double Height {get; set; }
[JsonIgnore]
public double Angle { get; set; }
[JsonIgnore]
public ICrossSection? CrossSection { get; set; }
public object Clone()
{
throw new NotImplementedException();

View File

@@ -0,0 +1,38 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ForceCalculatorDTO : IForceCalculator
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("InputData")]
public IForceCalculatorInputData InputData { get; set; } = new ForceCalculatorInputDataDTO();
[JsonIgnore]
public IShiftTraceLogger? TraceLogger { get; set; }
[JsonIgnore]
public Action<IResult> ActionToOutputResults { get; set; }
[JsonIgnore]
public IResult Result => throw new NotImplementedException();
public object Clone()
{
throw new NotImplementedException();
}
public void Run()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,37 @@
using DataAccess.DTOs.DTOEntities;
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Sections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
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 ForceCalculatorInputDataDTO : IForceCalculatorInputData
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("ForceActions")]
public List<IForceAction> ForceActions { get; set; } = new();
[JsonProperty("Primitives")]
public List<INdmPrimitive> Primitives { get; set; } = new();
[JsonProperty("LimitStatesList")]
public List<LimitStates> LimitStatesList { get; set; } = new();
[JsonProperty("CalcTermList")]
public List<CalcTerms> CalcTermsList { get; set; } = new();
[JsonProperty("Accuracy")]
public IAccuracy Accuracy { get; set; } = new AccuracyDTO();
[JsonProperty("CompressedMember")]
public ICompressedMember CompressedMember { get; set; } = new CompressedMemberDTO();
[JsonIgnore]
public List<IForceCombinationList> ForceCombinationLists { get; set; } = new();
}
}

View File

@@ -18,7 +18,7 @@ namespace DataAccess.DTOs
[JsonProperty("SetInGravityCenter")]
public bool SetInGravityCenter { get; set; }
[JsonProperty("ForcePoint")]
public IPoint2D ForcePoint { get; set; }
public IPoint2D ForcePoint { get; set; } = new Point2DDTO();
[JsonProperty("DesignForces")]
public List<IDesignForceTuple> DesignForces { get; set; } = new();

View File

@@ -0,0 +1,53 @@
using LoaderCalculator.Data.Ndms;
using Newtonsoft.Json;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class PointNdmPrimitiveDTO : IPointNdmPrimitive
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Name")]
public string? Name { get; set; }
[JsonProperty("NdmElement")]
public INdmElement NdmElement { get; set; } = new NdmElementDTO();
[JsonProperty("VisualProperty")]
public IVisualProperty VisualProperty { get; set; } = new VisualPropertyDTO();
[JsonProperty("Center")]
public IPoint2D Center { get; set; } = new Point2DDTO();
[JsonProperty("RotationAngle")]
public double RotationAngle { get; set; } = 0d;
[JsonProperty("Area")]
public double Area { get; set; } = 0d;
[JsonIgnore]
public ICrossSection? CrossSection { get; set; }
[JsonIgnore]
public IShape Shape { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
public IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions)
{
throw new NotImplementedException();
}
public List<INamedAreaPoint> GetValuePoints()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,64 @@
using LoaderCalculator.Data.Ndms;
using Newtonsoft.Json;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.DTOEntities
{
public class RebarNdmPrimitiveDTO : IRebarNdmPrimitive
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Name")]
public string? Name { get; set; }
[JsonIgnore]
public IShape Shape { get; set; }
[JsonProperty("NdmElement")]
public INdmElement NdmElement { get; set; } = new NdmElementDTO();
[JsonIgnore]
public ICrossSection? CrossSection { get; set; }
[JsonProperty("VisualProperty")]
public IVisualProperty VisualProperty { get; set; } = new VisualPropertyDTO();
[JsonProperty("Center")]
public IPoint2D Center { get; set; } = new Point2DDTO();
[JsonProperty("RotationAngle")]
public double RotationAngle { get; set; } = 0d;
[JsonProperty("Area")]
public double Area { get; set; } = 0d;
public INdmPrimitive? HostPrimitive { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
public Ndm GetConcreteNdm(ITriangulationOptions triangulationOptions)
{
throw new NotImplementedException();
}
public IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions)
{
throw new NotImplementedException();
}
public RebarNdm GetRebarNdm(ITriangulationOptions triangulationOptions)
{
throw new NotImplementedException();
}
public List<INamedAreaPoint> GetValuePoints()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,68 @@
using LoaderCalculator.Data.Ndms;
using Newtonsoft.Json;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class RectangleNdmPrimitiveDTO : IRectangleNdmPrimitive
{
private IRectangleShape shape = new RectangleShapeDTO();
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Name")]
public string? Name { get; set; }
[JsonProperty("RectangleShape")]
public IRectangleShape RectangleShape
{
get => shape;
set => shape = value;
}
[JsonIgnore]
public IShape Shape => shape;
[JsonProperty("NdmElement")]
public INdmElement NdmElement { get; set; } = new NdmElementDTO();
[JsonProperty("VisualProperty")]
public IVisualProperty VisualProperty { get; set; } = new VisualPropertyDTO();
[JsonProperty("Center")]
public IPoint2D Center { get; set; } = new Point2DDTO();
[JsonProperty("DivisionSize")]
public IDivisionSize DivisionSize { get; set; } = new DivisionSizeDTO();
[JsonProperty("RotationAngle")]
public double RotationAngle { get; set; }
[JsonIgnore]
public double Width { get; set; }
[JsonIgnore]
public double Height { get; set; }
[JsonIgnore]
public ICrossSection? CrossSection { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
public IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions)
{
throw new NotImplementedException();
}
public List<INamedAreaPoint> GetValuePoints()
{
throw new NotImplementedException();
}
public bool IsPointInside(IPoint2D point)
{
throw new NotImplementedException();
}
}
}

View File

@@ -16,8 +16,6 @@ namespace DataAccess.DTOs
public double Width { get; set; }
[JsonProperty("Height")]
public double Height { get; set; }
[JsonProperty("Angle")]
public double Angle { get; set; }
}
}

View File

@@ -1,4 +1,6 @@
using StructureHelper.Models.Materials;
using DataAccess.DTOs.DTOEntities;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Calculators;
@@ -34,18 +36,24 @@ namespace DataAccess.DTOs
private static List<(Type type, string name)> GetVersionV1()
{
return new List<(Type type, string name)>
List<(Type type, string name)> newList = new List<(Type type, string name)>
{
{ (typeof(AccuracyDTO), "Accuracy") },
{ (typeof(ConcreteLibMaterialDTO), "ConcreteLibMaterial") },
{ (typeof(CompressedMemberDTO), "CompressedMember") },
{ (typeof(CrackCalculatorDTO), "CrackCalculator") },
{ (typeof(CrackCalculatorInputDataDTO), "CrackCalculatorInputData") },
{ (typeof(CrossSectionDTO), "CrossSection") },
{ (typeof(CrossSectionNdmAnalysisDTO), "CrossSectionNdmAnalysis") },
{ (typeof(CrossSectionRepositoryDTO), "CrossSectionRepository") },
{ (typeof(DateVersionDTO), "DateVersion") },
{ (typeof(EllipseNdmPrimitiveDTO), "EllipseNdmPrimitive") },
{ (typeof(DesignForceTupleDTO), "DesignForceTuple") },
{ (typeof(DivisionSizeDTO), "DivisionSize") },
{ (typeof(ElasticMaterialDTO), "ElasticMaterial") },
{ (typeof(EllipseNdmPrimitiveDTO), "EllipseNdmPrimitive") },
{ (typeof(FileVersionDTO), "FileVersion") },
{ (typeof(ForceCalculatorDTO), "ForceCalculator") },
{ (typeof(ForceCalculatorInputDataDTO), "ForceCalculatorInputData") },
{ (typeof(ForceCombinationByFactorDTO), "ForceCombinationByFactor") },
{ (typeof(ForceCombinationListDTO), "ForceCombinationList") },
{ (typeof(ForceTupleDTO), "ForceTuple") },
@@ -54,25 +62,32 @@ namespace DataAccess.DTOs
{ (typeof(MaterialSafetyFactorDTO), "MaterialSafetyFactor") },
{ (typeof(NdmElementDTO), "NdmElement") },
{ (typeof(IVisualAnalysis), "IVisualAnalysis") },
{ (typeof(List<CalcTerms>), "ListOfCalcTerms") },
{ (typeof(List<ICalculator>), "ListOfICalculator") },
{ (typeof(List<IDateVersion>), "ListOfIDateVersion") },
{ (typeof(List<IDesignForceTuple>), "ListOfIDesignForceTuple") },
{ (typeof(List<IForceAction>), "ListOfIForceAction") },
{ (typeof(List<IHeadMaterial>), "ListOfIHeadMaterial") },
{ (typeof(List<LimitStates>), "ListOfLimitState") },
{ (typeof(List<IMaterialSafetyFactor>), "ListOfMaterialSafetyFactor") },
{ (typeof(List<IMaterialPartialFactor>), "ListOfMaterialPartialFactor") },
{ (typeof(List<INdmPrimitive>), "ListOfINdmPrimitive") },
{ (typeof(List<IPartialFactor>), "ListOfPartialFactor") },
{ (typeof(List<IVisualAnalysis>), "ListOfIVisualAnalysis") },
{ (typeof(Point2DDTO), "Point2D") },
{ (typeof(PointNdmPrimitiveDTO), "PointNdmPrimitive") },
{ (typeof(ProjectDTO), "Project") },
{ (typeof(RebarNdmPrimitiveDTO), "RebarNdmPrimitive") },
{ (typeof(RectangleNdmPrimitiveDTO), "RectangleNdmPrimitive") },
{ (typeof(RectangleShapeDTO), "RectangleShape") },
{ (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") },
{ (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") },
{ (typeof(VersionProcessorDTO), "VersionProcessor") },
{ (typeof(VisualAnalysisDTO), "VisualAnalysis") },
{ (typeof(VisualPropertyDTO), "VisualProperty") },
{ (typeof(UserCrackInputDataDTO), "UserCrackInputData") },
};
return newList;
}
}
}

View File

@@ -0,0 +1,29 @@
using Newtonsoft.Json;
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 UserCrackInputDataDTO : IUserCrackInputData
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("LengthBetweenCracks")]
public double LengthBetweenCracks { get; set; }
[JsonProperty("SetLengthBetweenCracks")]
public bool SetLengthBetweenCracks { get; set; }
[JsonProperty("SetSofteningFactors")]
public bool SetSofteningFactor { get; set; }
[JsonProperty("SofteningFactors")]
public double SofteningFactor { get; set; }
[JsonProperty("UltimateLongCrackWidths")]
public double UltimateLongCrackWidth { get; set; }
[JsonProperty("UltimateShortCrackWidths")]
public double UltimateShortCrackWidth { get; set; }
}
}