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") },
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
get
|
||||
{
|
||||
return primitive.DiameterByX;
|
||||
return primitive.Width;
|
||||
}
|
||||
set
|
||||
{
|
||||
primitive.DiameterByX = value;
|
||||
primitive.Width = value;
|
||||
RefreshPlacement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
var primitive = new EllipsePrimitive
|
||||
{
|
||||
DiameterByX = 0.5d
|
||||
Width = 0.5d
|
||||
};
|
||||
ndmPrimitive = primitive;
|
||||
viewPrimitive = new CircleViewPrimitive(primitive);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public enum CalcTerms
|
||||
{
|
||||
ShortTerm,
|
||||
LongTerm,
|
||||
ShortTerm = 1,
|
||||
LongTerm = 2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -9,11 +10,22 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public class CheckConvertLogic<T, V> : ICheckLogic
|
||||
where T : ISaveable
|
||||
public class CheckConvertLogic<T, V> : ICheckConvertLogic<T, V> where T : ISaveable
|
||||
where V : ISaveable
|
||||
{
|
||||
private string checkResult;
|
||||
|
||||
public CheckConvertLogic(IConvertStrategy<T, V> source)
|
||||
{
|
||||
ConvertStrategy = source;
|
||||
TraceLogger = source.TraceLogger;
|
||||
}
|
||||
|
||||
public CheckConvertLogic()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IConvertStrategy<T, V> ConvertStrategy { get; set; }
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
@@ -18,9 +18,20 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
public IConvertStrategy<T,V> ConvertStrategy { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
|
||||
public DictionaryConvertStrategy(IBaseConvertStrategy baseConvertStrategy, IConvertStrategy<T, V> convertStrategy)
|
||||
{
|
||||
ReferenceDictionary = baseConvertStrategy.ReferenceDictionary;
|
||||
TraceLogger = baseConvertStrategy.TraceLogger;
|
||||
ConvertStrategy = convertStrategy;
|
||||
}
|
||||
public DictionaryConvertStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public T Convert(V source)
|
||||
{
|
||||
ICheckInputData();
|
||||
CheckInputData();
|
||||
T val;
|
||||
var key = (source.Id, typeof(T));
|
||||
if (ReferenceDictionary.ContainsKey(key))
|
||||
@@ -38,7 +49,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
}
|
||||
return val;
|
||||
}
|
||||
private void ICheckInputData()
|
||||
private void CheckInputData()
|
||||
{
|
||||
if(ReferenceDictionary is null)
|
||||
{
|
||||
@@ -47,6 +58,6 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public interface IBaseConvertStrategy
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using StructureHelperCommon.Models;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public interface ICheckConvertLogic<T, V> : ICheckLogic
|
||||
where T : ISaveable
|
||||
where V : ISaveable
|
||||
{
|
||||
IConvertStrategy<T, V> ConvertStrategy { get; set; }
|
||||
IShiftTraceLogger? TraceLogger { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public interface IConvertStrategy<T,V>
|
||||
public interface IConvertStrategy<T,V> : IBaseConvertStrategy
|
||||
where T :ISaveable
|
||||
where V :ISaveable
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
T Convert(V source);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using System;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class DesignForceTuple : IDesignForceTuple
|
||||
{
|
||||
private IUpdateStrategy<IDesignForceTuple> updateStrategy = new DesignForceTupleUpdateStrategy();
|
||||
public Guid Id { get; }
|
||||
|
||||
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
public IForceTuple ForceTuple { get; set; }
|
||||
public IForceTuple ForceTuple { get; set; } = new ForceTuple();
|
||||
|
||||
public DesignForceTuple(LimitStates limitState, CalcTerms calcTerm) : this()
|
||||
public DesignForceTuple(Guid id)
|
||||
{
|
||||
LimitState = limitState;
|
||||
CalcTerm = calcTerm;
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public DesignForceTuple()
|
||||
public DesignForceTuple() : this (Guid.NewGuid())
|
||||
{
|
||||
ForceTuple = new ForceTuple();
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var newTuple = new DesignForceTuple(this.LimitState, this.CalcTerm);
|
||||
newTuple.ForceTuple = this.ForceTuple.Clone() as ForceTuple;
|
||||
var newTuple = new DesignForceTuple();
|
||||
updateStrategy.Update(newTuple, this);
|
||||
return newTuple;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
if (forceType == ForceType.Force_zero)
|
||||
{
|
||||
return new DesignForceTuple(limitState, calcTerm);
|
||||
return new DesignForceTuple() { LimitState = limitState, CalcTerm = calcTerm };
|
||||
}
|
||||
else if (forceType == ForceType.Force_Mx50My50Nz100)
|
||||
{
|
||||
var tuple = new DesignForceTuple(limitState, calcTerm);
|
||||
var tuple = new DesignForceTuple() { LimitState = limitState, CalcTerm = calcTerm };
|
||||
var forceTuple = tuple.ForceTuple;
|
||||
forceTuple.Mx = -50e3d;
|
||||
forceTuple.My = -50e3d;
|
||||
|
||||
@@ -32,10 +32,26 @@ namespace StructureHelperCommon.Models.Forces
|
||||
ForcePoint = new Point2D() { X = 0, Y = 0 };
|
||||
DesignForces = new List<IDesignForceTuple>
|
||||
{
|
||||
new DesignForceTuple(LimitStates.ULS, CalcTerms.ShortTerm),
|
||||
new DesignForceTuple(LimitStates.ULS, CalcTerms.LongTerm),
|
||||
new DesignForceTuple(LimitStates.SLS, CalcTerms.ShortTerm),
|
||||
new DesignForceTuple(LimitStates.SLS, CalcTerms.LongTerm)
|
||||
new DesignForceTuple()
|
||||
{
|
||||
LimitState = LimitStates.ULS,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
},
|
||||
new DesignForceTuple()
|
||||
{
|
||||
LimitState = LimitStates.ULS,
|
||||
CalcTerm = CalcTerms.LongTerm
|
||||
},
|
||||
new DesignForceTuple()
|
||||
{
|
||||
LimitState = LimitStates.SLS,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
},
|
||||
new DesignForceTuple()
|
||||
{
|
||||
LimitState = LimitStates.SLS,
|
||||
CalcTerm = CalcTerms.LongTerm
|
||||
}
|
||||
};
|
||||
}
|
||||
public ForceCombinationList() : this (Guid.NewGuid()) { }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
@@ -9,6 +10,8 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> updateStrategy = new ForceTupleUpdateStrategy();
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
public double Mx { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public double My { get; set; }
|
||||
@@ -21,6 +24,16 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <inheritdoc/>
|
||||
public double Mz { get; set; }
|
||||
|
||||
public ForceTuple(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public ForceTuple() : this (Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Mx = 0d;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public interface IDesignForceTuple : ICloneable
|
||||
public interface IDesignForceTuple : ISaveable, ICloneable
|
||||
{
|
||||
LimitStates LimitState { get; set; }
|
||||
CalcTerms CalcTerm { get; set; }
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for generic force for beams
|
||||
/// </summary>
|
||||
public interface IForceTuple : ICloneable
|
||||
public interface IForceTuple : ISaveable, ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Bending moment round about x-axis
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace StructureHelperCommon.Models.Forces
|
||||
readonly IUpdateStrategy<IForceAction> forceUpdateStrategy = new ForceActionUpdateStrategy();
|
||||
public void Update(IAction targetObject, IAction sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.Name = sourceObject.Name;
|
||||
if (targetObject is IForceAction forceAction)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces.Logics
|
||||
{
|
||||
public class DesignForceTupleUpdateStrategy : IUpdateStrategy<IDesignForceTuple>
|
||||
{
|
||||
private IUpdateStrategy<IForceTuple> forceTupleUpdateStrategy;
|
||||
|
||||
public DesignForceTupleUpdateStrategy(IUpdateStrategy<IForceTuple> forceTupleUpdateStrategy)
|
||||
{
|
||||
this.forceTupleUpdateStrategy = forceTupleUpdateStrategy;
|
||||
}
|
||||
|
||||
public DesignForceTupleUpdateStrategy() : this (new ForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IDesignForceTuple targetObject, IDesignForceTuple sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.LimitState = sourceObject.LimitState;
|
||||
targetObject.CalcTerm = sourceObject.CalcTerm;
|
||||
if (sourceObject.ForceTuple is not null)
|
||||
{
|
||||
forceTupleUpdateStrategy.Update(targetObject.ForceTuple, sourceObject.ForceTuple);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces.Logics
|
||||
{
|
||||
public class ForceActionBaseUpdateStrategy : IUpdateStrategy<IForceAction>
|
||||
{
|
||||
private readonly IUpdateStrategy<IPoint2D> pointStrategy;
|
||||
|
||||
public ForceActionBaseUpdateStrategy(IUpdateStrategy<IPoint2D> pointStrategy)
|
||||
{
|
||||
this.pointStrategy = pointStrategy;
|
||||
}
|
||||
|
||||
public ForceActionBaseUpdateStrategy() : this(new Point2DUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IForceAction targetObject, IForceAction sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.SetInGravityCenter = sourceObject.SetInGravityCenter;
|
||||
pointStrategy.Update(targetObject.ForcePoint, sourceObject.ForcePoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,21 +8,45 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ForceActionUpdateStrategy : IUpdateStrategy<IForceAction>
|
||||
{
|
||||
private readonly IUpdateStrategy<IPoint2D> pointStrategy = new Point2DUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IDesignForcePair> forcePairUpdateStrategy = new ForcePairUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IForceCombinationByFactor> factorUpdateStrategy = new FactorCombinationUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy = new ForceCombinationListUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IForceAction> forceActionUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IDesignForcePair> forcePairUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IForceCombinationByFactor> factorUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy;
|
||||
|
||||
public ForceActionUpdateStrategy(
|
||||
IUpdateStrategy<IForceAction> forceActionUpdateStrategy,
|
||||
IUpdateStrategy<IDesignForcePair> forcePairUpdateStrategy,
|
||||
IUpdateStrategy<IForceCombinationByFactor> factorUpdateStrategy,
|
||||
IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy)
|
||||
{
|
||||
this.forceActionUpdateStrategy = forceActionUpdateStrategy;
|
||||
this.forcePairUpdateStrategy = forcePairUpdateStrategy;
|
||||
this.factorUpdateStrategy = factorUpdateStrategy;
|
||||
this.forceListUpdateStrategy = forceListUpdateStrategy;
|
||||
}
|
||||
|
||||
public ForceActionUpdateStrategy() : this(
|
||||
new ForceActionBaseUpdateStrategy(),
|
||||
new ForcePairUpdateStrategy(),
|
||||
new ForceCombinationByFactorUpdateStrategy(),
|
||||
new ForceCombinationListUpdateStrategy()
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IForceAction targetObject, IForceAction sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.SetInGravityCenter = sourceObject.SetInGravityCenter;
|
||||
pointStrategy.Update(targetObject.ForcePoint, sourceObject.ForcePoint);
|
||||
forceActionUpdateStrategy.Update(targetObject, sourceObject);
|
||||
UpdateChildProperties(targetObject, sourceObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,20 +8,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class FactorCombinationUpdateStrategy : IUpdateStrategy<IForceCombinationByFactor>
|
||||
public class ForceCombinationByFactorUpdateStrategy : IUpdateStrategy<IForceCombinationByFactor>
|
||||
{
|
||||
private IUpdateStrategy<IForceTuple> tupleUpdateStrategy;
|
||||
public FactorCombinationUpdateStrategy(IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
|
||||
public ForceCombinationByFactorUpdateStrategy(IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
|
||||
{
|
||||
this.tupleUpdateStrategy = tupleUpdateStrategy;
|
||||
}
|
||||
public FactorCombinationUpdateStrategy() : this(new ForceTupleUpdateStrategy())
|
||||
public ForceCombinationByFactorUpdateStrategy() : this(new ForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
public void Update(IForceCombinationByFactor targetObject, IForceCombinationByFactor sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
tupleUpdateStrategy.Update(targetObject.FullSLSForces, sourceObject.FullSLSForces);
|
||||
targetObject.ULSFactor = sourceObject.ULSFactor;
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,10 +11,22 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ForceCombinationListUpdateStrategy : IUpdateStrategy<IForceCombinationList>
|
||||
{
|
||||
private IUpdateStrategy<IDesignForceTuple> designForceTupleUpdateStrategy;
|
||||
|
||||
public ForceCombinationListUpdateStrategy(IUpdateStrategy<IDesignForceTuple> designForceTupleUpdateStrategy)
|
||||
{
|
||||
this.designForceTupleUpdateStrategy = designForceTupleUpdateStrategy;
|
||||
}
|
||||
|
||||
public ForceCombinationListUpdateStrategy() : this (new DesignForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IForceCombinationList targetObject, IForceCombinationList sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.DesignForces.Clear();
|
||||
foreach (var item in sourceObject.DesignForces)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using System;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
@@ -8,6 +9,8 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> updateStrategy = new ForceTupleUpdateStrategy();
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
public double Mx { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public double My { get; set; }
|
||||
@@ -20,6 +23,16 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <inheritdoc/>
|
||||
public double Mz { get; set; }
|
||||
|
||||
public StrainTuple(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public StrainTuple() : this (Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Mx = 0d;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
public double Modulus { get; set; }
|
||||
public double CompressiveStrength { get; set; }
|
||||
public double TensileStrength { get; set; }
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = new();
|
||||
|
||||
public Guid Id { get; }
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
public double CompressiveStrength { get; set; }
|
||||
public double TensileStrength { get; set; }
|
||||
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = new();
|
||||
public double ULSConcreteStrength { get; set; }
|
||||
public double SumThickness { get; set; }
|
||||
public double GammaF2 => GetGammaF2();
|
||||
|
||||
@@ -12,6 +12,5 @@ namespace StructureHelperLogics.Models.Materials
|
||||
double Modulus { get; set; }
|
||||
double CompressiveStrength { get; set; }
|
||||
double TensileStrength { get; set; }
|
||||
List<IMaterialSafetyFactor> SafetyFactors { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,5 +13,6 @@ namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
|
||||
IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
|
||||
List<IMaterialSafetyFactor> SafetyFactors { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace StructureHelperLogics.Models.Materials
|
||||
public interface ILibMaterial : IHelperMaterial
|
||||
{
|
||||
ILibMaterialEntity MaterialEntity { get; set; }
|
||||
List<IMaterialSafetyFactor> SafetyFactors { get; set; }
|
||||
IMaterialLogic MaterialLogic { get; set; }
|
||||
List<IMaterialLogic> MaterialLogics { get; }
|
||||
(double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm);
|
||||
|
||||
@@ -9,11 +9,12 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal class ElasticUpdateStrategy : IUpdateStrategy<IElasticMaterial>
|
||||
public class ElasticUpdateStrategy : IUpdateStrategy<IElasticMaterial>
|
||||
{
|
||||
public void Update(IElasticMaterial targetObject, IElasticMaterial sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Modulus = sourceObject.Modulus;
|
||||
targetObject.CompressiveStrength = sourceObject.CompressiveStrength;
|
||||
|
||||
@@ -9,11 +9,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal class FRUpdateStrategy : IUpdateStrategy<IFRMaterial>
|
||||
/// <inheritdoc/>
|
||||
public class FRUpdateStrategy : IUpdateStrategy<IFRMaterial>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void Update(IFRMaterial targetObject, IFRMaterial sourceObject)
|
||||
{
|
||||
CheckObject.ReferenceEquals(targetObject, sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Modulus = sourceObject.Modulus;
|
||||
targetObject.CompressiveStrength = sourceObject.CompressiveStrength;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials.Logics
|
||||
{
|
||||
public class HelpermaterialSafetyFactorsUpdateStrategy : IUpdateStrategy<IHelperMaterial>
|
||||
{
|
||||
public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
if (sourceObject.SafetyFactors is not null)
|
||||
{
|
||||
if (targetObject.SafetyFactors is null)
|
||||
{
|
||||
targetObject.SafetyFactors = new();
|
||||
}
|
||||
targetObject.SafetyFactors.Clear();
|
||||
foreach (var item in sourceObject.SafetyFactors)
|
||||
{
|
||||
targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.Materials.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -15,6 +17,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
private IUpdateStrategy<IFRMaterial> frStrategy;
|
||||
private IUpdateStrategy<IConcreteLibMaterial> concreteStrategy;
|
||||
private IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelpermaterialSafetyFactorsUpdateStrategy();
|
||||
public HelperMaterialUpdateStrategy(IUpdateStrategy<IElasticMaterial> elasticStrategy,
|
||||
IUpdateStrategy<IFRMaterial> frStrategy,
|
||||
IUpdateStrategy<IConcreteLibMaterial> concreteStrategy,
|
||||
@@ -38,6 +41,8 @@ namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
safetyFactorUpdateStrategy.Update(targetObject, sourceObject);
|
||||
if (sourceObject is ILibMaterial)
|
||||
{
|
||||
UpdateLibMaterial(targetObject, sourceObject);
|
||||
|
||||
@@ -17,18 +17,6 @@ namespace StructureHelperLogics.Models.Materials
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.MaterialEntity = sourceObject.MaterialEntity;
|
||||
if (sourceObject.SafetyFactors is not null)
|
||||
{
|
||||
if (targetObject.SafetyFactors is null)
|
||||
{
|
||||
targetObject.SafetyFactors = new();
|
||||
}
|
||||
targetObject.SafetyFactors.Clear();
|
||||
foreach (var item in sourceObject.SafetyFactors)
|
||||
{
|
||||
targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor);
|
||||
}
|
||||
}
|
||||
targetObject.MaterialLogic = sourceObject.MaterialLogic;
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
var diameter = template.Shape.Diameter;
|
||||
var concreteMaterial = HeadMaterials.ToList()[0];
|
||||
var primitives = new List<INdmPrimitive>();
|
||||
concreteBlock = new EllipsePrimitive() { DiameterByX = diameter, Name = "Concrete block"};
|
||||
concreteBlock = new EllipsePrimitive() { Width = diameter, Name = "Concrete block"};
|
||||
concreteBlock.NdmElement.HeadMaterial = concreteMaterial;
|
||||
primitives.Add(concreteBlock);
|
||||
return primitives;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
/// <inheritdoc/>
|
||||
public IVisualProperty VisualProperty { get; } = new VisualProperty { Opacity = 0.8d };
|
||||
/// <inheritdoc/>
|
||||
public double DiameterByX
|
||||
public double Width
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -36,7 +36,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
}
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public double DiameterByY { get => rectangleShape.Height; set => rectangleShape.Height = value; }
|
||||
public double Height { get => rectangleShape.Height; set => rectangleShape.Height = value; }
|
||||
/// <inheritdoc/>
|
||||
public ICrossSection? CrossSection { get; set; }
|
||||
/// <inheritdoc/>
|
||||
@@ -46,6 +46,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
/// <inheritdoc/>
|
||||
public IShape Shape => rectangleShape;
|
||||
|
||||
public double Angle { get; set; }
|
||||
|
||||
public EllipsePrimitive(Guid id)
|
||||
{
|
||||
@@ -78,7 +79,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
var dX = Center.X - point.X;
|
||||
var dY = Center.Y - point.Y;
|
||||
var distance = Math.Sqrt(dX * dX + dY * dY);
|
||||
if (distance > DiameterByX / 2) { return false; }
|
||||
if (distance > Width / 2) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -96,28 +97,28 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
Name = "Left",
|
||||
Point = new Point2D() { X = Center.X - DiameterByX / 2d, Y = Center.Y},
|
||||
Point = new Point2D() { X = Center.X - Width / 2d, Y = Center.Y},
|
||||
Area = 0d
|
||||
};
|
||||
points.Add(newPoint);
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
Name = "Top",
|
||||
Point = new Point2D() { X = Center.X, Y = Center.Y + DiameterByX / 2d },
|
||||
Point = new Point2D() { X = Center.X, Y = Center.Y + Width / 2d },
|
||||
Area = 0d
|
||||
};
|
||||
points.Add(newPoint);
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
Name = "Right",
|
||||
Point = new Point2D() { X = Center.X + DiameterByX / 2d, Y = Center.Y },
|
||||
Point = new Point2D() { X = Center.X + Width / 2d, Y = Center.Y },
|
||||
Area = 0d
|
||||
};
|
||||
points.Add(newPoint);
|
||||
newPoint = new NamedAreaPoint
|
||||
{
|
||||
Name = "Bottom",
|
||||
Point = new Point2D() { X = Center.X, Y = Center.Y - DiameterByX / 2d },
|
||||
Point = new Point2D() { X = Center.X, Y = Center.Y - Width / 2d },
|
||||
Area = 0d
|
||||
};
|
||||
points.Add(newPoint);
|
||||
|
||||
@@ -7,10 +7,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public interface IEllipsePrimitive : INdmPrimitive, IHasDivisionSize
|
||||
public interface IEllipsePrimitive : INdmPrimitive, IHasDivisionSize, IRectangleShape
|
||||
{
|
||||
double DiameterByX { get; set; }
|
||||
double DiameterByY { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
Center = primitive.Center.Clone() as Point2D;
|
||||
//to do change to ellipse
|
||||
Circle = new CircleShape() { Diameter = primitive.DiameterByX };
|
||||
Circle = new CircleShape() { Diameter = primitive.Width };
|
||||
NdmMaxSize = primitive.DivisionSize.NdmMaxSize;
|
||||
NdmMinDivision = primitive.DivisionSize.NdmMinDivision;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
mainBlock.VisualProperty.ZIndex = 0;
|
||||
var opening = new EllipsePrimitive()
|
||||
{
|
||||
DiameterByX = 0.3d
|
||||
Width = 0.3d
|
||||
};
|
||||
opening.DivisionSize.ClearUnderlying = true;
|
||||
opening.NdmElement.HeadMaterial = material;
|
||||
@@ -155,7 +155,7 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
//Arrange
|
||||
ProgramSetting.NatSystem = NatSystems.RU;
|
||||
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
|
||||
var mainBlock = new EllipsePrimitive() { DiameterByX = diameter};
|
||||
var mainBlock = new EllipsePrimitive() { Width = diameter};
|
||||
mainBlock.NdmElement.HeadMaterial = material;
|
||||
mainBlock.Center.X = centerX;
|
||||
mainBlock.Center.Y = centerY;
|
||||
|
||||
Reference in New Issue
Block a user