Add beam shear clone strategies
This commit is contained in:
@@ -3,32 +3,32 @@ using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
|
||||
namespace DataAccess.DTOs.Converters
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class AnalysisToDTOConvertStrategy : IConvertStrategy<IAnalysis, IAnalysis>
|
||||
public class AnalysisToDTOConvertStrategy : ConvertStrategy<IAnalysis, IAnalysis>
|
||||
{
|
||||
private const string Message = "Analysis type is";
|
||||
private IConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis> convertCrossSectionNdmAnalysisStrategy = new CrossSectionNdmAnalysisToDTOConvertStrategy();
|
||||
private DictionaryConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis> convertLogic;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
private IConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis> crossSectionConvertLogic;
|
||||
private IConvertStrategy<BeamShearAnalysisDTO, IBeamShearAnalysis> beamShearConvertLogic;
|
||||
|
||||
public IAnalysis Convert(IAnalysis source)
|
||||
public AnalysisToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override IAnalysis GetNewItem(IAnalysis source)
|
||||
{
|
||||
Check();
|
||||
IAnalysis analysis;
|
||||
if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
||||
{
|
||||
analysis = GetCrossSectionNdmAnalysisDTO(crossSectionNdmAnalysis);
|
||||
}
|
||||
else if (source is IBeamShearAnalysis beamShearAnalysis)
|
||||
{
|
||||
analysis = GetBeamShearAnalysis(beamShearAnalysis);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
||||
@@ -41,23 +41,26 @@ namespace DataAccess.DTOs.Converters
|
||||
}
|
||||
return analysis;
|
||||
}
|
||||
private BeamShearAnalysisDTO GetBeamShearAnalysis(IBeamShearAnalysis beamShearAnalysis)
|
||||
{
|
||||
TraceLogger?.AddMessage(Message + " Beam Shear Analysis", TraceLogStatuses.Debug);
|
||||
beamShearConvertLogic ??= new DictionaryConvertStrategy<BeamShearAnalysisDTO, IBeamShearAnalysis>
|
||||
(this,
|
||||
new BeamShearAnalysisToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
||||
);
|
||||
BeamShearAnalysisDTO newItem = beamShearConvertLogic.Convert(beamShearAnalysis);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
private CrossSectionNdmAnalysisDTO GetCrossSectionNdmAnalysisDTO(ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
||||
{
|
||||
TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
||||
convertCrossSectionNdmAnalysisStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertCrossSectionNdmAnalysisStrategy.TraceLogger = TraceLogger;
|
||||
convertLogic = new DictionaryConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>(this, convertCrossSectionNdmAnalysisStrategy);
|
||||
CrossSectionNdmAnalysisDTO crossSectionNdmAnalysisDTO = convertLogic.Convert(crossSectionNdmAnalysis);
|
||||
return crossSectionNdmAnalysisDTO;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<IAnalysis, IAnalysis>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
checkLogic.Check();
|
||||
crossSectionConvertLogic ??= new DictionaryConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>
|
||||
(this,
|
||||
new CrossSectionNdmAnalysisToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
||||
);
|
||||
CrossSectionNdmAnalysisDTO newItem = crossSectionConvertLogic.Convert(crossSectionNdmAnalysis);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearAnalysisToDTOConvertStrategy : ConvertStrategy<BeamShearAnalysisDTO, IBeamShearAnalysis>
|
||||
{
|
||||
private IUpdateStrategy<IBeamShearAnalysis> updateStrategy;
|
||||
|
||||
public BeamShearAnalysisToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override BeamShearAnalysisDTO GetNewItem(IBeamShearAnalysis source)
|
||||
{
|
||||
updateStrategy ??= new BeamShearAnalysisUpdateStrategy();
|
||||
try
|
||||
{
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,8 @@ 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
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
internal class CrossSectionNdmAnalysisToDTOConvertStrategy : IConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>
|
||||
{
|
||||
@@ -37,6 +32,16 @@ namespace DataAccess.DTOs.Converters
|
||||
|
||||
}
|
||||
|
||||
public CrossSectionNdmAnalysisToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger? traceLogger)
|
||||
: this(
|
||||
new CrossSectionNdmAnalysisUpdateStrategy(),
|
||||
new VersionProcessorToDTOConvertStrategy(),
|
||||
null)
|
||||
{
|
||||
ReferenceDictionary = referenceDictionary;
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public CrossSectionNdmAnalysisDTO Convert(ICrossSectionNdmAnalysis source)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,49 +1,33 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ProjectToDTOConvertStrategy : IConvertStrategy<ProjectDTO, IProject>
|
||||
public class ProjectToDTOConvertStrategy : ConvertStrategy<ProjectDTO, IProject>
|
||||
{
|
||||
private IUpdateStrategy<IProject> updateStrategy;
|
||||
private IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertStrategy;
|
||||
private DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ProjectToDTOConvertStrategy(IUpdateStrategy<IProject> updateStrategy, IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertStrategy)
|
||||
public ProjectToDTOConvertStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ProjectToDTOConvertStrategy(
|
||||
IUpdateStrategy<IProject> updateStrategy,
|
||||
DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertLogic)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertStrategy = convertStrategy;
|
||||
this.convertLogic = convertLogic;
|
||||
}
|
||||
|
||||
public ProjectToDTOConvertStrategy() : this(new ProjectUpdateStrategy(), new VisualAnalysisToDTOConvertStrategy())
|
||||
public override ProjectDTO GetNewItem(IProject source)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ProjectDTO Convert(IProject source)
|
||||
{
|
||||
Check();
|
||||
ProjectDTO newItem = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
InitializeStrategies();
|
||||
ProjectDTO newItem = new(source.Id);
|
||||
updateStrategy.Update(newItem, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
convertLogic = new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>(this, convertStrategy);
|
||||
newItem.VisualAnalyses.Clear();
|
||||
foreach (var item in source.VisualAnalyses)
|
||||
{
|
||||
@@ -51,15 +35,15 @@ namespace DataAccess.DTOs
|
||||
newItem.VisualAnalyses.Add(newVisualAnalysis);
|
||||
}
|
||||
return newItem;
|
||||
|
||||
}
|
||||
|
||||
private void Check()
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<ProjectDTO, IProject>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
checkLogic.Check();
|
||||
updateStrategy ??= new ProjectUpdateStrategy();
|
||||
convertLogic ??= new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
|
||||
(this,
|
||||
new VisualAnalysisToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,16 @@
|
||||
using DataAccess.DTOs.Converters;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
internal class VisualAnalysisToDTOConvertStrategy : ConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
|
||||
{
|
||||
private IConvertStrategy<IAnalysis, IAnalysis> convertStrategy;
|
||||
|
||||
public VisualAnalysisToDTOConvertStrategy(IConvertStrategy<IAnalysis, IAnalysis> convertStrategy)
|
||||
{
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public VisualAnalysisToDTOConvertStrategy() : this(new AnalysisToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
private IConvertStrategy<IAnalysis, IAnalysis> convertLogic;
|
||||
|
||||
public override VisualAnalysisDTO GetNewItem(IVisualAnalysis source)
|
||||
{
|
||||
@@ -40,30 +21,29 @@ namespace DataAccess.DTOs
|
||||
return visualAnalysisDTO;
|
||||
}
|
||||
|
||||
public VisualAnalysisToDTOConvertStrategy
|
||||
(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary,
|
||||
IShiftTraceLogger traceLogger)
|
||||
: base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
private VisualAnalysisDTO GetNewAnalysis(IVisualAnalysis source)
|
||||
{
|
||||
VisualAnalysisDTO visualAnalysisDTO = new()
|
||||
InitializeStrategies();
|
||||
VisualAnalysisDTO visualAnalysisDTO = new(source.Id)
|
||||
{
|
||||
Id = source.Id
|
||||
Analysis = convertLogic.Convert(source.Analysis)
|
||||
};
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
convertStrategy.TraceLogger = TraceLogger;
|
||||
var convertLogic = new DictionaryConvertStrategy<IAnalysis, IAnalysis>(this, convertStrategy)
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = convertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
visualAnalysisDTO.Analysis = convertLogic.Convert(source.Analysis);
|
||||
return visualAnalysisDTO;
|
||||
}
|
||||
|
||||
private void Check()
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
var checkLogic = new CheckConvertLogic<VisualAnalysisDTO, IVisualAnalysis>();
|
||||
checkLogic.ConvertStrategy = this;
|
||||
checkLogic.TraceLogger = TraceLogger;
|
||||
checkLogic.Check();
|
||||
convertLogic ??= new DictionaryConvertStrategy<IAnalysis, IAnalysis>
|
||||
(this,
|
||||
new AnalysisToDTOConvertStrategy(ReferenceDictionary, TraceLogger)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DataAccess.DTOs.DTOEntities
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class BeamShearAnalysisDTO : IBeamShearAnalysis
|
||||
{
|
||||
@@ -18,6 +18,10 @@ namespace DataAccess.DTOs.DTOEntities
|
||||
[JsonProperty("Color")]
|
||||
public Color Color { get; set; }
|
||||
public IVersionProcessor VersionProcessor { get; set; } = new VersionProcessorDTO();
|
||||
public BeamShearAnalysisDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
|
||||
public object Clone()
|
||||
|
||||
@@ -13,16 +13,19 @@ namespace DataAccess.DTOs
|
||||
public class ProjectDTO : IProject
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
public Guid Id { get;}
|
||||
[JsonIgnore]
|
||||
public string FullFileName { get; set; }
|
||||
[JsonIgnore]
|
||||
public bool IsActual { get; set; }
|
||||
|
||||
[JsonProperty("VisualAnalyses")]
|
||||
public List<IVisualAnalysis> VisualAnalyses { get; set; } = new();
|
||||
|
||||
[JsonIgnore]
|
||||
public string FileName { get; set; }
|
||||
|
||||
public ProjectDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,16 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
public Guid Id { get;}
|
||||
[JsonProperty("Analysis")]
|
||||
public IAnalysis Analysis { get; set; }
|
||||
[JsonIgnore]
|
||||
public Action ActionToRun { get; set; }
|
||||
|
||||
public VisualAnalysisDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
return this;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace DataAccess.Infrastructures
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.IsValid = false;
|
||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||
result.Description += ex.Message;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace StructureHelper.Windows.BeamShears
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace StructureHelper.Windows.BeamShears
|
||||
var valueList = new List<double>
|
||||
{
|
||||
results[i].InputData.InclinedSection.EndCoord,
|
||||
results[i].InputData.InclinedSection.EndCoord / results[i].InputData.InclinedSection.EffectiveDepth,
|
||||
results[i].InputData.ForceTuple.Nz * unitForce.Multiplyer,
|
||||
results[i].InputData.ForceTuple.Qy * unitForce.Multiplyer,
|
||||
results[i].TotalStrength * unitForce.Multiplyer,
|
||||
@@ -68,9 +69,10 @@ namespace StructureHelper.Windows.BeamShears
|
||||
List<string> strings = new()
|
||||
{
|
||||
"End coord",
|
||||
"a/d-ratio",
|
||||
"Nz",
|
||||
"Qy",
|
||||
"Qlim",
|
||||
"Qult",
|
||||
"Qb",
|
||||
"Qsw",
|
||||
"Uf"
|
||||
|
||||
@@ -19,6 +19,12 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
protected ConvertStrategy(IConvertStrategy<ISaveable, ISaveable> convertStrategy)
|
||||
{
|
||||
ReferenceDictionary = convertStrategy.ReferenceDictionary;
|
||||
TraceLogger = convertStrategy.TraceLogger;
|
||||
}
|
||||
|
||||
public ConvertStrategy()
|
||||
{
|
||||
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelperCommon.Models.Analyses
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements propertis of analysis
|
||||
/// </summary>
|
||||
public interface IAnalysis : ISaveable, ICloneable
|
||||
{
|
||||
string Name { get; set; }
|
||||
string Tags { get; set; }
|
||||
string Comment { get; set; }
|
||||
Color Color { get; set; }
|
||||
/// <summary>
|
||||
/// Processor of subversions of analysis
|
||||
/// </summary>
|
||||
IVersionProcessor VersionProcessor { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,20 @@ using System.Windows.Media;
|
||||
|
||||
namespace StructureHelperLogics.Models.Analyses
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public class BeamShearAnalysis : IBeamShearAnalysis
|
||||
{
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
/// <inheritdoc/>
|
||||
public string Tags { get; set; } = string.Empty;
|
||||
/// <inheritdoc/>
|
||||
public string Comment { get; set; } = string.Empty;
|
||||
/// <inheritdoc/>
|
||||
public Color Color { get; set; } = Color.FromRgb(128, 0, 0);
|
||||
/// <inheritdoc/>
|
||||
public IVersionProcessor VersionProcessor { get; set; } = new VersionProcessor();
|
||||
public BeamShearAnalysis(Guid id)
|
||||
{
|
||||
|
||||
@@ -3,12 +3,6 @@ using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Analyses
|
||||
{
|
||||
|
||||
@@ -7,6 +7,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Analyses
|
||||
{
|
||||
/// <summary>
|
||||
/// Implemants properties for analysis of beam for shear
|
||||
/// </summary>
|
||||
public interface IBeamShearAnalysis : IAnalysis
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
public class BeamShear : IBeamShear
|
||||
{
|
||||
|
||||
private ICloneStrategy<IBeamShear> cloneStrategy;
|
||||
public Guid Id { get; }
|
||||
public IBeamShearRepository Repository { get; } = new BeamShearRepository(Guid.NewGuid());
|
||||
public IBeamShearRepository Repository { get; set; } = new BeamShearRepository(Guid.NewGuid());
|
||||
public BeamShear(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
@@ -18,7 +14,10 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var cloningStrategy = new DeepCloningStrategy();
|
||||
cloneStrategy = new BeamShearCloneStrategy(cloningStrategy);
|
||||
var newItem = cloneStrategy.GetClone(this);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
public class BeamShearRepository : IBeamShearRepository
|
||||
{
|
||||
|
||||
private ICloneStrategy<IBeamShearRepository> cloneStrategy;
|
||||
public Guid Id { get; }
|
||||
|
||||
public List<IBeamShearAction> Actions { get; } = new();
|
||||
|
||||
public List<ICalculator> Calculators { get; } = new();
|
||||
|
||||
public List<IBeamShearSection> Sections { get; } = new();
|
||||
|
||||
public List<IStirrup> Stirrups { get; } = new();
|
||||
|
||||
|
||||
@@ -30,7 +21,10 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var cloningStrategy = new DeepCloningStrategy();
|
||||
cloneStrategy = new BeamShearRepositoryCloneStrategy(cloningStrategy);
|
||||
var newItem = cloneStrategy.GetClone(this);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
public interface IBeamShear : ISaveable, ICloneable
|
||||
{
|
||||
IBeamShearRepository Repository { get; }
|
||||
IBeamShearRepository Repository { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
public class BeamShearCloneStrategy : ICloneStrategy<IBeamShear>
|
||||
{
|
||||
private ICloningStrategy cloningStrategy;
|
||||
private ICloneStrategy<IBeamShearRepository> cloneStrategy;
|
||||
private BeamShear beamShear;
|
||||
public BeamShearCloneStrategy(ICloningStrategy cloningStrategy)
|
||||
{
|
||||
this.cloningStrategy = cloningStrategy;
|
||||
}
|
||||
|
||||
public IBeamShear GetClone(IBeamShear sourceObject)
|
||||
{
|
||||
InitializeStrategies();
|
||||
beamShear = new(Guid.NewGuid())
|
||||
{
|
||||
Repository = cloneStrategy.GetClone(sourceObject.Repository)
|
||||
};
|
||||
return beamShear;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
cloningStrategy = new DeepCloningStrategy();
|
||||
cloneStrategy ??= new BeamShearRepositoryCloneStrategy(cloningStrategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
|
||||
//All rights reserved.
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
public class BeamShearRepositoryCloneStrategy : ICloneStrategy<IBeamShearRepository>
|
||||
{
|
||||
private ICloningStrategy cloningStrategy;
|
||||
private IUpdateStrategy<IHasBeamShearActions> actionUpdateStrategy;
|
||||
private IUpdateStrategy<IHasBeamShearSections> sectionUpdateStrategy;
|
||||
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
|
||||
private BeamShearRepository targetRepository;
|
||||
|
||||
public BeamShearRepositoryCloneStrategy(ICloningStrategy cloningStrategy)
|
||||
{
|
||||
this.cloningStrategy = cloningStrategy;
|
||||
}
|
||||
public IBeamShearRepository GetClone(IBeamShearRepository sourceObject)
|
||||
{
|
||||
InitializeStrategies();
|
||||
targetRepository = new(Guid.NewGuid());
|
||||
actionUpdateStrategy.Update(targetRepository, sourceObject);
|
||||
sectionUpdateStrategy.Update(targetRepository, sourceObject);
|
||||
stirrupUpdateStrategy.Update(targetRepository, sourceObject);
|
||||
return targetRepository;
|
||||
}
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
actionUpdateStrategy ??= new HasActionsUpdateCloneStrategy(cloningStrategy);
|
||||
sectionUpdateStrategy ??= new HasSectionsUpdateCloneStrategy(cloningStrategy);
|
||||
stirrupUpdateStrategy ??= new HasStirrupsUpdateCloneStrategy(cloningStrategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
public class HasActionsUpdateCloneStrategy : IUpdateStrategy<IHasBeamShearActions>
|
||||
{
|
||||
private readonly ICloningStrategy cloningStrategy;
|
||||
|
||||
public HasActionsUpdateCloneStrategy(ICloningStrategy cloningStrategy)
|
||||
{
|
||||
this.cloningStrategy = cloningStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasBeamShearActions targetObject, IHasBeamShearActions sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(cloningStrategy);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Actions.Clear();
|
||||
foreach (var item in sourceObject.Actions)
|
||||
{
|
||||
var newItem = cloningStrategy.Clone(item);
|
||||
targetObject.Actions.Add(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
public class HasSectionsUpdateCloneStrategy : IUpdateStrategy<IHasBeamShearSections>
|
||||
{
|
||||
private readonly ICloningStrategy cloningStrategy;
|
||||
|
||||
public HasSectionsUpdateCloneStrategy(ICloningStrategy cloningStrategy)
|
||||
{
|
||||
this.cloningStrategy = cloningStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasBeamShearSections targetObject, IHasBeamShearSections sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(cloningStrategy);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Sections.Clear();
|
||||
foreach (var item in sourceObject.Sections)
|
||||
{
|
||||
IBeamShearSection newSection = cloningStrategy.Clone(item);
|
||||
targetObject.Sections.Add(newSection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
public class HasStirrupsUpdateCloneStrategy : IUpdateStrategy<IHasStirrups>
|
||||
{
|
||||
private readonly ICloningStrategy cloningStrategy;
|
||||
|
||||
public HasStirrupsUpdateCloneStrategy(ICloningStrategy cloningStrategy)
|
||||
{
|
||||
this.cloningStrategy = cloningStrategy;
|
||||
}
|
||||
|
||||
public void Update(IHasStirrups targetObject, IHasStirrups sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(cloningStrategy);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Stirrups.Clear();
|
||||
foreach (var item in sourceObject.Stirrups)
|
||||
{
|
||||
IStirrup newStirrup = cloningStrategy.Clone(item);
|
||||
targetObject.Stirrups.Add(newStirrup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class CrossSectionRepositoryCloneStrategy : ICloneStrategy<ICrossSectionRepository>
|
||||
{
|
||||
private ICloningStrategy cloningStrategy;
|
||||
private readonly ICloningStrategy cloningStrategy;
|
||||
private CrossSectionRepository targetRepository;
|
||||
private IUpdateStrategy<IHasForceActions> forcesUpdateStrategy;
|
||||
private IUpdateStrategy<IHasHeadMaterials> materialsUpdateStrategy;
|
||||
|
||||
@@ -4,6 +4,7 @@ using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperLogics.Models.BeamShears.Logics;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
|
||||
namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
{
|
||||
@@ -23,18 +24,18 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
|
||||
{
|
||||
_mockLogger = new Mock<IShiftTraceLogger>();
|
||||
_mockSummaryForceLogic = new Mock<ISumForceByShearLoadLogic>();
|
||||
var mockAxisAction = new Mock<IBeamShearAxisAction>();
|
||||
var mockAction = new Mock<IBeamShearAction>();
|
||||
var mockInclinedSection = new Mock<IInclinedSection>();
|
||||
var mockShearLoad = new Mock<IBeamSpanLoad>();
|
||||
|
||||
mockAxisAction.Setup(a => a.SupportForce.ForceTuple.Qx).Returns(100.0);
|
||||
mockAxisAction.Setup(a => a.ShearLoads).Returns(new List<IBeamSpanLoad> { mockShearLoad.Object });
|
||||
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(mockAxisAction.Object, mockInclinedSection.Object, _mockLogger.Object, _mockSummaryForceLogic.Object);
|
||||
_logic = new GetDirectShearForceLogic(mockAction.Object, mockInclinedSection.Object, LimitStates.ULS, CalcTerms.ShortTerm, _mockLogger.Object, _mockSummaryForceLogic.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace StructureHelperTests.UnitTests.ConvertStrategiesTest
|
||||
public void GetNewItem_ShouldLogStartAndEndMessages()
|
||||
{
|
||||
// Arrange
|
||||
var projectDto = new ProjectDTO
|
||||
var projectDto = new ProjectDTO(Guid.Empty)
|
||||
{
|
||||
VisualAnalyses = new List<IVisualAnalysis> { new Mock<IVisualAnalysis>().Object }
|
||||
};
|
||||
@@ -59,7 +59,7 @@ namespace StructureHelperTests.UnitTests.ConvertStrategiesTest
|
||||
public void GetNewItem_ShouldLogWarningIfNoAnalyses()
|
||||
{
|
||||
// Arrange
|
||||
var projectDto = new ProjectDTO
|
||||
var projectDto = new ProjectDTO(Guid.Empty)
|
||||
{
|
||||
VisualAnalyses = Enumerable.Empty<IVisualAnalysis>().ToList()
|
||||
};
|
||||
@@ -75,7 +75,7 @@ namespace StructureHelperTests.UnitTests.ConvertStrategiesTest
|
||||
public void GetAnalyses_ShouldConvertEachVisualAnalysisAndLogCount()
|
||||
{
|
||||
// Arrange
|
||||
var projectDto = new ProjectDTO
|
||||
var projectDto = new ProjectDTO(Guid.Empty)
|
||||
{
|
||||
VisualAnalyses = new List<IVisualAnalysis> { new Mock<IVisualAnalysis>().Object, new Mock<IVisualAnalysis>().Object }
|
||||
};
|
||||
@@ -98,7 +98,7 @@ namespace StructureHelperTests.UnitTests.ConvertStrategiesTest
|
||||
public void GetAnalyses_ShouldLogConvertedAnalysisCount()
|
||||
{
|
||||
// Arrange
|
||||
var projectDto = new ProjectDTO
|
||||
var projectDto = new ProjectDTO(Guid.Empty)
|
||||
{
|
||||
VisualAnalyses = new List<IVisualAnalysis> { new Mock<IVisualAnalysis>().Object }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user