Add Force DTOs
This commit is contained in:
@@ -16,6 +16,8 @@ namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
private const string Message = "Analysis type is";
|
||||
private IConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis> convertCrossSectionNdmAnalysisStrategy = new CrossSectionNdmAnalysisToDTOConvertStrategy();
|
||||
private DictionaryConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis> convertLogic;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
@@ -45,12 +47,7 @@ namespace DataAccess.DTOs.Converters
|
||||
TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
||||
convertCrossSectionNdmAnalysisStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertCrossSectionNdmAnalysisStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = convertCrossSectionNdmAnalysisStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
convertLogic = new DictionaryConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>(this, convertCrossSectionNdmAnalysisStrategy);
|
||||
CrossSectionNdmAnalysisDTO crossSectionNdmAnalysisDTO = convertLogic.Convert(crossSectionNdmAnalysis);
|
||||
return crossSectionNdmAnalysisDTO;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
@@ -16,14 +19,22 @@ namespace DataAccess.DTOs
|
||||
public class CrossSectionRepositoryToDTOConvertStrategy : IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>
|
||||
{
|
||||
private IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy;
|
||||
private IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor> forceCombinationByFactorConvertStrategy;
|
||||
private IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy;
|
||||
|
||||
public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy)
|
||||
public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy,
|
||||
IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor> forceCombinationByFactorConvertStrategy,
|
||||
IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy)
|
||||
{
|
||||
this.materialConvertStrategy = materialConvertStrategy;
|
||||
this.forceCombinationByFactorConvertStrategy = forceCombinationByFactorConvertStrategy;
|
||||
this.forceCombinationListConvertStrategy = forceCombinationListConvertStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionRepositoryToDTOConvertStrategy() : this(
|
||||
new HeadMaterialToDTOConvertStrategy())
|
||||
new HeadMaterialToDTOConvertStrategy(),
|
||||
new ForceCombinationByFactorToDTOConvertStrategy(),
|
||||
new ForceCombinationListToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
@@ -34,15 +45,74 @@ namespace DataAccess.DTOs
|
||||
public CrossSectionRepositoryDTO Convert(ICrossSectionRepository source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
CrossSectionRepositoryDTO newItem = GetNewRepository(source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private CrossSectionRepositoryDTO GetNewRepository(ICrossSectionRepository source)
|
||||
{
|
||||
CrossSectionRepositoryDTO newItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
List<IForceAction> forceActions = ProcessForceActions(source);
|
||||
List<HeadMaterialDTO> materials = ProcessMaterials(source);
|
||||
newItem.ForceActions.AddRange(forceActions);
|
||||
newItem.HeadMaterials.AddRange(materials);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private List<IForceAction> ProcessForceActions(ICrossSectionRepository source)
|
||||
{
|
||||
List<IForceAction> forceActions = new();
|
||||
foreach (var item in source.ForceActions)
|
||||
{
|
||||
if (item is IForceCombinationByFactor forceCombinationByFactor)
|
||||
{
|
||||
ForceCombinationByFactorDTO forceCombination = GetForceCombinationByFactor(forceCombinationByFactor);
|
||||
forceActions.Add(forceCombination);
|
||||
}
|
||||
else if (item is IForceCombinationList forceCombinationList)
|
||||
{
|
||||
ForceCombinationListDTO forceCombination = GetForceCombinationList(forceCombinationList);
|
||||
forceActions.Add(forceCombination);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(item));
|
||||
}
|
||||
}
|
||||
return forceActions;
|
||||
}
|
||||
|
||||
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(IForceCombinationByFactor forceCombinationByFactor)
|
||||
{
|
||||
forceCombinationByFactorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceCombinationByFactorConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor>(this, forceCombinationByFactorConvertStrategy);
|
||||
var forceCombination = convertLogic.Convert(forceCombinationByFactor);
|
||||
return forceCombination;
|
||||
}
|
||||
|
||||
private List<HeadMaterialDTO> ProcessMaterials(ICrossSectionRepository source)
|
||||
{
|
||||
materialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
@@ -64,9 +134,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<CrossSectionRepositoryDTO, ICrossSectionRepository>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
var checkLogic = new CheckConvertLogic<CrossSectionRepositoryDTO, ICrossSectionRepository>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
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 CrossSectionToDTOConvertStrategy : IConvertStrategy<CrossSectionDTO, ICrossSection>
|
||||
{
|
||||
private IUpdateStrategy<ICrossSection> updateStrategy;
|
||||
private IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertStrategy;
|
||||
private IUpdateStrategy<ICrossSection> updateStrategy; //don't use since CrossSection does not have any properties
|
||||
private IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertRepositoryStrategy;
|
||||
private DictionaryConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertLogic;
|
||||
private ICheckConvertLogic<CrossSectionDTO, ICrossSection> checkLogic;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public CrossSectionToDTOConvertStrategy(IUpdateStrategy<ICrossSection> updateStrategy,
|
||||
IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertStrategy)
|
||||
IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertRepositoryStrategy,
|
||||
ICheckConvertLogic<CrossSectionDTO, ICrossSection> checkLogic)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertStrategy = convertStrategy;
|
||||
this.convertRepositoryStrategy = convertRepositoryStrategy;
|
||||
this.checkLogic = checkLogic;
|
||||
}
|
||||
|
||||
public CrossSectionToDTOConvertStrategy() : this(
|
||||
new CrossSectionUpdateStrategy(),
|
||||
new CrossSectionRepositoryToDTOConvertStrategy())
|
||||
new CrossSectionRepositoryToDTOConvertStrategy(),
|
||||
new CheckConvertLogic<CrossSectionDTO, ICrossSection>())
|
||||
{
|
||||
|
||||
}
|
||||
@@ -38,21 +38,15 @@ namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = convertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
convertRepositoryStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertRepositoryStrategy.TraceLogger = TraceLogger;
|
||||
convertLogic = new DictionaryConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>(this, convertRepositoryStrategy);
|
||||
newItem.SectionRepository = convertLogic.Convert(source.SectionRepository);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<CrossSectionDTO, ICrossSection>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
checkLogic.Check();
|
||||
|
||||
@@ -9,12 +9,13 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DateVersionToDTOConvertStrategy : IConvertStrategy<DateVersionDTO, IDateVersion>
|
||||
{
|
||||
private IUpdateStrategy<IDateVersion> updateStrategy;
|
||||
private IConvertStrategy<ISaveable, ISaveable> convertStrategy;
|
||||
private DictionaryConvertStrategy<ISaveable, ISaveable> convertLogic;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
@@ -44,12 +45,7 @@ namespace DataAccess.DTOs.Converters
|
||||
updateStrategy.Update(newItem, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = convertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>(this, convertStrategy);
|
||||
newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class DesignForceTupleToDTOConvertStrategy : IConvertStrategy<DesignForceTupleDTO, IDesignForceTuple>
|
||||
{
|
||||
private IUpdateStrategy<IDesignForceTuple> updateStrategy;
|
||||
private IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy;
|
||||
|
||||
public DesignForceTupleToDTOConvertStrategy(IUpdateStrategy<IDesignForceTuple> updateStrategy,
|
||||
IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
|
||||
}
|
||||
|
||||
public DesignForceTupleToDTOConvertStrategy() : this(new DesignForceTupleUpdateStrategy(),
|
||||
new ForceTupleToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public DesignForceTupleDTO Convert(IDesignForceTuple source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
DesignForceTupleDTO designForceTupleDTO = GetNewDesignForceTuple(source);
|
||||
return designForceTupleDTO;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private DesignForceTupleDTO GetNewDesignForceTuple(IDesignForceTuple source)
|
||||
{
|
||||
DesignForceTupleDTO newItem = new() { Id = source.Id };
|
||||
updateStrategy.Update(newItem, source);
|
||||
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceTupleConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>(this, forceTupleConvertStrategy);
|
||||
newItem.ForceTuple = convertLogic.Convert(source.ForceTuple);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<DesignForceTupleDTO, IDesignForceTuple>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ElasticMaterialToDTOConvertStrategy : IConvertStrategy<ElasticMaterialDTO, IElasticMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IElasticMaterial> updateStrategy;
|
||||
private ICheckConvertLogic<ElasticMaterialDTO, IElasticMaterial> checkLogic;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ElasticMaterialToDTOConvertStrategy(
|
||||
IUpdateStrategy<IElasticMaterial> updateStrategy,
|
||||
ICheckConvertLogic<ElasticMaterialDTO, IElasticMaterial> checkLogic)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.checkLogic = checkLogic;
|
||||
}
|
||||
|
||||
public ElasticMaterialToDTOConvertStrategy() : this (
|
||||
new ElasticUpdateStrategy(),
|
||||
new CheckConvertLogic<ElasticMaterialDTO, IElasticMaterial>())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ElasticMaterialDTO Convert(IElasticMaterial source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
ElasticMaterialDTO newItem = new() { Id = source.Id };
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
checkLogic = new CheckConvertLogic<ElasticMaterialDTO, IElasticMaterial>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
48
DataAccess/DTOs/Converters/FRMaterialToDTOConvertStrategy.cs
Normal file
48
DataAccess/DTOs/Converters/FRMaterialToDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FRMaterialToDTOConvertStrategy : IConvertStrategy<FRMaterialDTO, IFRMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IFRMaterial> updateStrategy;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public FRMaterialToDTOConvertStrategy(IUpdateStrategy<IFRMaterial> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public FRMaterialToDTOConvertStrategy() : this (new FRUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FRMaterialDTO Convert(IFRMaterial source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
FRMaterialDTO newItem = new() { Id = source.Id };
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<FRMaterialDTO, IFRMaterial>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
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, IForceCombinationByFactor>
|
||||
{
|
||||
private IUpdateStrategy<IForceCombinationByFactor> updateStrategy;
|
||||
private IConvertStrategy<Point2DDTO, IPoint2D> pointUpdateStrategy;
|
||||
|
||||
private IConvertStrategy<ForceTupleDTO, IForceTuple> forceTupleConvertStrategy;
|
||||
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
|
||||
|
||||
public ForceCombinationByFactorToDTOConvertStrategy(IUpdateStrategy<IForceCombinationByFactor> 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 ForceCombinationByFactorUpdateStrategy(),
|
||||
new Point2DToDTOConvertStrategy(),
|
||||
new ForceTupleToDTOConvertStrategy(),
|
||||
new ForceActionBaseUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ForceCombinationByFactorDTO Convert(IForceCombinationByFactor 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.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ForceCombinationByFactorDTO GetNewForceTuple(IForceCombinationByFactor 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(IForceCombinationByFactor source, ForceCombinationByFactorDTO newItem)
|
||||
{
|
||||
if (source.FullSLSForces is not null)
|
||||
{
|
||||
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceTupleConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertForceTupleLogic = new DictionaryConvertStrategy<ForceTupleDTO, IForceTuple>(this, forceTupleConvertStrategy);
|
||||
newItem.FullSLSForces = convertForceTupleLogic.Convert(source.FullSLSForces);
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNewForcePoint(IForceCombinationByFactor 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, IForceCombinationByFactor>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class ForceCombinationListToDTOConvertStrategy : IConvertStrategy<ForceCombinationListDTO, IForceCombinationList>
|
||||
{
|
||||
private IUpdateStrategy<IForceCombinationList> updateStrategy;
|
||||
private IConvertStrategy<DesignForceTupleDTO, IDesignForceTuple> convertStrategy;
|
||||
|
||||
public ForceCombinationListToDTOConvertStrategy(
|
||||
IUpdateStrategy<IForceCombinationList> updateStrategy,
|
||||
IConvertStrategy<DesignForceTupleDTO, IDesignForceTuple> convertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public ForceCombinationListToDTOConvertStrategy() : this (
|
||||
new ForceCombinationListUpdateStrategy(),
|
||||
new DesignForceTupleToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ForceCombinationListDTO Convert(IForceCombinationList source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
return GetNewForceCombinationList(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ForceCombinationListDTO GetNewForceCombinationList(IForceCombinationList source)
|
||||
{
|
||||
|
||||
ForceCombinationListDTO newItem = new() { Id = source.Id};
|
||||
updateStrategy.Update(newItem, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<DesignForceTupleDTO, IDesignForceTuple>(this, convertStrategy);
|
||||
newItem.DesignForces.Clear();
|
||||
foreach (var item in source.DesignForces)
|
||||
{
|
||||
newItem.DesignForces.Add(convertLogic.Convert(item));
|
||||
}
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ForceCombinationListDTO, IForceCombinationList>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
53
DataAccess/DTOs/Converters/ForceTupleToDTOConvertStrategy.cs
Normal file
53
DataAccess/DTOs/Converters/ForceTupleToDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
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 ForceTupleToDTOConvertStrategy : IConvertStrategy<ForceTupleDTO, IForceTuple>
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public ForceTupleToDTOConvertStrategy() : this(new ForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ForceTupleDTO Convert(IForceTuple source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
ForceTupleDTO newItem = new() { Id = source.Id};
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ForceTupleDTO, IForceTuple>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
@@ -34,6 +35,20 @@ namespace DataAccess.DTOs.Converters
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public HeadMaterialDTO Convert(IHeadMaterial source)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetMaterial(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private HeadMaterialDTO GetMaterial(IHeadMaterial source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Convert material Id={source.Id}, name is {source.Name}");
|
||||
HeadMaterialDTO newItem = new()
|
||||
@@ -42,12 +57,7 @@ namespace DataAccess.DTOs.Converters
|
||||
};
|
||||
updateStrategy.Update(newItem, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
var convertLogic = new DictionaryConvertStrategy<IHelperMaterial, IHelperMaterial>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = convertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var convertLogic = new DictionaryConvertStrategy<IHelperMaterial, IHelperMaterial>(this, convertStrategy);
|
||||
newItem.HelperMaterial = convertLogic.Convert(source.HelperMaterial);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class HelperMaterialDTOSafetyFactorUpdateStrategy : IUpdateStrategy<IHelperMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy;
|
||||
private IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy;
|
||||
|
||||
public HelperMaterialDTOSafetyFactorUpdateStrategy(
|
||||
IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy,
|
||||
IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy)
|
||||
{
|
||||
this.safetyFactorUpdateStrategy = safetyFactorUpdateStrategy;
|
||||
this.partialFactorUpdateStrategy = partialFactorUpdateStrategy;
|
||||
}
|
||||
|
||||
public HelperMaterialDTOSafetyFactorUpdateStrategy() : this(
|
||||
new MaterialSafetyFactorUpdateStrategy(),
|
||||
new MaterialPartialFactorUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
if (sourceObject.SafetyFactors is not null)
|
||||
{
|
||||
targetObject.SafetyFactors.Clear();
|
||||
foreach (var safetyFactor in sourceObject.SafetyFactors)
|
||||
{
|
||||
MaterialSafetyFactorDTO newSafetyFactor = GetNewSafetyFactorByOld(safetyFactor);
|
||||
targetObject.SafetyFactors.Add(newSafetyFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MaterialSafetyFactorDTO GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor)
|
||||
{
|
||||
MaterialSafetyFactorDTO newSafetyFactor = new()
|
||||
{
|
||||
Id = safetyFactor.Id
|
||||
};
|
||||
safetyFactorUpdateStrategy.Update(newSafetyFactor, safetyFactor);
|
||||
newSafetyFactor.PartialFactors.Clear();
|
||||
foreach (var partialFactor in safetyFactor.PartialFactors)
|
||||
{
|
||||
MaterialPartialFactorDTO newPartialFactor = GetNewPartialFactorByOld(partialFactor);
|
||||
newSafetyFactor.PartialFactors.Add(newPartialFactor);
|
||||
}
|
||||
|
||||
return newSafetyFactor;
|
||||
}
|
||||
|
||||
private MaterialPartialFactorDTO GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor)
|
||||
{
|
||||
MaterialPartialFactorDTO newPartialFactor = new()
|
||||
{
|
||||
Id = partialFactor.Id
|
||||
};
|
||||
partialFactorUpdateStrategy.Update(newPartialFactor, partialFactor);
|
||||
return newPartialFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.Models.Materials.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -15,20 +18,31 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy;
|
||||
private LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy;
|
||||
private IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> elasticConvertStrategy;
|
||||
private IConvertStrategy<FRMaterialDTO, IFRMaterial> frMaterialConvertStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy();
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public HelperMaterialToDTOConvertStrategy(
|
||||
LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy,
|
||||
LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy)
|
||||
LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy,
|
||||
IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> elasticConvertStrategy,
|
||||
IConvertStrategy<FRMaterialDTO, IFRMaterial> frMaterialConvertStrategy)
|
||||
{
|
||||
this.concreteConvertStrategy = concreteConvertStrategy;
|
||||
this.reinforcementConvertStrategy = reinforcementConvertStrategy;
|
||||
this.elasticConvertStrategy = elasticConvertStrategy;
|
||||
this.frMaterialConvertStrategy = frMaterialConvertStrategy;
|
||||
}
|
||||
|
||||
public HelperMaterialToDTOConvertStrategy() : this (
|
||||
new ConcreteLibMaterialToDTOConvertStrategy(),
|
||||
new ReinforcementLibMaterialToDTOConvertStrategy())
|
||||
new ReinforcementLibMaterialToDTOConvertStrategy(),
|
||||
new ElasticMaterialToDTOConvertStrategy(),
|
||||
new FRMaterialToDTOConvertStrategy()
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -36,17 +50,37 @@ namespace DataAccess.DTOs
|
||||
public IHelperMaterial Convert(IHelperMaterial source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
IHelperMaterial helperMaterial = GetMaterial(source);
|
||||
safetyFactorUpdateStrategy.Update(helperMaterial, source);
|
||||
return helperMaterial;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private IHelperMaterial GetMaterial(IHelperMaterial source)
|
||||
{
|
||||
if (source is IConcreteLibMaterial concreteLibMaterial)
|
||||
{
|
||||
concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
concreteConvertStrategy.TraceLogger = TraceLogger;
|
||||
return concreteConvertStrategy.Convert(concreteLibMaterial);
|
||||
return ProcessConcrete(concreteLibMaterial);
|
||||
}
|
||||
if (source is IReinforcementLibMaterial reinforcementMaterial)
|
||||
else if (source is IReinforcementLibMaterial reinforcementMaterial)
|
||||
{
|
||||
reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
reinforcementConvertStrategy.TraceLogger = TraceLogger;
|
||||
return reinforcementConvertStrategy.Convert(reinforcementMaterial);
|
||||
return ProcessReinforcement(reinforcementMaterial);
|
||||
}
|
||||
else if (source is IFRMaterial frMaterial)
|
||||
{
|
||||
return ProcessFRMaterial(frMaterial);
|
||||
}
|
||||
else if (source is IElasticMaterial elasticMaterial)
|
||||
{
|
||||
return ProcessElastic(elasticMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,11 +88,41 @@ namespace DataAccess.DTOs
|
||||
}
|
||||
}
|
||||
|
||||
private IHelperMaterial ProcessFRMaterial(IFRMaterial frMaterial)
|
||||
{
|
||||
frMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
frMaterialConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<FRMaterialDTO, IFRMaterial>(this, frMaterialConvertStrategy);
|
||||
return convertLogic.Convert(frMaterial);
|
||||
}
|
||||
|
||||
private IHelperMaterial ProcessElastic(IElasticMaterial elasticMaterial)
|
||||
{
|
||||
elasticConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
elasticConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ElasticMaterialDTO, IElasticMaterial>(this, elasticConvertStrategy);
|
||||
return convertLogic.Convert(elasticMaterial);
|
||||
}
|
||||
|
||||
private IHelperMaterial ProcessReinforcement(IReinforcementLibMaterial reinforcementMaterial)
|
||||
{
|
||||
reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
reinforcementConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial>(this, reinforcementConvertStrategy);
|
||||
return convertLogic.Convert(reinforcementMaterial);
|
||||
}
|
||||
|
||||
private IHelperMaterial ProcessConcrete(IConcreteLibMaterial concreteLibMaterial)
|
||||
{
|
||||
concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
concreteConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>(this, concreteConvertStrategy);
|
||||
return convertLogic.Convert(concreteLibMaterial);
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<IHelperMaterial, IHelperMaterial>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
var checkLogic = new CheckConvertLogic<IHelperMaterial, IHelperMaterial>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,64 +12,12 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
public class LibMaterialDTOUpdateStrategy : IUpdateStrategy<ILibMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy;
|
||||
private IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy;
|
||||
|
||||
public LibMaterialDTOUpdateStrategy(IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy,
|
||||
IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy)
|
||||
{
|
||||
this.safetyFactorUpdateStrategy = safetyFactorUpdateStrategy;
|
||||
this.partialFactorUpdateStrategy = partialFactorUpdateStrategy;
|
||||
}
|
||||
|
||||
public LibMaterialDTOUpdateStrategy() : this (new MaterialSafetyFactorUpdateStrategy(),
|
||||
new MaterialPartialFactorUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Update(ILibMaterial targetObject, ILibMaterial sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
if (sourceObject.SafetyFactors is not null)
|
||||
{
|
||||
targetObject.SafetyFactors.Clear();
|
||||
foreach (var safetyFactor in sourceObject.SafetyFactors)
|
||||
{
|
||||
MaterialSafetyFactorDTO newSafetyFactor = GetNewSafetyFactorByOld(safetyFactor);
|
||||
targetObject.SafetyFactors.Add(newSafetyFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MaterialSafetyFactorDTO GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor)
|
||||
{
|
||||
MaterialSafetyFactorDTO newSafetyFactor = new()
|
||||
{
|
||||
Id = safetyFactor.Id
|
||||
};
|
||||
safetyFactorUpdateStrategy.Update(newSafetyFactor, safetyFactor);
|
||||
newSafetyFactor.PartialFactors.Clear();
|
||||
foreach (var partialFactor in safetyFactor.PartialFactors)
|
||||
{
|
||||
MaterialPartialFactorDTO newPartialFactor = GetNewPartialFactorByOld(partialFactor);
|
||||
newSafetyFactor.PartialFactors.Add(newPartialFactor);
|
||||
}
|
||||
|
||||
return newSafetyFactor;
|
||||
}
|
||||
|
||||
private MaterialPartialFactorDTO GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor)
|
||||
{
|
||||
MaterialPartialFactorDTO newPartialFactor = new()
|
||||
{
|
||||
Id = partialFactor.Id
|
||||
};
|
||||
partialFactorUpdateStrategy.Update(newPartialFactor, partialFactor);
|
||||
return newPartialFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
public abstract IUpdateStrategy<V> UpdateStrategy { get; }
|
||||
public abstract T GetMaterialDTO(V source);
|
||||
private IUpdateStrategy<ILibMaterial> libMaterialUpdateStrategy = new LibMaterialDTOUpdateStrategy();
|
||||
//private IUpdateStrategy<ILibMaterial> libMaterialUpdateStrategy = new LibMaterialDTOUpdateStrategy();
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace DataAccess.DTOs
|
||||
try
|
||||
{
|
||||
UpdateStrategy.Update(newItem, source);
|
||||
libMaterialUpdateStrategy.Update(newItem, source);
|
||||
//libMaterialUpdateStrategy.Update(newItem, source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -43,9 +43,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<T, V>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
var checkLogic = new CheckConvertLogic<T, V>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
|
||||
|
||||
47
DataAccess/DTOs/Converters/Point2DToDTOConvertStrategy.cs
Normal file
47
DataAccess/DTOs/Converters/Point2DToDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
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 Point2DToDTOConvertStrategy : IConvertStrategy<Point2DDTO, IPoint2D>
|
||||
{
|
||||
private IUpdateStrategy<IPoint2D> updateStrategy;
|
||||
|
||||
public Point2DToDTOConvertStrategy(IUpdateStrategy<IPoint2D> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public Point2DToDTOConvertStrategy() : this (new Point2DUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary {get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public Point2DDTO Convert(IPoint2D source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Point2DDTO newItem = new() { Id = source.Id };
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private IUpdateStrategy<IProject> updateStrategy;
|
||||
private IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertStrategy;
|
||||
private DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
@@ -39,12 +40,7 @@ namespace DataAccess.DTOs
|
||||
updateStrategy.Update(newItem, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = convertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
convertLogic = new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>(this, convertStrategy);
|
||||
newItem.VisualAnalyses.Clear();
|
||||
foreach (var item in source.VisualAnalyses)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class VersionItemToDTOConvertStrategy : IConvertStrategy<ISaveable, ISaveable>
|
||||
{
|
||||
|
||||
@@ -8,14 +8,26 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class VersionProcessorToDTOConvertStrategy : IConvertStrategy<VersionProcessorDTO, IVersionProcessor>
|
||||
{
|
||||
private IConvertStrategy<DateVersionDTO, IDateVersion> convertStrategy = new DateVersionToDTOConvertStrategy();
|
||||
private IConvertStrategy<DateVersionDTO, IDateVersion> dataVersionConvertStrategy;
|
||||
private ICheckConvertLogic<VersionProcessorDTO, IVersionProcessor> checkLogic;
|
||||
|
||||
public VersionProcessorToDTOConvertStrategy(IConvertStrategy<DateVersionDTO, IDateVersion> dataVersionConvertStrategy)
|
||||
{
|
||||
this.dataVersionConvertStrategy = dataVersionConvertStrategy;
|
||||
}
|
||||
public VersionProcessorToDTOConvertStrategy() : this( new DateVersionToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
|
||||
public VersionProcessorDTO Convert(IVersionProcessor source)
|
||||
{
|
||||
Check();
|
||||
@@ -23,25 +35,18 @@ namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
dataVersionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
dataVersionConvertStrategy.TraceLogger = TraceLogger;
|
||||
foreach (var item in source.Versions)
|
||||
{
|
||||
var convertLogic = new DictionaryConvertStrategy<DateVersionDTO, IDateVersion>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = convertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var convertLogic = new DictionaryConvertStrategy<DateVersionDTO, IDateVersion>(this, dataVersionConvertStrategy);
|
||||
newItem.Versions.Add(convertLogic.Convert(item));
|
||||
}
|
||||
return newItem;
|
||||
}
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<VersionProcessorDTO, IVersionProcessor>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
checkLogic = new CheckConvertLogic<VersionProcessorDTO, IVersionProcessor>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace DataAccess.DTOs
|
||||
[JsonProperty("SectionRepository")]
|
||||
public ICrossSectionRepository SectionRepository { get; set; }
|
||||
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
29
DataAccess/DTOs/DesignForceTupleDTO.cs
Normal file
29
DataAccess/DTOs/DesignForceTupleDTO.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DesignForceTupleDTO : IDesignForceTuple
|
||||
{
|
||||
private IUpdateStrategy<IDesignForceTuple> updateStrategy;
|
||||
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("LimitState")]
|
||||
public LimitStates LimitState { get; set; }
|
||||
[JsonProperty("CalcTerm")]
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
[JsonProperty("ForceTuple")]
|
||||
public IForceTuple ForceTuple { get; set; } = new ForceTupleDTO();
|
||||
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
DesignForceTupleDTO newItem = new();
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace DataAccess.DTOs
|
||||
[JsonProperty("TensileStrength")]
|
||||
public double TensileStrength { get; set; }
|
||||
[JsonProperty("SafetyFactors")]
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = new();
|
||||
|
||||
|
||||
public object Clone()
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace DataAccess.DTOs
|
||||
[JsonProperty("TensileStrength")]
|
||||
public double TensileStrength { get; set; }
|
||||
[JsonProperty("SafetyFactors")]
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = new();
|
||||
|
||||
|
||||
public object Clone()
|
||||
|
||||
40
DataAccess/DTOs/ForceCombinationByFactorDTO.cs
Normal file
40
DataAccess/DTOs/ForceCombinationByFactorDTO.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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 ForceCombinationByFactorDTO : IForceCombinationByFactor
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("Name")]
|
||||
public string Name { get; set; }
|
||||
[JsonProperty("FullSLSForces")]
|
||||
public IForceTuple FullSLSForces { get; set; } = new ForceTupleDTO();
|
||||
[JsonProperty("ULSFactor")]
|
||||
public double ULSFactor { get; set; }
|
||||
[JsonProperty("LongTermFactor")]
|
||||
public double LongTermFactor { get; set; }
|
||||
[JsonProperty("SetInGravityCenter")]
|
||||
public bool SetInGravityCenter { get; set; }
|
||||
[JsonProperty("ForcePoint")]
|
||||
public IPoint2D ForcePoint { get; set; } = new Point2DDTO();
|
||||
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IForceCombinationList GetCombinations()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
35
DataAccess/DTOs/ForceCombinationListDTO.cs
Normal file
35
DataAccess/DTOs/ForceCombinationListDTO.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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 ForceCombinationListDTO : IForceCombinationList
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("Name")]
|
||||
public string Name { get; set; }
|
||||
[JsonProperty("SetInGravityCenter")]
|
||||
public bool SetInGravityCenter { get; set; }
|
||||
[JsonProperty("ForcePoint")]
|
||||
public IPoint2D ForcePoint { get; set; }
|
||||
[JsonProperty("DesignForces")]
|
||||
public List<IDesignForceTuple> DesignForces { get; set; } = new();
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IForceCombinationList GetCombinations()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
39
DataAccess/DTOs/ForceTupleDTO.cs
Normal file
39
DataAccess/DTOs/ForceTupleDTO.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Newtonsoft.Json;
|
||||
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 ForceTupleDTO : IForceTuple
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("Mx")]
|
||||
public double Mx { get; set; }
|
||||
[JsonProperty("My")]
|
||||
public double My { get; set; }
|
||||
[JsonProperty("Nz")]
|
||||
public double Nz { get; set; }
|
||||
[JsonProperty("Qx")]
|
||||
public double Qx { get; set; }
|
||||
[JsonProperty("Qy")]
|
||||
public double Qy { get; set; }
|
||||
[JsonProperty("Mz")]
|
||||
public double Mz { get; set; }
|
||||
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
27
DataAccess/DTOs/Point2DDTO.cs
Normal file
27
DataAccess/DTOs/Point2DDTO.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class Point2DDTO : IPoint2D
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("X")]
|
||||
public double X { get; set; }
|
||||
[JsonProperty("Y")]
|
||||
public double Y { get; set; }
|
||||
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,13 +42,20 @@ namespace DataAccess.DTOs
|
||||
{ (typeof(CrossSectionNdmAnalysisDTO), "CrossSectionNdmAnalysis") },
|
||||
{ (typeof(CrossSectionRepositoryDTO), "CrossSectionRepository") },
|
||||
{ (typeof(DateVersionDTO), "DateVersion") },
|
||||
{ (typeof(DesignForceTupleDTO), "DesignForceTuple") },
|
||||
{ (typeof(ElasticMaterialDTO), "ElasticMaterial") },
|
||||
{ (typeof(FileVersionDTO), "FileVersion") },
|
||||
{ (typeof(ForceCombinationByFactorDTO), "ForceCombinationByFactor") },
|
||||
{ (typeof(ForceCombinationListDTO), "ForceCombinationList") },
|
||||
{ (typeof(ForceTupleDTO), "ForceTuple") },
|
||||
{ (typeof(FRMaterialDTO), "FRMaterial") },
|
||||
{ (typeof(HeadMaterialDTO), "HeadMaterial") },
|
||||
{ (typeof(MaterialSafetyFactorDTO), "MaterialSafetyFactor") },
|
||||
{ (typeof(NdmPrimitiveDTO), "NdmPrimitive") },
|
||||
{ (typeof(IVisualAnalysis), "IVisualAnalysis") },
|
||||
{ (typeof(List<ICalculator>), "ListOfICalculator") },
|
||||
{ (typeof(List<IDateVersion>), "ListOfIDateVersion") },
|
||||
{ (typeof(List<IDesignForceTuple>), "ListOfIDesignForceTuple") },
|
||||
{ (typeof(List<IForceAction>), "ListOfIForceAction") },
|
||||
{ (typeof(List<IHeadMaterial>), "ListOfIHeadMaterial") },
|
||||
{ (typeof(List<IMaterialSafetyFactor>), "ListOfMaterialSafetyFactor") },
|
||||
@@ -56,6 +63,7 @@ namespace DataAccess.DTOs
|
||||
{ (typeof(List<INdmPrimitive>), "ListOfINdmPrimitive") },
|
||||
{ (typeof(List<IPartialFactor>), "ListOfPartialFactor") },
|
||||
{ (typeof(List<IVisualAnalysis>), "ListOfIVisualAnalysis") },
|
||||
{ (typeof(Point2DDTO), "Point2D") },
|
||||
{ (typeof(ProjectDTO), "Project") },
|
||||
{ (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") },
|
||||
{ (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") },
|
||||
|
||||
Reference in New Issue
Block a user