Add ForceCombinationPropertyUserControl

This commit is contained in:
Evgeny Redikultsev
2025-01-08 21:15:07 +05:00
parent 65253a907b
commit 932f87f566
51 changed files with 1674 additions and 360 deletions

View File

@@ -8,11 +8,11 @@ namespace DataAccess.DTOs.Converters
{
public class ForceActionToDTOConvertStrategy : ConvertStrategy<IForceAction, IForceAction>
{
private IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor> forceCombinationByFactorConvertStrategy;
private IConvertStrategy<ForceCombinationByFactorDTO, IForceFactoredList> forceCombinationByFactorConvertStrategy;
private IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy;
public ForceActionToDTOConvertStrategy(
IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor> forceCombinationByFactorConvertStrategy,
IConvertStrategy<ForceCombinationByFactorDTO, IForceFactoredList> forceCombinationByFactorConvertStrategy,
IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy)
{
this.forceCombinationByFactorConvertStrategy = forceCombinationByFactorConvertStrategy;
@@ -28,7 +28,7 @@ namespace DataAccess.DTOs.Converters
public override IForceAction GetNewItem(IForceAction source)
{
if (source is IForceCombinationByFactor forceCombinationByFactor)
if (source is IForceFactoredList forceCombinationByFactor)
{
return GetForceCombinationByFactor(forceCombinationByFactor);
}
@@ -54,11 +54,11 @@ namespace DataAccess.DTOs.Converters
return forceCombination;
}
private ForceCombinationByFactorDTO GetForceCombinationByFactor(IForceCombinationByFactor forceCombinationByFactor)
private ForceCombinationByFactorDTO GetForceCombinationByFactor(IForceFactoredList forceCombinationByFactor)
{
forceCombinationByFactorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceCombinationByFactorConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor>(this, forceCombinationByFactorConvertStrategy);
var convertLogic = new DictionaryConvertStrategy<ForceCombinationByFactorDTO, IForceFactoredList>(this, forceCombinationByFactorConvertStrategy);
var forceCombination = convertLogic.Convert(forceCombinationByFactor);
return forceCombination;
}

View File

@@ -13,18 +13,22 @@ namespace DataAccess.DTOs
public class ForceActionsFromDTOConvertStrategy : ConvertStrategy<IForceAction, IForceAction>
{
private IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy;
private IConvertStrategy<ForceCombinationByFactor, ForceCombinationByFactorDTO> factorConvertStrategy;
private IConvertStrategy<ForceFactoredList, ForceCombinationByFactorV1_0DTO> factorConvertStrategy_v1_0;
private IConvertStrategy<ForceFactoredList, ForceCombinationByFactorDTO> factorConvertStrategy;
public ForceActionsFromDTOConvertStrategy(
IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy,
IConvertStrategy<ForceCombinationByFactor, ForceCombinationByFactorDTO> factorConvertStrategy)
IConvertStrategy<ForceFactoredList, ForceCombinationByFactorV1_0DTO> factorConvertStrategy_v1_0,
IConvertStrategy<ForceFactoredList, ForceCombinationByFactorDTO> factorConvertStrategy)
{
this.listConvertStrategy = listConvertStrategy;
this.factorConvertStrategy_v1_0 = factorConvertStrategy_v1_0;
this.factorConvertStrategy = factorConvertStrategy;
}
public ForceActionsFromDTOConvertStrategy() : this (
new ForceCombinationListFromDTOConvertStrategy(),
new ForceCombinationByFactorV1_0FromDTOConvertStrategy(),
new ForceCombinationByFactorFromDTOConvertStrategy())
{
@@ -32,6 +36,10 @@ namespace DataAccess.DTOs
public override IForceAction GetNewItem(IForceAction source)
{
if (source is ForceCombinationByFactorV1_0DTO combination_v1_0)
{
return Obsolete_GetForceCombination_V1_0(combination_v1_0);
}
if (source is ForceCombinationByFactorDTO combination)
{
return GetForceCombination(combination);
@@ -45,15 +53,25 @@ namespace DataAccess.DTOs
throw new StructureHelperException(errorString);
}
private ForceFactoredList Obsolete_GetForceCombination_V1_0(ForceCombinationByFactorV1_0DTO source)
{
TraceLogger?.AddMessage("Force action is combination by factors version 1.0 (obsolete)", TraceLogStatuses.Warning);
factorConvertStrategy_v1_0.ReferenceDictionary = ReferenceDictionary;
factorConvertStrategy_v1_0.TraceLogger = TraceLogger;
ForceFactoredList newItem = factorConvertStrategy_v1_0.Convert(source);
return newItem;
}
private IForceAction GetForceCombination(ForceCombinationByFactorDTO source)
{
TraceLogger?.AddMessage("Force action is combination by factors");
factorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
factorConvertStrategy.TraceLogger = TraceLogger;
ForceCombinationByFactor newItem = factorConvertStrategy.Convert(source);
ForceFactoredList newItem = factorConvertStrategy.Convert(source);
return newItem;
}
private IForceAction GetForceList(ForceCombinationListDTO forceList)
{
TraceLogger?.AddMessage("Force action is combination by list");

View File

@@ -1,25 +1,22 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelperCommon.Services;
namespace DataAccess.DTOs
{
public class ForceCombinationByFactorFromDTOConvertStrategy : ConvertStrategy<ForceCombinationByFactor, ForceCombinationByFactorDTO>
public class ForceCombinationByFactorFromDTOConvertStrategy : ConvertStrategy<ForceFactoredList, ForceCombinationByFactorDTO>
{
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
private IUpdateStrategy<IForceCombinationByFactor> updateStrategy;
private IUpdateStrategy<IForceFactoredList> updateStrategy;
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
private IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy;
public ForceCombinationByFactorFromDTOConvertStrategy(
IUpdateStrategy<IForceAction> baseUpdateStrategy,
IUpdateStrategy<IForceCombinationByFactor> updateStrategy,
IUpdateStrategy<IForceFactoredList> updateStrategy,
IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy,
IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy)
{
@@ -31,17 +28,17 @@ namespace DataAccess.DTOs
public ForceCombinationByFactorFromDTOConvertStrategy() : this(
new ForceActionBaseUpdateStrategy(),
new ForceCombinationByFactorUpdateStrategy(),
new ForceFactoredListUpdateStrategy(),
new Point2DFromDTOConvertStrategy(),
new ForceTupleFromDTOConvertStrategy())
{
}
public override ForceCombinationByFactor GetNewItem(ForceCombinationByFactorDTO source)
public override ForceFactoredList GetNewItem(ForceCombinationByFactorDTO source)
{
TraceLogger.AddMessage($"Force combination by factor name = {source.Name} is starting");
ForceCombinationByFactor newItem = new(source.Id);
ForceFactoredList newItem = new(source.Id);
baseUpdateStrategy.Update(newItem, source);
updateStrategy.Update(newItem, source);
pointConvertStrategy.ReferenceDictionary = ReferenceDictionary;
@@ -49,7 +46,13 @@ namespace DataAccess.DTOs
newItem.ForcePoint = pointConvertStrategy.Convert((Point2DDTO)source.ForcePoint);
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceTupleConvertStrategy.TraceLogger = TraceLogger;
newItem.FullSLSForces = forceTupleConvertStrategy.Convert((ForceTupleDTO)source.FullSLSForces);
CheckObject.IsNull(newItem.ForceTuples, nameof(newItem.ForceTuples));
newItem.ForceTuples.Clear();
foreach (var item in source.ForceTuples)
{
var newTuple = forceTupleConvertStrategy.Convert((ForceTupleDTO)item);
newItem.ForceTuples.Add(newTuple);
}
TraceLogger.AddMessage($"Force combination by factor name = {newItem.Name} has been finished");
return newItem;
}

View File

@@ -12,15 +12,15 @@ using System.Threading.Tasks;
namespace DataAccess.DTOs.Converters
{
public class ForceCombinationByFactorToDTOConvertStrategy : IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor>
public class ForceCombinationByFactorToDTOConvertStrategy : IConvertStrategy<ForceCombinationByFactorDTO, IForceFactoredList>
{
private IUpdateStrategy<IForceCombinationByFactor> updateStrategy;
private IUpdateStrategy<IForceFactoredList> updateStrategy;
private IConvertStrategy<Point2DDTO, IPoint2D> pointUpdateStrategy;
private IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy;
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
public ForceCombinationByFactorToDTOConvertStrategy(IUpdateStrategy<IForceCombinationByFactor> updateStrategy,
public ForceCombinationByFactorToDTOConvertStrategy(IUpdateStrategy<IForceFactoredList> updateStrategy,
IConvertStrategy<Point2DDTO, IPoint2D> pointUpdateStrategy,
IConvertStrategy<ForceTupleDTO, IForceTuple> convertStrategy,
IUpdateStrategy<IForceAction> baseUpdateStrategy)
@@ -32,7 +32,7 @@ namespace DataAccess.DTOs.Converters
}
public ForceCombinationByFactorToDTOConvertStrategy() : this (
new ForceCombinationByFactorUpdateStrategy(),
new ForceFactoredListUpdateStrategy(),
new Point2DToDTOConvertStrategy(),
new ForceTupleToDTOConvertStrategy(),
new ForceActionBaseUpdateStrategy())
@@ -43,7 +43,7 @@ namespace DataAccess.DTOs.Converters
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ForceCombinationByFactorDTO Convert(IForceCombinationByFactor source)
public ForceCombinationByFactorDTO Convert(IForceFactoredList source)
{
Check();
try
@@ -61,7 +61,7 @@ namespace DataAccess.DTOs.Converters
}
private ForceCombinationByFactorDTO GetNewForceTuple(IForceCombinationByFactor source)
private ForceCombinationByFactorDTO GetNewForceTuple(IForceFactoredList source)
{
ForceCombinationByFactorDTO newItem = new() { Id = source.Id };
baseUpdateStrategy.Update(newItem, source);
@@ -71,18 +71,23 @@ namespace DataAccess.DTOs.Converters
return newItem;
}
private void GetNewFullSLSForces(IForceCombinationByFactor source, ForceCombinationByFactorDTO newItem)
private void GetNewFullSLSForces(IForceFactoredList source, ForceCombinationByFactorDTO newItem)
{
if (source.FullSLSForces is not null)
if (source.ForceTuples[0] is not null)
{
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceTupleConvertStrategy.TraceLogger = TraceLogger;
var convertForceTupleLogic = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>(this, forceTupleConvertStrategy);
newItem.FullSLSForces = convertForceTupleLogic.Convert(source.FullSLSForces);
newItem.ForceTuples.Clear();
foreach (var item in source.ForceTuples)
{
var forceTuple = convertForceTupleLogic.Convert(item);
newItem.ForceTuples.Add(forceTuple);
}
}
}
private void GetNewForcePoint(IForceCombinationByFactor source, ForceCombinationByFactorDTO newItem)
private void GetNewForcePoint(IForceFactoredList source, ForceCombinationByFactorDTO newItem)
{
if (source.ForcePoint is not null)
{
@@ -95,7 +100,7 @@ namespace DataAccess.DTOs.Converters
private void Check()
{
var checkLogic = new CheckConvertLogic<ForceCombinationByFactorDTO, IForceCombinationByFactor>(this);
var checkLogic = new CheckConvertLogic<ForceCombinationByFactorDTO, IForceFactoredList>(this);
checkLogic.Check();
}
}

View File

@@ -0,0 +1,60 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ForceCombinationByFactorV1_0FromDTOConvertStrategy : ConvertStrategy<ForceFactoredList, ForceCombinationByFactorV1_0DTO>
{
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
private IUpdateStrategy<IForceFactoredList> updateStrategy;
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
private IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy;
public ForceCombinationByFactorV1_0FromDTOConvertStrategy(
IUpdateStrategy<IForceAction> baseUpdateStrategy,
IUpdateStrategy<IForceFactoredList> updateStrategy,
IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy,
IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy)
{
this.baseUpdateStrategy = baseUpdateStrategy;
this.updateStrategy = updateStrategy;
this.pointConvertStrategy = pointConvertStrategy;
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
}
public ForceCombinationByFactorV1_0FromDTOConvertStrategy() : this(
new ForceActionBaseUpdateStrategy(),
new ForceFactoredListUpdateStrategy(),
new Point2DFromDTOConvertStrategy(),
new ForceTupleFromDTOConvertStrategy())
{
}
public override ForceFactoredList GetNewItem(ForceCombinationByFactorV1_0DTO source)
{
TraceLogger.AddMessage($"Force combination by factor name = {source.Name} is starting");
ForceFactoredList newItem = new(source.Id);
baseUpdateStrategy.Update(newItem, source);
updateStrategy.Update(newItem, source);
pointConvertStrategy.ReferenceDictionary = ReferenceDictionary;
pointConvertStrategy.TraceLogger = TraceLogger;
newItem.ForcePoint = pointConvertStrategy.Convert((Point2DDTO)source.ForcePoint);
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceTupleConvertStrategy.TraceLogger = TraceLogger;
var forceTuple = forceTupleConvertStrategy.Convert((ForceTupleDTO)source.ForceTuple);
newItem.ForceTuples[0] = forceTuple;
TraceLogger.AddMessage($"Force combination by factor name = {source.Name} was successfully converted from version 1.0", TraceLogStatuses.Warning);
TraceLogger.AddMessage($"Force combination by factor name = {newItem.Name} has been finished");
return newItem;
}
}
}