Add converting primitives and calculators

This commit is contained in:
Evgeny Redikultsev
2024-11-04 17:40:18 +05:00
parent 7ea82c9492
commit 0bf9cf6a0b
53 changed files with 854 additions and 71 deletions

View File

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

View File

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

View File

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

View File

@@ -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()
{

View File

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

View File

@@ -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()
{

View File

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

View File

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

View File

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

View File

@@ -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()
{

View File

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

View File

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

View File

@@ -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)
{

View File

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

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

View File

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

View 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");
}
}
}

View 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();
}
}

View 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();
}
}

View 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;
}
}
}

View File

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

View File

@@ -32,7 +32,7 @@ namespace DataAccess.DTOs
}
public PointNdmPrimitiveToDTOConvertStrategy() : this(
new PointPrimitiveUpdateStrategy(),
new PointNdmPrimitiveUpdateStrategy(),
new NdmElementDTOConvertStrategy(),
new Point2DToDTOConvertStrategy(),
new VisualPropertyToDTOConvertStrategy()

View File

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

View File

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

View File

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

View File

@@ -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")]

View File

@@ -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
{

View File

@@ -3,6 +3,7 @@ using DataAccess.JsonConverters;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models;
@@ -55,6 +56,13 @@ namespace DataAccess.Infrastructures
}
string jsonData = File.ReadAllText(fileName);
RootObjectDTO? rootObject = GetRootObject(jsonData);
if (rootObject.FileVersion is null)
{
var errorString = "Section of file version is damaged";
result.Description += errorString;
result.IsValid = false;
return result;
}
var fileVersion = rootObject.FileVersion;
var checkLogic = new CheckFileVersionLogic()
{
@@ -69,6 +77,13 @@ namespace DataAccess.Infrastructures
}
else
{
if (rootObject.Project is null)
{
var errorString = "Section of project is damaged";
result.Description += errorString;
result.IsValid = false;
return result;
}
Project project = GetProject(rootObject);
project.FullFileName = fileName;
result.Project = project;
@@ -78,6 +93,10 @@ namespace DataAccess.Infrastructures
private Project GetProject(RootObjectDTO? rootObject)
{
if (rootObject.Project is null)
{
}
var currentVersion = ProgramSetting.GetCurrentFileVersion();
IFileVersion fileVersion = rootObject.FileVersion;
TraceLogger?.AddMessage($"File version is {fileVersion.VersionNumber}.{fileVersion.SubVersionNumber}, current version is {currentVersion.VersionNumber}.{currentVersion.SubVersionNumber}");
@@ -94,7 +113,7 @@ namespace DataAccess.Infrastructures
private RootObjectDTO? GetRootObject(string jsonData)
{
JsonSerializerSettings settings = GetSettings();
var rootObject = JsonConvert.DeserializeObject<RootObjectDTO>(jsonData, settings);
RootObjectDTO rootObject = JsonConvert.DeserializeObject<RootObjectDTO>(jsonData, settings);
return rootObject;
}

View File

@@ -19,7 +19,7 @@ namespace DataAccess.Infrastructures
public void SaveFile(IProject project)
{
if (project.IsNewFile == true)
if (project.FullFileName == string.Empty || project.FullFileName == "")
{
var result = SelectFileName(project);
if (result.IsValid == false)
@@ -28,7 +28,6 @@ namespace DataAccess.Infrastructures
return;
}
project.FullFileName = result.FileName;
project.IsNewFile = false;
}
SaveToFile(project);
}
@@ -40,7 +39,6 @@ namespace DataAccess.Infrastructures
{
FilterString = "StructureHelper project file (*.shpj)|*.shpj|All Files (*.*)|*.*",
InitialDirectory = project.FullFileName,
};
saver.TraceLogger = TraceLogger;
var saveResult = saver.SaveFile();
@@ -58,7 +56,11 @@ namespace DataAccess.Infrastructures
File.Delete(project.FullFileName);
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
ProjectDTO projectDTO = GetProjectDTO(project);
RootObjectDTO rootObject = new() { FileVersion = versionDTO, Project = projectDTO };
RootObjectDTO rootObject = new()
{
FileVersion = versionDTO,
Project = projectDTO
};
var rootString = Serialize(rootObject, TraceLogger);
SaveStringToFile(project, rootString);
}
@@ -95,7 +97,8 @@ namespace DataAccess.Infrastructures
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
return dictionaryConvertStrategy.Convert(project);
ProjectDTO projectDTO = dictionaryConvertStrategy.Convert(project);
return projectDTO;
}
private FileVersionDTO GetVersionDTO()
@@ -116,17 +119,25 @@ namespace DataAccess.Infrastructures
}
private static string Serialize(object obj, IShiftTraceLogger logger)
{
JsonSerializerSettings settings = GetSerializingSettings(logger);
string serializedObject = JsonConvert.SerializeObject(obj, settings);
return serializedObject;
}
private static JsonSerializerSettings GetSerializingSettings(IShiftTraceLogger logger)
{
List<(Type type, string name)> typesNames = TypeBinderListFactory.GetTypeNameList(TypeFileVersion.version_v1);
TypeBinder typeBinder = new(typesNames);
List<JsonConverter> jsonConverters = new List<JsonConverter>
{
new FileVersionDTOJsonConverter(logger),
new ProjectDTOJsonConverter(logger)
};
var settings = new JsonSerializerSettings
{
Converters = new List<JsonConverter>
{
// Add other converters if needed
new FileVersionDTOJsonConverter(logger), // Add the specific converter
new ProjectDTOJsonConverter(logger)
},
Converters = jsonConverters,
SerializationBinder = typeBinder,
Formatting = Formatting.Indented,
PreserveReferencesHandling = PreserveReferencesHandling.All,
@@ -134,19 +145,15 @@ namespace DataAccess.Infrastructures
TypeNameHandling = TypeNameHandling.All,
NullValueHandling = NullValueHandling.Include
};
return JsonConvert.SerializeObject(obj, settings);
return settings;
}
public void SaveFileAs(IProject project)
{
var tmpIsNew = project.IsNewFile;
var tmpFullFileName = project.FullFileName;
project.IsNewFile = true;
SaveFile(project);
if (project.IsNewFile == true)
if (project.FullFileName == string.Empty)
{
project.IsNewFile = tmpIsNew;
project.FullFileName = tmpFullFileName;
}
}

