89 lines
2.9 KiB
C#
89 lines
2.9 KiB
C#
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
using StructureHelperCommon.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace StructureHelperLogics.Models.BeamShears
|
|
{
|
|
public class BeamShearCalculatorLogic : IGetResultByInputDataLogic<IBeamShearCalculatorInputData, IBeamShearCalculatorResult>
|
|
{
|
|
private IBeamShearCalculatorResult result;
|
|
private IBeamShearSectionLogic beamShearSectionLogic;
|
|
private List<IBeamShearSectionLogicInputData> sectionInputDatas;
|
|
public IShiftTraceLogger? TraceLogger { get; set; }
|
|
|
|
public BeamShearCalculatorLogic(IShiftTraceLogger? traceLogger)
|
|
{
|
|
TraceLogger = traceLogger;
|
|
}
|
|
|
|
|
|
public IBeamShearCalculatorResult GetResultByInputData(IBeamShearCalculatorInputData inputData)
|
|
{
|
|
PrepareNewResult();
|
|
InitializeStrategies();
|
|
try
|
|
{
|
|
GetSectionInputDatas(inputData);
|
|
CalculateResult();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
|
result.IsValid = false;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
private void CalculateResult()
|
|
{
|
|
foreach (var sectionInputData in sectionInputDatas)
|
|
{
|
|
beamShearSectionLogic.InputData = sectionInputData;
|
|
beamShearSectionLogic.Run();
|
|
var sectionResult = beamShearSectionLogic.Result as IBeamShearSectionLogicResult;
|
|
result.SectionResults.Add(sectionResult);
|
|
}
|
|
}
|
|
|
|
private void InitializeStrategies()
|
|
{
|
|
beamShearSectionLogic ??= new BeamShearSectionLogic();
|
|
}
|
|
|
|
private void PrepareNewResult()
|
|
{
|
|
result = new BeamShearCalculatorResult()
|
|
{
|
|
IsValid = true,
|
|
Description = string.Empty
|
|
};
|
|
}
|
|
|
|
private void GetSectionInputDatas(IBeamShearCalculatorInputData inputData)
|
|
{
|
|
//sectionInputDatas = new();
|
|
//foreach (var beamShearSection in inputData.Sections)
|
|
//{
|
|
// foreach (var stirrup in inputData.Stirrups)
|
|
// {
|
|
// foreach (var beamShearAction in inputData.Actions)
|
|
// {
|
|
// BeamShearSectionLogicInputData newInputData = new(Guid.NewGuid())
|
|
// {
|
|
// BeamShearSection = beamShearSection,
|
|
// Stirrup = stirrup,
|
|
// BeamShearAction = beamShearAction
|
|
// };
|
|
// sectionInputDatas.Add(newInputData);
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
}
|