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;
|
||||
@@ -38,7 +39,22 @@ namespace DataAccess.DTOs.Converters
|
||||
|
||||
public CrossSectionNdmAnalysisDTO Convert(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
Check();
|
||||
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;
|
||||
@@ -37,7 +38,22 @@ namespace DataAccess.DTOs
|
||||
|
||||
public DateVersionDTO Convert(IDateVersion source)
|
||||
{
|
||||
Check();
|
||||
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)
|
||||
public override ForceTupleDTO GetNewItem(IForceTuple source)
|
||||
{
|
||||
Check();
|
||||
try
|
||||
{
|
||||
ForceTupleDTO newItem = new() { Id = source.Id};
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ForceTupleDTO, IForceTuple>(this);
|
||||
checkLogic.Check();
|
||||
ForceTupleDTO newItem = new() { Id = source.Id};
|
||||
updateStrategy.Update(newItem, source);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,7 +14,7 @@ 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; }
|
||||
@@ -21,11 +22,25 @@ namespace DataAccess.DTOs
|
||||
|
||||
public ISaveable Convert(ISaveable source)
|
||||
{
|
||||
Check();
|
||||
ISaveable saveable;
|
||||
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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user