View File

@@ -127,6 +127,7 @@ namespace StructureHelper.Windows.MainWindow
analysis.Tags = "#New group";
var visualAnalysis = new VisualAnalysis(analysis);
ProgramSetting.CurrentProject.VisualAnalyses.Add(visualAnalysis);
//ProgramSetting.SetCurrentProjectToNotActual();
}
private void ActionToRun()

View File

@@ -58,7 +58,6 @@ namespace StructureHelper.Windows.MainWindow
{
var newProject = new Project()
{
IsNewFile = true,
IsActual = true
};
ProgramSetting.Projects.Add(newProject);
@@ -79,15 +78,19 @@ namespace StructureHelper.Windows.MainWindow
CloseFile(project);
}
}
private bool CloseFile()
public bool CloseFile()
{
var project = ProgramSetting.CurrentProject;
if (project is null) { return false; }
return CloseFile(project);
if (project is null)
{
return false;
}
bool closingResult = CloseFile(project);
return closingResult;
}
private bool CloseFile(IProject project)
{
if (project.IsActual == true & project.IsNewFile == false)
if (project.IsActual == true)
{
ProgramSetting.Projects.Remove(project);
return true;
@@ -97,12 +100,11 @@ namespace StructureHelper.Windows.MainWindow
{
SaveFile(project);
}
if (dialogResult == DialogResult.Cancel)
else if (dialogResult == DialogResult.Cancel)
{
return false;
}
project.IsActual = true;
project.IsNewFile = false;
CloseFile(project);
return true;
}
@@ -134,7 +136,6 @@ namespace StructureHelper.Windows.MainWindow
if (result.IsValid == true)
{
result.Project.IsActual = true;
result.Project.IsNewFile = false;
ProgramSetting.Projects.Clear();
ProgramSetting.Projects.Add(result.Project);
}

View File

@@ -32,7 +32,7 @@
</Viewbox>
</Button>
</ToolBar>
<ToolBar ToolTip="Diagrams">
<ToolBar ToolTip="Diagrams" Visibility="Hidden">
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" ToolTip="Diagrams">
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource Diagrams}"/>
@@ -49,7 +49,7 @@
</ToolBarTray>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="0"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid>

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -25,6 +26,15 @@ namespace StructureHelper.Windows.MainWindow
this.viewModel = new();
this.DataContext = viewModel;
InitializeComponent();
this.Closing += AnalysesManagerView_Closing;
}
private void AnalysesManagerView_Closing(object? sender, CancelEventArgs e)
{
if (viewModel.FileLogic.CloseFile() == true)
{
e.Cancel = true;
};
}
}
}

View File

