Change convert strategies to save xls imported forces

This commit is contained in:
Evgeny Redikultsev
2025-01-20 16:19:14 +05:00
parent f508399846
commit 50b173c805
80 changed files with 1684 additions and 617 deletions

View File

@@ -0,0 +1,25 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
namespace DataAccess.DTOs
{
public class AccuracyFromDTOConvertStrategy : ConvertStrategy<Accuracy, AccuracyDTO>
{
private IUpdateStrategy<IAccuracy> updateStrategy;
public override Accuracy GetNewItem(AccuracyDTO source)
{
updateStrategy ??= new AccuracyUpdateStrategy();
try
{
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
}
}

View File

@@ -0,0 +1,25 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
namespace DataAccess.DTOs
{
public class AccuracyToDTOConvertStrategy : ConvertStrategy<AccuracyDTO, IAccuracy>
{
private IUpdateStrategy<IAccuracy> updateStrategy;
public override AccuracyDTO GetNewItem(IAccuracy source)
{
updateStrategy ??= new AccuracyUpdateStrategy();
try
{
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
}
}

View File

@@ -61,6 +61,10 @@ namespace DataAccess.DTOs
{
return ProcessCrackCalculator(crackCalculator);
}
if (source is LimitCurvesCalculator limitCalculator)
{
TraceLogger?.AddMessage($"Current version of StructureHelper does not suppurt saving interaction diagram calculator, {limitCalculator.Name} was ignored");
}
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);

View File

@@ -0,0 +1,25 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ColumnFilePropertyFromDTOConvertStrategy : ConvertStrategy<ColumnFileProperty, ColumnFilePropertyDTO>
{
private IUpdateStrategy<IColumnFileProperty> updateStrategy;
public override ColumnFileProperty GetNewItem(ColumnFilePropertyDTO source)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
updateStrategy ??= new ColumnFilePropertyUpdateStrategy();
ColumnFileProperty newItem = new(source.Id, source.Name);
updateStrategy.Update(newItem, source);
return newItem;
}
}
}

View File

@@ -0,0 +1,30 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
namespace DataAccess.DTOs
{
public class ColumnFilePropertyToDTOConvertStrategy : ConvertStrategy<ColumnFilePropertyDTO, IColumnFileProperty>
{
private IUpdateStrategy<IColumnFileProperty> updateStrategy;
public ColumnFilePropertyToDTOConvertStrategy(IUpdateStrategy<IColumnFileProperty> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public ColumnFilePropertyToDTOConvertStrategy()
{
}
public override ColumnFilePropertyDTO GetNewItem(IColumnFileProperty source)
{
TraceLogger?.AddMessage($"Column file property Id={source.Id} converting to {typeof(ColumnFilePropertyDTO)} has been started");
updateStrategy ??= new ColumnFilePropertyUpdateStrategy();
ColumnFilePropertyDTO newItem = new(source.Id);
updateStrategy.Update(newItem, source);
TraceLogger?.AddMessage($"Column file property Id={source.Id} converting to {typeof(ColumnFilePropertyDTO)} has been finished");
return newItem;
}
}
}

View File

@@ -0,0 +1,58 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
namespace DataAccess.DTOs
{
public class ColumnedFilePropertyFromDTOConvertStrategy : ConvertStrategy<ColumnedFileProperty, ColumnedFilePropertyDTO>
{
private IUpdateStrategy<IColumnedFileProperty>? updateStrategy;
private IConvertStrategy<ColumnFileProperty, ColumnFilePropertyDTO>? columnConvertStrategy;
public override ColumnedFileProperty GetNewItem(ColumnedFilePropertyDTO source)
{
TraceLogger?.AddMessage($"Converting of columned file property Path={source.FilePath} has been started");
InitializeStrategies();
try
{
ColumnedFileProperty newItem = GetFilePropertyBySource(source);
TraceLogger?.AddMessage($"Converting of columned file property Path={newItem.FilePath} has been finished successfully");
return newItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(this)} made error: {ex.Message}", TraceLogStatuses.Error);
throw;
}
}
private ColumnedFileProperty GetFilePropertyBySource(ColumnedFilePropertyDTO source)
{
ColumnedFileProperty newItem = new(source.Id);
updateStrategy?.Update(newItem, source);
newItem.ColumnProperties.Clear();
foreach (var item in source.ColumnProperties)
{
if (item is ColumnFilePropertyDTO columnPropertyDTO)
{
ColumnFileProperty columnFileProperty = columnConvertStrategy.Convert(columnPropertyDTO);
newItem.ColumnProperties.Add(columnFileProperty);
}
else
{
string errorString = ErrorStrings.ExpectedWas(typeof(ColumnFilePropertyDTO), item);
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
}
return newItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new ColumnedFilePropertyUpdateStrategy();
columnConvertStrategy ??= new ColumnFilePropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
}
}
}

View File

@@ -0,0 +1,52 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
namespace DataAccess.DTOs
{
/// <inheritdoc/>
public class ColumnedFilePropertyToDTOConvertStrategy : ConvertStrategy<ColumnedFilePropertyDTO, IColumnedFileProperty>
{
private IUpdateStrategy<IColumnedFileProperty>? updateStrategy;
private IConvertStrategy<ColumnFilePropertyDTO, IColumnFileProperty>? columnConvertStrategy;
public override ColumnedFilePropertyDTO GetNewItem(IColumnedFileProperty source)
{
TraceLogger?.AddMessage($"Columned file property Id = {source.Id}, Path = {source.FilePath} converting has been started");
InitializeStrategies();
try
{
ColumnedFilePropertyDTO newItem = GetNewItemBySource(source);
TraceLogger?.AddMessage($"Columned file property Id={newItem.Id}, Path = {newItem.FilePath} converting has been finished successfully");
return newItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(this)} made error: {ex.Message}", TraceLogStatuses.Error);
throw;
}
}
private ColumnedFilePropertyDTO GetNewItemBySource(IColumnedFileProperty source)
{
ColumnedFilePropertyDTO newItem = new(source.Id);
updateStrategy?.Update(newItem, source);
newItem.ColumnProperties.Clear();
foreach (var item in source.ColumnProperties)
{
ColumnFilePropertyDTO columnFilePropertyDTO = columnConvertStrategy.Convert(item);
newItem.ColumnProperties.Add(columnFilePropertyDTO);
}
return newItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new ColumnedFilePropertyUpdateStrategy();
columnConvertStrategy ??= new ColumnFilePropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public enum ConvertDirection
{
FromDTO,
ToDTO
}
}

View File

@@ -12,35 +12,50 @@ 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();
private IUpdateStrategy<IUserCrackInputData> userDataUpdateStrategy;
private IHasPrimitivesProcessLogic primitivesProcessLogic;
private IHasForceActionsProcessLogic actionsProcessLogic;
private IConvertStrategy<UserCrackInputData, UserCrackInputDataDTO> userDataConvertStrategy;
public override CrackCalculatorInputData GetNewItem(CrackCalculatorInputDataDTO source)
{
InitializeStrategies();
try
{
GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewItemBySource(CrackCalculatorInputDataDTO source)
{
NewItem = new(source.Id);
ProcessPrimitives(source);
ProcessActions(source);
NewItem.UserCrackInputData = new UserCrackInputData(source.UserCrackInputData.Id);
userDataUpdateStrategy.Update(NewItem.UserCrackInputData, source.UserCrackInputData);
return NewItem;
}
private void InitializeStrategies()
{
userDataUpdateStrategy ??= new UserCrackInputDataUpdateStrategy();
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
userDataConvertStrategy ??= new UserCrackInputDataFromDTOConvertStrategy(ReferenceDictionary, TraceLogger);
}
private void ProcessPrimitives(IHasPrimitives source)
{
primitivesProcessLogic.Source = source;
primitivesProcessLogic.Target = NewItem;
primitivesProcessLogic.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

@@ -0,0 +1,64 @@
using DataAccess.DTOs.Converters;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class CrackCalculatorInputDataToDTOConvertStrategy : ConvertStrategy<CrackCalculatorInputDataDTO, ICrackCalculatorInputData>
{
private IUpdateStrategy<IUserCrackInputData> userDataUpdateStrategy;
private IHasPrimitivesProcessLogic primitivesProcessLogic;
private IHasForceActionsProcessLogic actionsProcessLogic;
private IConvertStrategy<UserCrackInputDataDTO, IUserCrackInputData> userDataConvertStrategy;
public override CrackCalculatorInputDataDTO GetNewItem(ICrackCalculatorInputData source)
{
InitializeStrategies();
try
{
GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewItemBySource(ICrackCalculatorInputData source)
{
NewItem = new(source.Id);
ProcessPrimitives(source);
ProcessActions(source);
NewItem.UserCrackInputData = userDataConvertStrategy.Convert(source.UserCrackInputData);
userDataUpdateStrategy.Update(NewItem.UserCrackInputData, source.UserCrackInputData);
}
private void InitializeStrategies()
{
userDataUpdateStrategy ??= new UserCrackInputDataUpdateStrategy();
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
userDataConvertStrategy ??= new UserCrackInputDataToDTOConvertStrategy(ReferenceDictionary, TraceLogger);
}
private void ProcessPrimitives(IHasPrimitives source)
{
primitivesProcessLogic.Source = source;
primitivesProcessLogic.Target = NewItem;
primitivesProcessLogic.Process();
}
private void ProcessActions(IHasForceActions source)
{
actionsProcessLogic.Source = source;
actionsProcessLogic.Target = NewItem;
actionsProcessLogic.Process();
}
}
}

View File

@@ -1,85 +1,51 @@
using DataAccess.DTOs.Converters;
using DataAccess.DTOs.DTOEntities;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class CrackCalculatorToDTOConvertStrategy : IConvertStrategy<CrackCalculatorDTO, ICrackCalculator>
public class CrackCalculatorToDTOConvertStrategy : ConvertStrategy<CrackCalculatorDTO, ICrackCalculator>
{
private readonly IUpdateStrategy<ICrackCalculator> updateStrategy;
private IUpdateStrategy<ICrackCalculator> updateStrategy;
private IConvertStrategy<CrackCalculatorInputDataDTO, ICrackCalculatorInputData> inputDataConvertStrategy;
public CrackCalculatorToDTOConvertStrategy(IUpdateStrategy<ICrackCalculator> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public CrackCalculatorToDTOConvertStrategy() : this (new CrackCalculatorUpdateStrategy())
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public CrackCalculatorDTO Convert(ICrackCalculator source)
public CrackCalculatorToDTOConvertStrategy() { }
public override CrackCalculatorDTO GetNewItem(ICrackCalculator source)
{
InitializeStrategies();
try
{
Check();
return GetNewItem(source);
GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private CrackCalculatorDTO GetNewItem(ICrackCalculator source)
private void InitializeStrategies()
{
CrackCalculatorDTO newItem = new() { Id = source.Id};
updateStrategy.Update(newItem, source);
ProcessForceActions(newItem.InputData, source.InputData);
ProcessPrimitives(newItem.InputData, source.InputData);
return newItem;
updateStrategy ??= new CrackCalculatorUpdateStrategy();
inputDataConvertStrategy ??= new CrackCalculatorInputDataToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
}
private void ProcessPrimitives(IHasPrimitives target, IHasPrimitives source)
private void GetNewItemBySource(ICrackCalculator source)
{
HasPrimitivesToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.InputData = inputDataConvertStrategy.Convert(source.InputData);
}
private void ProcessForceActions(IHasForceActions target, IHasForceActions source)
{
HasForceActionToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private void Check()
{
var checkLogic = new CheckConvertLogic<CrackCalculatorDTO, ICrackCalculator>(this);
checkLogic.Check();
}
}
}

View File

@@ -23,8 +23,8 @@ namespace DataAccess.DTOs
private const string convertFinished = " converting has been finished successfully";
private CrossSectionRepository newRepository;
private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic();
private IHasForceActionsProcessLogic actionsProcessLogic = new HasForceActionsProcessLogic();
private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic(ConvertDirection.FromDTO);
private IHasForceActionsProcessLogic actionsProcessLogic = new HasForceActionsProcessLogic(ConvertDirection.FromDTO);
public override CrossSectionRepository GetNewItem(ICrossSectionRepository source)
{

View File

@@ -1,23 +1,11 @@
using DataAccess.DTOs.Converters;
using NLog.Targets;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
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
{
@@ -58,8 +46,6 @@ namespace DataAccess.DTOs
private CrossSectionRepositoryDTO GetNewRepository(ICrossSectionRepository source)
{
var project = ProgramSetting.CurrentProject;
CrossSectionRepositoryDTO newItem = new()
{
Id = source.Id

View File

@@ -1,11 +1,8 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelperCommon.Models.Loggers;
namespace DataAccess.DTOs
{
@@ -31,14 +28,28 @@ namespace DataAccess.DTOs
public override DesignForceTuple GetNewItem(DesignForceTupleDTO source)
{
TraceLogger?.AddMessage("Design force tuple converting is started");
TraceLogger?.AddMessage("Design force tuple converting has been started");
try
{
DesignForceTuple newItem = GetNewItemBySource(source);
TraceLogger?.AddMessage("Design force tuple converting has been finished");
return newItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private DesignForceTuple GetNewItemBySource(DesignForceTupleDTO source)
{
DesignForceTuple newItem = new(source.Id);
updateStrategy.Update(newItem, source);
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceTupleConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ForceTuple, ForceTupleDTO>(this, forceTupleConvertStrategy);
newItem.ForceTuple = convertLogic.Convert((ForceTupleDTO)source.ForceTuple);
TraceLogger?.AddMessage("Design force tuple converting has been finished");
return newItem;
}
}

View File

@@ -10,7 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.Converters
namespace DataAccess.DTOs
{
public class DesignForceTupleToDTOConvertStrategy : IConvertStrategy<DesignForceTupleDTO, IDesignForceTuple>
{

View File

@@ -0,0 +1,24 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics;
namespace DataAccess.DTOs
{
public class FactoredCombinationPropertyFromDTOConvertStrategy : ConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO>
{
private IUpdateStrategy<IFactoredCombinationProperty> updateStrategy;
public override FactoredCombinationProperty GetNewItem(FactoredCombinationPropertyDTO source)
{
InitializeStrategies();
TraceLogger.AddMessage($"Force factored combination property Id={source.Id} converting has been started");
FactoredCombinationProperty newItem = new(source.Id);
updateStrategy.Update(newItem, source);
TraceLogger.AddMessage($"Force factored combination property Id={newItem.Id} converting has been finished");
return newItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new FactoredCombinationPropertyUpdateStrategy();
}
}
}

View File

@@ -0,0 +1,40 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class FactoredCombinationPropertyToDTOConvertStrategy : ConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty>
{
private IUpdateStrategy<IFactoredCombinationProperty> updateStrategy;
public FactoredCombinationPropertyToDTOConvertStrategy(IUpdateStrategy<IFactoredCombinationProperty> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public FactoredCombinationPropertyToDTOConvertStrategy()
{
}
public override FactoredCombinationPropertyDTO GetNewItem(IFactoredCombinationProperty source)
{
InitializeStrategies();
TraceLogger.AddMessage($"Force factored combination property Id={source.Id} converting has been started");
FactoredCombinationPropertyDTO newItem = new(source.Id);
updateStrategy.Update(newItem, source);
TraceLogger.AddMessage($"Force factored combination property Id={newItem.Id} converting has been finished");
return newItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new FactoredCombinationPropertyUpdateStrategy();
}
}
}

View File

@@ -0,0 +1,103 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
namespace DataAccess.DTOs
{
public class ForceActionFromDTOConvertStrategy : ConvertStrategy<IForceAction, IForceAction>
{
private IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy;
private IConvertStrategy<ForceFactoredList, ForceCombinationByFactorV1_0DTO> factorConvertStrategy_v1_0;
private IConvertStrategy<ForceFactoredList, ForceFactoredListDTO> factorConvertStrategy;
private IConvertStrategy<ForceCombinationFromFile, ForceCombinationFromFileDTO> fileConvertStrategy;
public ForceActionFromDTOConvertStrategy(
IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy,
IConvertStrategy<ForceFactoredList, ForceCombinationByFactorV1_0DTO> factorConvertStrategy_v1_0,
IConvertStrategy<ForceFactoredList, ForceFactoredListDTO> factorConvertStrategy,
IConvertStrategy<ForceCombinationFromFile, ForceCombinationFromFileDTO> fileConvertStrategy)
{
this.listConvertStrategy = listConvertStrategy;
this.factorConvertStrategy_v1_0 = factorConvertStrategy_v1_0;
this.factorConvertStrategy = factorConvertStrategy;
this.fileConvertStrategy = fileConvertStrategy;
}
public ForceActionFromDTOConvertStrategy() { }
public override IForceAction GetNewItem(IForceAction source)
{
InitializeStrategies();
try
{
NewItem = GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void InitializeStrategies()
{
listConvertStrategy ??= new ForceCombinationListFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
factorConvertStrategy ??= new ForceFactoredListFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
fileConvertStrategy ??= new ForceCombinationFromFileFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
}
private IForceAction GetNewItemBySource(IForceAction source)
{
if (source is ForceFactoredListDTO combination)
{
return GetFactoredCombination(combination);
}
if (source is ForceCombinationListDTO forceList)
{
return GetForceList(forceList);
}
if (source is ForceCombinationFromFileDTO fileCombination)
{
return GetFileCombination(fileCombination);
}
if (source is ForceCombinationByFactorV1_0DTO combination_v1_0)
{
return Obsolete_GetForceCombination_V1_0(combination_v1_0);
}
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
private ForceCombinationFromFile GetFileCombination(ForceCombinationFromFileDTO source)
{
TraceLogger?.AddMessage("Force action is combination by factors");
ForceCombinationFromFile newItem = fileConvertStrategy.Convert(source);
return newItem;
}
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 ??= new ForceCombinationByFactorV1_0FromDTOConvertStrategy()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
ForceFactoredList newItem = factorConvertStrategy_v1_0.Convert(source);
return newItem;
}
private IForceAction GetFactoredCombination(ForceFactoredListDTO source)
{
TraceLogger?.AddMessage("Force action is combination by factors");
ForceFactoredList newItem = factorConvertStrategy.Convert(source);
return newItem;
}
private IForceAction GetForceList(ForceCombinationListDTO forceList)
{
TraceLogger?.AddMessage("Force action is combination by list");
ForceCombinationList newItem = listConvertStrategy.Convert(forceList);
return newItem;
}
}
}

View File

@@ -4,61 +4,75 @@ using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
namespace DataAccess.DTOs.Converters
namespace DataAccess.DTOs
{
public class ForceActionToDTOConvertStrategy : ConvertStrategy<IForceAction, IForceAction>
{
private IConvertStrategy<ForceCombinationByFactorDTO, IForceFactoredList> forceCombinationByFactorConvertStrategy;
private IConvertStrategy<ForceFactoredListDTO, IForceFactoredList> forceFactoredListConvertStrategy;
private IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy;
private IConvertStrategy<ForceCombinationFromFileDTO, IForceCombinationFromFile> forceCombinationFromFileConvertStrategy;
public ForceActionToDTOConvertStrategy(
IConvertStrategy<ForceCombinationByFactorDTO, IForceFactoredList> forceCombinationByFactorConvertStrategy,
IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy)
IConvertStrategy<ForceFactoredListDTO, IForceFactoredList> forceFactoredListConvertStrategy,
IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy,
IConvertStrategy<ForceCombinationFromFileDTO, IForceCombinationFromFile> forceCombinationFromFileConvertStrategy)
{
this.forceCombinationByFactorConvertStrategy = forceCombinationByFactorConvertStrategy;
this.forceFactoredListConvertStrategy = forceFactoredListConvertStrategy;
this.forceCombinationListConvertStrategy = forceCombinationListConvertStrategy;
this.forceCombinationFromFileConvertStrategy = forceCombinationFromFileConvertStrategy;
}
public ForceActionToDTOConvertStrategy() : this(
new ForceCombinationByFactorToDTOConvertStrategy(),
new ForceCombinationListToDTOConvertStrategy())
{
}
public ForceActionToDTOConvertStrategy() { }
public override IForceAction GetNewItem(IForceAction source)
{
if (source is IForceFactoredList forceCombinationByFactor)
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Force action converting has been started");
InitializeStrategies();
if (source is IForceFactoredList forceFactoredList)
{
return GetForceCombinationByFactor(forceCombinationByFactor);
return GetForceCombinationByFactor(forceFactoredList);
}
else if (source is IForceCombinationList forceCombinationList)
{
return GetForceCombinationList(forceCombinationList);
}
else if (source is IForceCombinationFromFile forceCombinationFile)
{
return GetForceCombinationFile(forceCombinationFile);
}
else
{
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
}
private IForceAction GetForceCombinationFile(IForceCombinationFromFile forceCombinationFile)
{
var convertLogic = new DictionaryConvertStrategy<ForceCombinationFromFileDTO, IForceCombinationFromFile>(this, forceCombinationFromFileConvertStrategy);
var forceCombination = convertLogic.Convert(forceCombinationFile);
return forceCombination;
}
private void InitializeStrategies()
{
forceFactoredListConvertStrategy ??= new ForceFactoredListToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
forceCombinationListConvertStrategy ??= new ForceCombinationListToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; ;
forceCombinationFromFileConvertStrategy ??= new ForceCombinaionFromFileToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger }; ;
}
private ForceCombinationListDTO GetForceCombinationList(IForceCombinationList forceCombinationList)
{
forceCombinationListConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceCombinationListConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ForceCombinationListDTO, IForceCombinationList>(this, forceCombinationListConvertStrategy);
var forceCombination = convertLogic.Convert(forceCombinationList);
return forceCombination;
}
private ForceCombinationByFactorDTO GetForceCombinationByFactor(IForceFactoredList forceCombinationByFactor)
private ForceFactoredListDTO GetForceCombinationByFactor(IForceFactoredList forceCombinationByFactor)
{
forceCombinationByFactorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceCombinationByFactorConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ForceCombinationByFactorDTO, IForceFactoredList>(this, forceCombinationByFactorConvertStrategy);
var convertLogic = new DictionaryConvertStrategy<ForceFactoredListDTO, IForceFactoredList>(this, forceFactoredListConvertStrategy);
var forceCombination = convertLogic.Convert(forceCombinationByFactor);
return forceCombination;
}

View File

@@ -1,84 +0,0 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ForceActionsFromDTOConvertStrategy : ConvertStrategy<IForceAction, IForceAction>
{
private IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy;
private IConvertStrategy<ForceFactoredList, ForceCombinationByFactorV1_0DTO> factorConvertStrategy_v1_0;
private IConvertStrategy<ForceFactoredList, ForceCombinationByFactorDTO> factorConvertStrategy;
public ForceActionsFromDTOConvertStrategy(
IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy,
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())
{
}
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);
}
if (source is ForceCombinationListDTO forceList)
{
return GetForceList(forceList);
}
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
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;
ForceFactoredList newItem = factorConvertStrategy.Convert(source);
return newItem;
}
private IForceAction GetForceList(ForceCombinationListDTO forceList)
{
TraceLogger?.AddMessage("Force action is combination by list");
listConvertStrategy.ReferenceDictionary = ReferenceDictionary;
listConvertStrategy.TraceLogger = TraceLogger;
ForceCombinationList newItem = listConvertStrategy.Convert(forceList);
return newItem;
}
}
}

View File

@@ -1,25 +1,37 @@
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();
private IConvertStrategy<ForceCalculatorInputData, ForceCalculatorInputDataDTO> inputDataConvertStrategy;
public override ForceCalculator GetNewItem(ForceCalculatorDTO source)
{
InitializeStrategies();
try
{
GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void InitializeStrategies()
{
inputDataConvertStrategy ??= new ForceCalculatorInputDataFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
}
private void GetNewItemBySource(ForceCalculatorDTO source)
{
NewItem = new(source.Id);
NewItem.Name = source.Name;
inputDataConvertStrategy.ReferenceDictionary = ReferenceDictionary;
inputDataConvertStrategy.TraceLogger = TraceLogger;
NewItem.InputData = inputDataConvertStrategy.Convert(source.InputData as ForceCalculatorInputDataDTO);
return NewItem;
}
}
}

View File

@@ -1,28 +1,40 @@
using DataAccess.DTOs.Converters;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ForceCalculatorInputDataFromDTOConvertStrategy : ConvertStrategy<ForceCalculatorInputData, ForceCalculatorInputDataDTO>
{
private IUpdateStrategy<IForceCalculatorInputData> updateStrategy = new ForceCalculatorInputDataUpdateStrategy();
private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic();
private IHasForceActionsProcessLogic actionsProcessLogic = new HasForceActionsProcessLogic();
private IUpdateStrategy<IForceCalculatorInputData> updateStrategy;
private IHasPrimitivesProcessLogic primitivesProcessLogic;
private IHasForceActionsProcessLogic actionsProcessLogic;
private IConvertStrategy<Accuracy, AccuracyDTO> accuracyConvertStrategy;
public override ForceCalculatorInputData GetNewItem(ForceCalculatorInputDataDTO source)
{
InitializeStrategies();
try
{
GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewItemBySource(ForceCalculatorInputDataDTO source)
{
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.Accuracy = accuracyConvertStrategy.Convert((AccuracyDTO)source.Accuracy);
ProcessPrimitives(source);
ProcessActions(source);
return NewItem;
}
private void ProcessPrimitives(IHasPrimitives source)
@@ -33,7 +45,6 @@ namespace DataAccess.DTOs
primitivesProcessLogic.TraceLogger = TraceLogger;
primitivesProcessLogic.Process();
}
private void ProcessActions(IHasForceActions source)
{
actionsProcessLogic.Source = source;
@@ -42,5 +53,12 @@ namespace DataAccess.DTOs
actionsProcessLogic.TraceLogger = TraceLogger;
actionsProcessLogic.Process();
}
private void InitializeStrategies()
{
updateStrategy ??= new ForceCalculatorInputDataUpdateStrategy();
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.FromDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
accuracyConvertStrategy ??= new AccuracyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
}
}
}

View File

@@ -0,0 +1,69 @@
using DataAccess.DTOs.Converters;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ForceCalculatorInputDataToDTOConvertStrategy : ConvertStrategy<ForceCalculatorInputDataDTO, IForceCalculatorInputData>
{
private IUpdateStrategy<IForceCalculatorInputData> updateStrategy;
private IHasPrimitivesProcessLogic primitivesProcessLogic;
private IHasForceActionsProcessLogic actionsProcessLogic;
private IConvertStrategy<AccuracyDTO, IAccuracy> accuracyConvertStrategy;
public override ForceCalculatorInputDataDTO GetNewItem(IForceCalculatorInputData source)
{
InitializeStrategies();
try
{
GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewItemBySource(IForceCalculatorInputData source)
{
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
NewItem.Accuracy = accuracyConvertStrategy.Convert(source.Accuracy);
ProcessPrimitives(source);
ProcessActions(source);
}
private void ProcessPrimitives(IHasPrimitives source)
{
primitivesProcessLogic.Source = source;
primitivesProcessLogic.Target = NewItem;
primitivesProcessLogic.ReferenceDictionary = ReferenceDictionary;
primitivesProcessLogic.TraceLogger = TraceLogger;
primitivesProcessLogic.Process();
}
private void ProcessActions(IHasForceActions source)
{
actionsProcessLogic.Source = source;
actionsProcessLogic.Target = NewItem;
actionsProcessLogic.ReferenceDictionary = ReferenceDictionary;
actionsProcessLogic.TraceLogger = TraceLogger;
actionsProcessLogic.Process();
}
private void InitializeStrategies()
{
updateStrategy ??= new ForceCalculatorInputDataUpdateStrategy();
primitivesProcessLogic ??= new HasPrimitivesProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
actionsProcessLogic ??= new HasForceActionsProcessLogic(ConvertDirection.ToDTO) { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
accuracyConvertStrategy ??= new AccuracyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
}
}
}

View File

@@ -14,73 +14,37 @@ using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ForceCalculatorToDTOConvertStrategy : IConvertStrategy<ForceCalculatorDTO, IForceCalculator>
public class ForceCalculatorToDTOConvertStrategy : ConvertStrategy<ForceCalculatorDTO, IForceCalculator>
{
private readonly IUpdateStrategy<IForceCalculator> updateStrategy;
private IUpdateStrategy<IForceCalculator> updateStrategy;
private IConvertStrategy<ForceCalculatorInputDataDTO, IForceCalculatorInputData> inputDataConvertStrategy;
public ForceCalculatorToDTOConvertStrategy(IUpdateStrategy<IForceCalculator> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public ForceCalculatorToDTOConvertStrategy() : this (
new ForceCalculatorUpdateStrategy()
)
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ForceCalculatorDTO Convert(IForceCalculator source)
public override ForceCalculatorDTO GetNewItem(IForceCalculator source)
{
InitializeStrategies();
try
{
Check();
return GetNewItem(source);
GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private ForceCalculatorDTO GetNewItem(IForceCalculator source)
private void InitializeStrategies()
{
ForceCalculatorDTO newItem = new() { Id = source.Id};
updateStrategy.Update(newItem, source);
ProcessForceActions(newItem.InputData, source.InputData);
ProcessPrimitives(newItem.InputData, source.InputData);
return newItem;
updateStrategy ??= new ForceCalculatorUpdateStrategy();
inputDataConvertStrategy ??= new ForceCalculatorInputDataToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
}
private void ProcessPrimitives(IHasPrimitives target, IHasPrimitives source)
private void GetNewItemBySource(IForceCalculator source)
{
HasPrimitivesToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private void ProcessForceActions(IHasForceActions target, IHasForceActions source)
{
HasForceActionToDTOUpdateStrategy updateStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
updateStrategy.Update(target, source);
}
private void Check()
{
var checkLogic = new CheckConvertLogic<ForceCalculatorDTO, IForceCalculator>(this);
checkLogic.Check();
NewItem = new() { Id = source.Id};
updateStrategy.Update(NewItem, source);
NewItem.InputData = inputDataConvertStrategy.Convert(source.InputData);
}
}
}

View File

@@ -0,0 +1,76 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
namespace DataAccess.DTOs
{
public class ForceCombinaionFromFileToDTOConvertStrategy : ConvertStrategy<ForceCombinationFromFileDTO, IForceCombinationFromFile>
{
private IUpdateStrategy<IForceCombinationFromFile> updateStrategy;
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
private IConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty> combinationPropertyConvertStrategy;
private IConvertStrategy<ColumnedFilePropertyDTO, IColumnedFileProperty> filePropertyConvertStrategy;
public override ForceCombinationFromFileDTO GetNewItem(IForceCombinationFromFile source)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger.AddMessage($"Force combination from file, name = {source.Name} converting has been started");
InitializeStrategies();
ForceCombinationFromFileDTO newItem = new(source.Id);
updateStrategy.Update(newItem, source);
newItem.ForceFiles.Clear();
foreach (var item in source.ForceFiles)
{
ColumnedFilePropertyDTO columnedFilePropertyDTO = filePropertyConvertStrategy.Convert(item);
newItem.ForceFiles.Add(columnedFilePropertyDTO);
}
SetPoint(source, newItem);
SetCombinationProperty(source, newItem);
TraceLogger.AddMessage($"Force combination from file, name = {source.Name} converting has been finished successfully");
return newItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new ForceCombinationFromFileUpdateStrategy();
pointConvertStrategy ??= new Point2DToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
filePropertyConvertStrategy ??= new ColumnedFilePropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
}
private void SetPoint(IForceCombinationFromFile source, ForceCombinationFromFileDTO newItem)
{
if (source.ForcePoint is not null)
{
var convertLogic = new DictionaryConvertStrategy<Point2DDTO, IPoint2D>(this, pointConvertStrategy);
newItem.ForcePoint = convertLogic.Convert(source.ForcePoint);
}
else
{
string errorMessage = ErrorStrings.NullReference + $"File combination {source.Name} Id={source.Id} does not have force point";
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
private void SetCombinationProperty(IForceCombinationFromFile source, ForceCombinationFromFileDTO newItem)
{
if (source.CombinationProperty is not null)
{
var convertLogic = new DictionaryConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty>(this, combinationPropertyConvertStrategy);
newItem.CombinationProperty = convertLogic.Convert(source.CombinationProperty);
}
else
{
string errorMessage = ErrorStrings.NullReference + $"Factored combination {source.Name} Id={source.Id} does not have combination properties";
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
}
}

View File

@@ -1,60 +0,0 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services;
namespace DataAccess.DTOs
{
public class ForceCombinationByFactorFromDTOConvertStrategy : ConvertStrategy<ForceFactoredList, ForceCombinationByFactorDTO>
{
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
private IUpdateStrategy<IForceFactoredList> updateStrategy;
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
private IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy;
public ForceCombinationByFactorFromDTOConvertStrategy(
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 ForceCombinationByFactorFromDTOConvertStrategy() : this(
new ForceActionBaseUpdateStrategy(),
new ForceFactoredListUpdateStrategy(),
new Point2DFromDTOConvertStrategy(),
new ForceTupleFromDTOConvertStrategy())
{
}
public override ForceFactoredList GetNewItem(ForceCombinationByFactorDTO 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;
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

@@ -1,107 +0,0 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.Converters
{
public class ForceCombinationByFactorToDTOConvertStrategy : IConvertStrategy<ForceCombinationByFactorDTO, IForceFactoredList>
{
private IUpdateStrategy<IForceFactoredList> updateStrategy;
private IConvertStrategy<Point2DDTO, IPoint2D> pointUpdateStrategy;
private IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy;
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
public ForceCombinationByFactorToDTOConvertStrategy(IUpdateStrategy<IForceFactoredList> updateStrategy,
IConvertStrategy<Point2DDTO, IPoint2D> pointUpdateStrategy,
IConvertStrategy<ForceTupleDTO, IForceTuple> convertStrategy,
IUpdateStrategy<IForceAction> baseUpdateStrategy)
{
this.baseUpdateStrategy = baseUpdateStrategy;
this.updateStrategy = updateStrategy;
this.forceTupleConvertStrategy = convertStrategy;
this.pointUpdateStrategy = pointUpdateStrategy;
}
public ForceCombinationByFactorToDTOConvertStrategy() : this (
new ForceFactoredListUpdateStrategy(),
new Point2DToDTOConvertStrategy(),
new ForceTupleToDTOConvertStrategy(),
new ForceActionBaseUpdateStrategy())
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ForceCombinationByFactorDTO Convert(IForceFactoredList source)
{
Check();
try
{
ForceCombinationByFactorDTO newItem = GetNewForceTuple(source);
TraceLogger.AddMessage($"Force combination by factor, name = {newItem.Name} was converted", TraceLogStatuses.Debug);
return newItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private ForceCombinationByFactorDTO GetNewForceTuple(IForceFactoredList source)
{
ForceCombinationByFactorDTO newItem = new() { Id = source.Id };
baseUpdateStrategy.Update(newItem, source);
updateStrategy.Update(newItem, source);
GetNewForcePoint(source, newItem);
GetNewFullSLSForces(source, newItem);
return newItem;
}
private void GetNewFullSLSForces(IForceFactoredList source, ForceCombinationByFactorDTO newItem)
{
if (source.ForceTuples[0] is not null)
{
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
forceTupleConvertStrategy.TraceLogger = TraceLogger;
var convertForceTupleLogic = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>(this, forceTupleConvertStrategy);
newItem.ForceTuples.Clear();
foreach (var item in source.ForceTuples)
{
var forceTuple = convertForceTupleLogic.Convert(item);
newItem.ForceTuples.Add(forceTuple);
}
}
}
private void GetNewForcePoint(IForceFactoredList source, ForceCombinationByFactorDTO newItem)
{
if (source.ForcePoint is not null)
{
pointUpdateStrategy.ReferenceDictionary = ReferenceDictionary;
pointUpdateStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<Point2DDTO, IPoint2D>(this, pointUpdateStrategy);
newItem.ForcePoint = convertLogic.Convert(source.ForcePoint);
}
}
private void Check()
{
var checkLogic = new CheckConvertLogic<ForceCombinationByFactorDTO, IForceFactoredList>(this);
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,112 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
namespace DataAccess.DTOs
{
public class ForceCombinationFromFileFromDTOConvertStrategy : ConvertStrategy<ForceCombinationFromFile, ForceCombinationFromFileDTO>
{
private IUpdateStrategy<IForceCombinationFromFile> updateStrategy;
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
private IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationPropertyConvertStrategy;
private IConvertStrategy<ColumnedFileProperty, ColumnedFilePropertyDTO> fileConvertStrategy;
public ForceCombinationFromFileFromDTOConvertStrategy(
IUpdateStrategy<IForceCombinationFromFile> updateStrategy,
IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy,
IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationPropertyConvertStrategy,
IConvertStrategy<ColumnedFileProperty, ColumnedFilePropertyDTO> fileConvertStrategy)
{
this.updateStrategy = updateStrategy;
this.pointConvertStrategy = pointConvertStrategy;
this.combinationPropertyConvertStrategy = combinationPropertyConvertStrategy;
this.fileConvertStrategy = fileConvertStrategy;
}
public ForceCombinationFromFileFromDTOConvertStrategy() { }
public override ForceCombinationFromFile GetNewItem(ForceCombinationFromFileDTO source)
{
TraceLogger?.AddMessage($"Force combination from file Name = {source.Name} converting has been started");
InitializeStrategies();
try
{
ForceCombinationFromFile newItem = GetForceCombination(source);
TraceLogger?.AddMessage($"Force combination from file Name = {newItem.Name} converting has been finished successfully");
return newItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(this)} made error: {ex.Message}", TraceLogStatuses.Error);
throw;
}
}
private ForceCombinationFromFile GetForceCombination(ForceCombinationFromFileDTO source)
{
ForceCombinationFromFile newItem = new(source.Id);
updateStrategy.Update(newItem, source);
SetForceFiles(source, newItem);
SetPoint(source, newItem);
SetCombinationProperty(source, newItem);
return newItem;
}
private void SetForceFiles(ForceCombinationFromFileDTO source, ForceCombinationFromFile newItem)
{
newItem.ForceFiles.Clear();
foreach (var item in source.ForceFiles)
{
if (item is ColumnedFilePropertyDTO filePropertyDTO)
{
ColumnedFileProperty columnFileProperty = fileConvertStrategy.Convert(filePropertyDTO);
newItem.ForceFiles.Add(columnFileProperty);
}
else
{
string errorString = ErrorStrings.ExpectedWas(typeof(ColumnFilePropertyDTO), item);
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
}
}
private void SetPoint(IForceAction source, IForceAction newItem)
{
if (source.ForcePoint is Point2DDTO pointDTO)
{
newItem.ForcePoint = pointConvertStrategy.Convert(pointDTO);
}
else
{
string errorMessage = ErrorStrings.ExpectedWas(typeof(Point2DDTO), source.ForcePoint);
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
private void SetCombinationProperty(IForceFactoredCombination source, IForceFactoredCombination newItem)
{
if (source.CombinationProperty is FactoredCombinationPropertyDTO factoredPropertyDTO)
{
newItem.CombinationProperty = combinationPropertyConvertStrategy.Convert(factoredPropertyDTO);
}
else
{
string errorMessage = ErrorStrings.ExpectedWas(typeof(FactoredCombinationPropertyDTO), source.CombinationProperty);
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
private void InitializeStrategies()
{
updateStrategy ??= new ForceCombinationFromFileUpdateStrategy();
pointConvertStrategy = new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
combinationPropertyConvertStrategy = new FactoredCombinationPropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
fileConvertStrategy ??= new ColumnedFilePropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
}
}
}

View File

@@ -1,6 +1,8 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
@@ -29,26 +31,31 @@ namespace DataAccess.DTOs
this.designTupleConvertStrategy = designTupleConvertStrategy;
}
public ForceCombinationListFromDTOConvertStrategy() : this(
new ForceActionBaseUpdateStrategy(),
new ForceCombinationListUpdateStrategy(),
new Point2DFromDTOConvertStrategy(),
new DesignForceTupleFromDTOConvertStrategy())
{
}
public ForceCombinationListFromDTOConvertStrategy() { }
public override ForceCombinationList GetNewItem(ForceCombinationListDTO source)
{
TraceLogger?.AddMessage($"Force combination list name = {source.Name} is starting");
TraceLogger?.AddMessage($"Force combination list Id = {source.Id}, Name = {source.Name} converting has been started");
InitializeStrategies();
try
{
ForceCombinationList newItem = GetNewItemBySource(source);
TraceLogger?.AddMessage($"Force combination list Id = {source.Id}, Name = {source.Name} has been finished successfully");
return newItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private ForceCombinationList GetNewItemBySource(ForceCombinationListDTO source)
{
ForceCombinationList 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);
designTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
designTupleConvertStrategy.TraceLogger = TraceLogger;
newItem.DesignForces.Clear();
foreach (var item in source.DesignForces)
{
@@ -57,8 +64,16 @@ namespace DataAccess.DTOs
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 successfully");
return newItem;
}
private void InitializeStrategies()
{
baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy();
updateStrategy ??= new ForceCombinationListUpdateStrategy();
pointConvertStrategy ??= new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
designTupleConvertStrategy ??= new DesignForceTupleFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
}
}
}

View File

@@ -1,19 +1,12 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.Logics;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.Converters
namespace DataAccess.DTOs
{
public class ForceCombinationListToDTOConvertStrategy : IConvertStrategy<ForceCombinationListDTO, IForceCombinationList>
public class ForceCombinationListToDTOConvertStrategy : ConvertStrategy<ForceCombinationListDTO, IForceCombinationList>
{
private IUpdateStrategy<IForceCombinationList> updateStrategy;
private IConvertStrategy<DesignForceTupleDTO, IDesignForceTuple> convertStrategy;
@@ -32,37 +25,20 @@ namespace DataAccess.DTOs.Converters
this.pointUpdateStrategy = pointUpdateStrategy;
}
public ForceCombinationListToDTOConvertStrategy() : this (
new ForceCombinationListUpdateStrategy(),
new DesignForceTupleToDTOConvertStrategy(),
new ForceActionBaseUpdateStrategy(),
new Point2DToDTOConvertStrategy())
{
public ForceCombinationListToDTOConvertStrategy() { }
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ForceCombinationListDTO Convert(IForceCombinationList source)
public override ForceCombinationListDTO GetNewItem(IForceCombinationList source)
{
try
{
Check();
return GetNewForceCombinationList(source);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Factored combination list Name: {source.Name} has been started");
ForceCombinationListDTO forceCombinationListDTO = GetNewForceCombinationList(source);
TraceLogger?.AddMessage($"Factored combination list Name: {source.Name} has been finished");
return forceCombinationListDTO;
}
private ForceCombinationListDTO GetNewForceCombinationList(IForceCombinationList source)
{
InitializeStrategies();
ForceCombinationListDTO newItem = new() { Id = source.Id};
baseUpdateStrategy.Update(newItem, source);
updateStrategy.Update(newItem, source);
@@ -78,6 +54,14 @@ namespace DataAccess.DTOs.Converters
return newItem;
}
private void InitializeStrategies()
{
updateStrategy ??= new ForceCombinationListUpdateStrategy();
convertStrategy ??= new DesignForceTupleToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy();
pointUpdateStrategy ??= new Point2DToDTOConvertStrategy();
}
private void GetNewForcePoint(ForceCombinationListDTO newItem, IForceCombinationList source)
{
if (source.ForcePoint is not null)

View File

@@ -0,0 +1,93 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services;
namespace DataAccess.DTOs
{
public class ForceFactoredListFromDTOConvertStrategy : ConvertStrategy<ForceFactoredList, ForceFactoredListDTO>
{
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
private IUpdateStrategy<IForceFactoredList> updateStrategy;
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
private IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy;
private IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationPropertyConvertStrategy;
public ForceFactoredListFromDTOConvertStrategy(
IUpdateStrategy<IForceAction> baseUpdateStrategy,
IUpdateStrategy<IForceFactoredList> updateStrategy,
IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy,
IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy,
IConvertStrategy<FactoredCombinationProperty, FactoredCombinationPropertyDTO> combinationPropertyConvertStrategy)
{
this.baseUpdateStrategy = baseUpdateStrategy;
this.updateStrategy = updateStrategy;
this.pointConvertStrategy = pointConvertStrategy;
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
this.combinationPropertyConvertStrategy = combinationPropertyConvertStrategy;
}
public ForceFactoredListFromDTOConvertStrategy() { }
public override ForceFactoredList GetNewItem(ForceFactoredListDTO source)
{
InitializeStrategies();
TraceLogger.AddMessage($"Force combination by factor name = {source.Name} converting is starting");
ForceFactoredList newItem = new(source.Id);
baseUpdateStrategy.Update(newItem, source);
updateStrategy.Update(newItem, source);
SetPoint(source, newItem);
SetCombinationProperty(source, newItem);
SetForceTuples(source, newItem);
TraceLogger.AddMessage($"Force combination by factor name = {newItem.Name} converting has been finished");
return newItem;
}
private void SetForceTuples(ForceFactoredListDTO source, ForceFactoredList newItem)
{
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);
}
}
private void SetPoint(ForceFactoredListDTO source, ForceFactoredList newItem)
{
if (source.ForcePoint is Point2DDTO pointDTO)
{
newItem.ForcePoint = pointConvertStrategy.Convert(pointDTO);
}
else
{
string errorMessage = ErrorStrings.ExpectedWas(typeof(Point2DDTO), source.ForcePoint);
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
private void SetCombinationProperty(ForceFactoredListDTO source, ForceFactoredList newItem)
{
if (source.CombinationProperty is FactoredCombinationPropertyDTO factoredPropertyDTO)
{
newItem.CombinationProperty = combinationPropertyConvertStrategy.Convert(factoredPropertyDTO);
}
else
{
string errorMessage = ErrorStrings.ExpectedWas(typeof(FactoredCombinationPropertyDTO), source.CombinationProperty);
TraceLogger.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
private void InitializeStrategies()
{
baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy();
updateStrategy ??= new ForceFactoredListUpdateStrategy();
pointConvertStrategy ??= new Point2DFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
forceTupleConvertStrategy ??= new ForceTupleFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyFromDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
}
}
}

View File

@@ -0,0 +1,109 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
namespace DataAccess.DTOs
{
public class ForceFactoredListToDTOConvertStrategy : ConvertStrategy<ForceFactoredListDTO, IForceFactoredList>
{
private IUpdateStrategy<IForceFactoredList> updateStrategy;
private IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy;
private IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy;
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
private IConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty> combinationPropertyConvertStrategy;
public ForceFactoredListToDTOConvertStrategy(IUpdateStrategy<IForceFactoredList> updateStrategy,
IConvertStrategy<Point2DDTO, IPoint2D> pointConvertStrategy,
IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy,
IUpdateStrategy<IForceAction> baseUpdateStrategy)
{
this.updateStrategy = updateStrategy;
this.pointConvertStrategy = pointConvertStrategy;
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
this.baseUpdateStrategy = baseUpdateStrategy;
}
public ForceFactoredListToDTOConvertStrategy() { }
public override ForceFactoredListDTO GetNewItem(IForceFactoredList source)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Force combination by factor, name = {source.Name} converting has been started");
InitializeStrategies();
ForceFactoredListDTO newItem = GetNewForceTuple(source);
TraceLogger?.AddMessage($"Force combination by factor, name = {newItem.Name} converting has been finished successfully");
return newItem;
}
private void InitializeStrategies()
{
baseUpdateStrategy ??= new ForceActionBaseUpdateStrategy();
updateStrategy ??= new ForceFactoredListUpdateStrategy();
forceTupleConvertStrategy ??= new ForceTupleToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger };
pointConvertStrategy ??= new Point2DToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
combinationPropertyConvertStrategy ??= new FactoredCombinationPropertyToDTOConvertStrategy() { ReferenceDictionary = ReferenceDictionary, TraceLogger = TraceLogger};
}
private ForceFactoredListDTO GetNewForceTuple(IForceFactoredList source)
{
ForceFactoredListDTO newItem = new(source.Id);
baseUpdateStrategy.Update(newItem, source);
updateStrategy.Update(newItem, source);
SetPoint(source, newItem);
SetForces(source, newItem);
SetCombinationProperty(source, newItem);
return newItem;
}
private void SetForces(IForceFactoredList source, ForceFactoredListDTO newItem)
{
if (source.ForceTuples is not null)
{
var convertForceTupleLogic = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>(this, forceTupleConvertStrategy);
newItem.ForceTuples.Clear();
foreach (var item in source.ForceTuples)
{
var forceTuple = convertForceTupleLogic.Convert(item);
newItem.ForceTuples.Add(forceTuple);
}
}
else
{
string errorMessage = ErrorStrings.NullReference + $"Factored combination {source.Name} Id={source.Id} does not have list of forces";
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
private void SetPoint(IForceFactoredList source, ForceFactoredListDTO newItem)
{
if (source.ForcePoint is not null)
{
var convertLogic = new DictionaryConvertStrategy<Point2DDTO, IPoint2D>(this, pointConvertStrategy);
newItem.ForcePoint = convertLogic.Convert(source.ForcePoint);
}
else
{
string errorMessage = ErrorStrings.NullReference + $"Factored combination {source.Name} Id={source.Id} does not have force point";
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
private void SetCombinationProperty(IForceFactoredList source, ForceFactoredListDTO newItem)
{
if (source.CombinationProperty is not null)
{
var convertLogic = new DictionaryConvertStrategy<FactoredCombinationPropertyDTO, IFactoredCombinationProperty>(this, combinationPropertyConvertStrategy);
newItem.CombinationProperty = convertLogic.Convert(source.CombinationProperty);
}
else
{
string errorMessage = ErrorStrings.NullReference + $"Factored combination {source.Name} Id={source.Id} does not have combination properties";
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
}
}

View File

@@ -14,9 +14,6 @@ namespace DataAccess.DTOs
{
private IUpdateStrategy<IForceTuple> updateStrategy;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ForceTupleToDTOConvertStrategy(IUpdateStrategy<IForceTuple> updateStrategy)
{
this.updateStrategy = updateStrategy;
@@ -29,7 +26,7 @@ namespace DataAccess.DTOs
public override ForceTupleDTO GetNewItem(IForceTuple source)
{
ForceTupleDTO newItem = new() { Id = source.Id};
ForceTupleDTO newItem = new(source.Id);
updateStrategy.Update(newItem, source);
return newItem;
}

View File

@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelperCommon.Infrastructures.Exceptions;
namespace DataAccess.DTOs
{
@@ -13,6 +14,14 @@ namespace DataAccess.DTOs
{
private const string convertStarted = " converting is started";
private const string convertFinished = " converting has been finished successfully";
private IConvertStrategy<IForceAction, IForceAction> convertStrategy;
private DictionaryConvertStrategy<IForceAction, IForceAction> convertLogic;
private ConvertDirection convertDirection;
public HasForceActionsProcessLogic(ConvertDirection convertDirection)
{
this.convertDirection = convertDirection;
}
public IShiftTraceLogger TraceLogger { get; set; }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
@@ -22,20 +31,41 @@ namespace DataAccess.DTOs
public void Process()
{
TraceLogger?.AddMessage("Actions" + convertStarted);
ForceActionsFromDTOConvertStrategy convertStrategy = new()
HasForceActionsFromDTOUpdateStrategy updateStrategy = GetUpdateStrategyFactory();
updateStrategy.Update(Target, Source);
TraceLogger?.AddMessage("Actions" + convertFinished);
}
private HasForceActionsFromDTOUpdateStrategy GetUpdateStrategyFactory()
{
if (convertDirection == ConvertDirection.FromDTO)
{
convertStrategy ??= new ForceActionFromDTOConvertStrategy()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
DictionaryConvertStrategy<IForceAction, IForceAction> convertLogic = new()
}
else if (convertDirection == ConvertDirection.ToDTO)
{
convertStrategy ??= new ForceActionToDTOConvertStrategy()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(convertDirection));
}
convertLogic ??= new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger,
ConvertStrategy = convertStrategy
};
HasForceActionsFromDTOUpdateStrategy updateStrategy = new(convertLogic);
updateStrategy.Update(Target, Source);
TraceLogger?.AddMessage("Actions" + convertFinished);
return updateStrategy;
}
}
}

View File

@@ -1,18 +1,20 @@
using StructureHelperCommon.Infrastructures.Interfaces;
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;
namespace DataAccess.DTOs.Converters
{
public class HasPrimitivesProcessLogic : IHasPrimitivesProcessLogic
{
private const string convertStarted = " converting is started";
private const string convertStarted = " converting has been started";
private const string convertFinished = " converting has been finished successfully";
private ConvertDirection convertDirection;
public HasPrimitivesProcessLogic(ConvertDirection convertDirection)
{
this.convertDirection = convertDirection;
}
public IHasPrimitives Source { get; set; }
public IHasPrimitives Target { get; set; }
@@ -22,11 +24,40 @@ namespace DataAccess.DTOs.Converters
public void Process()
{
TraceLogger?.AddMessage("Primitives" + convertStarted);
IUpdateStrategy<IHasPrimitives> updateStrategy = GetUpdateStrategyFactory();
updateStrategy.Update(Target, Source);
TraceLogger?.AddMessage($"Primitives {convertFinished}, totally {Target.Primitives.Count} have been obtained");
}
private IUpdateStrategy<IHasPrimitives> GetUpdateStrategyFactory()
{
if (convertDirection == ConvertDirection.FromDTO)
{
NdmPrimitiveFromDTOConvertStrategy convertStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
return GetUpdateStrategy(convertStrategy);
}
else if (convertDirection == ConvertDirection.ToDTO)
{
NdmPrimitiveToDTOConvertStrategy convertStrategy = new()
{
ReferenceDictionary = ReferenceDictionary,
TraceLogger = TraceLogger
};
return GetUpdateStrategy(convertStrategy);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(convertDirection));
}
}
private IUpdateStrategy<IHasPrimitives> GetUpdateStrategy(IConvertStrategy<INdmPrimitive, INdmPrimitive> convertStrategy)
{
DictionaryConvertStrategy<INdmPrimitive, INdmPrimitive> convertLogic = new()
{
ReferenceDictionary = ReferenceDictionary,
@@ -34,8 +65,7 @@ namespace DataAccess.DTOs.Converters
ConvertStrategy = convertStrategy
};
HasPrimitivesFromDTOUpdateStrategy updateStrategy = new(convertLogic);
updateStrategy.Update(Target, Source);
TraceLogger?.AddMessage($"Primitives {convertFinished}, totally {Target.Primitives.Count} have been obtained");
return updateStrategy;
}
}
}

View File

@@ -3,13 +3,15 @@ using StructureHelperCommon.Models;
namespace DataAccess.DTOs
{
/// <summary>
/// Logic for antities which have force actions
/// </summary>
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

@@ -1,10 +1,7 @@
using DataAccess.DTOs.DTOEntities;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Primitives;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace DataAccess.DTOs.Converters
{

View File

@@ -1,4 +1,6 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
@@ -24,10 +26,24 @@ namespace DataAccess.DTOs
public override Point2D GetNewItem(Point2DDTO source)
{
TraceLogger?.AddMessage("Point 2D converting is started");
TraceLogger?.AddMessage("Point 2D converting has been started");
try
{
Point2D newItem = GetNewItemBySource(source);
TraceLogger?.AddMessage("Point 2D converting has been finished");
return newItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(this)} made error: {ex.Message}", TraceLogStatuses.Error);
throw;
}
}
private Point2D GetNewItemBySource(Point2DDTO source)
{
Point2D newItem = new(source.Id);
updateStrategy.Update(newItem, source);
TraceLogger?.AddMessage("Point 2D converting has been finished");
return newItem;
}
}

View File

@@ -8,7 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.Converters
namespace DataAccess.DTOs
{
public class Point2DToDTOConvertStrategy : IConvertStrategy<Point2DDTO, IPoint2D>
{

View File

@@ -1,15 +1,9 @@
using DataAccess.DTOs.Converters;
using DataAccess.DTOs.DTOEntities;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{

View File

@@ -0,0 +1,43 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.NdmCalculations.Cracking;
namespace DataAccess.DTOs
{
public class UserCrackInputDataFromDTOConvertStrategy : ConvertStrategy<UserCrackInputData, UserCrackInputDataDTO>
{
private IUpdateStrategy<IUserCrackInputData> updateStrategy;
public UserCrackInputDataFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{
ReferenceDictionary = referenceDictionary;
TraceLogger = traceLogger;
}
public override UserCrackInputData GetNewItem(UserCrackInputDataDTO source)
{
InitializeStrategies();
try
{
GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewItemBySource(IUserCrackInputData source)
{
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
}
private void InitializeStrategies()
{
updateStrategy ??= new UserCrackInputDataUpdateStrategy();
}
}
}

View File

@@ -0,0 +1,48 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
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 UserCrackInputDataToDTOConvertStrategy : ConvertStrategy<UserCrackInputDataDTO, IUserCrackInputData>
{
private IUpdateStrategy<IUserCrackInputData> updateStrategy;
public UserCrackInputDataToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
{
ReferenceDictionary = referenceDictionary;
TraceLogger = traceLogger;
}
public override UserCrackInputDataDTO GetNewItem(IUserCrackInputData source)
{
InitializeStrategies();
try
{
GetNewItemBySource(source);
return NewItem;
}
catch (Exception ex)
{
TraceErrorByEntity(this, ex.Message);
throw;
}
}
private void GetNewItemBySource(IUserCrackInputData source)
{
NewItem = new(source.Id);
updateStrategy.Update(NewItem, source);
}
private void InitializeStrategies()
{
updateStrategy ??= new UserCrackInputDataUpdateStrategy();
}
}
}

View File

@@ -17,11 +17,9 @@ using System.Threading.Tasks;
namespace DataAccess.DTOs
{
internal class VisualAnalysisToDTOConvertStrategy : IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
internal class VisualAnalysisToDTOConvertStrategy : ConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
{
private IConvertStrategy<IAnalysis, IAnalysis> convertStrategy;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public VisualAnalysisToDTOConvertStrategy(IConvertStrategy<IAnalysis, IAnalysis> convertStrategy)
{
@@ -33,21 +31,14 @@ namespace DataAccess.DTOs
}
public VisualAnalysisDTO Convert(IVisualAnalysis source)
{
Check();
try
public override VisualAnalysisDTO GetNewItem(IVisualAnalysis source)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Visual analysis Id = {source.Id} converting has been started");
VisualAnalysisDTO visualAnalysisDTO = GetNewAnalysis(source);
TraceLogger?.AddMessage($"Visual analysis Id = {visualAnalysisDTO.Id} converting has been finished successfully");
return visualAnalysisDTO;
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private VisualAnalysisDTO GetNewAnalysis(IVisualAnalysis source)
{

View File

@@ -6,16 +6,19 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.DTOEntities
namespace DataAccess.DTOs
{
public class AccuracyDTO : IAccuracy
{
[JsonProperty("Id")]
public Guid Id { get; set; } = Guid.NewGuid();
public Guid Id { get;}
[JsonProperty("IterationAccuracy")]
public double IterationAccuracy { get; set; }
[JsonProperty("MaxIterationCount")]
public int MaxIterationCount { get; set; }
public AccuracyDTO(Guid id)
{
Id = id;
}
}
}

View File

@@ -0,0 +1,30 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Forces;
namespace DataAccess.DTOs
{
public class ColumnFilePropertyDTO : IColumnFileProperty
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("SearchingName")]
public string SearchingName { get; set; }
[JsonProperty("Index")]
public int Index { get; set; }
[JsonProperty("Factor")]
public double Factor { get; set; }
public ColumnFilePropertyDTO(Guid id)
{
Id = id;
}
public object Clone()
{
return this;
}
}
}

View File

@@ -0,0 +1,33 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Forces;
namespace DataAccess.DTOs
{
public class ColumnedFilePropertyDTO : IColumnedFileProperty
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("FilePath")]
public string FilePath { get; set; } = string.Empty;
[JsonProperty("SkipRowBeforeHeaderCount")]
public int SkipRowBeforeHeaderCount { get; set; }
[JsonProperty("SkipRowHeaderCount")]
public int SkipRowHeaderCount { get; set; }
[JsonProperty("GlobalFactor")]
public double GlobalFactor { get; set; }
[JsonProperty("ColumnProperties")]
public List<IColumnFileProperty> ColumnProperties { get; } = new();
public ColumnedFilePropertyDTO(Guid id)
{
Id = id;
}
public object Clone()
{
return this;
}
}
}

View File

@@ -13,16 +13,20 @@ namespace DataAccess.DTOs
public class CrackCalculatorDTO : ICrackCalculator
{
[JsonProperty("Id")]
public Guid Id { get; set; }
public Guid Id { get;}
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("InputData")]
public ICrackCalculatorInputData InputData { get; set; } = new CrackCalculatorInputDataDTO();
public ICrackCalculatorInputData InputData { get; set; }
[JsonIgnore]
public IResult Result { get; }
[JsonIgnore]
public IShiftTraceLogger? TraceLogger { get; set; }
public CrackCalculatorDTO(Guid id)
{
Id = id;
}
public object Clone()
{

View File

@@ -8,13 +8,17 @@ namespace DataAccess.DTOs
public class CrackCalculatorInputDataDTO : ICrackCalculatorInputData
{
[JsonProperty("Id")]
public Guid Id { get; set; } = Guid.NewGuid();
public Guid Id { get; }
[JsonProperty("ForceActions")]
public List<IForceAction> ForceActions { get; set; } = new();
[JsonProperty("ForcePrimitives")]
public List<INdmPrimitive> Primitives { get; set; } = new();
[JsonProperty("UserCrackInputData")]
public IUserCrackInputData UserCrackInputData { get; set; } = new UserCrackInputDataDTO();
public IUserCrackInputData UserCrackInputData { get; set; }
public CrackCalculatorInputDataDTO(Guid id)
{
Id = id;
}
}
}

View File

@@ -16,7 +16,7 @@ namespace DataAccess.DTOs
[JsonProperty("CalcTerm")]
public CalcTerms CalcTerm { get; set; }
[JsonProperty("ForceTuple")]
public IForceTuple ForceTuple { get; set; } = new ForceTupleDTO();
public IForceTuple ForceTuple { get; set; } = new ForceTupleDTO(Guid.NewGuid());
public object Clone()

View File

@@ -4,8 +4,10 @@ using StructureHelperCommon.Models.Forces;
namespace DataAccess.DTOs
{
public class ForceFactoredCombinationPropertyDTO : IFactoredCombinationProperty
public class FactoredCombinationPropertyDTO : IFactoredCombinationProperty
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("CalctTerm")]
public CalcTerms CalcTerm { get; set; }
[JsonProperty("LimitState")]
@@ -14,5 +16,9 @@ namespace DataAccess.DTOs
public double LongTermFactor { get; set; }
[JsonProperty("ULSFactor")]
public double ULSFactor { get; set; }
public FactoredCombinationPropertyDTO(Guid id)
{
Id = id;
}
}
}

View File

@@ -17,7 +17,7 @@ namespace DataAccess.DTOs
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("InputData")]
public IForceCalculatorInputData InputData { get; set; } = new ForceCalculatorInputDataDTO();
public IForceCalculatorInputData InputData { get; set; }
[JsonIgnore]
public IShiftTraceLogger? TraceLogger { get; set; }
[JsonIgnore]

View File

@@ -1,23 +1,17 @@
using DataAccess.DTOs.DTOEntities;
using Newtonsoft.Json;
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Sections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ForceCalculatorInputDataDTO : IForceCalculatorInputData
{
[JsonProperty("Id")]
public Guid Id { get; set; } = Guid.NewGuid();
public Guid Id { get; }
[JsonProperty("ForceActions")]
public List<IForceAction> ForceActions { get; set; } = new();
[JsonProperty("Primitives")]
@@ -27,11 +21,14 @@ namespace DataAccess.DTOs
[JsonProperty("CalcTermList")]
public List<CalcTerms> CalcTermsList { get; set; } = new();
[JsonProperty("Accuracy")]
public IAccuracy Accuracy { get; set; } = new AccuracyDTO();
public IAccuracy Accuracy { get; set; }
[JsonProperty("CompressedMember")]
public ICompressedMember CompressedMember { get; set; } = new CompressedMemberDTO();
//[JsonIgnore]
//public List<IForceCombinationList> ForceCombinationLists { get; set; } = new();
public ForceCalculatorInputDataDTO(Guid id)
{
Id = id;
}
}
}

View File

@@ -0,0 +1,42 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Forces;
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 ForceCombinationFromFileDTO : IForceCombinationFromFile
{
[JsonProperty("Id")]
public Guid Id { get; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("ForceFiles")]
public List<IColumnedFileProperty> ForceFiles { get; set; } = new();
[JsonProperty("CombinationProperty")]
public IFactoredCombinationProperty CombinationProperty { get; set; } = new FactoredCombinationPropertyDTO(Guid.NewGuid());
[JsonProperty("SetInGravityCenter")]
public bool SetInGravityCenter { get; set; }
[JsonProperty("ForcePoint")]
public IPoint2D ForcePoint { get; set; } = new Point2DDTO();
public ForceCombinationFromFileDTO(Guid id)
{
Id = id;
}
public object Clone()
{
return this;
}
public List<IForceCombinationList> GetCombinations()
{
throw new NotImplementedException();
}
}
}

View File

@@ -10,10 +10,10 @@ using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ForceCombinationByFactorDTO : IForceFactoredList
public class ForceFactoredListDTO : IForceFactoredList
{
[JsonProperty("Id")]
public Guid Id { get; set; }
public Guid Id { get;}
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("ForceTuples")]
@@ -23,8 +23,12 @@ namespace DataAccess.DTOs
[JsonProperty("ForcePoint")]
public IPoint2D ForcePoint { get; set; } = new Point2DDTO();
[JsonProperty("CombinationProperty")]
public IFactoredCombinationProperty CombinationProperty { get; } = new ForceFactoredCombinationPropertyDTO();
public IFactoredCombinationProperty CombinationProperty { get; set; } = new FactoredCombinationPropertyDTO(Guid.NewGuid());
public ForceFactoredListDTO(Guid id)
{
Id = id;
}
public object Clone()
{

View File

@@ -25,6 +25,10 @@ namespace DataAccess.DTOs
[JsonProperty("Mz")]
public double Mz { get; set; }
public ForceTupleDTO(Guid id)
{
Id = id;
}
public void Clear()
{

View File

@@ -19,9 +19,9 @@ namespace DataAccess.DTOs
[JsonProperty("Triangulate")]
public bool Triangulate { get; set; }
[JsonProperty("UsersPrestrain")]
public IForceTuple UsersPrestrain { get; set; } = new ForceTupleDTO();
public IForceTuple UsersPrestrain { get; set; } = new ForceTupleDTO(Guid.NewGuid());
[JsonProperty("AutoPrestrain")]
public IForceTuple AutoPrestrain { get; set; } = new ForceTupleDTO();
public IForceTuple AutoPrestrain { get; set; } = new ForceTupleDTO(Guid.NewGuid());
public object Clone()

View File

@@ -21,7 +21,7 @@ namespace DataAccess.DTOs
[JsonProperty("CalcTerm")]
public CalcTerms CalcTerm { get; set; } = CalcTerms.ShortTerm;
[JsonProperty("FullSLSForces")]
public IForceTuple ForceTuple { get; set; } = new ForceTupleDTO();
public IForceTuple ForceTuple { get; set; } = new ForceTupleDTO(Guid.NewGuid());
[JsonProperty("ULSFactor")]
public double ULSFactor { get; set; }
[JsonProperty("LongTermFactor")]
@@ -31,13 +31,23 @@ namespace DataAccess.DTOs
[JsonProperty("ForcePoint")]
public IPoint2D ForcePoint { get; set; } = new Point2DDTO();
[JsonIgnore]
public IFactoredCombinationProperty CombinationProperty => new FactoredCombinationProperty()
public IFactoredCombinationProperty CombinationProperty
{
get
{
return new FactoredCombinationProperty()
{
CalcTerm = CalcTerm,
LimitState = LimitState,
LongTermFactor = LongTermFactor,
ULSFactor = ULSFactor,
};
}
set
{
throw new NotImplementedException();
}
}
[JsonIgnore]
public List<IForceTuple> ForceTuples => new() { ForceTuple};

View File

@@ -1,5 +1,4 @@
using DataAccess.DTOs.DTOEntities;
using StructureHelper.Models.Materials;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Analyses;
@@ -7,11 +6,6 @@ using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
@@ -40,6 +34,8 @@ namespace DataAccess.DTOs
{
{ (typeof(AccuracyDTO), "Accuracy") },
{ (typeof(ConcreteLibMaterialDTO), "ConcreteLibMaterial") },
{ (typeof(ColumnFilePropertyDTO), "ColumnFileProperty") },
{ (typeof(ColumnedFilePropertyDTO), "ColumnedFileProperty") },
{ (typeof(CompressedMemberDTO), "CompressedMember") },
{ (typeof(CrackCalculatorDTO), "CrackCalculator") },
{ (typeof(CrackCalculatorInputDataDTO), "CrackCalculatorInputData") },
@@ -55,9 +51,10 @@ namespace DataAccess.DTOs
{ (typeof(ForceCalculatorDTO), "ForceCalculator") },
{ (typeof(ForceCalculatorInputDataDTO), "ForceCalculatorInputData") },
{ (typeof(ForceCombinationByFactorV1_0DTO), "ForceCombinationByFactor") },
{ (typeof(ForceCombinationByFactorDTO), "ForceCombinationByFactor_v1_1") },
{ (typeof(ForceFactoredListDTO), "ForceCombinationByFactor_v1_1") },
{ (typeof(ForceCombinationFromFileDTO), "ForceCombinationFromFile") },
{ (typeof(ForceCombinationListDTO), "ForceCombinationList") },
{ (typeof(ForceFactoredCombinationPropertyDTO), "ForceFactoredCombinationProperty") },
{ (typeof(FactoredCombinationPropertyDTO), "ForceFactoredCombinationProperty") },
{ (typeof(ForceTupleDTO), "ForceTuple") },
{ (typeof(FRMaterialDTO), "FRMaterial") },
{ (typeof(HeadMaterialDTO), "HeadMaterial") },
@@ -65,6 +62,8 @@ namespace DataAccess.DTOs
{ (typeof(NdmElementDTO), "NdmElement") },
{ (typeof(IVisualAnalysis), "IVisualAnalysis") },
{ (typeof(List<CalcTerms>), "ListOfCalcTerms") },
{ (typeof(List<IColumnFileProperty>), "ColumnFileProperties") },
{ (typeof(List<IColumnedFileProperty>), "ColumnedFileProperties") },
{ (typeof(List<ICalculator>), "ListOfICalculator") },
{ (typeof(List<IDateVersion>), "ListOfIDateVersion") },
{ (typeof(List<IDesignForceTuple>), "ListOfIDesignForceTuple") },

View File

@@ -11,7 +11,7 @@ namespace DataAccess.DTOs
public class UserCrackInputDataDTO : IUserCrackInputData
{
[JsonProperty("Id")]
public Guid Id { get; set; } = Guid.NewGuid();
public Guid Id { get;}
[JsonProperty("LengthBetweenCracks")]
public double LengthBetweenCracks { get; set; }
[JsonProperty("SetLengthBetweenCracks")]
@@ -25,5 +25,9 @@ namespace DataAccess.DTOs
[JsonProperty("UltimateShortCrackWidths")]
public double UltimateShortCrackWidth { get; set; }
public UserCrackInputDataDTO(Guid id)
{
Id = id;
}
}
}

View File

@@ -1,10 +1,4 @@
using DataAccess.DTOs;
using DataAccess.DTOs.DTOEntities;
using DataAccess.JsonConverters;
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Projects;
using StructureHelperCommon.Services.FileServices;

View File

@@ -9,11 +9,11 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.Forces
{
public class ColumnPropertyVM : ViewModelBase, IDataErrorInfo
public class ColumnFilePropertyVM : ViewModelBase, IDataErrorInfo
{
private IColumnProperty model;
private IColumnFileProperty model;
public ColumnPropertyVM(IColumnProperty model)
public ColumnFilePropertyVM(IColumnFileProperty model)
{
this.model = model;
}

View File

@@ -18,7 +18,7 @@ namespace StructureHelper.Windows.Forces
this.model = model;
foreach (var item in model.ColumnProperties)
{
ColumnProperties.Add(new ColumnPropertyVM(item));
ColumnProperties.Add(new ColumnFilePropertyVM(item));
}
}
@@ -59,7 +59,7 @@ namespace StructureHelper.Windows.Forces
}
}
public ObservableCollection<ColumnPropertyVM> ColumnProperties { get; set; } = new();
public ObservableCollection<ColumnFilePropertyVM> ColumnProperties { get; set; } = new();
public IColumnedFileProperty Model
{

View File

@@ -8,6 +8,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <inheritdoc/>
public abstract class ConvertStrategy<T, V> : IConvertStrategy<T, V>
where T : ISaveable
where V : ISaveable
@@ -22,7 +23,10 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
try
{
Check();
return GetNewItem(source);
TraceStartOfConverting(source);
T target = GetNewItem(source);
TraceFinishOfConverting(target);
return target;
}
catch (Exception ex)
{
@@ -38,5 +42,18 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
var checkLogic = new CheckConvertLogic<T,V>(this);
checkLogic.Check();
}
public void TraceErrorByEntity(object obj, string message)
{
TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(obj)} made error: {message}", TraceLogStatuses.Error);
}
private void TraceStartOfConverting(ISaveable saveable)
{
TraceLogger?.AddMessage($"Converting {saveable.GetType()} Id = {saveable.Id} has been started");
}
private void TraceFinishOfConverting(ISaveable saveable)
{
TraceLogger?.AddMessage($"Converting {saveable.GetType()} Id = {saveable.Id} has been started");
}
}
}

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
/// <inheritdoc/>
public class ColumnProperty : IColumnProperty
public class ColumnFileProperty : IColumnFileProperty
{
/// <inheritdoc/>
public Guid Id { get; private set; }
@@ -20,19 +20,19 @@ namespace StructureHelperCommon.Models.Forces
/// <inheritdoc/>
public double Factor { get; set; } = 1d;
public ColumnProperty(Guid id, string columnName)
public ColumnFileProperty(Guid id, string name)
{
Id = id;
Name = columnName;
Name = name;
}
public ColumnProperty(string columnName) : this(Guid.NewGuid(), columnName)
public ColumnFileProperty(string columnName) : this(Guid.NewGuid(), columnName)
{
}
public object Clone()
{
var cloneLogic = new ColumnPropertyCloningStrategy();
var cloneLogic = new ColumnFilePropertyCloningStrategy();
return cloneLogic.GetClone(this);
}
}

View File

@@ -23,7 +23,7 @@ namespace StructureHelperCommon.Models.Forces
/// <inheritdoc/>
public double GlobalFactor { get; set; } = 1d;
/// <inheritdoc/>
public List<IColumnProperty> ColumnProperties { get; } = new();
public List<IColumnFileProperty> ColumnProperties { get; } = new();
public ColumnedFileProperty(Guid id)
{

View File

@@ -7,11 +7,27 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
/// <inheritdoc/>
public class FactoredCombinationProperty : IFactoredCombinationProperty
{
/// <inheritdoc/>
public Guid Id { get; }
/// <inheritdoc/>
public CalcTerms CalcTerm { get; set; } = CalcTerms.ShortTerm;
/// <inheritdoc/>
public LimitStates LimitState { get; set; } = LimitStates.SLS;
/// <inheritdoc/>
public double LongTermFactor { get; set; } = 1d;
/// <inheritdoc/>
public double ULSFactor { get; set; } = 1.2d;
public FactoredCombinationProperty(Guid id)
{
Id = id;
}
public FactoredCombinationProperty() : this(Guid.NewGuid())
{
}
}
}

View File

@@ -18,7 +18,7 @@ namespace StructureHelperCommon.Models.Forces
if (propertyType == FilePropertyType.Forces)
{
ColumnedFileProperty fileProperty = new();
List<IColumnProperty> columnProperties = GetForceColumns();
List<IColumnFileProperty> columnProperties = GetForceColumns();
fileProperty.ColumnProperties.AddRange(columnProperties);
return fileProperty;
}
@@ -28,12 +28,12 @@ namespace StructureHelperCommon.Models.Forces
}
}
private static List<IColumnProperty> GetForceColumns()
private static List<IColumnFileProperty> GetForceColumns()
{
List<IColumnProperty> columnProperties = new();
columnProperties.Add(new ColumnProperty("Nz") { SearchingName = "N", Index = 6 });
columnProperties.Add(new ColumnProperty("Mx") { SearchingName = "My", Index = 8 });
columnProperties.Add(new ColumnProperty("My") { SearchingName = "Mz", Index = 10 });
List<IColumnFileProperty> columnProperties = new();
columnProperties.Add(new ColumnFileProperty("Nz") { SearchingName = "N", Index = 6 });
columnProperties.Add(new ColumnFileProperty("Mx") { SearchingName = "My", Index = 8 });
columnProperties.Add(new ColumnFileProperty("My") { SearchingName = "Mz", Index = 10 });
return columnProperties;
}
}

View File

@@ -17,13 +17,24 @@ namespace StructureHelperCommon.Models.Forces
IGetTuplesFromFileLogic getTupleFromFileLogic;
private IForceFactoredList factoredCombination;
public Guid Id { get; set; }
public Guid Id { get; }
public ForceCombinationFromFile(Guid id)
{
Id = id;
}
public ForceCombinationFromFile() : this(Guid.NewGuid())
{
}
public string Name { get; set; } = string.Empty;
public List<IColumnedFileProperty> ForceFiles { get; set; } = new();
public bool SetInGravityCenter { get; set; } = true;
public IPoint2D ForcePoint { get; set; } = new Point2D();
public IFactoredCombinationProperty CombinationProperty { get; } = new FactoredCombinationProperty();
public IFactoredCombinationProperty CombinationProperty { get; set; } = new FactoredCombinationProperty();
public object Clone()
{

View File

@@ -23,7 +23,7 @@ namespace StructureHelperCommon.Models.Forces
/// <inheritdoc/>
public List<IForceTuple> ForceTuples { get; } = new() { new ForceTuple()};
/// <inheritdoc/>
public IFactoredCombinationProperty CombinationProperty { get; } = new FactoredCombinationProperty();
public IFactoredCombinationProperty CombinationProperty { get; set; }= new FactoredCombinationProperty();
public ForceFactoredList(Guid id)

View File

@@ -10,7 +10,7 @@ namespace StructureHelperCommon.Models.Forces
/// <summary>
/// Settingth for column reading from MSExcel file
/// </summary>
public interface IColumnProperty : ISaveable, ICloneable
public interface IColumnFileProperty : ISaveable, ICloneable
{
/// <summary>
/// Name of column

View File

@@ -28,6 +28,6 @@ namespace StructureHelperCommon.Models.Forces
/// <summary>
/// Collection of column's properties which will be imported
/// </summary>
List<IColumnProperty> ColumnProperties { get; }
List<IColumnFileProperty> ColumnProperties { get; }
}
}

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,7 +11,7 @@ namespace StructureHelperCommon.Models.Forces
/// <summary>
/// Properties of factored combination of forces
/// </summary>
public interface IFactoredCombinationProperty
public interface IFactoredCombinationProperty : ISaveable
{
/// <summary>
/// Term of calculation for assigned combination

View File

@@ -10,6 +10,6 @@ namespace StructureHelperCommon.Models.Forces
/// <summary>
/// Properties of factored combination of forces
/// </summary>
IFactoredCombinationProperty CombinationProperty { get; }
IFactoredCombinationProperty CombinationProperty { get; set; }
}
}

View File

@@ -8,28 +8,28 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
public class ColumnPropertyCloningStrategy : ICloneStrategy<IColumnProperty>
public class ColumnFilePropertyCloningStrategy : ICloneStrategy<IColumnFileProperty>
{
private IUpdateStrategy<IColumnProperty> updateStrategy;
private IUpdateStrategy<IColumnFileProperty> updateStrategy;
public ColumnPropertyCloningStrategy(IUpdateStrategy<IColumnProperty> updateStrategy)
public ColumnFilePropertyCloningStrategy(IUpdateStrategy<IColumnFileProperty> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public ColumnPropertyCloningStrategy()
public ColumnFilePropertyCloningStrategy()
{
}
public IColumnProperty GetClone(IColumnProperty sourceObject)
public IColumnFileProperty GetClone(IColumnFileProperty sourceObject)
{
CheckObject.IsNull(sourceObject);
if (updateStrategy is null)
{
updateStrategy = new ColumnPropertyUpdateStrategy();
updateStrategy = new ColumnFilePropertyUpdateStrategy();
}
ColumnProperty newItem = new(sourceObject.Name);
ColumnFileProperty newItem = new(sourceObject.Name);
updateStrategy.Update(newItem, sourceObject);
return newItem;
}

View File

@@ -8,9 +8,9 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
public class ColumnPropertyUpdateStrategy : IUpdateStrategy<IColumnProperty>
public class ColumnFilePropertyUpdateStrategy : IUpdateStrategy<IColumnFileProperty>
{
public void Update(IColumnProperty targetObject, IColumnProperty sourceObject)
public void Update(IColumnFileProperty targetObject, IColumnFileProperty sourceObject)
{
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);

View File

@@ -31,7 +31,7 @@ namespace StructureHelperCommon.Models.Forces
targetObject.ColumnProperties.Clear();
foreach (var item in sourceObject.ColumnProperties)
{
IColumnProperty clone = (IColumnProperty)item.Clone();
IColumnFileProperty clone = (IColumnFileProperty)item.Clone();
targetObject.ColumnProperties.Add(clone);
}
}

View File

@@ -15,7 +15,6 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.SetSofteningFactor = sourceObject.SetSofteningFactor;
targetObject.SofteningFactor = sourceObject.SofteningFactor;
targetObject.SetLengthBetweenCracks = sourceObject.SetLengthBetweenCracks;

View File

@@ -37,9 +37,9 @@ namespace StructureHelperTests.UnitTests.ForcesTests
public void GetForceTuple_ShouldReturnForceTuple_WhenDataIsValid()
{
// Arrange
var columnProperties = new List<IColumnProperty>
var columnProperties = new List<IColumnFileProperty>
{
new Mock<IColumnProperty>().SetupAllProperties().Object
new Mock<IColumnFileProperty>().SetupAllProperties().Object
};
_mockFileProperty.Setup(x => x.ColumnProperties).Returns(columnProperties);

View File

@@ -0,0 +1,38 @@
using Moq;
using NUnit.Framework;
using StructureHelper.Windows.Forces;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperTests.ViewModelTests
{
[TestFixture]
public class ColumnPropertyVMTests
{
private Mock<IColumnFileProperty> _mockColumnProperty;
[SetUp]
public void SetUp()
{
_mockColumnProperty = new Mock<IColumnFileProperty>();
}
[Test]
public void CheckViewModelCreating_RunShouldPass()
{
//Arrange
_mockColumnProperty.Setup(x => x.Name).Returns("TestName");
_mockColumnProperty.Setup(x => x.SearchingName).Returns("TestSearchName");
_mockColumnProperty.Setup(x => x.Index).Returns(0);
_mockColumnProperty.Setup(x => x.Factor).Returns(1);
//Act
ColumnFilePropertyVM viewModel = new(_mockColumnProperty.Object);
//Assert
Assert.That(viewModel, !Is.Null);
}
}
}

View File

@@ -0,0 +1,46 @@
using Moq;
using NUnit.Framework;
using StructureHelper.Windows.Forces;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperTests.ViewModelTests
{
[TestFixture]
public class FactoreCombinationPropertyVMTests
{
private Mock<IFactoredCombinationProperty> _mockModel;
[SetUp]
public void SetUp()
{
_mockModel = new Mock<IFactoredCombinationProperty>();
}
[TestCase(LimitStates.SLS, CalcTerms.ShortTerm, 0.9, 1.2)]
[TestCase(LimitStates.ULS, CalcTerms.ShortTerm, 0.9, 1.2)]
[TestCase(LimitStates.ULS, CalcTerms.LongTerm, 0.9, 1.2)]
public void CreateViewModel_RunShouldPass(LimitStates limitStates, CalcTerms calcTerms, double longTermFactor, double ulsFactor)
{
//Arrange
_mockModel.Setup(x => x.LimitState).Returns(limitStates);
_mockModel.Setup(x => x.CalcTerm).Returns(calcTerms);
_mockModel.Setup(x => x.LongTermFactor).Returns(longTermFactor);
_mockModel.Setup(x => x.ULSFactor).Returns(ulsFactor);
//Act
FactoredCombinationPropertyVM viewModel = new(_mockModel.Object);
//Assert
Assert.That(viewModel, !Is.Null);
Assert.That(viewModel.LimitState, Is.EqualTo(limitStates));
Assert.That(viewModel.CalcTerm, Is.EqualTo(calcTerms));
Assert.That(viewModel.LongTermFactor, Is.EqualTo(longTermFactor));
Assert.That(viewModel.ULSFactor, Is.EqualTo(ulsFactor));
}
}
}