Add beam shear converting to DTO
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 CrackCalculatorFromDTOConvertStrategy : ConvertStrategy<CrackCalculator, CrackCalculatorDTO>
|
||||
{
|
||||
private IConvertStrategy<CrackCalculatorInputData, CrackCalculatorInputDataDTO> convertStrategy = new CrackCalculatorInputDataFromDTOConvertStrategy();
|
||||
|
||||
public override CrackCalculator GetNewItem(CrackCalculatorDTO source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
NewItem.Name = source.Name;
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
NewItem.InputData = convertStrategy.Convert(source.InputData as CrackCalculatorInputDataDTO);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 CrackCalculatorInputDataFromDTOConvertStrategy : ConvertStrategy<CrackCalculatorInputData, CrackCalculatorInputDataDTO>
|
||||
{
|
||||
private IUpdateStrategy<IUserCrackInputData> userDataUpdateStrategy;
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic;
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic;
|
||||
private IConvertStrategy<UserCrackInputData, UserCrackInputDataDTO> userDataConvertStrategy;
|
||||
|
||||
public override CrackCalculatorInputData GetNewItem(CrackCalculatorInputDataDTO source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
GetNewItemBySource(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
private void GetNewItemBySource(CrackCalculatorInputDataDTO source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
ProcessPrimitives(source);
|
||||
ProcessActions(source);
|
||||
NewItem.UserCrackInputData = new UserCrackInputData(source.UserCrackInputData.Id);
|
||||
userDataUpdateStrategy.Update(NewItem.UserCrackInputData, source.UserCrackInputData);
|
||||
}
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
userDataUpdateStrategy ??= new UserCrackInputDataUpdateStrategy();
|
||||
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
userDataConvertStrategy ??= new UserCrackInputDataFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
{
|
||||
primitivesProcessLogic.Source = source;
|
||||
primitivesProcessLogic.Target = NewItem;
|
||||
primitivesProcessLogic.Process();
|
||||
}
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
{
|
||||
actionsProcessLogic.Source = source;
|
||||
actionsProcessLogic.Target = NewItem;
|
||||
actionsProcessLogic.Process();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 CrackCalculatorInputDataToDTOConvertStrategy : ConvertStrategy<CrackCalculatorInputDataDTO, ICrackCalculatorInputData>
|
||||
{
|
||||
private IUpdateStrategy<IUserCrackInputData> userDataUpdateStrategy;
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic;
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic;
|
||||
private IConvertStrategy<UserCrackInputDataDTO, IUserCrackInputData> userDataConvertStrategy;
|
||||
|
||||
public override CrackCalculatorInputDataDTO GetNewItem(ICrackCalculatorInputData source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
GetNewItemBySource(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewItemBySource(ICrackCalculatorInputData source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
ProcessPrimitives(source);
|
||||
ProcessActions(source);
|
||||
NewItem.UserCrackInputData = userDataConvertStrategy.Convert(source.UserCrackInputData);
|
||||
userDataUpdateStrategy.Update(NewItem.UserCrackInputData, source.UserCrackInputData);
|
||||
}
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
userDataUpdateStrategy ??= new UserCrackInputDataUpdateStrategy();
|
||||
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
userDataConvertStrategy ??= new UserCrackInputDataToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
{
|
||||
primitivesProcessLogic.Source = source;
|
||||
primitivesProcessLogic.Target = NewItem;
|
||||
primitivesProcessLogic.Process();
|
||||
}
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
{
|
||||
actionsProcessLogic.Source = source;
|
||||
actionsProcessLogic.Target = NewItem;
|
||||
actionsProcessLogic.Process();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CrackCalculatorToDTOConvertStrategy : ConvertStrategy<CrackCalculatorDTO, ICrackCalculator>
|
||||
{
|
||||
private IUpdateStrategy<ICrackCalculator> updateStrategy;
|
||||
private IConvertStrategy<CrackCalculatorInputDataDTO, ICrackCalculatorInputData> inputDataConvertStrategy;
|
||||
|
||||
public CrackCalculatorToDTOConvertStrategy(IUpdateStrategy<ICrackCalculator> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public CrackCalculatorToDTOConvertStrategy() { }
|
||||
public override CrackCalculatorDTO GetNewItem(ICrackCalculator source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
GetNewItemBySource(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new CrackCalculatorUpdateStrategy();
|
||||
inputDataConvertStrategy ??= new CrackCalculatorInputDataToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
}
|
||||
|
||||
private void GetNewItemBySource(ICrackCalculator source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.InputData = inputDataConvertStrategy.Convert(source.InputData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.WorkPlanes;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CrossSectionFromDTOConvertStrategy : IConvertStrategy<ICrossSection, ICrossSection>
|
||||
{
|
||||
private IConvertStrategy<ICrossSectionRepository, ICrossSectionRepository> repositoryConvertStrategy;
|
||||
private IConvertStrategy<WorkPlaneProperty, WorkPlanePropertyDTO> workPlaneConvertStrategy;
|
||||
|
||||
public CrossSectionFromDTOConvertStrategy(IConvertStrategy<ICrossSectionRepository, ICrossSectionRepository> repositoryConvertStrategy,
|
||||
IConvertStrategy<WorkPlaneProperty, WorkPlanePropertyDTO> workPlaneConvertStrategy)
|
||||
{
|
||||
this.repositoryConvertStrategy = repositoryConvertStrategy;
|
||||
this.workPlaneConvertStrategy = workPlaneConvertStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionFromDTOConvertStrategy() { }
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ICrossSection Convert(ICrossSection source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
Check();
|
||||
return GetNewCrossSection(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
repositoryConvertStrategy ??= new CrossSectionRepositoryFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
workPlaneConvertStrategy ??= new WorkPlanePropertyFromDTOConvertStrategy(ReferenceDictionary,TraceLogger);
|
||||
}
|
||||
|
||||
private ICrossSection GetNewCrossSection(ICrossSection source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Cross-Section converting is started", TraceLogStatuses.Service);
|
||||
CrossSection newItem = new(source.Id);
|
||||
newItem.SectionRepository = GetNewCrossSectionRepository(source.SectionRepository);
|
||||
TraceLogger?.AddMessage("Cross-Section converting has been finished successfully", TraceLogStatuses.Service);
|
||||
if (source.WorkPlaneProperty is null)
|
||||
{
|
||||
TraceLogger?.AddMessage("Work plane properties is not found", TraceLogStatuses.Warning);
|
||||
newItem.WorkPlaneProperty = new WorkPlaneProperty(Guid.NewGuid());
|
||||
TraceLogger?.AddMessage("New work plane properties were generated", TraceLogStatuses.Debug);
|
||||
}
|
||||
else if (source.WorkPlaneProperty is WorkPlanePropertyDTO dto)
|
||||
{
|
||||
newItem.WorkPlaneProperty = workPlaneConvertStrategy.Convert(dto);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.WorkPlaneProperty));
|
||||
}
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private ICrossSectionRepository GetNewCrossSectionRepository(ICrossSectionRepository source)
|
||||
{
|
||||
ICrossSectionRepository newItem = repositoryConvertStrategy.Convert(source);
|
||||
TraceLogger?.AddMessage($"Object of type <<{newItem.GetType()}>> was obtained", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ICrossSection, ICrossSection>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class CrossSectionNdmAnalysisFromDTOConvertStrategy : IConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>
|
||||
{
|
||||
private IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy;
|
||||
|
||||
public CrossSectionNdmAnalysisFromDTOConvertStrategy(IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionNdmAnalysisFromDTOConvertStrategy() : this(new CrossSectionNdmAnalysisUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ICrossSectionNdmAnalysis Convert(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
ICrossSectionNdmAnalysis newItem = GetCrossSectionNDMAnalysis(source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ICrossSectionNdmAnalysis GetCrossSectionNDMAnalysis(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Cross-section sonverting is started");
|
||||
CrossSectionNdmAnalysis newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("Cross-section analysis was obtained successfully");
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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
|
||||
{
|
||||
internal class CrossSectionNdmAnalysisToDTOConvertStrategy : ConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>
|
||||
{
|
||||
private IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy;
|
||||
private IConvertStrategy<VersionProcessorDTO, IVersionProcessor> convertStrategy;
|
||||
|
||||
public CrossSectionNdmAnalysisToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override CrossSectionNdmAnalysisDTO GetNewItem(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewAnalysis(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
private void GetNewAnalysis(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Cross-section ndm analysis converting is started", TraceLogStatuses.Debug);
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
TraceLogger?.AddMessage("Convert version processor is started", TraceLogStatuses.Service);
|
||||
NewItem.VersionProcessor = convertStrategy.Convert(source.VersionProcessor);
|
||||
TraceLogger?.AddMessage("Cross-section ndm analysis has been converted successfully", TraceLogStatuses.Service);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new CrossSectionNdmAnalysisUpdateStrategy();
|
||||
convertStrategy = new DictionaryConvertStrategy<VersionProcessorDTO, IVersionProcessor>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = new VersionProcessorToDTOConvertStrategy(ReferenceDictionary, TraceLogger),
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
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 CrossSectionRepositoryFromDTOConvertStrategy : ConvertStrategy<ICrossSectionRepository, ICrossSectionRepository>
|
||||
{
|
||||
private const string convertStarted = " converting is started";
|
||||
private const string convertFinished = " converting has been finished successfully";
|
||||
private CrossSectionRepository newRepository;
|
||||
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic(ConvertDirection.FromDTO);
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic = new HasForceActionsProcessLogic(ConvertDirection.FromDTO);
|
||||
|
||||
public CrossSectionRepositoryFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override CrossSectionRepository GetNewItem(ICrossSectionRepository source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertStarted);
|
||||
newRepository = new(source.Id);
|
||||
ProcessMaterials(source);
|
||||
ProcessActions(source);
|
||||
ProcessPrimitives(source);
|
||||
ProcessCalculators(source);
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertFinished);
|
||||
return newRepository;
|
||||
}
|
||||
|
||||
private void ProcessCalculators(ICrossSectionRepository source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Calculators" + convertStarted);
|
||||
var convertStrategy = new CalculatorsFromDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var convertLogic = new DictionaryConvertStrategy<ICalculator, ICalculator>(this, convertStrategy);
|
||||
var updateStrategy = new HasCalculatorsFromDTOUpdateStrategy(convertLogic);
|
||||
updateStrategy.Update(newRepository, source);
|
||||
TraceLogger?.AddMessage("Calculators" + convertFinished);
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
{
|
||||
primitivesProcessLogic.Source = source;
|
||||
primitivesProcessLogic.Target = newRepository;
|
||||
primitivesProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
primitivesProcessLogic.TraceLogger = TraceLogger;
|
||||
primitivesProcessLogic.Process();
|
||||
}
|
||||
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
{
|
||||
actionsProcessLogic.Source = source;
|
||||
actionsProcessLogic.Target = newRepository;
|
||||
actionsProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
actionsProcessLogic.TraceLogger = TraceLogger;
|
||||
actionsProcessLogic.Process();
|
||||
}
|
||||
|
||||
private void ProcessMaterials(IHasHeadMaterials source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Materials" + convertStarted);
|
||||
var convertStrategy = new HeadMaterialFromDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var convertLogic = new DictionaryConvertStrategy<IHeadMaterial, IHeadMaterial>(this, convertStrategy);
|
||||
var updateStrategy = new HasMaterialFromDTOUpdateStrategy(convertLogic);
|
||||
updateStrategy.Update(newRepository, source);
|
||||
TraceLogger?.AddMessage("Materials" + convertFinished);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CrossSectionRepositoryToDTOConvertStrategy : IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>
|
||||
{
|
||||
private IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy;
|
||||
|
||||
|
||||
public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy)
|
||||
{
|
||||
this.materialConvertStrategy = materialConvertStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionRepositoryToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
ReferenceDictionary = referenceDictionary;
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public CrossSectionRepositoryDTO Convert(ICrossSectionRepository source)
|
||||
{
|
||||
Check();
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
CrossSectionRepositoryDTO newItem = GetNewRepository(source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
materialConvertStrategy ??= new HeadMaterialToDTOConvertStrategy();
|
||||
}
|
||||
|
||||
private CrossSectionRepositoryDTO GetNewRepository(ICrossSectionRepository source)
|
||||
{
|
||||
CrossSectionRepositoryDTO newItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
ProcessForceActions(newItem, source);
|
||||
List<IHeadMaterial> materials = ProcessMaterials(source);
|
||||
newItem.HeadMaterials.AddRange(materials);
|
||||
ProcessPrimitives(newItem, source);
|
||||
ProcessCalculators(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void ProcessCalculators(IHasCalculators target, IHasCalculators source)
|
||||
{
|
||||
HasCalculatorsToDTOUpdateStrategy updateStrategy = new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
updateStrategy.Update(target, source);
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives target, IHasPrimitives source)
|
||||
{
|
||||
HasPrimitivesToDTOUpdateStrategy updateStrategy = new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
updateStrategy.Update(target, source);
|
||||
}
|
||||
|
||||
private void ProcessForceActions(IHasForceActions target, IHasForceActions source)
|
||||
{
|
||||
HasForceActionToDTOUpdateStrategy updateStrategy = new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
updateStrategy.Update(target, source);
|
||||
}
|
||||
|
||||
private List<IHeadMaterial> ProcessMaterials(ICrossSectionRepository source)
|
||||
{
|
||||
materialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
materialConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<HeadMaterialDTO, IHeadMaterial>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = materialConvertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
List<IHeadMaterial> materials = new();
|
||||
foreach (var item in source.HeadMaterials)
|
||||
{
|
||||
materials.Add(convertLogic.Convert(item));
|
||||
}
|
||||
|
||||
return materials;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<CrossSectionRepositoryDTO, ICrossSectionRepository>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.WorkPlanes;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CrossSectionToDTOConvertStrategy : ConvertStrategy<CrossSectionDTO, ICrossSection>
|
||||
{
|
||||
private IUpdateStrategy<ICrossSection> updateStrategy; //don't use since CrossSection does not have any properties
|
||||
private IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertRepositoryStrategy;
|
||||
private DictionaryConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertLogic;
|
||||
private ICheckConvertLogic<CrossSectionDTO, ICrossSection> checkLogic;
|
||||
private IConvertStrategy<WorkPlanePropertyDTO, IWorkPlaneProperty> workPlanePropertyConvertStrategy;
|
||||
|
||||
public CrossSectionToDTOConvertStrategy(IUpdateStrategy<ICrossSection> updateStrategy,
|
||||
IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertRepositoryStrategy,
|
||||
ICheckConvertLogic<CrossSectionDTO, ICrossSection> checkLogic,
|
||||
IConvertStrategy<WorkPlanePropertyDTO, IWorkPlaneProperty> workPlanePropertyConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertRepositoryStrategy = convertRepositoryStrategy;
|
||||
this.checkLogic = checkLogic;
|
||||
this.workPlanePropertyConvertStrategy = workPlanePropertyConvertStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionToDTOConvertStrategy() { }
|
||||
|
||||
|
||||
private void Check()
|
||||
{
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
checkLogic.Check();
|
||||
}
|
||||
|
||||
public override CrossSectionDTO GetNewItem(ICrossSection source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
GetNewItemBySource(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new CrossSectionUpdateStrategy();
|
||||
convertRepositoryStrategy ??= new CrossSectionRepositoryToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
checkLogic ??= new CheckConvertLogic<CrossSectionDTO, ICrossSection>();
|
||||
workPlanePropertyConvertStrategy ??= new WorkPlanePropertyToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
|
||||
private void GetNewItemBySource(ICrossSection source)
|
||||
{
|
||||
Check();
|
||||
NewItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
convertLogic = new DictionaryConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>(this, convertRepositoryStrategy);
|
||||
NewItem.SectionRepository = convertLogic.Convert(source.SectionRepository);
|
||||
NewItem.WorkPlaneProperty = workPlanePropertyConvertStrategy.Convert(source.WorkPlaneProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 EllipseNdmPrimitiveFromDTOConvertStrategy : ConvertStrategy<EllipseNdmPrimitive, EllipseNdmPrimitiveDTO>
|
||||
{
|
||||
private IUpdateStrategy<IEllipseNdmPrimitive> updateStrategy = new EllipsePrimitiveUpdateStrategy();
|
||||
public override EllipseNdmPrimitive GetNewItem(EllipseNdmPrimitiveDTO source)
|
||||
{
|
||||
EllipseNdmPrimitive newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
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 EllipseNdmPrimitiveToDTOConvertStrategy : IConvertStrategy<EllipseNdmPrimitiveDTO, IEllipseNdmPrimitive>
|
||||
{
|
||||
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 EllipseNdmPrimitiveToDTOConvertStrategy(
|
||||
IUpdateStrategy<IEllipseNdmPrimitive> 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 EllipseNdmPrimitiveToDTOConvertStrategy() : this(
|
||||
new EllipsePrimitiveUpdateStrategy(),
|
||||
new RectangleShapeToDTOConvertStrategy(),
|
||||
new NdmElementToDTOConvertStrategy(),
|
||||
new Point2DToDTOConvertStrategy(),
|
||||
new VisualPropertyToDTOConvertStrategy(),
|
||||
new DivisionSizeToDTOConvertStrategy()
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public EllipseNdmPrimitiveDTO Convert(IEllipseNdmPrimitive 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 EllipseNdmPrimitiveDTO GetNewPrimitive(IEllipseNdmPrimitive source)
|
||||
{
|
||||
EllipseNdmPrimitiveDTO 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<EllipseNdmPrimitiveDTO, IEllipseNdmPrimitive>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceCalculatorFromDTOConvertStrategy : ConvertStrategy<ForceCalculator, ForceCalculatorDTO>
|
||||
{
|
||||
|
||||
private IConvertStrategy<ForceCalculatorInputData, ForceCalculatorInputDataDTO> inputDataConvertStrategy;
|
||||
public override ForceCalculator GetNewItem(ForceCalculatorDTO source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
GetNewItemBySource(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
inputDataConvertStrategy ??= new ForceCalculatorInputDataFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
}
|
||||
|
||||
private void GetNewItemBySource(ForceCalculatorDTO source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
NewItem.Name = source.Name;
|
||||
NewItem.InputData = inputDataConvertStrategy.Convert(source.InputData as ForceCalculatorInputDataDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceCalculatorInputDataFromDTOConvertStrategy : ConvertStrategy<ForceCalculatorInputData, ForceCalculatorInputDataDTO>
|
||||
{
|
||||
private IUpdateStrategy<IForceCalculatorInputData> updateStrategy;
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic;
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic;
|
||||
private IConvertStrategy<Accuracy, AccuracyDTO> accuracyConvertStrategy;
|
||||
|
||||
public override ForceCalculatorInputData GetNewItem(ForceCalculatorInputDataDTO source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
GetNewItemBySource(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewItemBySource(ForceCalculatorInputDataDTO source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.Accuracy = accuracyConvertStrategy.Convert((AccuracyDTO)source.Accuracy);
|
||||
ProcessPrimitives(source);
|
||||
ProcessActions(source);
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
{
|
||||
primitivesProcessLogic.Source = source;
|
||||
primitivesProcessLogic.Target = NewItem;
|
||||
primitivesProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
primitivesProcessLogic.TraceLogger = TraceLogger;
|
||||
primitivesProcessLogic.Process();
|
||||
}
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
{
|
||||
actionsProcessLogic.Source = source;
|
||||
actionsProcessLogic.Target = NewItem;
|
||||
actionsProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
actionsProcessLogic.TraceLogger = TraceLogger;
|
||||
actionsProcessLogic.Process();
|
||||
}
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ForceCalculatorInputDataUpdateStrategy();
|
||||
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
accuracyConvertStrategy ??= new AccuracyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
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 ForceCalculatorInputDataToDTOConvertStrategy : ConvertStrategy<ForceCalculatorInputDataDTO, IForceCalculatorInputData>
|
||||
{
|
||||
private IUpdateStrategy<IForceCalculatorInputData> updateStrategy;
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic;
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic;
|
||||
private IConvertStrategy<AccuracyDTO, IAccuracy> accuracyConvertStrategy;
|
||||
|
||||
public override ForceCalculatorInputDataDTO GetNewItem(IForceCalculatorInputData source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
GetNewItemBySource(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewItemBySource(IForceCalculatorInputData source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.Accuracy = accuracyConvertStrategy.Convert(source.Accuracy);
|
||||
ProcessPrimitives(source);
|
||||
ProcessActions(source);
|
||||
}
|
||||
|
||||
private void ProcessPrimitives(IHasPrimitives source)
|
||||
{
|
||||
primitivesProcessLogic.Source = source;
|
||||
primitivesProcessLogic.Target = NewItem;
|
||||
primitivesProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
primitivesProcessLogic.TraceLogger = TraceLogger;
|
||||
primitivesProcessLogic.Process();
|
||||
}
|
||||
private void ProcessActions(IHasForceActions source)
|
||||
{
|
||||
actionsProcessLogic.Source = source;
|
||||
actionsProcessLogic.Target = NewItem;
|
||||
actionsProcessLogic.ReferenceDictionary = ReferenceDictionary;
|
||||
actionsProcessLogic.TraceLogger = TraceLogger;
|
||||
actionsProcessLogic.Process();
|
||||
}
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ForceCalculatorInputDataUpdateStrategy();
|
||||
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
accuracyConvertStrategy ??= new AccuracyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
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 : ConvertStrategy<ForceCalculatorDTO, IForceCalculator>
|
||||
{
|
||||
private IUpdateStrategy<IForceCalculator> updateStrategy;
|
||||
private IConvertStrategy<ForceCalculatorInputDataDTO, IForceCalculatorInputData> inputDataConvertStrategy;
|
||||
|
||||
public override ForceCalculatorDTO GetNewItem(IForceCalculator source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
try
|
||||
{
|
||||
GetNewItemBySource(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new ForceCalculatorUpdateStrategy();
|
||||
inputDataConvertStrategy ??= new ForceCalculatorInputDataToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
|
||||
}
|
||||
|
||||
private void GetNewItemBySource(IForceCalculator source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
NewItem.InputData = inputDataConvertStrategy.Convert(source.InputData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives.Logics;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class NdmElementToDTOConvertStrategy : IConvertStrategy<NdmElementDTO, INdmElement>
|
||||
{
|
||||
private IUpdateStrategy<INdmElement> updateStrategy;
|
||||
private IConvertStrategy<HeadMaterialDTO, IHeadMaterial> headMaterialConvertStrategy;
|
||||
private IUpdateStrategy<IForceTuple> forceUpdateStrategy = new ForceTupleUpdateStrategy();
|
||||
|
||||
public NdmElementToDTOConvertStrategy(
|
||||
IUpdateStrategy<INdmElement> updateStrategy,
|
||||
IConvertStrategy<HeadMaterialDTO, IHeadMaterial> headMaterialConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.headMaterialConvertStrategy = headMaterialConvertStrategy;
|
||||
}
|
||||
|
||||
public NdmElementToDTOConvertStrategy() : this(
|
||||
new NdmElementUpdateStrategy(),
|
||||
new HeadMaterialToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public NdmElementDTO Convert(INdmElement source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
return GenNewNdmElementDTO(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private NdmElementDTO GenNewNdmElementDTO(INdmElement source)
|
||||
{
|
||||
NdmElementDTO newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
headMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
headMaterialConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<HeadMaterialDTO, IHeadMaterial>(this, headMaterialConvertStrategy);
|
||||
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;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<NdmElementDTO, INdmElement>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class NdmPrimitiveFromDTOConvertStrategy : ConvertStrategy<INdmPrimitive, INdmPrimitive>
|
||||
{
|
||||
private const string PrimitiveIs = "Primtive is";
|
||||
private IConvertStrategy<RebarNdmPrimitive, RebarNdmPrimitiveDTO> rebarConvertStrategy;
|
||||
private IConvertStrategy<PointNdmPrimitive, PointNdmPrimitiveDTO> pointConvertStrategy;
|
||||
private IConvertStrategy<EllipseNdmPrimitive, EllipseNdmPrimitiveDTO> ellipseConvertStrategy;
|
||||
private IConvertStrategy<RectangleNdmPrimitive, RectangleNdmPrimitiveDTO> rectangleConvertStrategy;
|
||||
|
||||
private IHeadMaterial headMaterial;
|
||||
|
||||
public NdmPrimitiveFromDTOConvertStrategy(
|
||||
IConvertStrategy<RebarNdmPrimitive, RebarNdmPrimitiveDTO> rebarConvertStrategy,
|
||||
IConvertStrategy<PointNdmPrimitive, PointNdmPrimitiveDTO> pointConvertStrategy,
|
||||
IConvertStrategy<EllipseNdmPrimitive, EllipseNdmPrimitiveDTO> ellipseConvertStrategy,
|
||||
IConvertStrategy<RectangleNdmPrimitive, RectangleNdmPrimitiveDTO> rectangleConvertStrategy)
|
||||
{
|
||||
this.rebarConvertStrategy = rebarConvertStrategy;
|
||||
this.pointConvertStrategy = pointConvertStrategy;
|
||||
this.ellipseConvertStrategy = ellipseConvertStrategy;
|
||||
this.rectangleConvertStrategy = rectangleConvertStrategy;
|
||||
}
|
||||
|
||||
public NdmPrimitiveFromDTOConvertStrategy() : this(
|
||||
new RebarNdmPrimitiveFromDTOConvertStrategy(),
|
||||
new PointNdmPrimitiveFromDTOConvertStrategy(),
|
||||
new EllipseNdmPrimitiveFromDTOConvertStrategy(),
|
||||
new RectanglePrimitiveFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override INdmPrimitive GetNewItem(INdmPrimitive source)
|
||||
{
|
||||
GetMaterial(source.NdmElement.HeadMaterial);
|
||||
INdmPrimitive newItem = GetNewPrimitive(source);
|
||||
newItem.NdmElement.HeadMaterial = headMaterial;
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private INdmPrimitive GetNewPrimitive(INdmPrimitive source)
|
||||
{
|
||||
if (source is RebarNdmPrimitiveDTO rebar)
|
||||
{
|
||||
return GetRebar(rebar);
|
||||
}
|
||||
if (source is PointNdmPrimitiveDTO point)
|
||||
{
|
||||
return GetPoint(point);
|
||||
}
|
||||
if (source is EllipseNdmPrimitiveDTO ellipse)
|
||||
{
|
||||
return GetEllipse(ellipse);
|
||||
}
|
||||
if (source is RectangleNdmPrimitiveDTO rectangle)
|
||||
{
|
||||
return GetRectangle(rectangle);
|
||||
}
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
|
||||
private void GetMaterial(IHeadMaterial source)
|
||||
{
|
||||
HeadMaterialFromDTOConvertStrategy convertStrategy = new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
DictionaryConvertStrategy<IHeadMaterial, IHeadMaterial> convertLogic = new(this, convertStrategy);
|
||||
headMaterial = convertLogic.Convert(source);
|
||||
}
|
||||
|
||||
private INdmPrimitive GetRebar(RebarNdmPrimitiveDTO rebar)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{PrimitiveIs} rebar ndm primitive");
|
||||
rebarConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
rebarConvertStrategy.TraceLogger = TraceLogger;
|
||||
RebarNdmPrimitive newItem = rebarConvertStrategy.Convert(rebar);
|
||||
TraceLogger?.AddMessage($"Primtive has been obtained successfully, Name = {newItem.Name}");
|
||||
newItem.HostPrimitive = GetHostPrimitive(rebar);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private INdmPrimitive GetHostPrimitive(RebarNdmPrimitiveDTO rebar)
|
||||
{
|
||||
NdmPrimitiveFromDTOConvertStrategy convertStrategy = new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
DictionaryConvertStrategy<INdmPrimitive, INdmPrimitive> convertLogic = new(this, convertStrategy);
|
||||
INdmPrimitive hostPrimitive = convertLogic.Convert(rebar.HostPrimitive);
|
||||
TraceLogger?.AddMessage($"Host primitive Id = {hostPrimitive.Id}, Name = {hostPrimitive.Name}");
|
||||
return hostPrimitive;
|
||||
}
|
||||
|
||||
private INdmPrimitive GetPoint(PointNdmPrimitiveDTO point)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{PrimitiveIs} point ndm primitive");
|
||||
pointConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
pointConvertStrategy.TraceLogger = TraceLogger;
|
||||
PointNdmPrimitive newItem = pointConvertStrategy.Convert(point);
|
||||
TraceLogger?.AddMessage($"Primtive has been obtained successfully, Name = {newItem.Name}");
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private INdmPrimitive GetEllipse(EllipseNdmPrimitiveDTO ellipse)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{PrimitiveIs} ellipse ndm primitive");
|
||||
ellipseConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
ellipseConvertStrategy.TraceLogger = TraceLogger;
|
||||
EllipseNdmPrimitive newItem = ellipseConvertStrategy.Convert(ellipse);
|
||||
TraceLogger?.AddMessage($"Primtive has been obtained successfully, Name = {newItem.Name}");
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private INdmPrimitive GetRectangle(RectangleNdmPrimitiveDTO rectangle)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{PrimitiveIs} rectangle ndm primitive");
|
||||
rectangleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
rectangleConvertStrategy.TraceLogger = TraceLogger;
|
||||
RectangleNdmPrimitive newItem = rectangleConvertStrategy.Convert(rectangle);
|
||||
TraceLogger?.AddMessage($"Primtive has been obtained successfully, Name = {newItem.Name}");
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 PointNdmPrimitiveFromDTOConvertStrategy : ConvertStrategy<PointNdmPrimitive, PointNdmPrimitiveDTO>
|
||||
{
|
||||
private IUpdateStrategy<IPointNdmPrimitive> updateStrategy = new PointNdmPrimitiveUpdateStrategy();
|
||||
|
||||
|
||||
public override PointNdmPrimitive GetNewItem(PointNdmPrimitiveDTO source)
|
||||
{
|
||||
PointNdmPrimitive newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 PointNdmPrimitiveUpdateStrategy(),
|
||||
new NdmElementToDTOConvertStrategy(),
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 RebarNdmPrimitiveFromDTOConvertStrategy : ConvertStrategy<RebarNdmPrimitive, RebarNdmPrimitiveDTO>
|
||||
{
|
||||
private IUpdateStrategy<IRebarNdmPrimitive> updateStrategy = new RebarNdmPrimitiveUpdateStrategy();
|
||||
|
||||
public override RebarNdmPrimitive GetNewItem(RebarNdmPrimitiveDTO source)
|
||||
{
|
||||
RebarNdmPrimitive newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
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 NdmElementToDTOConvertStrategy(),
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 NdmElementToDTOConvertStrategy(),
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 RectanglePrimitiveFromDTOConvertStrategy : ConvertStrategy<RectangleNdmPrimitive, RectangleNdmPrimitiveDTO>
|
||||
{
|
||||
private IUpdateStrategy<IRectangleNdmPrimitive> updateStrategy;
|
||||
|
||||
public RectanglePrimitiveFromDTOConvertStrategy(IUpdateStrategy<IRectangleNdmPrimitive> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public RectanglePrimitiveFromDTOConvertStrategy() : this (new RectanglePrimitiveUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override RectangleNdmPrimitive GetNewItem(RectangleNdmPrimitiveDTO source)
|
||||
{
|
||||
RectangleNdmPrimitive newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class RectangleShapeToDTOConvertStrategy : ConvertStrategy<RectangleShapeDTO, IRectangleShape>
|
||||
{
|
||||
private IUpdateStrategy<IRectangleShape> updateStrategy;
|
||||
|
||||
public RectangleShapeToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public RectangleShapeToDTOConvertStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override RectangleShapeDTO GetNewItem(IRectangleShape source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewRectangleShape(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewRectangleShape(IRectangleShape source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Rectangle shape converting Id = {source.Id} has been started", TraceLogStatuses.Debug);
|
||||
InitializeStrategies();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
TraceLogger?.AddMessage($"Rectangle shape converting Id = {NewItem.Id} has been finished successfully", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new RectangleShapeUpdateStrategy();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user