Add cross-section convert strategies

This commit is contained in:
Evgeny Redikultsev
2024-09-28 20:46:42 +05:00
parent c10d6eb94e
commit 58b6e0eb8b
89 changed files with 1204 additions and 174 deletions

View File

@@ -0,0 +1,59 @@
using LoaderCalculator.Data.Materials;
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
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 ConcreteLibMaterialDTO : IConcreteLibMaterial
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("RelativeHumidity")]
public double RelativeHumidity { get; set; }
[JsonProperty("MinAge")]
public double MinAge { get; set; }
[JsonProperty("MaxAge")]
public double MaxAge { get; set; }
[JsonProperty("MaterialEntity")]
public ILibMaterialEntity MaterialEntity { get; set; }
[JsonProperty("SafetyFactors")]
public List<IMaterialSafetyFactor> SafetyFactors { get; set; }
[JsonProperty("TensionForULS")]
public bool TensionForULS { get; set; }
[JsonProperty("TensionForSLS")]
public bool TensionForSLS { get; set; }
public IMaterialLogic MaterialLogic { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public List<IMaterialLogic> MaterialLogics => throw new NotImplementedException();
public object Clone()
{
throw new NotImplementedException();
}
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
throw new NotImplementedException();
}
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
throw new NotImplementedException();
}
public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,66 @@
using StructureHelperCommon.Infrastructures.Exceptions;
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;
namespace DataAccess.DTOs.Converters
{
public class AnalysisToDTOConvertStrategy : IConvertStrategy<IAnalysis, IAnalysis>
{
private const string Message = "Analysis type is";
private IConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis> convertCrossSectionNdmAnalysisStrategy = new CrossSectionNdmAnalysisToDTOConvertStrategy();
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public IAnalysis Convert(IAnalysis source)
{
Check();
IAnalysis analysis;
if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
{
analysis = GetCrossSectionNdmAnalysisDTO(crossSectionNdmAnalysis);
}
else
{
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
foreach (var item in source.VersionProcessor.Versions)
{
}
return analysis;
}
private CrossSectionNdmAnalysisDTO GetCrossSectionNdmAnalysisDTO(ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
{
TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
convertCrossSectionNdmAnalysisStrategy.ReferenceDictionary = ReferenceDictionary;
convertCrossSectionNdmAnalysisStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>()
{
ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = convertCrossSectionNdmAnalysisStrategy,
TraceLogger = TraceLogger
};
CrossSectionNdmAnalysisDTO crossSectionNdmAnalysisDTO = convertLogic.Convert(crossSectionNdmAnalysis);
return crossSectionNdmAnalysisDTO;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<IAnalysis, IAnalysis>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,33 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
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 ConcreteLibMaterialToDTOConvertStrategy : IConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>
{
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ConcreteLibMaterialDTO Convert(IConcreteLibMaterial source)
{
Check();
}
private void Check()
{
var checkLogic = new CheckConvertLogic<ConcreteLibMaterialDTO, IConcreteLibMaterial>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,64 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
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
{
internal class CrossSectionNdmAnalysisToDTOConvertStrategy : IConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>
{
private IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy;
private IConvertStrategy<VersionProcessorDTO, IVersionProcessor> convertStrategy;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public CrossSectionNdmAnalysisToDTOConvertStrategy(
IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy,
IConvertStrategy<VersionProcessorDTO, IVersionProcessor> convertStrategy,
IShiftTraceLogger traceLogger)
{
this.updateStrategy = updateStrategy;
this.convertStrategy = convertStrategy;
this.TraceLogger = traceLogger;
}
public CrossSectionNdmAnalysisToDTOConvertStrategy() : this(new CrossSectionNdmAnalysisUpdateStrategy(),
new VersionProcessorToDTOConvertStrategy(),
null)
{
}
public CrossSectionNdmAnalysisDTO Convert(ICrossSectionNdmAnalysis source)
{
Check();
CrossSectionNdmAnalysisDTO newItem = new();
newItem.Id = source.Id;
updateStrategy.Update(newItem, source);
convertStrategy.ReferenceDictionary = ReferenceDictionary;
convertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<VersionProcessorDTO, IVersionProcessor>()
{
ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = convertStrategy,
TraceLogger = TraceLogger
};
newItem.VersionProcessor = convertLogic.Convert(source.VersionProcessor);
return newItem;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,73 @@
using DataAccess.DTOs.Converters;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
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 CrossSectionRepositoryToDTOConvertStrategy : IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>
{
private IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy;
public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy)
{
this.materialConvertStrategy = materialConvertStrategy;
}
public CrossSectionRepositoryToDTOConvertStrategy() : this(
new HeadMaterialToDTOConvertStrategy())
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public CrossSectionRepositoryDTO Convert(ICrossSectionRepository source)
{
Check();
CrossSectionRepositoryDTO newItem = new()
{
Id = source.Id
};
List<HeadMaterialDTO> materials = ProcessMaterials(source);
newItem.HeadMaterials.AddRange(materials);
return newItem;
}
private List<HeadMaterialDTO> ProcessMaterials(ICrossSectionRepository source)
{
materialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
materialConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<HeadMaterialDTO, IHeadMaterial>()
{
ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = materialConvertStrategy,
TraceLogger = TraceLogger
};
List<HeadMaterialDTO> materials = new();
foreach (var item in source.HeadMaterials)
{
materials.Add(convertLogic.Convert(item));
}
return materials;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<CrossSectionRepositoryDTO, ICrossSectionRepository>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,61 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.Converters
{
public class CrossSectionToDTOConvertStrategy : IConvertStrategy<CrossSectionDTO, ICrossSection>
{
private IUpdateStrategy<ICrossSection> updateStrategy;
private IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertStrategy;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public CrossSectionToDTOConvertStrategy(IUpdateStrategy<ICrossSection> updateStrategy,
IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertStrategy)
{
this.updateStrategy = updateStrategy;
this.convertStrategy = convertStrategy;
}
public CrossSectionToDTOConvertStrategy() : this(
new CrossSectionUpdateStrategy(),
new CrossSectionRepositoryToDTOConvertStrategy())
{
}
public CrossSectionDTO Convert(ICrossSection source)
{
Check();
CrossSectionDTO newItem = new()
{
Id = source.Id
};
convertStrategy.ReferenceDictionary = ReferenceDictionary;
convertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>()
{
ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = convertStrategy,
TraceLogger = TraceLogger
};
newItem.SectionRepository = convertLogic.Convert(source.SectionRepository);
return newItem;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<CrossSectionDTO, ICrossSection>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,65 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
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 DataAccess.DTOs.Converters
{
public class DateVersionToDTOConvertStrategy : IConvertStrategy<DateVersionDTO, IDateVersion>
{
private IUpdateStrategy<IDateVersion> updateStrategy;
private IConvertStrategy<ISaveable, ISaveable> convertStrategy;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public DateVersionToDTOConvertStrategy(
IUpdateStrategy<IDateVersion> updateStrategy,
IConvertStrategy<ISaveable, ISaveable> convertStrategy)
{
this.updateStrategy = updateStrategy;
this.convertStrategy = convertStrategy;
}
public DateVersionToDTOConvertStrategy() : this (
new DateVersionUpdateStrategy(),
new VersionItemToDTOConvertStrategy())
{
}
public DateVersionDTO Convert(IDateVersion source)
{
Check();
DateVersionDTO newItem = new()
{
Id = source.Id
};
updateStrategy.Update(newItem, source);
convertStrategy.ReferenceDictionary = ReferenceDictionary;
convertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>()
{
ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = convertStrategy,
TraceLogger = TraceLogger
};
newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion);
return newItem;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<DateVersionDTO, IDateVersion>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,37 @@
using StructureHelper.Models.Materials;
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.Converters
{
public class HeadMaterialToDTOConvertStrategy : IConvertStrategy<HeadMaterialDTO, IHeadMaterial>
{
private IUpdateStrategy<IHeadMaterial> updateStrategy;
public HeadMaterialToDTOConvertStrategy(IUpdateStrategy<IHeadMaterial> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public HeadMaterialToDTOConvertStrategy() : this (new HeadMaterialUpdateStrategy())
{
}
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public HeadMaterialDTO Convert(IHeadMaterial source)
{
HeadMaterialDTO newItem = new() { Id = source.Id};
updateStrategy.Update(newItem, source);
return newItem;
}
}
}

View File

@@ -0,0 +1,31 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
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
{
internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy<IHelperMaterial, IHelperMaterial>
{
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public IHelperMaterial Convert(IHelperMaterial source)
{
Check();
}
private void Check()
{
var checkLogic = new CheckConvertLogic<IHelperMaterial, IHelperMaterial>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
}
}

View File

@@ -31,21 +31,35 @@ namespace DataAccess.DTOs
public ProjectDTO Convert(IProject source) public ProjectDTO Convert(IProject source)
{ {
ProjectDTO projectDTO = new(source.Id); Check();
updateStrategy.Update(projectDTO, source); ProjectDTO newItem = new()
{
Id = source.Id
};
updateStrategy.Update(newItem, source);
convertStrategy.ReferenceDictionary = ReferenceDictionary; convertStrategy.ReferenceDictionary = ReferenceDictionary;
convertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>() var convertLogic = new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>()
{ {
ReferenceDictionary = ReferenceDictionary, ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = convertStrategy, ConvertStrategy = convertStrategy,
TraceLogger = TraceLogger TraceLogger = TraceLogger
}; };
newItem.VisualAnalyses.Clear();
foreach (var item in source.VisualAnalyses) foreach (var item in source.VisualAnalyses)
{ {
var newVisualAnalysis = convertLogic.Convert(item); var newVisualAnalysis = convertLogic.Convert(item);
projectDTO.VisualAnalyses.Add(newVisualAnalysis); newItem.VisualAnalyses.Add(newVisualAnalysis);
} }
return projectDTO; return newItem;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<ProjectDTO, IProject>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
} }
} }
} }

View File

@@ -0,0 +1,63 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DataAccess.DTOs.Converters
{
public class VersionItemToDTOConvertStrategy : IConvertStrategy<ISaveable, ISaveable>
{
private const string Message = "Analysis type is";
private IConvertStrategy<CrossSectionDTO, ICrossSection> crossSectionConvertStrategy = new CrossSectionToDTOConvertStrategy();
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public ISaveable Convert(ISaveable source)
{
Check();
ISaveable saveable;
if (source is ICrossSection crossSection)
{
saveable = ProcessCrossSection(crossSection);
}
else
{
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
return saveable;
}
private ISaveable ProcessCrossSection(ICrossSection crossSection)
{
TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
ISaveable saveable;
crossSectionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
crossSectionConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<CrossSectionDTO, ICrossSection>()
{
ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = crossSectionConvertStrategy,
TraceLogger = TraceLogger
};
saveable = convertLogic.Convert(crossSection);
return saveable;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<ISaveable, ISaveable>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
}
}

View File

@@ -0,0 +1,48 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs.Converters
{
public class VersionProcessorToDTOConvertStrategy : IConvertStrategy<VersionProcessorDTO, IVersionProcessor>
{
private IConvertStrategy<DateVersionDTO, IDateVersion> convertStrategy = new DateVersionToDTOConvertStrategy();
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public VersionProcessorDTO Convert(IVersionProcessor source)
{
Check();
VersionProcessorDTO newItem = new()
{
Id = source.Id
};
convertStrategy.ReferenceDictionary = ReferenceDictionary;
convertStrategy.TraceLogger = TraceLogger;
foreach (var item in source.Versions)
{
var convertLogic = new DictionaryConvertStrategy<DateVersionDTO, IDateVersion>()
{
ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = convertStrategy,
TraceLogger = TraceLogger
};
newItem.Versions.Add(convertLogic.Convert(item));
}
return newItem;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<VersionProcessorDTO, IVersionProcessor>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
}
}

View File

@@ -1,9 +1,13 @@
using StructureHelperCommon.Infrastructures.Interfaces; using DataAccess.DTOs.Converters;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses; using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Projects;
using StructureHelperLogic.Models.Analyses;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -11,16 +15,45 @@ namespace DataAccess.DTOs
{ {
internal class VisualAnalysisToDTOConvertStrategy : IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> internal class VisualAnalysisToDTOConvertStrategy : IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
{ {
private IConvertStrategy<IAnalysis, IAnalysis> convertStrategy;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; } public IShiftTraceLogger TraceLogger { get; set; }
public VisualAnalysisToDTOConvertStrategy(IConvertStrategy<IAnalysis, IAnalysis> convertStrategy)
{
this.convertStrategy = convertStrategy;
}
public VisualAnalysisToDTOConvertStrategy() : this(new AnalysisToDTOConvertStrategy())
{
}
public VisualAnalysisDTO Convert(IVisualAnalysis source) public VisualAnalysisDTO Convert(IVisualAnalysis source)
{ {
Check();
VisualAnalysisDTO visualAnalysisDTO = new() VisualAnalysisDTO visualAnalysisDTO = new()
{ {
Id = source.Id Id = source.Id
}; };
convertStrategy.ReferenceDictionary = ReferenceDictionary;
convertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<IAnalysis, IAnalysis>()
{
ReferenceDictionary = ReferenceDictionary,
ConvertStrategy = convertStrategy,
TraceLogger = TraceLogger
};
visualAnalysisDTO.Analysis = convertLogic.Convert(source.Analysis);
return visualAnalysisDTO; return visualAnalysisDTO;
} }
private void Check()
{
var checkLogic = new CheckConvertLogic<VisualAnalysisDTO, IVisualAnalysis>();
checkLogic.ConvertStrategy = this;
checkLogic.TraceLogger = TraceLogger;
checkLogic.Check();
}
} }
} }

View File

@@ -1,4 +1,5 @@
using StructureHelperLogics.Models.CrossSections; using Newtonsoft.Json;
using StructureHelperLogics.Models.CrossSections;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -9,9 +10,11 @@ namespace DataAccess.DTOs
{ {
public class CrossSectionDTO : ICrossSection public class CrossSectionDTO : ICrossSection
{ {
public ICrossSectionRepository SectionRepository { get; } [JsonProperty("Id")]
public Guid Id { get; set; } public Guid Id { get; set; }
[JsonProperty("SectionRepository")]
public ICrossSectionRepository SectionRepository { get; set; }
public object Clone() public object Clone()
{ {

View File

@@ -0,0 +1,28 @@
using Newtonsoft.Json;
using StructureHelperCommon.Models.Analyses;
using StructureHelperLogic.Models.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class CrossSectionNdmAnalysisDTO : ICrossSectionNdmAnalysis
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Tags")]
public string Tags { get; set; }
[JsonProperty("VersionProcessor")]
public IVersionProcessor VersionProcessor { get; set; } = new VersionProcessorDTO();
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,29 @@
using Newtonsoft.Json;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class CrossSectionRepositoryDTO : ICrossSectionRepository
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("HeadMaterials")]
public List<IHeadMaterial> HeadMaterials { get; } = new();
[JsonProperty("ForceActions")]
public List<IForceAction> ForceActions { get; } = new();
[JsonProperty("Primitives")]
public List<INdmPrimitive> Primitives { get; } = new();
[JsonProperty("Calculators")]
public List<ICalculator> Calculators { get; } = new();
}
}

View File

@@ -0,0 +1,22 @@
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class DateVersionDTO : IDateVersion
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("DateTime")]
public DateTime DateTime { get; set; }
[JsonProperty("AnalysisVersion")]
public ISaveable AnalysisVersion { get; set; }
}
}

View File

@@ -0,0 +1,44 @@
using LoaderCalculator.Data.Materials;
using Newtonsoft.Json;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace DataAccess.DTOs
{
public class HeadMaterialDTO : IHeadMaterial
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Color")]
public Color Color { get; set; }
[JsonProperty("HelperMaterial")]
public IHelperMaterial HelperMaterial { get; set; }
public object Clone()
{
throw new NotImplementedException();
}
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
throw new NotImplementedException();
}
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
throw new NotImplementedException();
}
}
}

View File

@@ -25,16 +25,5 @@ namespace DataAccess.DTOs
[JsonIgnore] [JsonIgnore]
public string FileName { get; set; } public string FileName { get; set; }
public ProjectDTO(Guid id)
{
Id = id;
}
public ProjectDTO() : this (Guid.NewGuid())
{
}
} }
} }

View File

@@ -0,0 +1,42 @@
using Newtonsoft.Json.Serialization;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class TypeBinder : ISerializationBinder
{
private List<(Type type, string name)> typesNames;
public static IShiftTraceLogger TraceLogger;
public TypeBinder(List<(Type type, string name)> typesNames, IShiftTraceLogger traceLogger = null)
{
this.typesNames = typesNames;
TraceLogger = traceLogger;
}
public void BindToName(Type serializedType, out string? assemblyName, out string? typeName)
{
assemblyName = null;
if (typesNames.Any(x => x.type == serializedType))
{
typeName = typesNames.Single(x => x.type == serializedType).name;
}
else
{
typeName = serializedType.FullName;
}
}
public Type BindToType(string? assemblyName, string typeName)
{
return typesNames.SingleOrDefault(x => x.name == typeName).type;
}
}
}

View File

@@ -0,0 +1,60 @@
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
internal enum TypeFileVersion
{
version_v1
}
internal static class TypeBinderListFactory
{
public static List<(Type type, string name)> GetTypeNameList(TypeFileVersion fileVersion)
{
if (fileVersion == TypeFileVersion.version_v1)
{
List<(Type type, string name)> typesNames = GetVersionV1();
return typesNames;
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(fileVersion));
}
}
private static List<(Type type, string name)> GetVersionV1()
{
return new List<(Type type, string name)>
{
{ (typeof(CirclePrimitiveDTO), "CircleNdmPrimitive") },
{ (typeof(ConcreteLibMaterialDTO), "ConcreteLibMaterial") },
{ (typeof(CrossSectionDTO), "CrossSection") },
{ (typeof(CrossSectionNdmAnalysisDTO), "CrossSectionNdmAnalysis") },
{ (typeof(CrossSectionRepositoryDTO), "CrossSectionRepository") },
{ (typeof(DateVersionDTO), "DateVersion") },
{ (typeof(FileVersionDTO), "FileVersion") },
{ (typeof(HeadMaterialDTO), "HeadMaterial") },
{ (typeof(NdmPrimitiveDTO), "NdmPrimitive") },
{ (typeof(IVisualAnalysis), "IVisualAnalysis") },
{ (typeof(List<ICalculator>), "ListOfICalculator") },
{ (typeof(List<IDateVersion>), "ListOfIDateVersion") },
{ (typeof(List<IForceAction>), "ListOfIForceAction") },
{ (typeof(List<IHeadMaterial>), "ListOfIHeadMaterial") },
{ (typeof(List<INdmPrimitive>), "ListOfINdmPrimitive") },
{ (typeof(List<IVisualAnalysis>), "ListOfIVisualAnalysis") },
{ (typeof(ProjectDTO), "Project") },
{ (typeof(VersionProcessorDTO), "VersionProcessor") },
{ (typeof(VisualAnalysisDTO), "VisualAnalysis") },
};
}
}
}

View File

@@ -0,0 +1,30 @@
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class VersionProcessorDTO : IVersionProcessor
{
[JsonProperty("Id")]
public Guid Id { get; set; }
[JsonProperty("Versions")]
public List<IDateVersion> Versions { get; } = new();
public void AddVersion(ISaveable newItem)
{
throw new NotImplementedException();
}
public IDateVersion GetCurrentVersion()
{
throw new NotImplementedException();
}
}
}

View File

@@ -19,4 +19,10 @@
<Folder Include="NewFolder\" /> <Folder Include="NewFolder\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="LoaderCalculator">
<HintPath>..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>
</Reference>
</ItemGroup>
</Project> </Project>

View File

@@ -48,22 +48,31 @@ namespace DataAccess.Infrastructures
private void SaveToFile(IProject project) private void SaveToFile(IProject project)
{ {
version = ProgramSetting.GetCurrentFileVersion(); try
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>(); {
FileVersionDTO versionDTO = GetVersionDTO(); version = ProgramSetting.GetCurrentFileVersion();
var versionString = Serialize(versionDTO, TraceLogger); refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
SaveStringToFile(project, versionString); FileVersionDTO versionDTO = GetVersionDTO();
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>(); var versionString = Serialize(versionDTO, TraceLogger);
ProjectDTO projectDTO = GetProjectDTO(project); File.Delete(project.FullFileName);
var projectString = Serialize(projectDTO, TraceLogger); SaveStringToFile(project, versionString);
SaveStringToFile(project, projectString); refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
ProjectDTO projectDTO = GetProjectDTO(project);
var projectString = Serialize(projectDTO, TraceLogger);
SaveStringToFile(project, projectString);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
}
} }
private void SaveStringToFile(IProject project, string versionString) private void SaveStringToFile(IProject project, string versionString)
{ {
try try
{ {
File.WriteAllText(project.FullFileName, versionString); File.AppendAllText(project.FullFileName, versionString);
TraceLogger?.AddMessage($"File {project.FullFileName} was saved successfully", TraceLogStatuses.Service); TraceLogger?.AddMessage($"File {project.FullFileName} was saved successfully", TraceLogStatuses.Service);
} }
catch (Exception ex) catch (Exception ex)
@@ -107,14 +116,17 @@ namespace DataAccess.Infrastructures
private static string Serialize(object obj, IShiftTraceLogger logger) private static string Serialize(object obj, IShiftTraceLogger logger)
{ {
List<(Type type, string name)> typesNames = TypeBinderListFactory.GetTypeNameList(TypeFileVersion.version_v1);
TypeBinder typeBinder = new(typesNames);
var settings = new JsonSerializerSettings var settings = new JsonSerializerSettings
{ {
Converters = new List<JsonConverter> Converters = new List<JsonConverter>
{ {
// Add other converters if needed // Add other converters if needed
new FileVersionDTOJsonConverter(logger), // Add the specific converter new FileVersionDTOJsonConverter(logger), // Add the specific converter
new ProjectDTOJsonConverter(logger) new ProjectDTOJsonConverter(logger)
}, },
SerializationBinder = typeBinder,
Formatting = Formatting.Indented, Formatting = Formatting.Indented,
PreserveReferencesHandling = PreserveReferencesHandling.All, PreserveReferencesHandling = PreserveReferencesHandling.All,
MissingMemberHandling = MissingMemberHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore,

View File

@@ -20,7 +20,7 @@ namespace StructureHelper.Services.Settings
{ {
get get
{ {
materials ??= new ListRepository<IHeadMaterial>(new MaterialUpdateStrategy()); materials ??= new ListRepository<IHeadMaterial>(new HeadMaterialUpdateStrategy());
return materials; return materials;
} }
} }

View File

@@ -31,7 +31,7 @@ namespace StructureHelper.Windows.MainWindow.Analyses
{ {
throw new StructureHelperException(ErrorStrings.NullReference); throw new StructureHelperException(ErrorStrings.NullReference);
} }
if (version.Item is ICrossSection crossSection) if (version.AnalysisVersion is ICrossSection crossSection)
{ {
ProcessCrossSection(crossSection); ProcessCrossSection(crossSection);
} }
@@ -49,9 +49,9 @@ namespace StructureHelper.Windows.MainWindow.Analyses
public object Clone() public object Clone()
{ {
var newAnalysis = Analysis.Clone() as IAnalysis; var newAnalysis = Analysis.Clone() as IAnalysis;
VisualAnalysis newItem = new(newAnalysis); VisualAnalysis newItem = new(newAnalysis);
return newItem; return newItem;
} }
} }
} }

View File

@@ -284,21 +284,21 @@ namespace StructureHelper.Windows.MainWindow
repository.HeadMaterials.AddRange(newRepository.HeadMaterials); repository.HeadMaterials.AddRange(newRepository.HeadMaterials);
repository.Primitives.AddRange(newRepository.Primitives); repository.Primitives.AddRange(newRepository.Primitives);
repository.ForceActions.AddRange(newRepository.ForceActions); repository.ForceActions.AddRange(newRepository.ForceActions);
repository.CalculatorsList.AddRange(newRepository.CalculatorsList); repository.Calculators.AddRange(newRepository.Calculators);
OnPropertyChanged(nameof(HeadMaterials)); OnPropertyChanged(nameof(HeadMaterials));
CombinationsLogic.AddItems(newRepository.ForceActions); CombinationsLogic.AddItems(newRepository.ForceActions);
CalculatorsLogic.AddItems(newRepository.CalculatorsList); CalculatorsLogic.AddItems(newRepository.Calculators);
var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(newRepository.Primitives); var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(newRepository.Primitives);
PrimitiveLogic.Refresh(); PrimitiveLogic.Refresh();
foreach (var item in newRepository.HeadMaterials) foreach (var item in newRepository.HeadMaterials)
{ {
GlobalRepository.Materials.Create(item); GlobalRepository.Materials.Create(item);
} }
foreach (var item in newRepository.ForceActions) foreach (var item in newRepository.ForceActions)
{ {
GlobalRepository.Actions.Create(item); GlobalRepository.Actions.Create(item);
} }
return primitives; return primitives;
} }
} }

View File

@@ -92,7 +92,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
private bool DeleteAction() private bool DeleteAction()
{ {
bool result = true; bool result = true;
var calcRepository = repository.CalculatorsList; var calcRepository = repository.Calculators;
foreach (var calc in calcRepository) foreach (var calc in calcRepository)
{ {
if (calc is ForceCalculator forceCalculator) if (calc is ForceCalculator forceCalculator)

View File

@@ -73,7 +73,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
} }
else else
{ {
var updateStrategy = new MaterialUpdateStrategy(); var updateStrategy = new HeadMaterialUpdateStrategy();
updateStrategy.Update(SelectedItem, copyObject); updateStrategy.Update(SelectedItem, copyObject);
} }
base.EditMethod(parameter); base.EditMethod(parameter);

View File

@@ -245,7 +245,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
} }
} }
public AnalysisViewModelLogic(ICrossSectionRepository sectionRepository) : base(sectionRepository.CalculatorsList) public AnalysisViewModelLogic(ICrossSectionRepository sectionRepository) : base(sectionRepository.Calculators)
{ {
repository = sectionRepository; repository = sectionRepository;
} }

View File

@@ -134,7 +134,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
{ {
var ndmPrimitive = SelectedItem.GetNdmPrimitive(); var ndmPrimitive = SelectedItem.GetNdmPrimitive();
repository.Primitives.Remove(ndmPrimitive); repository.Primitives.Remove(ndmPrimitive);
foreach (var calc in repository.CalculatorsList) foreach (var calc in repository.Calculators)
{ {
if (calc is ForceCalculator forceCalculator) if (calc is ForceCalculator forceCalculator)
{ {

View File

@@ -0,0 +1,46 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public class CheckConvertLogic<T, V> : ICheckLogic
where T : ISaveable
where V : ISaveable
{
private string checkResult;
public IConvertStrategy<T, V> ConvertStrategy { get; set; }
public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; }
public bool Check()
{
checkResult = string.Empty;
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage(LoggerStrings.LogicType(ConvertStrategy), TraceLogStatuses.Service);
if (ConvertStrategy is null)
{
string errorString = ErrorStrings.ParameterIsNull + ": Convert Strategy";
checkResult += "\n" + errorString;
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
if (ConvertStrategy.ReferenceDictionary is null)
{
string errorString = ErrorStrings.ParameterIsNull + ": Reference Dictionary";
checkResult += "\n" + errorString;
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
TraceLogger?.AddMessage("Checking of convert strategy is ok", TraceLogStatuses.Debug);
return true;
}
}
}

View File

@@ -17,6 +17,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public IConvertStrategy<T,V> ConvertStrategy { get; set; } public IConvertStrategy<T,V> ConvertStrategy { get; set; }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public T Convert(V source) public T Convert(V source)
{ {
ICheckInputData(); ICheckInputData();

View File

@@ -9,8 +9,18 @@ namespace StructureHelperCommon.Models.Analyses
{ {
public class DateVersion : IDateVersion public class DateVersion : IDateVersion
{ {
public Guid Id { get; }
public DateTime DateTime { get; set; } public DateTime DateTime { get; set; }
public ISaveable AnalysisVersion { get; set; }
public ISaveable Item { get; set; } public DateVersion(Guid id)
{
Id = id;
}
public DateVersion() : this (Guid.NewGuid())
{
}
} }
} }

View File

@@ -7,9 +7,9 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Analyses namespace StructureHelperCommon.Models.Analyses
{ {
public interface IDateVersion public interface IDateVersion : ISaveable
{ {
DateTime DateTime { get; set; } DateTime DateTime { get; set; }
ISaveable Item { get; set; } ISaveable AnalysisVersion { get; set; }
} }
} }

View File

@@ -19,7 +19,7 @@ namespace StructureHelperCommon.Models.Analyses
Id = id; Id = id;
Versions = new(); Versions = new();
} }
public VersionProcessor() : this (new Guid()) public VersionProcessor() : this (Guid.NewGuid())
{ {
} }
@@ -34,7 +34,7 @@ namespace StructureHelperCommon.Models.Analyses
var version = new DateVersion() var version = new DateVersion()
{ {
DateTime = DateTime.Now, DateTime = DateTime.Now,
Item = newItem AnalysisVersion = newItem
}; };
AddVersion(version); AddVersion(version);
} }

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Calculators
{
public interface IHasCalculators
{
List<ICalculator> Calculators { get; }
}
}

View File

@@ -15,6 +15,6 @@ namespace StructureHelperCommon.Models.Loggers
public static string Summary => "Summary"; public static string Summary => "Summary";
public static string Maximum => "Maximum"; public static string Maximum => "Maximum";
public static string Minimum => "Minimum"; public static string Minimum => "Minimum";
public static string CalculatorType(object obj) => string.Format("Calculator type: {0}", obj.GetType()); public static string LogicType(object obj) => string.Format("Logic type: {0}", obj.GetType());
} }
} }

View File

@@ -40,7 +40,7 @@ namespace StructureHelperCommon.Models.Sections.Logics
public (double ex, double ey) GetValue() public (double ex, double ey) GetValue()
{ {
eccentricityLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50); eccentricityLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage(string.Format(accEccMessage, "x")); TraceLogger?.AddMessage(string.Format(accEccMessage, "x"));
eccentricityLogic.Length = Length; eccentricityLogic.Length = Length;
eccentricityLogic.Size = SizeX; eccentricityLogic.Size = SizeX;

View File

@@ -30,7 +30,7 @@ namespace StructureHelperCommon.Models.Sections.Logics
} }
public double GetValue() public double GetValue()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
var lengthEccetricity = Length / lengthFactor; var lengthEccetricity = Length / lengthFactor;
TraceLogger?.AddMessage(string.Format("Length of member = {0}(m)", Length)); TraceLogger?.AddMessage(string.Format("Length of member = {0}(m)", Length));
TraceLogger?.AddMessage(string.Format("Accidental eccentricity by length e,a = {0}(m) / {1} = {2}(m)", Length, lengthFactor, lengthEccetricity)); TraceLogger?.AddMessage(string.Format("Accidental eccentricity by length e,a = {0}(m) / {1} = {2}(m)", Length, lengthFactor, lengthEccetricity));

