Add beam shear converting to DTO

This commit is contained in:
Evgeny Redikultsev
2025-06-08 15:49:17 +05:00
parent 3dab65e3bd
commit 0d7f47653b
150 changed files with 710 additions and 259 deletions

View File

@@ -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 successfully", TraceLogStatuses.Service);
return newItem;
}
}
}

View File

@@ -0,0 +1,20 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.Materials;
namespace DataAccess.DTOs
{
public class ConcreteLibMaterialToDTOConvertStrategy : LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>
{
public override IUpdateStrategy<IConcreteLibMaterial> UpdateStrategy { get; } = new ConcreteLibUpdateStrategy();
public override ConcreteLibMaterialDTO GetMaterialDTO(IConcreteLibMaterial source)
{
ConcreteLibMaterialDTO newItem = new()
{
Id = source.Id
};
return newItem;
}
}
}

View File

@@ -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 successfully", TraceLogStatuses.Service);
return newItem;
}
}
}

View File

@@ -0,0 +1,62 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ElasticMaterialToDTOConvertStrategy : IConvertStrategy<ElasticMaterialDTO, IElasticMaterial>
{
private IUpdateStrategy<IElasticMaterial> updateStrategy;
private ICheckConvertLogic<ElasticMaterialDTO, IElasticMaterial> checkLogic;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ElasticMaterialToDTOConvertStrategy(
IUpdateStrategy<IElasticMaterial> updateStrategy,
ICheckConvertLogic<ElasticMaterialDTO, IElasticMaterial> checkLogic)
{
this.updateStrategy = updateStrategy;
this.checkLogic = checkLogic;
}
public ElasticMaterialToDTOConvertStrategy() : this (
new ElasticUpdateStrategy(),
new CheckConvertLogic<ElasticMaterialDTO, IElasticMaterial>())
{
}
public ElasticMaterialDTO Convert(IElasticMaterial source)
{
Check();
try
{
ElasticMaterialDTO newItem = new() { Id = source.Id };
updateStrategy.Update(newItem, source);
return newItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private void Check()
{
checkLogic = new CheckConvertLogic<ElasticMaterialDTO, IElasticMaterial>(this);
checkLogic.Check();
}
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -0,0 +1,59 @@
using DataAccess.DTOs.Converters;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Materials;
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 successfully", 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;
}
}
}

View File

@@ -0,0 +1,66 @@
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Materials;
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.Converters
{
public class HeadMaterialToDTOConvertStrategy : IConvertStrategy<HeadMaterialDTO, IHeadMaterial>
{
private IUpdateStrategy<IHeadMaterial> updateStrategy;
private IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy;
public HeadMaterialToDTOConvertStrategy(IUpdateStrategy<IHeadMaterial> updateStrategy,
IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy)
{
this.updateStrategy = updateStrategy;
this.convertStrategy = convertStrategy;
}
public HeadMaterialToDTOConvertStrategy() : this (
new HeadMaterialUpdateStrategy(),
new HelperMaterialToDTOConvertStrategy())
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public HeadMaterialDTO Convert(IHeadMaterial source)
{
try
{
return GetMaterial(source);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private HeadMaterialDTO GetMaterial(IHeadMaterial source)
{
TraceLogger?.AddMessage($"Convert material Id={source.Id}, name is {source.Name}");
HeadMaterialDTO newItem = new()
{
Id = source.Id
};
updateStrategy.Update(newItem, source);
convertStrategy.ReferenceDictionary = ReferenceDictionary;
var convertLogic = new DictionaryConvertStrategy<IHelperMaterial, IHelperMaterial>(this, convertStrategy);
newItem.HelperMaterial = convertLogic.Convert(source.HelperMaterial);
return newItem;
}
}
}

View File

@@ -0,0 +1,66 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperCommon.Services;
namespace DataAccess.DTOs
{
public class HelperMaterialDTOSafetyFactorUpdateStrategy : IUpdateStrategy<IHelperMaterial>
{
private IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy;
private IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy;
private IMaterialSafetyFactorDTOLogic factorDTOLogic;
public HelperMaterialDTOSafetyFactorUpdateStrategy(
IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy,
IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy)
{
this.safetyFactorUpdateStrategy = safetyFactorUpdateStrategy;
this.partialFactorUpdateStrategy = partialFactorUpdateStrategy;
}
public HelperMaterialDTOSafetyFactorUpdateStrategy(IMaterialSafetyFactorDTOLogic factorDTOLogic) : this(
new MaterialSafetyFactorBaseUpdateStrategy(),
new MaterialPartialFactorUpdateStrategy())
{
this.factorDTOLogic = factorDTOLogic;
}
public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject)
{
CheckObject.IsNull(sourceObject);
CheckObject.IsNull(targetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
if (sourceObject.SafetyFactors is not null)
{
targetObject.SafetyFactors.Clear();
foreach (var safetyFactor in sourceObject.SafetyFactors)
{
IMaterialSafetyFactor newSafetyFactor = GetNewSafetyFactorByOld(safetyFactor);
targetObject.SafetyFactors.Add(newSafetyFactor);
}
}
}
private IMaterialSafetyFactor GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor)
{
IMaterialSafetyFactor newSafetyFactor = factorDTOLogic.GetNewSafetyFactorByOld(safetyFactor);
safetyFactorUpdateStrategy.Update(newSafetyFactor, safetyFactor);
newSafetyFactor.PartialFactors.Clear();
foreach (var partialFactor in safetyFactor.PartialFactors)
{
IMaterialPartialFactor newPartialFactor = GetNewPartialFactorByOld(partialFactor);
newSafetyFactor.PartialFactors.Add(newPartialFactor);
}
return newSafetyFactor;
}
private IMaterialPartialFactor GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor)
{
IMaterialPartialFactor newPartialFactor = factorDTOLogic.GetNewPartialFactorByOld(partialFactor);
partialFactorUpdateStrategy.Update(newPartialFactor, partialFactor);
return newPartialFactor;
}
}
}