@@ -97,12 +97,12 @@ namespace StructureHelper.Windows.ViewModels.Forces
{
if (calc is ForceCalculator forceCalculator)
{
var forceCombinations = forceCalculator.InputData as IHasForceCombinations;
var forceCombinations = forceCalculator.InputData as IHasForceActions;
result = DeleteActionFromHost(result, calc, forceCombinations);
}
else if (calc is CrackCalculator calculator)
{
var forceCombinations = calculator.InputData as IHasForceCombinations;
var forceCombinations = calculator.InputData as IHasForceActions;
result = DeleteActionFromHost(result, calc, forceCombinations);
}
else
@@ -113,7 +113,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
return result;
}
private bool DeleteActionFromHost(bool result, ICalculator item, IHasForceCombinations? forceCombinations)
private bool DeleteActionFromHost(bool result, ICalculator item, IHasForceActions? forceCombinations)
{
var containSelected = forceCombinations.ForceActions.Contains(SelectedItem);
if (containSelected)

View File

@@ -15,6 +15,8 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public T NewItem { get; set; }
public virtual T Convert(V source)
{
try

View File

@@ -3,7 +3,7 @@ using StructureHelperCommon.Models.Forces;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IHasForceCombinations
public interface IHasForceActions
{
/// <summary>
/// Collection of force actions

View File

@@ -8,9 +8,9 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces.Logics
{
public class HasForceCombinationUpdateStrategy : IUpdateStrategy<IHasForceCombinations>
public class HasForceCombinationUpdateStrategy : IUpdateStrategy<IHasForceActions>
{
public void Update(IHasForceCombinations targetObject, IHasForceCombinations sourceObject)
public void Update(IHasForceActions targetObject, IHasForceActions sourceObject)
{
CheckObject.IsNull(targetObject, sourceObject, "Interface IHasForceCombination");
if (ReferenceEquals(targetObject, sourceObject)) { return; }

View File

@@ -12,7 +12,6 @@ namespace StructureHelperCommon.Models.Projects
{
string FullFileName { get; set; }
string FileName { get; }
bool IsNewFile { get; set; }
bool IsActual { get; set; }
List<IVisualAnalysis> VisualAnalyses { get;}
}

View File

@@ -15,7 +15,6 @@ namespace StructureHelperCommon.Models.Projects
public string FullFileName { get; set; } = string.Empty;
public bool IsActual { get; set; } = true;
public List<IVisualAnalysis> VisualAnalyses { get; } = new();
public bool IsNewFile { get; set; } = true;
public string FileName => Path.GetFileName(FullFileName);
public Project(Guid id)

View File

@@ -6,7 +6,7 @@ using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.Models.CrossSections
{
public interface ICrossSectionRepository : ISaveable, IHasHeadMaterials, IHasPrimitives, IHasForceCombinations, IHasCalculators
public interface ICrossSectionRepository : ISaveable, IHasHeadMaterials, IHasPrimitives, IHasForceActions, IHasCalculators
{
}

View File

@@ -44,6 +44,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
}
public ForceCalculator(Guid id) : this()
{
Id = id;
}
public void Run()
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);

View File

@@ -16,11 +16,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public class ForceCalculatorInputDataUpdateStrategy : IUpdateStrategy<IForceCalculatorInputData>
{
private IUpdateStrategy<IHasPrimitives> primitivesUpdateStrategy;
private IUpdateStrategy<IHasForceCombinations> forceCombinationUpdateStrategy;
private IUpdateStrategy<IHasForceActions> forceCombinationUpdateStrategy;
private IUpdateStrategy<IAccuracy> accuracyUpdateStrategy;
private IUpdateStrategy<ICompressedMember> compressedMemberUpdateStrategy;
public ForceCalculatorInputDataUpdateStrategy(IUpdateStrategy<IHasPrimitives> primitivesUpdateStrategy,
IUpdateStrategy<IHasForceCombinations> forceCombinationUpdateStrategy,
IUpdateStrategy<IHasForceActions> forceCombinationUpdateStrategy,
IUpdateStrategy<IAccuracy> accuracyUpdateStrategy,
IUpdateStrategy<ICompressedMember> compressedMemberUpdateStrategy)
{

View File

@@ -7,7 +7,7 @@ using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public interface IForceCalculatorInputData : IInputData, ISaveable, IHasPrimitives, IHasForceCombinations
public interface IForceCalculatorInputData : IInputData, ISaveable, IHasPrimitives, IHasForceActions
{
IAccuracy Accuracy { get; set; }
List<CalcTerms> CalcTermsList { get; }

View File

@@ -51,6 +51,11 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
new ShiftTraceLogger())
{ }
public CrackCalculator(Guid id) : this()
{
Id = id;
}
public object Clone()
{
CrackCalculatorInputData crackInputData = new CrackCalculatorInputData();

View File

@@ -12,13 +12,23 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{
public class CrackCalculatorInputData : ICrackCalculatorInputData
{
public Guid Id { get; } = new();
public Guid Id { get; }
/// <inheritdoc/>
public List<INdmPrimitive> Primitives { get; private set; } = new();
/// <inheritdoc/>
public List<IForceAction> ForceActions { get; private set; } = new();
public IUserCrackInputData UserCrackInputData { get; set; } = GetNewUserData();
public CrackCalculatorInputData(Guid id)
{
Id = id;
}
public CrackCalculatorInputData() : this (Guid.NewGuid())
{
}
private static UserCrackInputData GetNewUserData()
{
return new UserCrackInputData()

View File

@@ -5,7 +5,7 @@ using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
public interface ICrackCalculatorInputData : IInputData, IHasPrimitives, IHasForceCombinations, ISaveable
public interface ICrackCalculatorInputData : IInputData, IHasPrimitives, IHasForceActions, ISaveable
{
List<IForceAction> ForceActions { get; }
List<INdmPrimitive> Primitives { get; }

View File

@@ -5,7 +5,7 @@ using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
public interface IGetTupleInputDatasLogic : ILogic, IHasPrimitives, IHasForceCombinations
public interface IGetTupleInputDatasLogic : ILogic, IHasPrimitives, IHasForceActions
{
LimitStates LimitState { get; set; }
CalcTerms LongTerm { get; set; }

View File

@@ -3,13 +3,34 @@ using StructureHelperCommon.Models.Calculators;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <summary>
/// User settings for crack width calculation
/// </summary>
public interface IUserCrackInputData : IInputData, ISaveable
{
double LengthBetweenCracks { get; set; }
/// <summary>
/// Flag of assigning of length betweenCracks by user or auto
/// </summary>
bool SetLengthBetweenCracks { get; set; }
/// <summary>
/// User value of length between cracks
/// </summary>
double LengthBetweenCracks { get; set; }
/// <summary>
/// Flag of assigning of softening factor by user or auto
/// </summary>
bool SetSofteningFactor { get; set; }
/// <summary>
/// User value of softening factor
/// </summary>
double SofteningFactor { get; set; }
/// <summary>
/// Ultimate value of crack width due to long term loads, m
/// </summary>
double UltimateLongCrackWidth { get; set; }
/// <summary>
/// Ultimate value of crack width due to short term loads, m
/// </summary>
double UltimateShortCrackWidth { get; set; }
}
}

View File

@@ -12,7 +12,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// </summary>
public class UserCrackInputData : IUserCrackInputData
{
public Guid Id { get; } = new();
public Guid Id { get; } = Guid.NewGuid();
/// <summary>
/// Flag of assigning of user value of softening factor
/// </summary>
@@ -38,5 +38,14 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// </summary>
public double UltimateShortCrackWidth { get; set; }
public UserCrackInputData(Guid id)
{
Id = id;
}
public UserCrackInputData() : this (Guid.NewGuid())
{
}
}
}

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
internal class UserCrackInputDataUpdateStrategy : IUpdateStrategy<IUserCrackInputData>
public class UserCrackInputDataUpdateStrategy : IUpdateStrategy<IUserCrackInputData>
{
public void Update(IUserCrackInputData targetObject, IUserCrackInputData sourceObject)
{
@@ -20,6 +20,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
targetObject.SofteningFactor = sourceObject.SofteningFactor;
targetObject.SetLengthBetweenCracks = sourceObject.SetLengthBetweenCracks;
targetObject.LengthBetweenCracks = sourceObject.LengthBetweenCracks;
targetObject.UltimateLongCrackWidth = sourceObject.UltimateLongCrackWidth;
targetObject.UltimateShortCrackWidth = sourceObject.UltimateShortCrackWidth;
}
}
}

View File

@@ -13,7 +13,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
CheckObject.CompareTypes(targetObject, sourceObject);
if (targetObject is PointNdmPrimitive point)
{
new PointPrimitiveUpdateStrategy().Update(point, (PointNdmPrimitive)sourceObject);
new PointNdmPrimitiveUpdateStrategy().Update(point, (PointNdmPrimitive)sourceObject);
}
else if (targetObject is RebarNdmPrimitive rebar)
{

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class PointPrimitiveUpdateStrategy : IUpdateStrategy<IPointNdmPrimitive>
public class PointNdmPrimitiveUpdateStrategy : IUpdateStrategy<IPointNdmPrimitive>
{
static readonly BaseUpdateStrategy basePrimitiveUpdateStrategy = new();
public void Update(IPointNdmPrimitive targetObject, IPointNdmPrimitive sourceObject)

View File

@@ -7,11 +7,11 @@ using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
namespace StructureHelperLogics.Models.Primitives
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class PointNdmPrimitive : IPointNdmPrimitive
{
static readonly PointPrimitiveUpdateStrategy updateStrategy = new();
static readonly PointNdmPrimitiveUpdateStrategy updateStrategy = new();
public Guid Id { get; }
public string? Name { get; set; }
public IPoint2D Center { get; set; }