View File

@@ -51,7 +51,7 @@ namespace StructureHelperCommon.Models.Sections
public IForceTuple GetValue() public IForceTuple GetValue()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
if (InputForceTuple is null) if (InputForceTuple is null)
{ {
string errorString = ErrorStrings.NullReference + $": {nameof(InputForceTuple)}"; string errorString = ErrorStrings.NullReference + $": {nameof(InputForceTuple)}";

View File

@@ -4,7 +4,7 @@ using StructureHelperLogics.Models.CrossSections;
namespace StructureHelperLogic.Models.Analyses namespace StructureHelperLogic.Models.Analyses
{ {
public class CrossSectionNdmAnalysis : IAnalysis public class CrossSectionNdmAnalysis : ICrossSectionNdmAnalysis
{ {
private CrossSectionNdmAnalysisUpdateStrategy updateStrategy = new(); private CrossSectionNdmAnalysisUpdateStrategy updateStrategy = new();
public Guid Id { get; private set; } public Guid Id { get; private set; }

View File

@@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Analyses namespace StructureHelperLogics.Models.Analyses
{ {
public class CrossSectionNdmAnalysisUpdateStrategy : IUpdateStrategy<CrossSectionNdmAnalysis> public class CrossSectionNdmAnalysisUpdateStrategy : IUpdateStrategy<ICrossSectionNdmAnalysis>
{ {
private IUpdateStrategy<IAnalysis> analysisUpdateStrategy; private IUpdateStrategy<IAnalysis> analysisUpdateStrategy;
private IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy; private IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy;
@@ -35,7 +35,7 @@ namespace StructureHelperLogics.Models.Analyses
} }
public void Update(CrossSectionNdmAnalysis targetObject, CrossSectionNdmAnalysis sourceObject) public void Update(ICrossSectionNdmAnalysis targetObject, ICrossSectionNdmAnalysis sourceObject)
{ {
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject); CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject); CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
@@ -44,24 +44,24 @@ namespace StructureHelperLogics.Models.Analyses
targetObject.VersionProcessor.Versions.Clear(); targetObject.VersionProcessor.Versions.Clear();
foreach (var version in sourceObject.VersionProcessor.Versions) foreach (var version in sourceObject.VersionProcessor.Versions)
{ {
if (version.Item is ICrossSection crossSection) if (version.AnalysisVersion is ICrossSection crossSection)
{ {
updateVersion(targetObject, version, crossSection); updateVersion(targetObject, version, crossSection);
} }
else else
{ {
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version.Item)); throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version.AnalysisVersion));
} }
} }
} }
private void updateVersion(CrossSectionNdmAnalysis targetObject, IDateVersion version, ICrossSection crossSection) private void updateVersion(ICrossSectionNdmAnalysis targetObject, IDateVersion version, ICrossSection crossSection)
{ {
DateVersion newVersion = new(); DateVersion newVersion = new();
dateUpdateStrategy.Update(newVersion, version); dateUpdateStrategy.Update(newVersion, version);
CrossSection newCrossection = new(); CrossSection newCrossection = new();
crossSectionUpdateStrategy.Update(newCrossection, crossSection); crossSectionUpdateStrategy.Update(newCrossection, crossSection);
newVersion.Item = newCrossection; newVersion.AnalysisVersion = newCrossection;
targetObject.VersionProcessor.Versions.Add(newVersion); targetObject.VersionProcessor.Versions.Add(newVersion);
} }
} }