View File

@@ -0,0 +1,114 @@
using DataAccess.DTOs.Converters;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Materials;
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);
elasticConvertStrategy.ReferenceDictionary = ReferenceDictionary;
elasticConvertStrategy.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);
frConvertStrategy.ReferenceDictionary = ReferenceDictionary;
frConvertStrategy.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;
}
}
}

View File

@@ -0,0 +1,122 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.Models.Materials;
namespace DataAccess.DTOs
{
internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy<IHelperMaterial, IHelperMaterial>
{
private LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy;
private LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy;
private IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> elasticConvertStrategy;
private IConvertStrategy<FRMaterialDTO, IFRMaterial> frMaterialConvertStrategy;
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic());
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public HelperMaterialToDTOConvertStrategy(
LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy,
LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy,
IConvertStrategy<ElasticMaterialDTO, IElasticMaterial> elasticConvertStrategy,
IConvertStrategy<FRMaterialDTO, IFRMaterial> frMaterialConvertStrategy)
{
this.concreteConvertStrategy = concreteConvertStrategy;
this.reinforcementConvertStrategy = reinforcementConvertStrategy;
this.elasticConvertStrategy = elasticConvertStrategy;
this.frMaterialConvertStrategy = frMaterialConvertStrategy;
}
public HelperMaterialToDTOConvertStrategy() : this (
new ConcreteLibMaterialToDTOConvertStrategy(),
new ReinforcementLibMaterialToDTOConvertStrategy(),
new ElasticMaterialToDTOConvertStrategy(),
new FRMaterialToDTOConvertStrategy()
)
{
}
public IHelperMaterial Convert(IHelperMaterial source)
{
Check();
try
{
IHelperMaterial helperMaterial = GetMaterial(source);
safetyFactorUpdateStrategy.Update(helperMaterial, source);
return helperMaterial;
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private IHelperMaterial GetMaterial(IHelperMaterial source)
{
if (source is IConcreteLibMaterial concreteLibMaterial)
{
return ProcessConcrete(concreteLibMaterial);
}
else if (source is IReinforcementLibMaterial reinforcementMaterial)
{
return ProcessReinforcement(reinforcementMaterial);
}
else if (source is IFRMaterial frMaterial)
{
return ProcessFRMaterial(frMaterial);
}
else if (source is IElasticMaterial elasticMaterial)
{
return ProcessElastic(elasticMaterial);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
}
}
private IHelperMaterial ProcessFRMaterial(IFRMaterial frMaterial)
{
frMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
frMaterialConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<FRMaterialDTO, IFRMaterial>(this, frMaterialConvertStrategy);
return convertLogic.Convert(frMaterial);
}
private IHelperMaterial ProcessElastic(IElasticMaterial elasticMaterial)
{
elasticConvertStrategy.ReferenceDictionary = ReferenceDictionary;
elasticConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ElasticMaterialDTO, IElasticMaterial>(this, elasticConvertStrategy);
return convertLogic.Convert(elasticMaterial);
}
private IHelperMaterial ProcessReinforcement(IReinforcementLibMaterial reinforcementMaterial)
{
reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary;
reinforcementConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial>(this, reinforcementConvertStrategy);
return convertLogic.Convert(reinforcementMaterial);
}
private IHelperMaterial ProcessConcrete(IConcreteLibMaterial concreteLibMaterial)
{
concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary;
concreteConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>(this, concreteConvertStrategy);
return convertLogic.Convert(concreteLibMaterial);
}
private void Check()
{
var checkLogic = new CheckConvertLogic<IHelperMaterial, IHelperMaterial>(this);
checkLogic.Check();
}
}
}

View 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;
}
}
}

View File

@@ -0,0 +1,23 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Materials.Libraries;
namespace DataAccess.DTOs
{
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 MaterialSafetyFactorsToDTOConvertStrategy(IUpdateStrategy<IMaterialSafetyFactor> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public MaterialSafetyFactorDTO Convert(IMaterialSafetyFactor source)
{
throw new NotImplementedException();
}
}
}

View File

@@ -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 successfully", TraceLogStatuses.Service);
return newItem;
}
}
}

View File

@@ -0,0 +1,24 @@
using StructureHelperCommon.Infrastructures.Interfaces;
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 ReinforcementLibMaterialToDTOConvertStrategy : LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial>
{
public override IUpdateStrategy<IReinforcementLibMaterial> UpdateStrategy { get; } = new ReinforcementLibUpdateStrategy();
public override ReinforcementLibMaterialDTO GetMaterialDTO(IReinforcementLibMaterial source)
{
ReinforcementLibMaterialDTO newItem = new()
{
Id = source.Id
};
return newItem;
}
}
}