Add VisualAnalysisDTO

This commit is contained in:
Evgeny Redikultsev
2024-09-14 19:03:35 +05:00
parent 5a9e7c3c4f
commit c10d6eb94e
84 changed files with 958 additions and 410 deletions

View File

@@ -1,15 +1,12 @@
using StructureHelperCommon.Models.Analyses;
using StructureHelperLogics.Models.Analyses;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogic.Models.Analyses
{
public class CrossSectionNdmAnalysis : IAnalysis
{
private CrossSectionNdmAnalysisUpdateStrategy updateStrategy = new();
public Guid Id { get; private set; }
public string Name { get; set; }
public string Tags { get; set; }
@@ -21,7 +18,7 @@ namespace StructureHelperLogic.Models.Analyses
VersionProcessor = versionProcessor;
}
public CrossSectionNdmAnalysis() : this(new Guid(), new VersionProcessor())
public CrossSectionNdmAnalysis() : this(Guid.NewGuid(), new VersionProcessor())
{
CrossSection crossSection = new CrossSection();
VersionProcessor.AddVersion(crossSection);
@@ -29,7 +26,9 @@ namespace StructureHelperLogic.Models.Analyses
public object Clone()
{
throw new NotImplementedException();
CrossSectionNdmAnalysis newAnalysis = new();
updateStrategy.Update(newAnalysis, this);
return newAnalysis;
}
}
}

View File

@@ -0,0 +1,68 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Services;
using StructureHelperLogic.Models.Analyses;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Analyses
{
public class CrossSectionNdmAnalysisUpdateStrategy : IUpdateStrategy<CrossSectionNdmAnalysis>
{
private IUpdateStrategy<IAnalysis> analysisUpdateStrategy;
private IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy;
private IUpdateStrategy<IDateVersion> dateUpdateStrategy;
public CrossSectionNdmAnalysisUpdateStrategy(IUpdateStrategy<IAnalysis> analysisUpdateStrategy,
IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy,
IUpdateStrategy<IDateVersion> dateUpdateStrategy)
{
this.analysisUpdateStrategy = analysisUpdateStrategy;
this.crossSectionUpdateStrategy = crossSectionUpdateStrategy;
this.dateUpdateStrategy = dateUpdateStrategy;
}
public CrossSectionNdmAnalysisUpdateStrategy() : this(
new AnalysisUpdateStrategy(),
new CrossSectionUpdateStrategy(),
new DateVersionUpdateStrategy())
{
}
public void Update(CrossSectionNdmAnalysis targetObject, CrossSectionNdmAnalysis sourceObject)
{
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; };
analysisUpdateStrategy.Update(targetObject, sourceObject);
targetObject.VersionProcessor.Versions.Clear();
foreach (var version in sourceObject.VersionProcessor.Versions)
{
if (version.Item is ICrossSection crossSection)
{
updateVersion(targetObject, version, crossSection);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version.Item));
}
}
}
private void updateVersion(CrossSectionNdmAnalysis targetObject, IDateVersion version, ICrossSection crossSection)
{
DateVersion newVersion = new();
dateUpdateStrategy.Update(newVersion, version);
CrossSection newCrossection = new();
crossSectionUpdateStrategy.Update(newCrossection, crossSection);
newVersion.Item = newCrossection;
targetObject.VersionProcessor.Versions.Add(newVersion);
}
}
}