View File

@@ -0,0 +1,8 @@
using StructureHelperCommon.Models.Analyses;
namespace StructureHelperLogic.Models.Analyses
{
public interface ICrossSectionNdmAnalysis : IAnalysis
{
}
}

View File

@@ -8,13 +8,18 @@ namespace StructureHelperLogics.Models.CrossSections
{ {
public class CrossSection : ICrossSection public class CrossSection : ICrossSection
{ {
public ICrossSectionRepository SectionRepository { get; private set; } public ICrossSectionRepository SectionRepository { get; private set; } = new CrossSectionRepository();
public Guid Id { get; private set; } public Guid Id { get; private set; }
public CrossSection() public CrossSection(Guid id)
{ {
SectionRepository = new CrossSectionRepository(); Id = id;
}
public CrossSection() : this(Guid.NewGuid())
{
} }
public object Clone() public object Clone()

View File

@@ -14,17 +14,19 @@ namespace StructureHelperLogics.Models.CrossSections
{ {
public class CrossSectionRepository : ICrossSectionRepository public class CrossSectionRepository : ICrossSectionRepository
{ {
public List<IForceAction> ForceActions { get; private set; } public Guid Id { get; }
public List<IHeadMaterial> HeadMaterials { get; private set; } public List<IForceAction> ForceActions { get; private set; } = new();
public List<INdmPrimitive> Primitives { get; } public List<IHeadMaterial> HeadMaterials { get; private set; } = new();
public List<ICalculator> CalculatorsList { get; private set; } public List<INdmPrimitive> Primitives { get; } = new();
public List<ICalculator> Calculators { get; private set; } = new();
public CrossSectionRepository() public CrossSectionRepository(Guid id)
{
Id = id;
}
public CrossSectionRepository() : this(Guid.NewGuid())
{ {
ForceActions = new List<IForceAction>();
HeadMaterials = new List<IHeadMaterial>();
Primitives = new List<INdmPrimitive>();
CalculatorsList = new List<ICalculator>();
} }
} }
} }

View File

@@ -1,6 +1,7 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services; using StructureHelperCommon.Services;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives.Logics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -11,18 +12,29 @@ namespace StructureHelperLogics.Models.CrossSections
{ {
public class CrossSectionUpdateStrategy : IUpdateStrategy<ICrossSection> public class CrossSectionUpdateStrategy : IUpdateStrategy<ICrossSection>
{ {
private IUpdateStrategy<ICrossSectionRepository> repositoryUpdateStrategy;
public CrossSectionUpdateStrategy() public CrossSectionUpdateStrategy(IUpdateStrategy<ICrossSectionRepository> repositoryUpdateStrategy)
{ {
this.repositoryUpdateStrategy = repositoryUpdateStrategy;
}
public CrossSectionUpdateStrategy() : this (
new CrossSectionRepositoryUpdateStrategy()
)
{
} }
public void Update(ICrossSection targetObject, ICrossSection sourceObject) public void Update(ICrossSection targetObject, ICrossSection sourceObject)
{ {
CheckObject.IsNull(targetObject, sourceObject); CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.SectionRepository.Calculators.Clear();
targetObject.SectionRepository.Primitives.Clear();
targetObject.SectionRepository.ForceActions.Clear();
targetObject.SectionRepository.HeadMaterials.Clear();
repositoryUpdateStrategy.Update(targetObject.SectionRepository, sourceObject.SectionRepository);
} }
} }
} }

View File

@@ -1,22 +1,13 @@
using StructureHelper.Models.Materials; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.Materials; using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.CrossSections namespace StructureHelperLogics.Models.CrossSections
{ {
public interface ICrossSectionRepository : IHasHeadMaterials, IHasPrimitives, IHasForceCombinations public interface ICrossSectionRepository : ISaveable, IHasHeadMaterials, IHasPrimitives, IHasForceCombinations, IHasCalculators
{ {
List<IForceAction> ForceActions { get; }
List<ICalculator> CalculatorsList { get; }
} }
} }

View File

@@ -18,6 +18,9 @@ namespace StructureHelperLogics.Models.Materials
private IMaterialOptionLogic optionLogic; private IMaterialOptionLogic optionLogic;
private IFactorLogic factorLogic => new FactorLogic(SafetyFactors); private IFactorLogic factorLogic => new FactorLogic(SafetyFactors);
private LMLogic.ITrueStrengthLogic strengthLogic; private LMLogic.ITrueStrengthLogic strengthLogic;
/// <inheritdoc/>
public Guid Id { get; }
/// <inheritdoc/> /// <inheritdoc/>
public ILibMaterialEntity MaterialEntity { get; set; } public ILibMaterialEntity MaterialEntity { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
@@ -38,8 +41,9 @@ namespace StructureHelperLogics.Models.Materials
public List<IMaterialLogic> MaterialLogics => materialLogics; public List<IMaterialLogic> MaterialLogics => materialLogics;
public ConcreteLibMaterial() public ConcreteLibMaterial(Guid id)
{ {
Id = id;
materialLogics = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList(); materialLogics = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
MaterialLogic = materialLogics.First(); MaterialLogic = materialLogics.First();
SafetyFactors = new List<IMaterialSafetyFactor>(); SafetyFactors = new List<IMaterialSafetyFactor>();
@@ -50,7 +54,12 @@ namespace StructureHelperLogics.Models.Materials
RelativeHumidity = 0.55d; RelativeHumidity = 0.55d;
MinAge = 0d; MinAge = 0d;
MaxAge = maxAge; MaxAge = maxAge;
} }
public ConcreteLibMaterial() : this (Guid.NewGuid())
{
}
public object Clone() public object Clone()
{ {

View File

@@ -16,11 +16,18 @@ namespace StructureHelperLogics.Models.Materials
public double Modulus { get; set; } public double Modulus { get; set; }
public double CompressiveStrength { get; set; } public double CompressiveStrength { get; set; }
public double TensileStrength { get; set; } public double TensileStrength { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; } public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
public ElasticMaterial() public Guid Id { get; }
public ElasticMaterial(Guid id)
{ {
SafetyFactors = new List<IMaterialSafetyFactor>(); Id = id;
}
public ElasticMaterial() : this(Guid.NewGuid())
{
} }
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)

View File

@@ -15,43 +15,34 @@ namespace StructureHelperLogics.Models.Materials
{ {
private IElasticMaterialLogic elasticMaterialLogic => new ElasticMaterialLogic(); private IElasticMaterialLogic elasticMaterialLogic => new ElasticMaterialLogic();
private MaterialTypes materialType; private MaterialTypes materialType;
IUpdateStrategy<IFRMaterial> fRUpdateStrategy = new FRUpdateStrategy(); IUpdateStrategy<IFRMaterial> updateStrategy = new FRUpdateStrategy();
public Guid Id { get; }
public double Modulus{ get; set; } public double Modulus{ get; set; }
public double CompressiveStrength { get; set; } public double CompressiveStrength { get; set; }
public double TensileStrength { get; set; } public double TensileStrength { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; } public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
public double ULSConcreteStrength { get; set; } public double ULSConcreteStrength { get; set; }
public double SumThickness { get; set; } public double SumThickness { get; set; }
public double GammaF2 => GetGammaF2(); public double GammaF2 => GetGammaF2();
private double GetGammaF2() public FRMaterial(MaterialTypes materialType, Guid id)
{ {
const double gammaF2Max = 0.9d; Id = id;
double gammaF2;
IFactorLogic factorLogic = new FactorLogic(SafetyFactors);
var factors = factorLogic.GetTotalFactor(LimitStates.ULS, CalcTerms.ShortTerm);
var rf = TensileStrength * factors.Tensile;
var epsUlt = rf / Modulus;
gammaF2 = 0.4d / epsUlt * Math.Sqrt(ULSConcreteStrength / (Modulus * SumThickness * 1e3d));
gammaF2 = Math.Min(gammaF2, gammaF2Max);
return gammaF2;
}
public FRMaterial(MaterialTypes materialType)
{
ULSConcreteStrength = 14e6d; ULSConcreteStrength = 14e6d;
SumThickness = 0.175e-3d; SumThickness = 0.175e-3d;
SafetyFactors = new List<IMaterialSafetyFactor>();
this.materialType = materialType; this.materialType = materialType;
SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultFRSafetyFactors(ProgramSetting.FRCodeType, this.materialType)); SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultFRSafetyFactors(ProgramSetting.FRCodeType, this.materialType));
} }
public FRMaterial(MaterialTypes materialType) : this (materialType, Guid.NewGuid())
{
}
public object Clone() public object Clone()
{ {
var newItem = new FRMaterial(this.materialType); var newItem = new FRMaterial(this.materialType);
var updateStrategy = fRUpdateStrategy;
updateStrategy.Update(newItem, this); updateStrategy.Update(newItem, this);
return newItem; return newItem;
} }
@@ -71,5 +62,17 @@ namespace StructureHelperLogics.Models.Materials
{ {
return GetLoaderMaterial(limitState, calcTerm); return GetLoaderMaterial(limitState, calcTerm);
} }
private double GetGammaF2()
{
const double gammaF2Max = 0.9d;
double gammaF2;
IFactorLogic factorLogic = new FactorLogic(SafetyFactors);
var factors = factorLogic.GetTotalFactor(LimitStates.ULS, CalcTerms.ShortTerm);
var rf = TensileStrength * factors.Tensile;
var epsUlt = rf / Modulus;
gammaF2 = 0.4d / epsUlt * Math.Sqrt(ULSConcreteStrength / (Modulus * SumThickness * 1e3d));
gammaF2 = Math.Min(gammaF2, gammaF2Max);
return gammaF2;
}
} }
} }

View File

@@ -16,6 +16,7 @@ namespace StructureHelper.Models.Materials
{ {
public class HeadMaterial : IHeadMaterial, INotifyPropertyChanged public class HeadMaterial : IHeadMaterial, INotifyPropertyChanged
{ {
private HeadMaterialUpdateStrategy updateStrategy = new HeadMaterialUpdateStrategy();
private Color color; private Color color;
public Guid Id { get; } public Guid Id { get; }
@@ -31,6 +32,7 @@ namespace StructureHelper.Models.Materials
} }
public IHelperMaterial HelperMaterial {get; set;} public IHelperMaterial HelperMaterial {get; set;}
public HeadMaterial(Guid id) public HeadMaterial(Guid id)
{ {
Id = id; Id = id;
@@ -51,8 +53,7 @@ namespace StructureHelper.Models.Materials
public object Clone() public object Clone()
{ {
var newItem = new HeadMaterial(); var newItem = new HeadMaterial();
newItem.HelperMaterial = this.HelperMaterial.Clone() as IHelperMaterial; newItem.HelperMaterial = HelperMaterial.Clone() as IHelperMaterial;
var updateStrategy = new MaterialUpdateStrategy();
updateStrategy.Update(newItem, this); updateStrategy.Update(newItem, this);
return newItem; return newItem;
} }

View File

@@ -2,11 +2,6 @@
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.Materials; using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media; using System.Windows.Media;
namespace StructureHelper.Models.Materials namespace StructureHelper.Models.Materials

View File

@@ -1,5 +1,6 @@
using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.Materials; using StructureHelperLogics.Models.Materials;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -7,7 +8,7 @@ using System.Text;
namespace StructureHelperLogics.Models.Materials namespace StructureHelperLogics.Models.Materials
{ {
public interface IHelperMaterial : ICloneable public interface IHelperMaterial : ISaveable, ICloneable
{ {
IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm); IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm); IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);

View File

@@ -28,6 +28,8 @@ namespace StructureHelperLogics.Models.Materials
public List<IMaterialLogic> MaterialLogics => throw new NotImplementedException(); public List<IMaterialLogic> MaterialLogics => throw new NotImplementedException();
public Guid Id => throw new NotImplementedException();
public LibMaterial(MaterialTypes materialType, CodeTypes codeType, string name, double mainStrength) public LibMaterial(MaterialTypes materialType, CodeTypes codeType, string name, double mainStrength)
{ {
this.MaterialType = materialType; this.MaterialType = materialType;

View File

@@ -5,13 +5,13 @@ using StructureHelperCommon.Services;
namespace StructureHelperLogics.Models.Materials namespace StructureHelperLogics.Models.Materials
{ {
public class MaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial> public class HeadMaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
{ {
private IUpdateStrategy<IElasticMaterial> elasticStrategy; private IUpdateStrategy<IElasticMaterial> elasticStrategy;
private IUpdateStrategy<IFRMaterial> frStrategy; private IUpdateStrategy<IFRMaterial> frStrategy;
private IUpdateStrategy<IConcreteLibMaterial> concreteStrategy; private IUpdateStrategy<IConcreteLibMaterial> concreteStrategy;
private IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy; private IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy;
public MaterialUpdateStrategy(IUpdateStrategy<IElasticMaterial> elasticStrategy, public HeadMaterialUpdateStrategy(IUpdateStrategy<IElasticMaterial> elasticStrategy,
IUpdateStrategy<IFRMaterial> frStrategy, IUpdateStrategy<IFRMaterial> frStrategy,
IUpdateStrategy<IConcreteLibMaterial> concreteStrategy, IUpdateStrategy<IConcreteLibMaterial> concreteStrategy,
IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy
@@ -22,7 +22,7 @@ namespace StructureHelperLogics.Models.Materials
this.concreteStrategy = concreteStrategy; this.concreteStrategy = concreteStrategy;
this.reinforcementStrategy= reinforcementStrategy; this.reinforcementStrategy= reinforcementStrategy;
} }
public MaterialUpdateStrategy() : this( public HeadMaterialUpdateStrategy() : this(
new ElasticUpdateStrategy(), new ElasticUpdateStrategy(),
new FRUpdateStrategy(), new FRUpdateStrategy(),
new ConcreteLibUpdateStrategy(), new ConcreteLibUpdateStrategy(),
@@ -31,7 +31,8 @@ namespace StructureHelperLogics.Models.Materials
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject) public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
{ {
CheckObject.CompareTypes(targetObject, sourceObject); CheckObject.IsNull(sourceObject);
CheckObject.IsNull(targetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name; targetObject.Name = sourceObject.Name;
targetObject.Color = sourceObject.Color; targetObject.Color = sourceObject.Color;

View File

@@ -22,16 +22,23 @@ namespace StructureHelperLogics.Models.Materials
private LoaderMaterialLogics.ITrueStrengthLogic strengthLogic; private LoaderMaterialLogics.ITrueStrengthLogic strengthLogic;
private readonly List<IMaterialLogic> materialLogics; private readonly List<IMaterialLogic> materialLogics;
public Guid Id { get; }
public ILibMaterialEntity MaterialEntity { get; set; } public ILibMaterialEntity MaterialEntity { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = new();
public IMaterialLogic MaterialLogic { get; set; } public IMaterialLogic MaterialLogic { get; set; }
public List<IMaterialLogic> MaterialLogics => materialLogics; public List<IMaterialLogic> MaterialLogics => materialLogics;
public ReinforcementLibMaterial()
public ReinforcementLibMaterial(Guid id)
{ {
Id = id;
materialLogics = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList(); materialLogics = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
MaterialLogic = materialLogics.First(); MaterialLogic = materialLogics.First();
SafetyFactors = new List<IMaterialSafetyFactor>(); }
public ReinforcementLibMaterial() : this (Guid.NewGuid())
{
} }
public object Clone() public object Clone()

View File

@@ -51,7 +51,7 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
calculators = calculatorLogic.GetNdmCalculators(); calculators = calculatorLogic.GetNdmCalculators();
AddAllForcesToCalculators(); AddAllForcesToCalculators();
AddAllPrimitivesToCalculator(); AddAllPrimitivesToCalculator();
repository.CalculatorsList.AddRange(calculators); repository.Calculators.AddRange(calculators);
return section; return section;
} }

View File

@@ -40,7 +40,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public void Run() public void Run()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
checkInputDataLogic.InputData = InputData; checkInputDataLogic.InputData = InputData;
checkInputDataLogic.TraceLogger = TraceLogger; checkInputDataLogic.TraceLogger = TraceLogger;
if (checkInputDataLogic.Check() != true) if (checkInputDataLogic.Check() != true)

View File

@@ -25,7 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public ForcesResults GetForcesResults() public ForcesResults GetForcesResults()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
GetCombinations(); GetCombinations();
CalculateResult(); CalculateResult();
return result; return result;

View File

@@ -67,7 +67,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
public void Run() public void Run()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage(LoggerStrings.MethodBasedOn + "SP63.13330.2018"); TraceLogger?.AddMessage(LoggerStrings.MethodBasedOn + "SP63.13330.2018");
var checkResult = CheckInputData(); var checkResult = CheckInputData();
if (checkResult != "") if (checkResult != "")

View File

@@ -31,7 +31,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
public double GetDeltaE() public double GetDeltaE()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage(string.Format("Eccentricity e = {0}", eccentricity)); TraceLogger?.AddMessage(string.Format("Eccentricity e = {0}", eccentricity));
TraceLogger?.AddMessage(string.Format("Height h = {0}", size)); TraceLogger?.AddMessage(string.Format("Height h = {0}", size));
var deltaE = Math.Abs(eccentricity) / size; var deltaE = Math.Abs(eccentricity) / size;

View File

@@ -26,7 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
public double GetEtaFactor() public double GetEtaFactor()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
if (LongitudinalForce >= 0d) return 1d; if (LongitudinalForce >= 0d) return 1d;
var Ncr = GetCriticalForce(); var Ncr = GetCriticalForce();
if (LongitudinalForce <= Ncr) if (LongitudinalForce <= Ncr)

View File

@@ -31,7 +31,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
public GenericResult<IForceTuple> GetForceTupleByBuckling() public GenericResult<IForceTuple> GetForceTupleByBuckling()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
var tuple = bucklingInputData.ForceTuple.Clone() as IForceTuple; var tuple = bucklingInputData.ForceTuple.Clone() as IForceTuple;

View File

@@ -29,7 +29,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
public double GetPhil() public double GetPhil()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
var distance = Math.Sqrt(point.X * point.X + point.Y * point.Y); var distance = Math.Sqrt(point.X * point.X + point.Y * point.Y);
string distMessage = string.Format("Distance = Sqrt(dX ^2 + dY^2) = Sqrt(({0})^2 + ({1})^2) = {2}, m", point.X, point.Y, distance); string distMessage = string.Format("Distance = Sqrt(dX ^2 + dY^2) = Sqrt(({0})^2 + ({1})^2) = {2}, m", point.X, point.Y, distance);
TraceLogger?.AddMessage(distMessage); TraceLogger?.AddMessage(distMessage);

View File

@@ -45,7 +45,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
public IForceTuple GetValue() public IForceTuple GetValue()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage("Get eccentricity taking into account accidental eccentricity"); TraceLogger?.AddMessage("Get eccentricity taking into account accidental eccentricity");
TraceLogger?.AddMessage(string.Format("Cross-section size along x-axis dx = {0}, along y-axis dy = {1}", sizeX, sizeY)); TraceLogger?.AddMessage(string.Format("Cross-section size along x-axis dx = {0}, along y-axis dy = {1}", sizeX, sizeY));

View File

@@ -42,7 +42,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public bool Check() public bool Check()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
result = true; result = true;
CheckResult = string.Empty; CheckResult = string.Empty;
CheckPrimitives(); CheckPrimitives();

View File

@@ -64,7 +64,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
PrepareNewResult(); PrepareNewResult();
CheckInputData(); CheckInputData();
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
try try
{ {
ProcessCalculations(); ProcessCalculations();

View File

@@ -54,7 +54,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public void Run() public void Run()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
PrepareNewResult(); PrepareNewResult();
ProcessCrackWidthCalculation(); ProcessCrackWidthCalculation();
} }

View File

@@ -33,7 +33,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public double GetCrackWidth() public double GetCrackWidth()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
CheckOptions(); CheckOptions();
TraceLogger?.AddMessage("Method of crack width calculation based on SP 63.13330.2018"); TraceLogger?.AddMessage("Method of crack width calculation based on SP 63.13330.2018");
TraceInputData(); TraceInputData();

View File

@@ -43,7 +43,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// <inheritdoc/> /// <inheritdoc/>
public List<INdm> GetNdmCollection() public List<INdm> GetNdmCollection()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug); TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
triangulateLogic = new TriangulatePrimitiveLogic() triangulateLogic = new TriangulatePrimitiveLogic()
{ {
@@ -57,7 +57,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// <inheritdoc/> /// <inheritdoc/>
public List<INdm> GetCrackedNdmCollection() public List<INdm> GetCrackedNdmCollection()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug); TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
triangulateLogic = new TriangulatePrimitiveLogic(new MeshCrackedConcreteLogic()) triangulateLogic = new TriangulatePrimitiveLogic(new MeshCrackedConcreteLogic())
{ {
@@ -72,7 +72,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// <inheritdoc/> /// <inheritdoc/>
public List<IRebarPrimitive> GetRebarPrimitives() public List<IRebarPrimitive> GetRebarPrimitives()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug); TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
List<IRebarPrimitive> rebarPrimitives = new(); List<IRebarPrimitive> rebarPrimitives = new();
foreach (var item in NdmPrimitives) foreach (var item in NdmPrimitives)
@@ -90,7 +90,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// <inheritdoc/> /// <inheritdoc/>
public List<INdm> GetElasticNdmCollection() public List<INdm> GetElasticNdmCollection()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug); TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
triangulateLogic = new TriangulatePrimitiveLogic(new MeshElasticLogic()) triangulateLogic = new TriangulatePrimitiveLogic(new MeshElasticLogic())
{ {

View File

@@ -17,7 +17,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public double GetAverageDiameter() public double GetAverageDiameter()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
Check(); Check();
var rebarArea = Rebars var rebarArea = Rebars
.Sum(x => x.Area); .Sum(x => x.Area);

View File

@@ -33,7 +33,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public List<TupleCrackInputData> GetTupleInputDatas() public List<TupleCrackInputData> GetTupleInputDatas()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
List<TupleCrackInputData> resultList = new(); List<TupleCrackInputData> resultList = new();
CheckInputData(); CheckInputData();

View File

@@ -52,7 +52,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// <inheritdoc/> /// <inheritdoc/>
public double GetLength() public double GetLength()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
IEnumerable<RebarNdm?> rebars = GetRebars(); IEnumerable<RebarNdm?> rebars = GetRebars();
double rebarArea = GetRebarArea(rebars); double rebarArea = GetRebarArea(rebars);
double rebarDiameter = GetAverageDiameter(rebars); double rebarDiameter = GetAverageDiameter(rebars);

View File

@@ -41,7 +41,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public void Run() public void Run()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Rebar primitive {InputData.RebarPrimitive.Name}"); TraceLogger?.AddMessage($"Rebar primitive {InputData.RebarPrimitive.Name}");
PrepareNewResult(); PrepareNewResult();
if (CheckInputData() != true) if (CheckInputData() != true)

View File

@@ -65,7 +65,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// <inheritdoc/> /// <inheritdoc/>
public double GetSofteningFactor() public double GetSofteningFactor()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Logic of calculation of psi_s factor based on exponential softening model"); TraceLogger?.AddMessage($"Logic of calculation of psi_s factor based on exponential softening model");
TraceLogger?.AddMessage($"psi_s = 1 - BettaFactor * ForceRatio ^ PowerFactor"); TraceLogger?.AddMessage($"psi_s = 1 - BettaFactor * ForceRatio ^ PowerFactor");
TraceLogger?.AddMessage($"But not less than psi_s_min = {PsiSMin}"); TraceLogger?.AddMessage($"But not less than psi_s_min = {PsiSMin}");

View File

@@ -69,7 +69,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public double GetSofteningFactor() public double GetSofteningFactor()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
if (IsResultActual == false) if (IsResultActual == false)
{ {
GetRebarAndConcreteNdms(); GetRebarAndConcreteNdms();

View File

@@ -26,7 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public double GetTensileArea() public double GetTensileArea()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
var rebarCollection = NdmCollection var rebarCollection = NdmCollection
.Where(x => x is RebarNdm & stressLogic.GetSectionStrain(StrainMatrix, x) > 0d); .Where(x => x is RebarNdm & stressLogic.GetSectionStrain(StrainMatrix, x) > 0d);

View File

@@ -29,7 +29,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
} }
public double GetTensionRebarArea() public double GetTensionRebarArea()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
TraceLogger?.AddMessage("Method of obtaining of summary area of rebars in tension based on areas which are proportional by maximum strain"); TraceLogger?.AddMessage("Method of obtaining of summary area of rebars in tension based on areas which are proportional by maximum strain");
var rebars = Rebars var rebars = Rebars
.Where(x => stressLogic.GetSectionStrain(StrainMatrix, x) > 0d); .Where(x => stressLogic.GetSectionStrain(StrainMatrix, x) > 0d);

View File

@@ -32,7 +32,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
} }
public double GetTensionRebarArea() public double GetTensionRebarArea()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage("Method of obtaining of summary area of rebars in tension based on ordinary summarizing of areas"); TraceLogger?.AddMessage("Method of obtaining of summary area of rebars in tension based on ordinary summarizing of areas");
var rebars = Rebars var rebars = Rebars
.Where(x => stressLogic.GetSectionStrain(StrainMatrix, x) > 0d); .Where(x => stressLogic.GetSectionStrain(StrainMatrix, x) > 0d);

View File

@@ -62,7 +62,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public void Run() public void Run()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
PrepareNewResult(); PrepareNewResult();
try try

View File

@@ -18,7 +18,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
public bool Check() public bool Check()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
if (!Primitives.Any()) if (!Primitives.Any())
{ {
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Count of primitive must be greater than zero"); string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Count of primitive must be greater than zero");

View File

@@ -27,7 +27,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
List<INdm> IMeshPrimitiveLogic.MeshPrimitive() List<INdm> IMeshPrimitiveLogic.MeshPrimitive()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
CheckPrimitive(); CheckPrimitive();
List<INdm> ndmCollection = new(); List<INdm> ndmCollection = new();
if (Primitive.NdmElement.HeadMaterial.HelperMaterial is ICrackedMaterial) if (Primitive.NdmElement.HeadMaterial.HelperMaterial is ICrackedMaterial)

View File

@@ -23,7 +23,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
public List<INdm> MeshPrimitive() public List<INdm> MeshPrimitive()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
CheckInputData(); CheckInputData();
List<INdm> ndms = new(); List<INdm> ndms = new();
regularMeshLogic = new MeshPrimitiveLogic() regularMeshLogic = new MeshPrimitiveLogic()

View File

@@ -26,7 +26,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
public void MeshHasDivision() public void MeshHasDivision()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
CheckInputData(); CheckInputData();
if (Primitive is IHasDivisionSize hasDivision) if (Primitive is IHasDivisionSize hasDivision)
{ {

View File

@@ -23,7 +23,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
public List<INdm> MeshPrimitive() public List<INdm> MeshPrimitive()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
List<INdm> ndmCollection = new(); List<INdm> ndmCollection = new();
var itemNdms = Primitive.GetNdms(TriangulationOptions); var itemNdms = Primitive.GetNdms(TriangulationOptions);
ndmCollection.AddRange(itemNdms); ndmCollection.AddRange(itemNdms);

View File

@@ -33,7 +33,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
public List<INdm> GetNdms() public List<INdm> GetNdms()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
CheckPrimitives(); CheckPrimitives();
ndmCollection = new List<INdm>(); ndmCollection = new List<INdm>();
SetLogics(); SetLogics();

View File

@@ -16,4 +16,8 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Models\Materials\DTOs\" />
</ItemGroup>
</Project> </Project>

View File

@@ -23,7 +23,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
HeightCount = heightCount HeightCount = heightCount
}; };
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator; var calculator = newSection.SectionRepository.Calculators[0] as ForceCalculator;
calculator.InputData.CompressedMember.Buckling = isBuckling; calculator.InputData.CompressedMember.Buckling = isBuckling;
//Act //Act
calculator.Run(); calculator.Run();
@@ -48,7 +48,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
//Arrange //Arrange
var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount }; var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount };
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator; var calculator = newSection.SectionRepository.Calculators[0] as ForceCalculator;
calculator.InputData.CompressedMember.Buckling = isBuckling; calculator.InputData.CompressedMember.Buckling = isBuckling;
//Act //Act
calculator.Run(); calculator.Run();
@@ -65,7 +65,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
//Arrange //Arrange
var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount }; var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount };
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator; var calculator = newSection.SectionRepository.Calculators[0] as ForceCalculator;
calculator.InputData.CompressedMember.Buckling = false; calculator.InputData.CompressedMember.Buckling = false;
calculator.Run(); calculator.Run();
var ndmPrimitives = newSection.SectionRepository.Primitives; var ndmPrimitives = newSection.SectionRepository.Primitives;