Add materials converting from DTOs
This commit is contained in:
@@ -16,17 +16,32 @@ namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class AnalysisFromDTOConvertStrategy : IConvertStrategy<IAnalysis, IAnalysis>
|
||||
{
|
||||
private const string Message = "Analysis type is";
|
||||
private IConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis> convertCrossSectionNdmAnalysisStrategy = new CrossSectionNdmAnalysisFromDTOConvertStrategy();
|
||||
private const string AnalysisIs = "Analysis type is";
|
||||
|
||||
private IConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis> convertCrossSectionNdmAnalysisStrategy;
|
||||
private IConvertStrategy<IVersionProcessor, IVersionProcessor> versionProcessorConvertStrategy;
|
||||
|
||||
public AnalysisFromDTOConvertStrategy(IConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis> convertCrossSectionNdmAnalysisStrategy,
|
||||
IConvertStrategy<IVersionProcessor, IVersionProcessor> versionProcessorConvertStrategy)
|
||||
{
|
||||
this.convertCrossSectionNdmAnalysisStrategy = convertCrossSectionNdmAnalysisStrategy;
|
||||
this.versionProcessorConvertStrategy = versionProcessorConvertStrategy;
|
||||
}
|
||||
|
||||
public AnalysisFromDTOConvertStrategy() : this (new CrossSectionNdmAnalysisFromDTOConvertStrategy(),
|
||||
new VersionProcessorFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public IAnalysis Convert(IAnalysis source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
Check();
|
||||
IAnalysis analysis = GetAnalysis(source);
|
||||
return analysis;
|
||||
}
|
||||
@@ -41,10 +56,10 @@ namespace DataAccess.DTOs.Converters
|
||||
|
||||
private IAnalysis GetAnalysis(IAnalysis source)
|
||||
{
|
||||
IAnalysis analysis;
|
||||
IAnalysis newItem;
|
||||
if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
||||
{
|
||||
analysis = GetCrossSectionNdmAnalysis(crossSectionNdmAnalysis);
|
||||
newItem = GetCrossSectionNdmAnalysis(crossSectionNdmAnalysis);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -52,21 +67,29 @@ namespace DataAccess.DTOs.Converters
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
foreach (var item in source.VersionProcessor.Versions)
|
||||
{
|
||||
//to do
|
||||
newItem.VersionProcessor = GetVersionProcessor(source.VersionProcessor);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
return analysis;
|
||||
private IVersionProcessor GetVersionProcessor(IVersionProcessor source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Version processor converting is started", TraceLogStatuses.Service);
|
||||
versionProcessorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
versionProcessorConvertStrategy.TraceLogger = TraceLogger;
|
||||
IVersionProcessor versionProcessor = versionProcessorConvertStrategy.Convert(source);
|
||||
TraceLogger?.AddMessage("Version processor converting has been finished succesfully", TraceLogStatuses.Service);
|
||||
return versionProcessor;
|
||||
}
|
||||
|
||||
private ICrossSectionNdmAnalysis GetCrossSectionNdmAnalysis(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section Ndm Analysis", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting is started", TraceLogStatuses.Service);
|
||||
convertCrossSectionNdmAnalysisStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertCrossSectionNdmAnalysisStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>(this, convertCrossSectionNdmAnalysisStrategy);
|
||||
ICrossSectionNdmAnalysis crossSectionNdmAnalysis = convertLogic.Convert(source);
|
||||
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been finished succesfully", TraceLogStatuses.Service);
|
||||
return crossSectionNdmAnalysis;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
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 ConcreteLibMaterialFromDTOConvertStrategy : ConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO>
|
||||
{
|
||||
private readonly IUpdateStrategy<IConcreteLibMaterial> updateStrategy;
|
||||
|
||||
public ConcreteLibMaterialFromDTOConvertStrategy(IUpdateStrategy<IConcreteLibMaterial> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ConcreteLibMaterialFromDTOConvertStrategy() : this (new ConcreteLibUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ConcreteLibMaterial GetNewItem(ConcreteLibMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Concrete library material converting is started", TraceLogStatuses.Service);
|
||||
ConcreteLibMaterial newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("Concrete library material converting has been finished succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
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
|
||||
{
|
||||
public class CrossSectionFromDTOConvertStrategy : IConvertStrategy<ICrossSection, ICrossSection>
|
||||
{
|
||||
private readonly IConvertStrategy<ICrossSectionRepository, ICrossSectionRepository> convertStrategy;
|
||||
|
||||
public CrossSectionFromDTOConvertStrategy(IConvertStrategy<ICrossSectionRepository, ICrossSectionRepository> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionFromDTOConvertStrategy() : this (new CrossSectionRepositoryFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ICrossSection Convert(ICrossSection source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
return GetNewCrossSection(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ICrossSection GetNewCrossSection(ICrossSection source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Cross-Section converting is started", TraceLogStatuses.Service);
|
||||
CrossSection newItem = new(source.Id);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
newItem.SectionRepository = GetNewCrossSectionRepository(source.SectionRepository);
|
||||
TraceLogger?.AddMessage("Cross-Section converting has been finished succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private ICrossSectionRepository GetNewCrossSectionRepository(ICrossSectionRepository source)
|
||||
{
|
||||
ICrossSectionRepository newItem = convertStrategy.Convert(source);
|
||||
TraceLogger?.AddMessage($"Object of type <<{newItem.GetType()}>> was obtained", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ICrossSection, ICrossSection>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
@@ -13,7 +14,18 @@ namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class CrossSectionNdmAnalysisFromDTOConvertStrategy : IConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>
|
||||
{
|
||||
private IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy = new CrossSectionNdmAnalysisUpdateStrategy();
|
||||
private IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy;
|
||||
|
||||
public CrossSectionNdmAnalysisFromDTOConvertStrategy(IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionNdmAnalysisFromDTOConvertStrategy() : this(new CrossSectionNdmAnalysisUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
@@ -21,7 +33,8 @@ namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
try
|
||||
{
|
||||
CrossSectionNdmAnalysis newItem = GetCrossSectinNDMAnalysis(source);
|
||||
Check();
|
||||
ICrossSectionNdmAnalysis newItem = GetCrossSectinNDMAnalysis(source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -33,11 +46,19 @@ namespace DataAccess.DTOs.Converters
|
||||
|
||||
}
|
||||
|
||||
private CrossSectionNdmAnalysis GetCrossSectinNDMAnalysis(ICrossSectionNdmAnalysis source)
|
||||
private ICrossSectionNdmAnalysis GetCrossSectinNDMAnalysis(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Cross-section sonverting is started");
|
||||
CrossSectionNdmAnalysis newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("Cross-section analysis was obtained succesfully");
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
using System;
|
||||
@@ -37,8 +38,23 @@ namespace DataAccess.DTOs.Converters
|
||||
}
|
||||
|
||||
public CrossSectionNdmAnalysisDTO Convert(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
return GetNewAnalysis(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private CrossSectionNdmAnalysisDTO GetNewAnalysis(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Cross-section ndm analysis converting is started", TraceLogStatuses.Debug);
|
||||
CrossSectionNdmAnalysisDTO newItem = new();
|
||||
newItem.Id = source.Id;
|
||||
updateStrategy.Update(newItem, source);
|
||||
@@ -50,7 +66,9 @@ namespace DataAccess.DTOs.Converters
|
||||
ConvertStrategy = convertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
TraceLogger?.AddMessage("Convert version processor is started", TraceLogStatuses.Service);
|
||||
newItem.VersionProcessor = convertLogic.Convert(source.VersionProcessor);
|
||||
TraceLogger?.AddMessage("Cross-section ndm analysis has been converted succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CrossSectionRepositoryFromDTOConvertStrategy : ConvertStrategy<ICrossSectionRepository, ICrossSectionRepository>
|
||||
{
|
||||
private const string convertStarted = " converting is started";
|
||||
private const string convertFinished = " converting has been finished succesfully";
|
||||
private CrossSectionRepository newRepository;
|
||||
|
||||
public override CrossSectionRepository GetNewItem(ICrossSectionRepository source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertStarted, TraceLogStatuses.Service);
|
||||
newRepository = new(source.Id);
|
||||
ProcessMaterials(source);
|
||||
ProcessActions(source);
|
||||
TraceLogger?.AddMessage("Cross-Section repository" + convertFinished, TraceLogStatuses.Service);
|
||||
return newRepository;
|
||||
}
|
||||
|
||||
private void ProcessActions(ICrossSectionRepository source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Actions"+ convertStarted, TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage("Actions" + convertFinished, TraceLogStatuses.Service);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void ProcessMaterials(IHasHeadMaterials source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Materials" + convertStarted, TraceLogStatuses.Service);
|
||||
var convertStrategy = new HeadMaterialFromDTOConvertStrategy
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var convertLogic = new DictionaryConvertStrategy<IHeadMaterial, IHeadMaterial>(this, convertStrategy);
|
||||
var updateStrategy = new HasMaterialFromDTOUpdateStrategy(convertLogic);
|
||||
updateStrategy.Update(newRepository, source);
|
||||
TraceLogger?.AddMessage("Materials" + convertFinished, TraceLogStatuses.Service);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
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 DateVersionFromDTOConvertStrategy : IConvertStrategy<IDateVersion, IDateVersion>
|
||||
{
|
||||
private IUpdateStrategy<IDateVersion> updateStrategy;
|
||||
private IConvertStrategy<ISaveable, ISaveable> convertStrategy;
|
||||
private DictionaryConvertStrategy<ISaveable, ISaveable> convertLogic;
|
||||
|
||||
public DateVersionFromDTOConvertStrategy(IUpdateStrategy<IDateVersion> updateStrategy,
|
||||
IConvertStrategy<ISaveable, ISaveable> convertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public DateVersionFromDTOConvertStrategy() : this (
|
||||
new DateVersionUpdateStrategy(),
|
||||
new VersionItemFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public IDateVersion Convert(IDateVersion source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
return GetDateVersion(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private DateVersion GetDateVersion(IDateVersion source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Date version converting is started", TraceLogStatuses.Service);
|
||||
DateVersion newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>(this, convertStrategy);
|
||||
newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion);
|
||||
TraceLogger?.AddMessage($"Date version date = {newItem.DateTime} converting has been finished", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<IDateVersion, IDateVersion>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
@@ -36,8 +37,23 @@ namespace DataAccess.DTOs
|
||||
}
|
||||
|
||||
public DateVersionDTO Convert(IDateVersion source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
return GetNewDateVersion(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private DateVersionDTO GetNewDateVersion(IDateVersion source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Date version converting is started", TraceLogStatuses.Debug);
|
||||
DateVersionDTO newItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
@@ -47,14 +63,13 @@ namespace DataAccess.DTOs
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>(this, convertStrategy);
|
||||
newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion);
|
||||
TraceLogger?.AddMessage("Date version converting has been finished", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<DateVersionDTO, IDateVersion>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
var checkLogic = new CheckConvertLogic<DateVersionDTO, IDateVersion>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DesignForceTupleFromDTOConvertStrategy : ConvertStrategy<DesignForceTuple, DesignForceTupleDTO>
|
||||
{
|
||||
private IUpdateStrategy<IDesignForceTuple> updateStrategy;
|
||||
private IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy;
|
||||
|
||||
public DesignForceTupleFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IDesignForceTuple> updateStrategy,
|
||||
IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
|
||||
}
|
||||
|
||||
public DesignForceTupleFromDTOConvertStrategy() : this(
|
||||
new DesignForceTupleUpdateStrategy(),
|
||||
new ForceTupleFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override DesignForceTuple GetNewItem(DesignForceTupleDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Design force tuple converting is started");
|
||||
DesignForceTuple newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceTupleConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ForceTuple, ForceTupleDTO>(this, forceTupleConvertStrategy);
|
||||
newItem.ForceTuple = convertLogic.Convert((ForceTupleDTO)source.ForceTuple);
|
||||
TraceLogger?.AddMessage("Design force tuple converting has been finished");
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,8 @@ namespace DataAccess.DTOs.Converters
|
||||
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
|
||||
}
|
||||
|
||||
public DesignForceTupleToDTOConvertStrategy() : this(new DesignForceTupleUpdateStrategy(),
|
||||
public DesignForceTupleToDTOConvertStrategy() : this(
|
||||
new DesignForceTupleUpdateStrategy(),
|
||||
new ForceTupleToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
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 ElasticMaterialFromDTOConvertStrategy : ConvertStrategy<ElasticMaterial, ElasticMaterialDTO>
|
||||
{
|
||||
private readonly IUpdateStrategy<IElasticMaterial> updateStrategy;
|
||||
|
||||
public ElasticMaterialFromDTOConvertStrategy(IUpdateStrategy<IElasticMaterial> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ElasticMaterialFromDTOConvertStrategy() : this (new ElasticUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ElasticMaterial GetNewItem(ElasticMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Elastic material converting is started", TraceLogStatuses.Service);
|
||||
ElasticMaterial newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("Elastic material converting has been finished succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
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 FRMaterialFromDTOConvertStrategy : ConvertStrategy<FRMaterial, FRMaterialDTO>
|
||||
{
|
||||
private IUpdateStrategy<IFRMaterial> updateStrategy;
|
||||
|
||||
public FRMaterialFromDTOConvertStrategy(IUpdateStrategy<IFRMaterial> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public FRMaterialFromDTOConvertStrategy() : this(new FRUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override FRMaterial GetNewItem(FRMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Fiber reinforcement material converting is started", TraceLogStatuses.Service);
|
||||
FRMaterial newItem = new(source.MaterialType, source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("FiberReinforcement material converting has been finished succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using StructureHelperCommon.Models.Loggers;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class ForceActionToDTOConvertStrategy : IConvertStrategy<IForceAction, IForceAction>
|
||||
public class ForceActionToDTOConvertStrategy : ConvertStrategy<IForceAction, IForceAction>
|
||||
{
|
||||
private IConvertStrategy<ForceCombinationByFactorDTO, IForceCombinationByFactor> forceCombinationByFactorConvertStrategy;
|
||||
private IConvertStrategy<ForceCombinationListDTO, IForceCombinationList> forceCombinationListConvertStrategy;
|
||||
@@ -26,24 +26,7 @@ namespace DataAccess.DTOs.Converters
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public IForceAction Convert(IForceAction source)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ProcessForceAction(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private IForceAction ProcessForceAction(IForceAction source)
|
||||
public override IForceAction GetNewItem(IForceAction source)
|
||||
{
|
||||
if (source is IForceCombinationByFactor forceCombinationByFactor)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceActionsFromDTOConvertStrategy : ConvertStrategy<IForceAction, IForceAction>
|
||||
{
|
||||
private IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy;
|
||||
private IConvertStrategy<ForceCombinationByFactor, ForceCombinationByFactorDTO> factorConvertStrategy;
|
||||
|
||||
public ForceActionsFromDTOConvertStrategy(
|
||||
IConvertStrategy<ForceCombinationList, ForceCombinationListDTO> listConvertStrategy,
|
||||
IConvertStrategy<ForceCombinationByFactor, ForceCombinationByFactorDTO> factorConvertStrategy)
|
||||
{
|
||||
this.listConvertStrategy = listConvertStrategy;
|
||||
this.factorConvertStrategy = factorConvertStrategy;
|
||||
}
|
||||
|
||||
public ForceActionsFromDTOConvertStrategy() : this (
|
||||
new ForceCombinationListFromDTOConvertStrategy(),
|
||||
new ForceCombinationByFactorFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override IForceAction GetNewItem(IForceAction source)
|
||||
{
|
||||
if (source is ForceCombinationByFactorDTO combination)
|
||||
{
|
||||
return GetForceCombination(combination);
|
||||
}
|
||||
if (source is ForceCombinationListDTO forceList)
|
||||
{
|
||||
return GetForceList(forceList);
|
||||
}
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
|
||||
private IForceAction GetForceCombination(ForceCombinationByFactorDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force action is combination by factors");
|
||||
factorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
factorConvertStrategy.TraceLogger = TraceLogger;
|
||||
ForceCombinationByFactor newItem = factorConvertStrategy.Convert(source);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IForceAction GetForceList(ForceCombinationListDTO forceList)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force action is combination by list");
|
||||
listConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
listConvertStrategy.TraceLogger = TraceLogger;
|
||||
ForceCombinationList newItem = listConvertStrategy.Convert(forceList);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceCombinationByFactorFromDTOConvertStrategy : ConvertStrategy<ForceCombinationByFactor, ForceCombinationByFactorDTO>
|
||||
{
|
||||
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
|
||||
private IUpdateStrategy<IForceCombinationByFactor> updateStrategy;
|
||||
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
|
||||
private IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy;
|
||||
|
||||
public ForceCombinationByFactorFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IForceAction> baseUpdateStrategy,
|
||||
IUpdateStrategy<IForceCombinationByFactor> updateStrategy,
|
||||
IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy,
|
||||
IConvertStrategy<ForceTuple, ForceTupleDTO> forceTupleConvertStrategy)
|
||||
{
|
||||
this.baseUpdateStrategy = baseUpdateStrategy;
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.pointConvertStrategy = pointConvertStrategy;
|
||||
this.forceTupleConvertStrategy = forceTupleConvertStrategy;
|
||||
}
|
||||
|
||||
public ForceCombinationByFactorFromDTOConvertStrategy() : this(
|
||||
new ForceActionBaseUpdateStrategy(),
|
||||
new ForceCombinationByFactorUpdateStrategy(),
|
||||
new Point2DFromDTOConvertStrategy(),
|
||||
new ForceTupleFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ForceCombinationByFactor GetNewItem(ForceCombinationByFactorDTO source)
|
||||
{
|
||||
TraceLogger.AddMessage($"Force combination by factor name = {source.Name} is starting");
|
||||
ForceCombinationByFactor newItem = new(source.Id);
|
||||
baseUpdateStrategy.Update(newItem, source);
|
||||
updateStrategy.Update(newItem, source);
|
||||
pointConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
pointConvertStrategy.TraceLogger = TraceLogger;
|
||||
newItem.ForcePoint = pointConvertStrategy.Convert((Point2DDTO)source.ForcePoint);
|
||||
forceTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
forceTupleConvertStrategy.TraceLogger = TraceLogger;
|
||||
newItem.FullSLSForces = forceTupleConvertStrategy.Convert((ForceTupleDTO)source.FullSLSForces);
|
||||
TraceLogger.AddMessage($"Force combination by factor name = {newItem.Name} has been finished");
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceCombinationListFromDTOConvertStrategy : ConvertStrategy<ForceCombinationList, ForceCombinationListDTO>
|
||||
{
|
||||
private IUpdateStrategy<IForceAction> baseUpdateStrategy;
|
||||
private IUpdateStrategy<IForceCombinationList> updateStrategy;
|
||||
private IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy;
|
||||
private IConvertStrategy<DesignForceTuple, DesignForceTupleDTO> designTupleConvertStrategy;
|
||||
|
||||
public ForceCombinationListFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IForceAction> baseUpdateStrategy,
|
||||
IUpdateStrategy<IForceCombinationList> updateStrategy,
|
||||
IConvertStrategy<Point2D, Point2DDTO> pointConvertStrategy,
|
||||
IConvertStrategy<DesignForceTuple, DesignForceTupleDTO> designTupleConvertStrategy)
|
||||
{
|
||||
this.baseUpdateStrategy = baseUpdateStrategy;
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.pointConvertStrategy = pointConvertStrategy;
|
||||
this.designTupleConvertStrategy = designTupleConvertStrategy;
|
||||
}
|
||||
|
||||
public ForceCombinationListFromDTOConvertStrategy() : this(
|
||||
new ForceActionBaseUpdateStrategy(),
|
||||
new ForceCombinationListUpdateStrategy(),
|
||||
new Point2DFromDTOConvertStrategy(),
|
||||
new DesignForceTupleFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ForceCombinationList GetNewItem(ForceCombinationListDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Force combination list name = {source.Name} is starting");
|
||||
ForceCombinationList newItem = new(source.Id);
|
||||
baseUpdateStrategy.Update(newItem, source);
|
||||
updateStrategy.Update(newItem, source);
|
||||
pointConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
pointConvertStrategy.TraceLogger = TraceLogger;
|
||||
newItem.ForcePoint = pointConvertStrategy.Convert((Point2DDTO)source.ForcePoint);
|
||||
designTupleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
designTupleConvertStrategy.TraceLogger = TraceLogger;
|
||||
foreach (var item in source.DesignForces)
|
||||
{
|
||||
DesignForceTuple newDesignTuple = designTupleConvertStrategy.Convert((DesignForceTupleDTO)item);
|
||||
newItem.DesignForces.Add(newDesignTuple);
|
||||
}
|
||||
TraceLogger?.AddMessage($"Force combination list name = {newItem.Name} has been finished succesfully");
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 ForceTupleFromDTOConvertStrategy : ConvertStrategy<ForceTuple, ForceTupleDTO>
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> updateStrategy;
|
||||
|
||||
public ForceTupleFromDTOConvertStrategy(IUpdateStrategy<IForceTuple> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ForceTupleFromDTOConvertStrategy() : this(new ForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ForceTuple GetNewItem(ForceTupleDTO source)
|
||||
{
|
||||
ForceTuple newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ForceTupleToDTOConvertStrategy : IConvertStrategy<ForceTupleDTO, IForceTuple>
|
||||
public class ForceTupleToDTOConvertStrategy : ConvertStrategy<ForceTupleDTO, IForceTuple>
|
||||
{
|
||||
private IUpdateStrategy<IForceTuple> updateStrategy;
|
||||
|
||||
@@ -27,27 +27,11 @@ namespace DataAccess.DTOs
|
||||
|
||||
}
|
||||
|
||||
public ForceTupleDTO Convert(IForceTuple source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
public override ForceTupleDTO GetNewItem(IForceTuple source)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//Copyright (c) 2024 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates copies of materials from source and adds them into target material list
|
||||
/// </summary>
|
||||
public class HasMaterialFromDTOUpdateStrategy : IUpdateStrategy<IHasHeadMaterials>
|
||||
{
|
||||
private readonly IConvertStrategy<IHeadMaterial, IHeadMaterial> convertStrategy;
|
||||
|
||||
public HasMaterialFromDTOUpdateStrategy(IConvertStrategy<IHeadMaterial, IHeadMaterial> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasHeadMaterials targetObject, IHasHeadMaterials sourceObject)
|
||||
{
|
||||
targetObject.HeadMaterials.Clear();
|
||||
foreach (var item in sourceObject.HeadMaterials)
|
||||
{
|
||||
var newItem = convertStrategy.Convert(item);
|
||||
targetObject.HeadMaterials.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HeadMaterialFromDTOConvertStrategy : ConvertStrategy<IHeadMaterial, IHeadMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IHeadMaterial> updateStrategy;
|
||||
private IConvertStrategy<IHelperMaterial, IHelperMaterial> helperMaterialConvertStrategy;
|
||||
|
||||
public HeadMaterialFromDTOConvertStrategy(
|
||||
IUpdateStrategy<IHeadMaterial> updateStrategy,
|
||||
IConvertStrategy<IHelperMaterial, IHelperMaterial> helperMaterialConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.helperMaterialConvertStrategy = helperMaterialConvertStrategy;
|
||||
}
|
||||
|
||||
public HeadMaterialFromDTOConvertStrategy() : this (
|
||||
new HeadMaterialBaseUpdateStrategy(),
|
||||
new HelperMaterialFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
public override IHeadMaterial GetNewItem(IHeadMaterial source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Head material converting is started", TraceLogStatuses.Service);
|
||||
HeadMaterial newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
IHelperMaterial helperMaterial = GetHelperMaterial(source.HelperMaterial);
|
||||
newItem.HelperMaterial = helperMaterial;
|
||||
//GlobalRepository
|
||||
TraceLogger?.AddMessage($"Head material Name = {newItem.Name} converting has been finished succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IHelperMaterial GetHelperMaterial(IHelperMaterial source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Helper material converting is started", TraceLogStatuses.Service);
|
||||
helperMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
helperMaterialConvertStrategy.TraceLogger = TraceLogger;
|
||||
IHelperMaterial newItem = helperMaterialConvertStrategy.Convert(source);
|
||||
TraceLogger?.AddMessage($"Object of type <<{newItem.GetType()}>> was obtained", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,13 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HelperMaterialDTOSafetyFactorUpdateStrategy : IUpdateStrategy<IHelperMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy;
|
||||
private IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy;
|
||||
private IMaterialSafetyFactorDTOLogic factorDTOLogic;
|
||||
|
||||
public HelperMaterialDTOSafetyFactorUpdateStrategy(
|
||||
IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy,
|
||||
@@ -23,11 +24,11 @@ namespace DataAccess.DTOs.Converters
|
||||
this.partialFactorUpdateStrategy = partialFactorUpdateStrategy;
|
||||
}
|
||||
|
||||
public HelperMaterialDTOSafetyFactorUpdateStrategy() : this(
|
||||
new MaterialSafetyFactorUpdateStrategy(),
|
||||
public HelperMaterialDTOSafetyFactorUpdateStrategy(IMaterialSafetyFactorDTOLogic factorDTOLogic) : this(
|
||||
new MaterialSafetyFactorBaseUpdateStrategy(),
|
||||
new MaterialPartialFactorUpdateStrategy())
|
||||
{
|
||||
|
||||
this.factorDTOLogic = factorDTOLogic;
|
||||
}
|
||||
|
||||
public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||
@@ -40,35 +41,29 @@ namespace DataAccess.DTOs.Converters
|
||||
targetObject.SafetyFactors.Clear();
|
||||
foreach (var safetyFactor in sourceObject.SafetyFactors)
|
||||
{
|
||||
MaterialSafetyFactorDTO newSafetyFactor = GetNewSafetyFactorByOld(safetyFactor);
|
||||
IMaterialSafetyFactor newSafetyFactor = GetNewSafetyFactorByOld(safetyFactor);
|
||||
targetObject.SafetyFactors.Add(newSafetyFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MaterialSafetyFactorDTO GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor)
|
||||
private IMaterialSafetyFactor GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor)
|
||||
{
|
||||
MaterialSafetyFactorDTO newSafetyFactor = new()
|
||||
{
|
||||
Id = safetyFactor.Id
|
||||
};
|
||||
IMaterialSafetyFactor newSafetyFactor = factorDTOLogic.GetNewSafetyFactorByOld(safetyFactor);
|
||||
safetyFactorUpdateStrategy.Update(newSafetyFactor, safetyFactor);
|
||||
newSafetyFactor.PartialFactors.Clear();
|
||||
foreach (var partialFactor in safetyFactor.PartialFactors)
|
||||
{
|
||||
MaterialPartialFactorDTO newPartialFactor = GetNewPartialFactorByOld(partialFactor);
|
||||
IMaterialPartialFactor newPartialFactor = GetNewPartialFactorByOld(partialFactor);
|
||||
newSafetyFactor.PartialFactors.Add(newPartialFactor);
|
||||
}
|
||||
|
||||
return newSafetyFactor;
|
||||
}
|
||||
|
||||
private MaterialPartialFactorDTO GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor)
|
||||
private IMaterialPartialFactor GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor)
|
||||
{
|
||||
MaterialPartialFactorDTO newPartialFactor = new()
|
||||
{
|
||||
Id = partialFactor.Id
|
||||
};
|
||||
IMaterialPartialFactor newPartialFactor = factorDTOLogic.GetNewPartialFactorByOld(partialFactor);
|
||||
partialFactorUpdateStrategy.Update(newPartialFactor, partialFactor);
|
||||
return newPartialFactor;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HelperMaterialFromDTOConvertStrategy : ConvertStrategy<IHelperMaterial, IHelperMaterial>
|
||||
{
|
||||
const string MaterialIs = "Material type is: ";
|
||||
private IConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO> concreteConvertStrategy;
|
||||
private IConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO> reinforcementConvertStrategy;
|
||||
private IConvertStrategy<ElasticMaterial, ElasticMaterialDTO> elasticConvertStrategy;
|
||||
private IConvertStrategy<FRMaterial, FRMaterialDTO> frConvertStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorsFromDTOLogic());
|
||||
|
||||
public HelperMaterialFromDTOConvertStrategy() : this(
|
||||
new ConcreteLibMaterialFromDTOConvertStrategy(),
|
||||
new ReinforcementLibMaterialFromDTOConvertStrategy(),
|
||||
new ElasticMaterialFromDTOConvertStrategy(),
|
||||
new FRMaterialFromDTOConvertStrategy()
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public HelperMaterialFromDTOConvertStrategy(
|
||||
IConvertStrategy<ConcreteLibMaterial, ConcreteLibMaterialDTO> concreteConvertStrategy,
|
||||
IConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO> reinforcementConvertStrategy,
|
||||
IConvertStrategy<ElasticMaterial, ElasticMaterialDTO> elasticConvertStrategy,
|
||||
IConvertStrategy<FRMaterial, FRMaterialDTO> frConvertStrategy)
|
||||
{
|
||||
this.concreteConvertStrategy = concreteConvertStrategy;
|
||||
this.reinforcementConvertStrategy = reinforcementConvertStrategy;
|
||||
this.elasticConvertStrategy = elasticConvertStrategy;
|
||||
this.frConvertStrategy = frConvertStrategy;
|
||||
}
|
||||
|
||||
public override IHelperMaterial GetNewItem(IHelperMaterial source)
|
||||
{
|
||||
if (source is ConcreteLibMaterialDTO concrete)
|
||||
{
|
||||
return GetConcreteMaterial(concrete);
|
||||
}
|
||||
else if (source is ReinforcementLibMaterialDTO reinforcement)
|
||||
{
|
||||
return GetReinforcementMaterial(reinforcement);
|
||||
}
|
||||
else if (source is FRMaterialDTO frMaterial)
|
||||
{
|
||||
return GetFRMaterial(frMaterial);
|
||||
}
|
||||
else if (source is ElasticMaterialDTO elastic)
|
||||
{
|
||||
return GetElasticMaterial(elastic);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source) + ": helper material type";
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
}
|
||||
|
||||
private IHelperMaterial GetElasticMaterial(ElasticMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage(MaterialIs + "Elastic material", TraceLogStatuses.Service);
|
||||
reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
reinforcementConvertStrategy.TraceLogger = TraceLogger;
|
||||
var newItem = elasticConvertStrategy.Convert(source);
|
||||
safetyFactorUpdateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IHelperMaterial GetFRMaterial(FRMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage(MaterialIs + "Fiber reinforcement material", TraceLogStatuses.Service);
|
||||
reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
reinforcementConvertStrategy.TraceLogger = TraceLogger;
|
||||
var newItem = frConvertStrategy.Convert(source);
|
||||
safetyFactorUpdateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IHelperMaterial GetReinforcementMaterial(ReinforcementLibMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage(MaterialIs + "Reinforcement library material", TraceLogStatuses.Service);
|
||||
reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
reinforcementConvertStrategy.TraceLogger = TraceLogger;
|
||||
var newItem = reinforcementConvertStrategy.Convert(source);
|
||||
safetyFactorUpdateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private IHelperMaterial GetConcreteMaterial(ConcreteLibMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage(MaterialIs + "Concrete library material", TraceLogStatuses.Service);
|
||||
concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
concreteConvertStrategy.TraceLogger = TraceLogger;
|
||||
var newItem = concreteConvertStrategy.Convert(source);
|
||||
safetyFactorUpdateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace DataAccess.DTOs
|
||||
private LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy;
|
||||
private IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> elasticConvertStrategy;
|
||||
private IConvertStrategy<FRMaterialDTO, IFRMaterial> frMaterialConvertStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy();
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic());
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
10
DataAccess/DTOs/Converters/IMaterialSafetyFactorDTOLogic.cs
Normal file
10
DataAccess/DTOs/Converters/IMaterialSafetyFactorDTOLogic.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public interface IMaterialSafetyFactorDTOLogic
|
||||
{
|
||||
IMaterialPartialFactor GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor);
|
||||
IMaterialSafetyFactor GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor);
|
||||
}
|
||||
}
|
||||
30
DataAccess/DTOs/Converters/MaterialSafetyFactorToDTOLogic.cs
Normal file
30
DataAccess/DTOs/Converters/MaterialSafetyFactorToDTOLogic.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class MaterialSafetyFactorToDTOLogic : IMaterialSafetyFactorDTOLogic
|
||||
{
|
||||
public IMaterialSafetyFactor GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor)
|
||||
{
|
||||
MaterialSafetyFactorDTO newSafetyFactor = new()
|
||||
{
|
||||
Id = safetyFactor.Id
|
||||
};
|
||||
return newSafetyFactor;
|
||||
}
|
||||
|
||||
public IMaterialPartialFactor GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor)
|
||||
{
|
||||
MaterialPartialFactorDTO newPartialFactor = new()
|
||||
{
|
||||
Id = partialFactor.Id
|
||||
};
|
||||
return newPartialFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class MaterialSafetyFactorsFromDTOLogic : IMaterialSafetyFactorDTOLogic
|
||||
{
|
||||
public IMaterialSafetyFactor GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor)
|
||||
{
|
||||
MaterialSafetyFactor newItem = new(safetyFactor.Id);
|
||||
return newItem;
|
||||
}
|
||||
public IMaterialPartialFactor GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor)
|
||||
{
|
||||
MaterialPartialFactor newItem = new(partialFactor.Id);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class MaterialSafetyFactorToDTOConvertStrategy : IConvertStrategy<MaterialSafetyFactorDTO, IMaterialSafetyFactor>
|
||||
public class MaterialSafetyFactorsToDTOConvertStrategy : IConvertStrategy<MaterialSafetyFactorDTO, IMaterialSafetyFactor>
|
||||
{
|
||||
private IUpdateStrategy<IMaterialSafetyFactor> updateStrategy;
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public MaterialSafetyFactorToDTOConvertStrategy(IUpdateStrategy<IMaterialSafetyFactor> updateStrategy)
|
||||
public MaterialSafetyFactorsToDTOConvertStrategy(IUpdateStrategy<IMaterialSafetyFactor> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
34
DataAccess/DTOs/Converters/Point2DFromDTOConvertStrategy.cs
Normal file
34
DataAccess/DTOs/Converters/Point2DFromDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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 Point2DFromDTOConvertStrategy : ConvertStrategy<Point2D, Point2DDTO>
|
||||
{
|
||||
private IUpdateStrategy<IPoint2D> updateStrategy;
|
||||
|
||||
public Point2DFromDTOConvertStrategy(IUpdateStrategy<IPoint2D> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public Point2DFromDTOConvertStrategy() : this (new Point2DUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override Point2D GetNewItem(Point2DDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Point 2D converting is started");
|
||||
Point2D newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("Point 2D converting has been finished");
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,18 +48,28 @@ namespace DataAccess.DTOs
|
||||
|
||||
private Project GetProject(ProjectDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Converting of project is started", TraceLogStatuses.Service);
|
||||
Project newItem = new();
|
||||
updateStrategy.Update(newItem, source);
|
||||
visualAnalysisConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
visualAnalysisConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<IVisualAnalysis, IVisualAnalysis>(this, visualAnalysisConvertStrategy);
|
||||
newItem.VisualAnalyses.Clear();
|
||||
TraceLogger?.AddMessage($"Source project has {source.VisualAnalyses.Count()} analyses", TraceLogStatuses.Service);
|
||||
foreach (var item in source.VisualAnalyses)
|
||||
{
|
||||
var visualAnalysis = convertLogic.Convert(item);
|
||||
newItem.VisualAnalyses.Add(visualAnalysis);
|
||||
}
|
||||
TraceLogger?.AddMessage("Converting project has completed succesfully", TraceLogStatuses.Info);
|
||||
if (newItem.VisualAnalyses.Any())
|
||||
{
|
||||
TraceLogger?.AddMessage($"Totaly {newItem.VisualAnalyses.Count()} were(was) obtained", TraceLogStatuses.Service);
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceLogger?.AddMessage($"Project does not have any analyses", TraceLogStatuses.Warning);
|
||||
}
|
||||
TraceLogger?.AddMessage("Converting of project has completed succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
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 ReinforcementLibMaterialFromDTOConvertStrategy : ConvertStrategy<ReinforcementLibMaterial, ReinforcementLibMaterialDTO>
|
||||
{
|
||||
private readonly IUpdateStrategy<IReinforcementLibMaterial> updateStrategy;
|
||||
|
||||
public ReinforcementLibMaterialFromDTOConvertStrategy(IUpdateStrategy<IReinforcementLibMaterial> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ReinforcementLibMaterialFromDTOConvertStrategy() : this(new ReinforcementLibUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override ReinforcementLibMaterial GetNewItem(ReinforcementLibMaterialDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Reinforcement library material converting is started", TraceLogStatuses.Service);
|
||||
ReinforcementLibMaterial newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
TraceLogger?.AddMessage("Reinforcement library material converting has been finished succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class VersionItemFromDTOConvertStrategy : IConvertStrategy<ISaveable, ISaveable>
|
||||
{
|
||||
private const string AnalysisIs = "Analysis type is";
|
||||
private IConvertStrategy<ICrossSection, ICrossSection> crossSectionConvertStrategy;
|
||||
|
||||
public VersionItemFromDTOConvertStrategy(IConvertStrategy<ICrossSection, ICrossSection> crossSectionConvertStrategy)
|
||||
{
|
||||
this.crossSectionConvertStrategy = crossSectionConvertStrategy;
|
||||
}
|
||||
|
||||
public VersionItemFromDTOConvertStrategy() : this (new CrossSectionFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ISaveable Convert(ISaveable source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
return GetNewAnalysis(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ISaveable GetNewAnalysis(ISaveable source)
|
||||
{
|
||||
ISaveable newItem;
|
||||
if (source is ICrossSection crossSection)
|
||||
{
|
||||
newItem = ProcessCrossSection(crossSection);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
TraceLogger?.AddMessage($"Object of type <<{newItem.GetType()}>> was obtained", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private ICrossSection ProcessCrossSection(ICrossSection source)
|
||||
{
|
||||
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage("Cross-Section converting is started", TraceLogStatuses.Service);
|
||||
crossSectionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
crossSectionConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ICrossSection, ICrossSection>(this, crossSectionConvertStrategy);
|
||||
ICrossSection newItem = convertLogic.Convert(source);
|
||||
TraceLogger?.AddMessage("Cross-Section converting has been finished succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ISaveable, ISaveable>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,19 +14,33 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
public class VersionItemToDTOConvertStrategy : IConvertStrategy<ISaveable, ISaveable>
|
||||
{
|
||||
private const string Message = "Analysis type is";
|
||||
private const string AnalysisIs = "Analysis type is";
|
||||
private IConvertStrategy<CrossSectionDTO, ICrossSection> crossSectionConvertStrategy = new CrossSectionToDTOConvertStrategy();
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
|
||||
public ISaveable Convert(ISaveable source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
ISaveable saveable;
|
||||
return GetNewAnalysis(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ISaveable GetNewAnalysis(ISaveable source)
|
||||
{
|
||||
ISaveable newItem;
|
||||
if (source is ICrossSection crossSection)
|
||||
{
|
||||
saveable = ProcessCrossSection(crossSection);
|
||||
newItem = ProcessCrossSection(crossSection);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -33,12 +48,12 @@ namespace DataAccess.DTOs
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
return saveable;
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private ISaveable ProcessCrossSection(ICrossSection crossSection)
|
||||
{
|
||||
TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
||||
ISaveable saveable;
|
||||
crossSectionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
crossSectionConvertStrategy.TraceLogger = TraceLogger;
|
||||
@@ -54,9 +69,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ISaveable, ISaveable>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
var checkLogic = new CheckConvertLogic<ISaveable, ISaveable>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
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 VersionProcessorFromDTOConvertStrategy : IConvertStrategy<IVersionProcessor, IVersionProcessor>
|
||||
{
|
||||
private IConvertStrategy<IDateVersion, IDateVersion> dateVersionConvertStrategy;
|
||||
private ICheckConvertLogic<IVersionProcessor, IVersionProcessor> checkLogic;
|
||||
|
||||
public VersionProcessorFromDTOConvertStrategy(
|
||||
IConvertStrategy<IDateVersion, IDateVersion> dateVersionConvertStrategy)
|
||||
{
|
||||
this.dateVersionConvertStrategy = dateVersionConvertStrategy;
|
||||
this.checkLogic = checkLogic;
|
||||
}
|
||||
|
||||
public VersionProcessorFromDTOConvertStrategy() : this(new DateVersionFromDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public IVersionProcessor Convert(IVersionProcessor source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
IVersionProcessor versionProcessor = GetVersionProcessor(source);
|
||||
return versionProcessor;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private IVersionProcessor GetVersionProcessor(IVersionProcessor source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Version processor converting is started", TraceLogStatuses.Debug);
|
||||
IVersionProcessor newItem = new VersionProcessor(source.Id);
|
||||
TraceLogger?.AddMessage($"Source version processor has {source.Versions.Count} version(s)", TraceLogStatuses.Service);
|
||||
dateVersionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
dateVersionConvertStrategy.TraceLogger = TraceLogger;
|
||||
foreach (var item in source.Versions)
|
||||
{
|
||||
IDateVersion dateVersion = dateVersionConvertStrategy.Convert(item);
|
||||
newItem.Versions.Add(dateVersion);
|
||||
}
|
||||
TraceLogger?.AddMessage($"Totaly {newItem.Versions.Count} version(s) was(were) obtained", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage("Version processor has been converted succesfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<IVersionProcessor, IVersionProcessor>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("MaterialType")]
|
||||
public MaterialTypes MaterialType { get; set; } = MaterialTypes.CarbonFiber;
|
||||
[JsonProperty("ULSConcreteStrength")]
|
||||
public double ULSConcreteStrength { get; set; }
|
||||
[JsonProperty("SunThickness")]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,36 +0,0 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Repositories;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Services.Settings
|
||||
{
|
||||
internal static class GlobalRepository
|
||||
{
|
||||
private static IDataRepository<IHeadMaterial> materials;
|
||||
private static IDataRepository<IAction> actions;
|
||||
|
||||
public static IDataRepository<IHeadMaterial> Materials
|
||||
{
|
||||
get
|
||||
{
|
||||
materials ??= new ListRepository<IHeadMaterial>(new HeadMaterialUpdateStrategy());
|
||||
return materials;
|
||||
}
|
||||
}
|
||||
public static IDataRepository<IAction> Actions
|
||||
{
|
||||
get
|
||||
{
|
||||
actions ??= new ListRepository<IAction>(new ActionUpdateStrategy());
|
||||
return actions;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,7 @@
|
||||
<Folder Include="Documentation\Manuals\" />
|
||||
<Folder Include="Infrastructure\UI\DataContexts\Logics\" />
|
||||
<Folder Include="Resources\" />
|
||||
<Folder Include="Services\Settings\" />
|
||||
<Folder Include="Windows\UserControls\MultiplyTuples\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelper.Services.Settings;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.RCs.Beams;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
@@ -15,7 +14,6 @@ using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Templates.CrossSections.RCs;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
@@ -290,14 +288,14 @@ namespace StructureHelper.Windows.MainWindow
|
||||
CalculatorsLogic.AddItems(newRepository.Calculators);
|
||||
var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(newRepository.Primitives);
|
||||
PrimitiveLogic.Refresh();
|
||||
foreach (var item in newRepository.HeadMaterials)
|
||||
{
|
||||
GlobalRepository.Materials.Create(item);
|
||||
}
|
||||
foreach (var item in newRepository.ForceActions)
|
||||
{
|
||||
GlobalRepository.Actions.Create(item);
|
||||
}
|
||||
//foreach (var item in newRepository.HeadMaterials)
|
||||
//{
|
||||
// GlobalRepository.Materials.Create(item);
|
||||
//}
|
||||
//foreach (var item in newRepository.ForceActions)
|
||||
//{
|
||||
// GlobalRepository.Actions.Create(item);
|
||||
//}
|
||||
return primitives;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Services.Settings;
|
||||
using StructureHelper.Windows.Forces;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
@@ -31,7 +30,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
NewItem = new ForceCombinationByFactor() { Name = "New Factored Combination" };
|
||||
}
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $": Actual type: {nameof(paramType)}");
|
||||
GlobalRepository.Actions.Create(NewItem);
|
||||
//GlobalRepository.Actions.Create(NewItem);
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
}
|
||||
@@ -42,7 +41,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
if (DeleteAction() != true) return;
|
||||
GlobalRepository.Actions.Delete(SelectedItem.Id);
|
||||
//GlobalRepository.Actions.Delete(SelectedItem.Id);
|
||||
base.DeleteMethod(parameter);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +50,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
NewItem = SelectedItem.Clone() as IForceAction;
|
||||
NewItem.Name = $"{NewItem.Name} copy";
|
||||
GlobalRepository.Actions.Create(NewItem);
|
||||
//GlobalRepository.Actions.Create(NewItem);
|
||||
Collection.Add(NewItem);
|
||||
Items.Add(NewItem);
|
||||
SelectedItem = NewItem;
|
||||
@@ -59,7 +58,8 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
|
||||
public override void EditMethod(object parameter)
|
||||
{
|
||||
var copyObject = GlobalRepository.Actions.GetById(SelectedItem.Id).Clone() as IAction;
|
||||
//var copyObject = GlobalRepository.Actions.GetById(SelectedItem.Id).Clone() as IAction;
|
||||
var copyObject = SelectedItem.Clone() as IAction;
|
||||
System.Windows.Window wnd;
|
||||
if (SelectedItem is IForceCombinationList)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
{
|
||||
GlobalRepository.Actions.Update(SelectedItem);
|
||||
//GlobalRepository.Actions.Update(SelectedItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelper.Services.Settings;
|
||||
using StructureHelper.Windows.MainWindow.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
@@ -42,7 +41,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
else if (parameterType == MaterialType.CarbonFiber) { AddCarbonFiber(); }
|
||||
else if (parameterType == MaterialType.GlassFiber) { AddGlassFiber(); }
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)}, Actual type: {nameof(parameterType)}");
|
||||
GlobalRepository.Materials.Create(NewItem);
|
||||
//GlobalRepository.Materials.Create(NewItem);
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
public override void DeleteMethod(object parameter)
|
||||
@@ -58,18 +57,19 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
var dialogResult = MessageBox.Show("Delete material?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
GlobalRepository.Materials.Delete(SelectedItem.Id);
|
||||
//GlobalRepository.Materials.Delete(SelectedItem.Id);
|
||||
base.DeleteMethod(parameter);
|
||||
}
|
||||
}
|
||||
public override void EditMethod(object parameter)
|
||||
{
|
||||
var copyObject = GlobalRepository.Materials.GetById(SelectedItem.Id).Clone() as IHeadMaterial;
|
||||
//var copyObject = GlobalRepository.Materials.GetById(SelectedItem.Id).Clone() as IHeadMaterial;
|
||||
var copyObject = SelectedItem.Clone() as IHeadMaterial;
|
||||
var wnd = new HeadMaterialView(SelectedItem);
|
||||
wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
{
|
||||
GlobalRepository.Materials.Update(SelectedItem);
|
||||
//
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -82,7 +82,6 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
{
|
||||
NewItem = SelectedItem.Clone() as IHeadMaterial;
|
||||
NewItem.Name = $"{NewItem.Name} copy";
|
||||
GlobalRepository.Materials.Create(NewItem);
|
||||
Collection.Add(NewItem);
|
||||
Items.Add(NewItem);
|
||||
SelectedItem = NewItem;
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Services.Settings;
|
||||
using StructureHelper.Windows.PrimitiveProperiesWindow;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.RCs.Beams;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
|
||||
using StructureHelper.Windows.Services;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.Models.Templates.CrossSections.RCs;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
@@ -25,7 +18,7 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
|
||||
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//Copyright (c) 2024 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
{
|
||||
public enum MaterialTypes
|
||||
{
|
||||
Concrete,
|
||||
Reinforcement,
|
||||
//Steel,
|
||||
CarbonFiber,
|
||||
GlassFiber,
|
||||
Concrete = 0,
|
||||
Reinforcement = 1,
|
||||
Steel = 3,
|
||||
CarbonFiber = 4,
|
||||
GlassFiber = 5,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public abstract class ConvertStrategy<T, V> : IConvertStrategy<T, V>
|
||||
where T : ISaveable
|
||||
where V : ISaveable
|
||||
{
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public virtual T Convert(V source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
return GetNewItem(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract T GetNewItem(V source);
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<T,V>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,11 @@ using System.Windows.Media;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Find object in refernce dictionary, if it exists return existing object, else return new one by child logic
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of target object</typeparam>
|
||||
/// <typeparam name="V">Type of source object</typeparam>
|
||||
public class DictionaryConvertStrategy<T, V> : IConvertStrategy<T, V>
|
||||
where T : ISaveable
|
||||
where V : ISaveable
|
||||
|
||||
@@ -7,10 +7,20 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts object of type of ISaveable to another one
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Target object type</typeparam>
|
||||
/// <typeparam name="V">Source object type</typeparam>
|
||||
public interface IConvertStrategy<T,V> : IBaseConvertStrategy
|
||||
where T :ISaveable
|
||||
where V :ISaveable
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts object to another one
|
||||
/// </summary>
|
||||
/// <param name="source">Source object</param>
|
||||
/// <returns>Converted object</returns>
|
||||
T Convert(V source);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Repositories;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Settings
|
||||
{
|
||||
internal static class GlobalRepository
|
||||
{
|
||||
private static IDataRepository<IHeadMaterial> materials;
|
||||
private static IDataRepository<IAction> actions;
|
||||
|
||||
//public static IDataRepository<IHeadMaterial> Materials
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// materials ??= new ListRepository<IHeadMaterial>(new HeadMaterialUpdateStrategy());
|
||||
// return materials;
|
||||
// }
|
||||
//}
|
||||
//public static IDataRepository<IAction> Actions
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// actions ??= new ListRepository<IAction>(new ActionUpdateStrategy());
|
||||
// return actions;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,6 @@ namespace StructureHelperCommon.Models.Analyses
|
||||
{
|
||||
string Name { get; set; }
|
||||
string Tags { get; set; }
|
||||
IVersionProcessor VersionProcessor { get;}
|
||||
IVersionProcessor VersionProcessor { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <inheritdoc/>
|
||||
public IPoint2D ForcePoint { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public IForceTuple FullSLSForces { get; private set; }
|
||||
public IForceTuple FullSLSForces { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public double ULSFactor { get; set; }
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <inheritdoc/>
|
||||
public IPoint2D ForcePoint { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public List<IDesignForceTuple> DesignForces { get; private set; }
|
||||
public List<IDesignForceTuple> DesignForces { get; set; }
|
||||
|
||||
|
||||
public ForceCombinationList(Guid id)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public interface IForceCombinationByFactor : IForceAction
|
||||
{
|
||||
IForceTuple FullSLSForces { get; }
|
||||
IForceTuple FullSLSForces { get; set; }
|
||||
double ULSFactor { get; set; }
|
||||
double LongTermFactor { get; set; }
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public interface IForceCombinationList : IForceAction
|
||||
{
|
||||
List<IDesignForceTuple> DesignForces { get;}
|
||||
List<IDesignForceTuple> DesignForces { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
10
StructureHelperCommon/Models/Materials/IHasSafetyFactors.cs
Normal file
10
StructureHelperCommon/Models/Materials/IHasSafetyFactors.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public interface IHasSafetyFactors
|
||||
{
|
||||
List<IMaterialSafetyFactor> SafetyFactors { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelper.Models.Materials
|
||||
@@ -9,10 +9,9 @@ using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public interface IHelperMaterial : ISaveable, ICloneable
|
||||
public interface IHelperMaterial : ISaveable, ICloneable, IHasSafetyFactors
|
||||
{
|
||||
IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
|
||||
IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
|
||||
List<IMaterialSafetyFactor> SafetyFactors { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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.Materials.Libraries
|
||||
{
|
||||
public class MaterialSafetyFactorBaseUpdateStrategy : IUpdateStrategy<IMaterialSafetyFactor>
|
||||
{
|
||||
public void Update(IMaterialSafetyFactor targetObject, IMaterialSafetyFactor sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.Take = sourceObject.Take;
|
||||
targetObject.Description = sourceObject.Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,13 @@ namespace StructureHelperCommon.Models.Materials.Libraries
|
||||
{
|
||||
public class MaterialSafetyFactorUpdateStrategy : IUpdateStrategy<IMaterialSafetyFactor>
|
||||
{
|
||||
private IUpdateStrategy<IMaterialSafetyFactor> baseUpdateStrategy = new MaterialSafetyFactorBaseUpdateStrategy();
|
||||
public void Update(IMaterialSafetyFactor targetObject, IMaterialSafetyFactor sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.Take = sourceObject.Take;
|
||||
targetObject.Description = sourceObject.Description;
|
||||
baseUpdateStrategy.Update(targetObject, sourceObject);
|
||||
targetObject.PartialFactors.Clear();
|
||||
foreach (var item in sourceObject.PartialFactors)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace StructureHelperLogic.Models.Analyses
|
||||
public Guid Id { get; private set; }
|
||||
public string Name { get; set; }
|
||||
public string Tags { get; set; }
|
||||
public IVersionProcessor VersionProcessor { get; private set; }
|
||||
public IVersionProcessor VersionProcessor { get; set; }
|
||||
|
||||
public CrossSectionNdmAnalysis(Guid id, IVersionProcessor versionProcessor)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class CrossSection : ICrossSection
|
||||
{
|
||||
public ICrossSectionRepository SectionRepository { get; private set; } = new CrossSectionRepository();
|
||||
public ICrossSectionRepository SectionRepository { get; set; } = new CrossSectionRepository();
|
||||
|
||||
public Guid Id { get; private set; }
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public interface ICrossSection : ISaveable, ICloneable
|
||||
{
|
||||
ICrossSectionRepository SectionRepository { get; }
|
||||
ICrossSectionRepository SectionRepository { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
@@ -14,9 +15,9 @@ namespace StructureHelperLogics.Models.Materials
|
||||
public class FRMaterial : IFRMaterial
|
||||
{
|
||||
private IElasticMaterialLogic elasticMaterialLogic => new ElasticMaterialLogic();
|
||||
private MaterialTypes materialType;
|
||||
IUpdateStrategy<IFRMaterial> updateStrategy = new FRUpdateStrategy();
|
||||
public Guid Id { get; }
|
||||
public MaterialTypes MaterialType { get; }
|
||||
public double Modulus{ get; set; }
|
||||
public double CompressiveStrength { get; set; }
|
||||
public double TensileStrength { get; set; }
|
||||
@@ -28,11 +29,16 @@ namespace StructureHelperLogics.Models.Materials
|
||||
|
||||
public FRMaterial(MaterialTypes materialType, Guid id)
|
||||
{
|
||||
if (materialType != MaterialTypes.CarbonFiber ||
|
||||
materialType != MaterialTypes.GlassFiber)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Material type {materialType} is not right");
|
||||
}
|
||||
Id = id;
|
||||
ULSConcreteStrength = 14e6d;
|
||||
SumThickness = 0.175e-3d;
|
||||
this.materialType = materialType;
|
||||
SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultFRSafetyFactors(ProgramSetting.FRCodeType, this.materialType));
|
||||
MaterialType = materialType;
|
||||
SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultFRSafetyFactors(ProgramSetting.FRCodeType, this.MaterialType));
|
||||
}
|
||||
|
||||
public FRMaterial(MaterialTypes materialType) : this (materialType, Guid.NewGuid())
|
||||
@@ -42,7 +48,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var newItem = new FRMaterial(this.materialType);
|
||||
var newItem = new FRMaterial(this.MaterialType);
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -9,6 +10,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public interface IFRMaterial : IElasticMaterial
|
||||
{
|
||||
MaterialTypes MaterialType { get; }
|
||||
double ULSConcreteStrength { get; set; }
|
||||
double SumThickness { get; set; }
|
||||
double GammaF2 { get; }
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public class HeadMaterialRepository : IHeadMaterialRepository
|
||||
{
|
||||
public object Parent { get; private set; }
|
||||
|
||||
public List<IHeadMaterial> HeadMaterials { get; set; }
|
||||
|
||||
public HeadMaterialRepository()
|
||||
{
|
||||
HeadMaterials = new List<IHeadMaterial>();
|
||||
}
|
||||
|
||||
public HeadMaterialRepository(object parent)
|
||||
{
|
||||
Parent = parent;
|
||||
HeadMaterials = new List<IHeadMaterial>();
|
||||
}
|
||||
|
||||
public void RegisterParent(object obj)
|
||||
{
|
||||
Parent = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public interface IHeadMaterialRepository
|
||||
{
|
||||
object Parent { get; }
|
||||
List<IHeadMaterial> HeadMaterials { get; set; }
|
||||
void RegisterParent(object obj);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public class HeadMaterialBaseUpdateStrategy : IUpdateStrategy<IHeadMaterial>
|
||||
{
|
||||
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.Color = sourceObject.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public class HeadMaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
|
||||
{
|
||||
private IUpdateStrategy<IHeadMaterial> updateStrategy = new HeadMaterialBaseUpdateStrategy();
|
||||
private IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy;
|
||||
|
||||
public HeadMaterialUpdateStrategy(IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy)
|
||||
@@ -19,8 +20,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.Color = sourceObject.Color;
|
||||
updateStrategy.Update(targetObject, sourceObject);
|
||||
targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial;
|
||||
helperMaterialUpdateStrategy.Update(targetObject.HelperMaterial, sourceObject.HelperMaterial);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="FunctionalTests\Ndms\SteelSections\" />
|
||||
<Folder Include="FunctionalTests\RCs\Anchorage\" />
|
||||
<Folder Include="UnitTests\ConvertStrategiesTest\" />
|
||||
<Folder Include="UnitTests\WindowTests\Calculations\CalculationProperties\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -60,17 +60,6 @@ namespace StructureHelperTests.UnitTests.UpdateStrategiesTests
|
||||
targetMock.VerifySet(t => t.TensionForSLS = It.IsAny<bool>(), Times.Never);
|
||||
targetMock.VerifySet(t => t.RelativeHumidity = It.IsAny<double>(), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Update_ShouldThrowStructureHelperException_WhenObjectsAreOfDifferentTypes()
|
||||
{
|
||||
// Arrange
|
||||
var targetMock = new Mock<IConcreteLibMaterial>();
|
||||
var sourceMock = new Mock<ConcreteLibMaterial>();
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<StructureHelperException>(() => strategy.Update(targetMock.Object, sourceMock.Object));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,6 @@ namespace StructureHelperTests.UnitTests.UpdateStrategiesTests
|
||||
mockTargetMaterial.Setup(t => t.SafetyFactors).Returns(targetSafetyFactors);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Update_ShouldThrowException_WhenTargetAndSourceAreDifferentTypes()
|
||||
{
|
||||
// Arrange
|
||||
var mockTarget1 = new ConcreteLibMaterial();
|
||||
var mockTarget2 = new ReinforcementLibMaterial();
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<StructureHelperException>(() => updateStrategy.Update(mockTarget1, mockTarget2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Update_ShouldCopyMaterialEntityAndMaterialLogic()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user