Add converting primitives and calculators
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
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 CalculatorsFromDTOConvertStrategy : ConvertStrategy<ICalculator, ICalculator>
|
||||
{
|
||||
private const string CalculatorIs = "Calculator is";
|
||||
private IConvertStrategy<ForceCalculator, ForceCalculatorDTO> forceConvertStrategy = new ForceCalculatorFromDTOConvertStrategy();
|
||||
private IConvertStrategy<CrackCalculator, CrackCalculatorDTO> crackConvertStrategy = new CrackCalculatorFromDTOConvertStrategy();
|
||||
|
||||
public override ICalculator GetNewItem(ICalculator source)
|
||||
{
|
||||
NewItem = GetNewCalculator(source);
|
||||
TraceLogger?.AddMessage($"Calculator Id = {NewItem.Id}, Name = {NewItem.Name} has been obtained");
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private ICalculator GetNewCalculator(ICalculator source)
|
||||
{
|
||||
if (source is IForceCalculator forceCalculator)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{CalculatorIs} force calculator");
|
||||
IForceCalculator calculator = GetForcCalculator(forceCalculator);
|
||||
return calculator;
|
||||
}
|
||||
if (source is ICrackCalculator crackCalculator)
|
||||
{
|
||||
TraceLogger?.AddMessage($"{CalculatorIs} crack calculator");
|
||||
ICrackCalculator calculator = GetCrackCalculator(crackCalculator);
|
||||
return calculator;
|
||||
}
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
|
||||
private ICrackCalculator GetCrackCalculator(ICrackCalculator crackCalculator)
|
||||
{
|
||||
crackConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
crackConvertStrategy.TraceLogger = TraceLogger;
|
||||
CrackCalculator newItem = crackConvertStrategy.Convert(crackCalculator as CrackCalculatorDTO);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IForceCalculator GetForcCalculator(IForceCalculator forceCalculator)
|
||||
{
|
||||
forceConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceConvertStrategy.TraceLogger = TraceLogger;
|
||||
ForceCalculator newItem = forceConvertStrategy.Convert(forceCalculator as ForceCalculatorDTO);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,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,47 @@
|
||||
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 = new UserCrackInputDataUpdateStrategy();
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic();
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic = new HasForceActionsProcessLogic();
|
||||
|
||||
public override CrackCalculatorInputData GetNewItem(CrackCalculatorInputDataDTO source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
ProcessPrimitives(source);
|
||||
ProcessActions(source);
|
||||
NewItem.UserCrackInputData = new UserCrackInputData(source.UserCrackInputData.Id);
|
||||
userDataUpdateStrategy.Update(NewItem.UserCrackInputData, source.UserCrackInputData);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ namespace DataAccess.DTOs
|
||||
updateStrategy.Update(target, source);
|
||||
}
|
||||
|
||||
private void ProcessForceActions(IHasForceCombinations target, IHasForceCombinations source)
|
||||
private void ProcessForceActions(IHasForceActions target, IHasForceActions source)
|
||||
{
|
||||
HasForceActionToDTOUpdateStrategy updateStrategy = new()
|
||||
{
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
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;
|
||||
@@ -18,27 +23,57 @@ namespace DataAccess.DTOs
|
||||
private const string convertFinished = " converting has been finished succesfully";
|
||||
private CrossSectionRepository newRepository;
|
||||
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic();
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic = new HasForceActionsProcessLogic();
|
||||
|
||||
public override CrossSectionRepository GetNewItem(ICrossSectionRepository source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertStarted, TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertStarted);
|
||||
newRepository = new(source.Id);
|
||||
ProcessMaterials(source);
|
||||
ProcessActions(source);
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertFinished, TraceLogStatuses.Service);
|
||||
ProcessPrimitives(source);
|
||||
ProcessCalculators(source);
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertFinished);
|
||||
return newRepository;
|
||||
}
|
||||
|
||||
private void ProcessActions(ICrossSectionRepository source)
|
||||
private void ProcessCalculators(ICrossSectionRepository source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Actions"+ convertStarted, TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage("Actions" + convertFinished, TraceLogStatuses.Service);
|
||||
throw new NotImplementedException();
|
||||
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, TraceLogStatuses.Service);
|
||||
var convertStrategy = new HeadMaterialFromDTOConvertStrategy
|
||||
TraceLogger?.AddMessage("Materials" + convertStarted);
|
||||
var convertStrategy = new HeadMaterialFromDTOConvertStrategy()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
@@ -46,7 +81,7 @@ namespace DataAccess.DTOs
|
||||
var convertLogic = new DictionaryConvertStrategy<IHeadMaterial, IHeadMaterial>(this, convertStrategy);
|
||||
var updateStrategy = new HasMaterialFromDTOUpdateStrategy(convertLogic);
|
||||
updateStrategy.Update(newRepository, source);
|
||||
TraceLogger?.AddMessage("Materials" + convertFinished, TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage("Materials" + convertFinished);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace DataAccess.DTOs
|
||||
updateStrategy.Update(target, source);
|
||||
}
|
||||
|
||||
private void ProcessForceActions(IHasForceCombinations target, IHasForceCombinations source)
|
||||
private void ProcessForceActions(IHasForceActions target, IHasForceActions source)
|
||||
{
|
||||
HasForceActionToDTOUpdateStrategy updateStrategy = new()
|
||||
{
|
||||
|
||||
@@ -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,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 ForceCalculatorFromDTOConvertStrategy : ConvertStrategy<ForceCalculator, ForceCalculatorDTO>
|
||||
{
|
||||
|
||||
private IConvertStrategy<ForceCalculatorInputData, ForceCalculatorInputDataDTO> inputDataConvertStrategy = new ForceCalculatorInputDataFromDTOConvertStrategy();
|
||||
public override ForceCalculator GetNewItem(ForceCalculatorDTO source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
NewItem.Name = source.Name;
|
||||
inputDataConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
inputDataConvertStrategy.TraceLogger = TraceLogger;
|
||||
NewItem.InputData = inputDataConvertStrategy.Convert(source.InputData as ForceCalculatorInputDataDTO);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 ForceCalculatorInputDataFromDTOConvertStrategy : ConvertStrategy<ForceCalculatorInputData, ForceCalculatorInputDataDTO>
|
||||
{
|
||||
private IUpdateStrategy<IForceCalculatorInputData> updateStrategy = new ForceCalculatorInputDataUpdateStrategy();
|
||||
private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic();
|
||||
private IHasForceActionsProcessLogic actionsProcessLogic = new HasForceActionsProcessLogic();
|
||||
|
||||
public override ForceCalculatorInputData GetNewItem(ForceCalculatorInputDataDTO source)
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
ProcessPrimitives(source);
|
||||
ProcessActions(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ namespace DataAccess.DTOs
|
||||
updateStrategy.Update(target, source);
|
||||
}
|
||||
|
||||
private void ProcessForceActions(IHasForceCombinations target, IHasForceCombinations source)
|
||||
private void ProcessForceActions(IHasForceActions target, IHasForceActions source)
|
||||
{
|
||||
HasForceActionToDTOUpdateStrategy updateStrategy = new()
|
||||
{
|
||||
|
||||
@@ -43,15 +43,18 @@ namespace DataAccess.DTOs
|
||||
TraceLogger?.AddMessage($"Force combination list name = {source.Name} is starting");
|
||||
ForceCombinationList newItem = new(source.Id);
|
||||
baseUpdateStrategy.Update(newItem, source);
|
||||
updateStrategy.Update(newItem, source);
|
||||
//updateStrategy.Update(newItem, source);
|
||||
pointConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
pointConvertStrategy.TraceLogger = TraceLogger;
|
||||
newItem.ForcePoint = pointConvertStrategy.Convert((Point2DDTO)source.ForcePoint);
|
||||
designTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
designTupleConvertStrategy.TraceLogger = TraceLogger;
|
||||
newItem.DesignForces.Clear();
|
||||
foreach (var item in source.DesignForces)
|
||||
{
|
||||
DesignForceTuple newDesignTuple = designTupleConvertStrategy.Convert((DesignForceTupleDTO)item);
|
||||
TraceLogger?.AddMessage($"New Design Tuple Limit state = {newDesignTuple.LimitState}, Calc term = {newDesignTuple.CalcTerm}");
|
||||
TraceLogger?.AddMessage($"Mx = {newDesignTuple.ForceTuple.Mx}, My = {newDesignTuple.ForceTuple.My}, Nz = {newDesignTuple.ForceTuple.Nz}");
|
||||
newItem.DesignForces.Add(newDesignTuple);
|
||||
}
|
||||
TraceLogger?.AddMessage($"Force combination list name = {newItem.Name} has been finished succesfully");
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class HasCalculatorsFromDTOUpdateStrategy : IUpdateStrategy<IHasCalculators>
|
||||
{
|
||||
private IConvertStrategy<ICalculator, ICalculator> convertStrategy;
|
||||
|
||||
public HasCalculatorsFromDTOUpdateStrategy(IConvertStrategy<ICalculator, ICalculator> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasCalculators targetObject, IHasCalculators sourceObject)
|
||||
{
|
||||
targetObject.Calculators.Clear();
|
||||
foreach (var item in sourceObject.Calculators)
|
||||
{
|
||||
var newItem = convertStrategy.Convert(item);
|
||||
targetObject.Calculators.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasForceActionToDTOUpdateStrategy : IUpdateStrategy<IHasForceCombinations>
|
||||
public class HasForceActionToDTOUpdateStrategy : IUpdateStrategy<IHasForceActions>
|
||||
{
|
||||
private readonly IConvertStrategy<IForceAction, IForceAction> forceActionStrategy;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace DataAccess.DTOs
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public void Update(IHasForceCombinations targetObject, IHasForceCombinations sourceObject)
|
||||
public void Update(IHasForceActions targetObject, IHasForceActions sourceObject)
|
||||
{
|
||||
if (sourceObject.ForceActions is null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasForceActionsFromDTOUpdateStrategy : IUpdateStrategy<IHasForceActions>
|
||||
{
|
||||
private readonly IConvertStrategy<IForceAction, IForceAction> convertStrategy;
|
||||
|
||||
public HasForceActionsFromDTOUpdateStrategy(IConvertStrategy<IForceAction, IForceAction> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasForceActions targetObject, IHasForceActions sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.ForceActions.Clear();
|
||||
foreach (var item in sourceObject.ForceActions)
|
||||
{
|
||||
var newItem = convertStrategy.Convert(item);
|
||||
targetObject.ForceActions.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
DataAccess/DTOs/Converters/HasForceActionsProcessLogic.cs
Normal file
41
DataAccess/DTOs/Converters/HasForceActionsProcessLogic.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasForceActionsProcessLogic : IHasForceActionsProcessLogic
|
||||
{
|
||||
private const string convertStarted = " converting is started";
|
||||
private const string convertFinished = " converting has been finished succesfully";
|
||||
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
|
||||
public IHasForceActions Source { get; set; }
|
||||
public IHasForceActions Target { get; set; }
|
||||
public void Process()
|
||||
{
|
||||
TraceLogger?.AddMessage("Actions" + convertStarted);
|
||||
ForceActionsFromDTOConvertStrategy convertStrategy = new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
DictionaryConvertStrategy<IForceAction, IForceAction> convertLogic = new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger,
|
||||
ConvertStrategy = convertStrategy
|
||||
};
|
||||
HasForceActionsFromDTOUpdateStrategy updateStrategy = new(convertLogic);
|
||||
updateStrategy.Update(Target, Source);
|
||||
TraceLogger?.AddMessage("Actions" + convertFinished);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
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 HasPrimitivesFromDTOUpdateStrategy : IUpdateStrategy<IHasPrimitives>
|
||||
{
|
||||
private IConvertStrategy<INdmPrimitive, INdmPrimitive> convertStrategy;
|
||||
|
||||
public HasPrimitivesFromDTOUpdateStrategy(IConvertStrategy<INdmPrimitive, INdmPrimitive> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasPrimitives targetObject, IHasPrimitives sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Primitives.Clear();
|
||||
foreach (var item in sourceObject.Primitives)
|
||||
{
|
||||
var newItem = convertStrategy.Convert(item);
|
||||
targetObject.Primitives.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
DataAccess/DTOs/Converters/HasPrimitivesProcessLogic.cs
Normal file
41
DataAccess/DTOs/Converters/HasPrimitivesProcessLogic.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class HasPrimitivesProcessLogic : IHasPrimitivesProcessLogic
|
||||
{
|
||||
private const string convertStarted = " converting is started";
|
||||
private const string convertFinished = " converting has been finished succesfully";
|
||||
|
||||
public IHasPrimitives Source { get; set; }
|
||||
public IHasPrimitives Target { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public void Process()
|
||||
{
|
||||
TraceLogger?.AddMessage("Primitives" + convertStarted);
|
||||
NdmPrimitiveFromDTOConvertStrategy convertStrategy = new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
DictionaryConvertStrategy<INdmPrimitive, INdmPrimitive> convertLogic = new()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger,
|
||||
ConvertStrategy = convertStrategy
|
||||
};
|
||||
HasPrimitivesFromDTOUpdateStrategy updateStrategy = new(convertLogic);
|
||||
updateStrategy.Update(Target, Source);
|
||||
TraceLogger?.AddMessage($"Primitives {convertFinished}, totally {Target.Primitives.Count} have been obtained");
|
||||
}
|
||||
}
|
||||
}
|
||||
15
DataAccess/DTOs/Converters/IHasForceActionsProcessLogic.cs
Normal file
15
DataAccess/DTOs/Converters/IHasForceActionsProcessLogic.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public interface IHasForceActionsProcessLogic
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
IHasForceActions Source { get; set; }
|
||||
IHasForceActions Target { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
void Process();
|
||||
}
|
||||
}
|
||||
16
DataAccess/DTOs/Converters/IHasPrimitivesProcessLogic.cs
Normal file
16
DataAccess/DTOs/Converters/IHasPrimitivesProcessLogic.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public interface IHasPrimitivesProcessLogic
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
IHasPrimitives Source { get; set; }
|
||||
IHasPrimitives Target { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
void Process();
|
||||
}
|
||||
}
|
||||
142
DataAccess/DTOs/Converters/NdmPrimitiveFromDTOConvertStrategy.cs
Normal file
142
DataAccess/DTOs/Converters/NdmPrimitiveFromDTOConvertStrategy.cs
Normal file
@@ -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 succesfully, 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 succesfully, 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 succesfully, 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 succesfully, Name = {newItem.Name}");
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace DataAccess.DTOs
|
||||
}
|
||||
|
||||
public PointNdmPrimitiveToDTOConvertStrategy() : this(
|
||||
new PointPrimitiveUpdateStrategy(),
|
||||
new PointNdmPrimitiveUpdateStrategy(),
|
||||
new NdmElementDTOConvertStrategy(),
|
||||
new Point2DToDTOConvertStrategy(),
|
||||
new VisualPropertyToDTOConvertStrategy()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ namespace DataAccess.DTOs
|
||||
private RebarNdmPrimitiveDTO GetNewPrimitive(IRebarNdmPrimitive source)
|
||||
{
|
||||
RebarNdmPrimitiveDTO newItem = new() { Id = source.Id };
|
||||
//updateStrategy.Update(newItem, source);
|
||||
updateStrategy.Update(newItem, source);
|
||||
newItem.NdmElement = ndmElementConvertStrategy.Convert(source.NdmElement);
|
||||
newItem.Center = pointConvertStrategy.Convert(source.Center);
|
||||
newItem.VisualProperty = visualPropsConvertStrategy.Convert(source.VisualProperty);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,6 @@ namespace DataAccess.DTOs
|
||||
[JsonIgnore]
|
||||
public string FullFileName { get; set; }
|
||||
[JsonIgnore]
|
||||
public bool IsNewFile { get; set; }
|
||||
[JsonIgnore]
|
||||
public bool IsActual { get; set; }
|
||||
|
||||
[JsonProperty("VisualAnalyses")]
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.DTOEntities
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class RebarNdmPrimitiveDTO : IRebarNdmPrimitive
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user