Add beam shear analysis converting from DTO
This commit is contained in:
@@ -1,47 +1,32 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class AnalysisFromDTOConvertStrategy : IConvertStrategy<IAnalysis, IAnalysis>
|
||||
public class AnalysisFromDTOConvertStrategy : ConvertStrategy<IAnalysis, IAnalysis>
|
||||
{
|
||||
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)
|
||||
public AnalysisFromDTOConvertStrategy()
|
||||
{
|
||||
this.convertCrossSectionNdmAnalysisStrategy = convertCrossSectionNdmAnalysisStrategy;
|
||||
this.versionProcessorConvertStrategy = versionProcessorConvertStrategy;
|
||||
}
|
||||
|
||||
public AnalysisFromDTOConvertStrategy() : this (new CrossSectionNdmAnalysisFromDTOConvertStrategy(),
|
||||
new VersionProcessorFromDTOConvertStrategy())
|
||||
public AnalysisFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public IAnalysis Convert(IAnalysis source)
|
||||
public override IAnalysis GetNewItem(IAnalysis source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
IAnalysis analysis = GetAnalysis(source);
|
||||
return analysis;
|
||||
}
|
||||
@@ -51,29 +36,51 @@ namespace DataAccess.DTOs.Converters
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private IAnalysis GetAnalysis(IAnalysis source)
|
||||
{
|
||||
IAnalysis newItem;
|
||||
if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
||||
{
|
||||
newItem = GetCrossSectionNdmAnalysis(crossSectionNdmAnalysis);
|
||||
GetCrossSectionNdmAnalysis(crossSectionNdmAnalysis);
|
||||
}
|
||||
else if (source is IBeamShearAnalysis beamShearAnalysis)
|
||||
{
|
||||
GetBeamShearAnalysis(beamShearAnalysis);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
newItem.VersionProcessor = GetVersionProcessor(source.VersionProcessor);
|
||||
return newItem;
|
||||
NewItem.VersionProcessor = GetVersionProcessor(source.VersionProcessor);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void GetBeamShearAnalysis(IBeamShearAnalysis beamShearAnalysis)
|
||||
{
|
||||
TraceLogger?.AddMessage(AnalysisIs + " beam shear Analysis", TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage("Beam shear analysis converting has been started", TraceLogStatuses.Debug);
|
||||
var convertStrategy = new DictionaryConvertStrategy<IBeamShearAnalysis, IBeamShearAnalysis>
|
||||
(this, new BeamShearAnalysisFromDTOConvertStrategy(this));
|
||||
NewItem = convertStrategy.Convert(beamShearAnalysis);
|
||||
TraceLogger?.AddMessage("Beam shear analysis converting has been finished succesfully", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
|
||||
private void GetCrossSectionNdmAnalysis(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been started", TraceLogStatuses.Debug);
|
||||
var convertStrategy = new DictionaryConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>
|
||||
(this, new CrossSectionNdmAnalysisFromDTOConvertStrategy(this));
|
||||
NewItem = convertStrategy.Convert(source);
|
||||
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been finished successfully", TraceLogStatuses.Debug);
|
||||
}
|
||||
private IVersionProcessor GetVersionProcessor(IVersionProcessor source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Version processor converting is started", TraceLogStatuses.Service);
|
||||
versionProcessorConvertStrategy ??= new VersionProcessorFromDTOConvertStrategy();
|
||||
versionProcessorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
versionProcessorConvertStrategy.TraceLogger = TraceLogger;
|
||||
IVersionProcessor versionProcessor = versionProcessorConvertStrategy.Convert(source);
|
||||
@@ -81,22 +88,5 @@ namespace DataAccess.DTOs.Converters
|
||||
return versionProcessor;
|
||||
}
|
||||
|
||||
private ICrossSectionNdmAnalysis GetCrossSectionNdmAnalysis(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
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 successfully", TraceLogStatuses.Service);
|
||||
return crossSectionNdmAnalysis;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<IAnalysis, IAnalysis>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearAnalysisFromDTOConvertStrategy : ConvertStrategy<IBeamShearAnalysis, IBeamShearAnalysis>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShearAnalysis> updateStrategy;
|
||||
|
||||
public BeamShearAnalysisFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override IBeamShearAnalysis GetNewItem(IBeamShearAnalysis source)
|
||||
{
|
||||
ChildClass = this;
|
||||
GetAnalysis(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void GetAnalysis(IBeamShearAnalysis source)
|
||||
{
|
||||
updateStrategy ??= new BeamShearAnalysisUpdateStrategy();
|
||||
BeamShearAnalysis beamShearAnalysis = new(source.Id);
|
||||
updateStrategy.Update(beamShearAnalysis, source);
|
||||
NewItem = beamShearAnalysis;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,62 +10,34 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class DateVersionFromDTOConvertStrategy : IConvertStrategy<IDateVersion, IDateVersion>
|
||||
public class DateVersionFromDTOConvertStrategy : ConvertStrategy<IDateVersion, IDateVersion>
|
||||
{
|
||||
private IUpdateStrategy<IDateVersion> updateStrategy;
|
||||
private IConvertStrategy<ISaveable, ISaveable> convertStrategy;
|
||||
private DictionaryConvertStrategy<ISaveable, ISaveable> convertLogic;
|
||||
private IConvertStrategy<ISaveable, ISaveable> convertLogic;
|
||||
|
||||
public DateVersionFromDTOConvertStrategy(IUpdateStrategy<IDateVersion> updateStrategy,
|
||||
IConvertStrategy<ISaveable, ISaveable> convertStrategy)
|
||||
public override IDateVersion GetNewItem(IDateVersion source)
|
||||
{
|
||||
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();
|
||||
ChildClass = this;
|
||||
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);
|
||||
InitializeStrategies();
|
||||
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()
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<IDateVersion, IDateVersion>(this);
|
||||
checkLogic.Check();
|
||||
updateStrategy ??= new DateVersionUpdateStrategy();
|
||||
convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>
|
||||
(this, new VersionItemFromDTOConvertStrategy(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +1,34 @@
|
||||
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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
{
|
||||
public class CrossSectionNdmAnalysisFromDTOConvertStrategy : IConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>
|
||||
public class CrossSectionNdmAnalysisFromDTOConvertStrategy : ConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>
|
||||
{
|
||||
private IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy;
|
||||
|
||||
public CrossSectionNdmAnalysisFromDTOConvertStrategy(IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy)
|
||||
public CrossSectionNdmAnalysisFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionNdmAnalysisFromDTOConvertStrategy() : this(new CrossSectionNdmAnalysisUpdateStrategy())
|
||||
public override ICrossSectionNdmAnalysis GetNewItem(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
|
||||
ChildClass = this;
|
||||
GetAnalysis(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ICrossSectionNdmAnalysis Convert(ICrossSectionNdmAnalysis source)
|
||||
private void GetAnalysis(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
ICrossSectionNdmAnalysis newItem = GetCrossSectionNDMAnalysis(source);
|
||||
return newItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
TraceLogger?.AddMessage("Cross-section analysis converting has been started");
|
||||
updateStrategy ??= new CrossSectionNdmAnalysisUpdateStrategy();
|
||||
NewItem = new CrossSectionNdmAnalysis(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
TraceLogger?.AddMessage("Cross-section analysis has been finished successfully");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ICrossSectionNdmAnalysis GetCrossSectionNDMAnalysis(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 successfully");
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
public override Project GetNewItem(ProjectDTO source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Converting of project is started");
|
||||
TraceLogger?.AddMessage("Converting of project has been started");
|
||||
Project newItem = new(source.Id);
|
||||
List<IVisualAnalysis> analyses = GetAnalyses(source, newItem);
|
||||
newItem.VisualAnalyses.Clear();
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace DataAccess.DTOs
|
||||
public class ProjectToDTOConvertStrategy : ConvertStrategy<ProjectDTO, IProject>
|
||||
{
|
||||
private IUpdateStrategy<IProject> updateStrategy;
|
||||
private DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic;
|
||||
private IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic;
|
||||
|
||||
|
||||
public ProjectToDTOConvertStrategy()
|
||||
@@ -17,7 +17,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
public ProjectToDTOConvertStrategy(
|
||||
IUpdateStrategy<IProject> updateStrategy,
|
||||
DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic)
|
||||
IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertLogic = convertLogic;
|
||||
@@ -41,9 +41,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
updateStrategy ??= new ProjectUpdateStrategy();
|
||||
convertLogic ??= new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
|
||||
(this,
|
||||
new VisualAnalysisToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
||||
);
|
||||
(this, new VisualAnalysisToDTOConvertStrategy(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class VersionItemFromDTOConvertStrategy : IConvertStrategy<ISaveable, ISaveable>
|
||||
public class VersionItemFromDTOConvertStrategy : ConvertStrategy<ISaveable, ISaveable>
|
||||
{
|
||||
private const string AnalysisIs = "Analysis type is";
|
||||
private IConvertStrategy<ICrossSection, ICrossSection> crossSectionConvertStrategy;
|
||||
|
||||
public VersionItemFromDTOConvertStrategy(IConvertStrategy<ICrossSection, ICrossSection> crossSectionConvertStrategy)
|
||||
public VersionItemFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
this.crossSectionConvertStrategy = crossSectionConvertStrategy;
|
||||
}
|
||||
|
||||
public VersionItemFromDTOConvertStrategy() : this (new CrossSectionFromDTOConvertStrategy())
|
||||
public override ISaveable GetNewItem(ISaveable source)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ISaveable Convert(ISaveable source)
|
||||
{
|
||||
try
|
||||
{
|
||||
Check();
|
||||
ChildClass = this;
|
||||
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)
|
||||
{
|
||||
@@ -46,6 +28,10 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
newItem = ProcessCrossSection(crossSection);
|
||||
}
|
||||
else if (source is IBeamShear beamShear)
|
||||
{
|
||||
newItem = ProcessBeamShear(beamShear);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
@@ -56,10 +42,16 @@ namespace DataAccess.DTOs
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private ISaveable ProcessBeamShear(IBeamShear beamShear)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private ICrossSection ProcessCrossSection(ICrossSection source)
|
||||
{
|
||||
TraceLogger?.AddMessage(AnalysisIs + " Cross-Section", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage("Cross-Section converting is started", TraceLogStatuses.Service);
|
||||
crossSectionConvertStrategy ??= new CrossSectionFromDTOConvertStrategy();
|
||||
crossSectionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
crossSectionConvertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<ICrossSection, ICrossSection>(this, crossSectionConvertStrategy);
|
||||
@@ -67,11 +59,5 @@ namespace DataAccess.DTOs
|
||||
TraceLogger?.AddMessage("Cross-Section converting has been finished successfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ISaveable, ISaveable>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,45 +10,20 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class VersionProcessorFromDTOConvertStrategy : IConvertStrategy<IVersionProcessor, IVersionProcessor>
|
||||
public class VersionProcessorFromDTOConvertStrategy : ConvertStrategy<IVersionProcessor, IVersionProcessor>
|
||||
{
|
||||
private IConvertStrategy<IDateVersion, IDateVersion> dateVersionConvertStrategy;
|
||||
private ICheckConvertLogic<IVersionProcessor, IVersionProcessor> checkLogic;
|
||||
|
||||
public VersionProcessorFromDTOConvertStrategy(
|
||||
IConvertStrategy<IDateVersion, IDateVersion> dateVersionConvertStrategy)
|
||||
public override IVersionProcessor GetNewItem(IVersionProcessor source)
|
||||
{
|
||||
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;
|
||||
}
|
||||
ChildClass = this;
|
||||
return GetVersionProcessor(source);
|
||||
}
|
||||
|
||||
private IVersionProcessor GetVersionProcessor(IVersionProcessor source)
|
||||
{
|
||||
TraceLogger?.AddMessage("Version processor converting is started", TraceLogStatuses.Debug);
|
||||
dateVersionConvertStrategy ??= new DateVersionFromDTOConvertStrategy();
|
||||
IVersionProcessor newItem = new VersionProcessor(source.Id);
|
||||
TraceLogger?.AddMessage($"Source version processor has {source.Versions.Count} version(s)", TraceLogStatuses.Service);
|
||||
dateVersionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
@@ -62,11 +37,5 @@ namespace DataAccess.DTOs
|
||||
TraceLogger?.AddMessage("Version processor has been converted successfully", TraceLogStatuses.Service);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<IVersionProcessor, IVersionProcessor>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
}
|
||||
|
||||
public VisualAnalysisToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
private VisualAnalysisDTO GetNewAnalysis(IVisualAnalysis source)
|
||||
{
|
||||
InitializeStrategies();
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace DataAccess.DTOs
|
||||
public class ProjectDTO : IProject
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get;}
|
||||
public Guid Id { get; set; }
|
||||
[JsonIgnore]
|
||||
public string FullFileName { get; set; }
|
||||
[JsonIgnore]
|
||||
@@ -27,5 +27,10 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public ProjectDTO() : this(Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
|
||||
@@ -11,12 +11,8 @@ using StructureHelperLogics.Models.Analyses;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace StructureHelper.Windows.MainWindow
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using LoaderCalculator;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
||||
@@ -14,7 +13,6 @@ using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using MessageBox = System.Windows.Forms.MessageBox;
|
||||
@@ -210,8 +208,11 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
ProcessResult();
|
||||
}
|
||||
}
|
||||
if (SelectedItem.ShowTraceData == true)
|
||||
{
|
||||
TraceDocumentService.ShowDocument(SelectedItem.TraceLogger.TraceLoggerEntries);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowInteractionDiagramByInputData(LimitCurvesCalculator calculator)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -40,6 +41,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public T NewItem { get; set; }
|
||||
public ConvertStrategy<T, V> ChildClass { get; set; }
|
||||
|
||||
public virtual T Convert(V source)
|
||||
{
|
||||
@@ -48,12 +50,18 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
Check();
|
||||
TraceStartOfConverting(source);
|
||||
T target = GetNewItem(source);
|
||||
if (target is null)
|
||||
{
|
||||
string errorString = ErrorStrings.ParameterIsNull + ": result of converting";
|
||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
TraceFinishOfConverting(target);
|
||||
return target;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(ChildClass ?? this), TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
throw;
|
||||
}
|
||||
@@ -76,7 +84,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
}
|
||||
private void TraceFinishOfConverting(ISaveable saveable)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting {saveable.GetType()} Id = {saveable.Id} has been started");
|
||||
TraceLogger?.AddMessage($"Converting {saveable.GetType()} Id = {saveable.Id} has been finished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.BeamShears.Logics;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
|
||||
namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
{
|
||||
|
||||
|
||||
namespace YourNamespace.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class GetDirectShearForceLogicTests
|
||||
{
|
||||
private Mock<IShiftTraceLogger> _mockLogger;
|
||||
private Mock<ISumForceByShearLoadLogic> _mockSummaryForceLogic;
|
||||
private GetDirectShearForceLogic _logic;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockLogger = new Mock<IShiftTraceLogger>();
|
||||
_mockSummaryForceLogic = new Mock<ISumForceByShearLoadLogic>();
|
||||
var mockAction = new Mock<IBeamShearAction>();
|
||||
var mockInclinedSection = new Mock<IInclinedSection>();
|
||||
var mockShearLoad = new Mock<IBeamSpanLoad>();
|
||||
|
||||
mockAction.Setup(a => a.SupportAction.SupportForce.ForceTuple.Qx).Returns(100.0);
|
||||
mockAction.Setup(a => a.SupportAction.ShearLoads).Returns(new List<IBeamSpanLoad> { mockShearLoad.Object });
|
||||
|
||||
mockInclinedSection.Setup(i => i.StartCoord).Returns(2.0);
|
||||
mockInclinedSection.Setup(i => i.EndCoord).Returns(5.0);
|
||||
|
||||
_mockSummaryForceLogic.Setup(s => s.GetSumShearForce(mockShearLoad.Object, 2.0, 5.0)).Returns(new ForceTuple() { Qy = 50.0});
|
||||
_logic = new GetDirectShearForceLogic(mockAction.Object, mockInclinedSection.Object, LimitStates.ULS, CalcTerms.ShortTerm, _mockLogger.Object, _mockSummaryForceLogic.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetShearForce_ShouldReturnCorrectShearForce()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
// Act
|
||||
double result = _logic.CalculateShearForceTuple().Qy;
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(150.0));
|
||||
_mockLogger.Verify(l => l.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.AtLeastOnce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
|
||||
namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
{
|
||||
@@ -12,13 +13,16 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
{
|
||||
private Mock<IShiftTraceLogger> _mockLogger;
|
||||
private Mock<ICoordinateByLevelLogic> _mockCoordinateByLevelLogic;
|
||||
private Mock<IFactoredCombinationProperty> _mockCombination;
|
||||
private SumConcentratedForceLogic _logic;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockLogger = new Mock<IShiftTraceLogger>();
|
||||
_mockCoordinateByLevelLogic = new Mock<ICoordinateByLevelLogic>();
|
||||
_mockCombination = new Mock<IFactoredCombinationProperty>();
|
||||
_logic = new SumConcentratedForceLogic(_mockCoordinateByLevelLogic.Object, _mockLogger.Object);
|
||||
}
|
||||
|
||||
@@ -26,11 +30,16 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
public void GetSumShearForce_ShouldReturnCorrectForce_ForValidConcentratedForce()
|
||||
{
|
||||
// Arrange
|
||||
_mockCombination.Setup(f => f.LimitState).Returns(LimitStates.ULS);
|
||||
_mockCombination.Setup(f => f.CalcTerm).Returns(CalcTerms.ShortTerm);
|
||||
_mockCombination.Setup(f => f.LongTermFactor).Returns(0.9);
|
||||
_mockCombination.Setup(f => f.ULSFactor).Returns(1.2);
|
||||
var mockConcentratedForce = new Mock<IConcentratedForce>();
|
||||
mockConcentratedForce.Setup(f => f.ForceCoordinate).Returns(3.0);
|
||||
mockConcentratedForce.Setup(f => f.ForceValue).Returns(new ForceTuple() { Qy = 100.0 });
|
||||
mockConcentratedForce.Setup(f => f.LoadRatio).Returns(0.8);
|
||||
mockConcentratedForce.Setup(f => f.RelativeLoadLevel).Returns(0.5);
|
||||
mockConcentratedForce.Setup(f => f.CombinationProperty).Returns(_mockCombination.Object);
|
||||
|
||||
_mockCoordinateByLevelLogic.Setup(c => c.GetCoordinate(2.0, 5.0, 0.5)).Returns(3.5);
|
||||
|
||||
@@ -38,7 +47,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
double result = _logic.GetSumShearForce(mockConcentratedForce.Object, 2.0, 5.0).Qy;
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(80.0));
|
||||
Assert.That(result, Is.EqualTo(72.000000000000014d));
|
||||
_mockLogger.Verify(l => l.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
@@ -48,6 +57,8 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
// Arrange
|
||||
var mockConcentratedForce = new Mock<IConcentratedForce>();
|
||||
mockConcentratedForce.Setup(f => f.ForceCoordinate).Returns(6.0);
|
||||
mockConcentratedForce.Setup(f => f.ForceValue).Returns(new ForceTuple() { Qy = 100.0 });
|
||||
mockConcentratedForce.Setup(f => f.Name).Returns("Zero_name");
|
||||
|
||||
// Act
|
||||
double result = _logic.GetSumShearForce(mockConcentratedForce.Object, 2.0, 5.0).Qy;
|
||||
|
||||
@@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
|
||||
namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
{
|
||||
@@ -13,12 +14,14 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
private Mock<IShiftTraceLogger> _mockLogger;
|
||||
private Mock<ICoordinateByLevelLogic> _mockCoordinateByLevelLogic;
|
||||
private SumDistributedLoadLogic _logic;
|
||||
private Mock<IFactoredCombinationProperty> _mockCombination;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockLogger = new Mock<IShiftTraceLogger>();
|
||||
_mockCoordinateByLevelLogic = new Mock<ICoordinateByLevelLogic>();
|
||||
_mockCombination = new Mock<IFactoredCombinationProperty>();
|
||||
_logic = new SumDistributedLoadLogic(_mockCoordinateByLevelLogic.Object, _mockLogger.Object);
|
||||
}
|
||||
|
||||
@@ -26,12 +29,17 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
public void GetSumShearForce_ShouldReturnCorrectForce_ForValidDistributedLoad()
|
||||
{
|
||||
// Arrange
|
||||
_mockCombination.Setup(f => f.LimitState).Returns(LimitStates.ULS);
|
||||
_mockCombination.Setup(f => f.CalcTerm).Returns(CalcTerms.ShortTerm);
|
||||
_mockCombination.Setup(f => f.LongTermFactor).Returns(0.9);
|
||||
_mockCombination.Setup(f => f.ULSFactor).Returns(1.2);
|
||||
var mockDistributedLoad = new Mock<IDistributedLoad>();
|
||||
mockDistributedLoad.Setup(d => d.StartCoordinate).Returns(1.0);
|
||||
mockDistributedLoad.Setup(d => d.EndCoordinate).Returns(4.0);
|
||||
mockDistributedLoad.Setup(d => d.LoadValue).Returns(new ForceTuple() { Qy = 50.0 });
|
||||
mockDistributedLoad.Setup(d => d.LoadRatio).Returns(0.9);
|
||||
mockDistributedLoad.Setup(d => d.RelativeLoadLevel).Returns(0.5);
|
||||
mockDistributedLoad.Setup(d => d.CombinationProperty).Returns(_mockCombination.Object);
|
||||
|
||||
_mockCoordinateByLevelLogic.Setup(c => c.GetCoordinate(2.0, 5.0, 0.5)).Returns(4.5);
|
||||
|
||||
@@ -39,7 +47,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
double result = _logic.GetSumShearForce(mockDistributedLoad.Object, 2.0, 5.0).Qy;
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(135.0));
|
||||
Assert.That(result, Is.EqualTo(121.50000000000001d));
|
||||
_mockLogger.Verify(l => l.AddMessage(It.IsAny<string>(), It.IsAny<TraceLogStatuses>()), Times.AtLeastOnce);
|
||||
}
|
||||
|
||||
@@ -49,6 +57,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
// Arrange
|
||||
var mockDistributedLoad = new Mock<IDistributedLoad>();
|
||||
mockDistributedLoad.Setup(d => d.StartCoordinate).Returns(6.0);
|
||||
mockDistributedLoad.Setup(d => d.LoadValue.Qy).Returns(100);
|
||||
|
||||
// Act
|
||||
double result = _logic.GetSumShearForce(mockDistributedLoad.Object, 2.0, 5.0).Qy;
|
||||
|
||||
Reference in New Issue
Block a user