Change convert strategies to save xls imported forces
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public abstract class ConvertStrategy<T, V> : IConvertStrategy<T, V>
|
||||
where T : ISaveable
|
||||
where V : ISaveable
|
||||
@@ -22,7 +23,10 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
try
|
||||
{
|
||||
Check();
|
||||
return GetNewItem(source);
|
||||
TraceStartOfConverting(source);
|
||||
T target = GetNewItem(source);
|
||||
TraceFinishOfConverting(target);
|
||||
return target;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -38,5 +42,18 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
var checkLogic = new CheckConvertLogic<T,V>(this);
|
||||
checkLogic.Check();
|
||||
}
|
||||
|
||||
public void TraceErrorByEntity(object obj, string message)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Logic: {LoggerStrings.LogicType(obj)} made error: {message}", TraceLogStatuses.Error);
|
||||
}
|
||||
private void TraceStartOfConverting(ISaveable saveable)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting {saveable.GetType()} Id = {saveable.Id} has been started");
|
||||
}
|
||||
private void TraceFinishOfConverting(ISaveable saveable)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Converting {saveable.GetType()} Id = {saveable.Id} has been started");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public class ColumnProperty : IColumnProperty
|
||||
public class ColumnFileProperty : IColumnFileProperty
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; private set; }
|
||||
@@ -20,19 +20,19 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <inheritdoc/>
|
||||
public double Factor { get; set; } = 1d;
|
||||
|
||||
public ColumnProperty(Guid id, string columnName)
|
||||
public ColumnFileProperty(Guid id, string name)
|
||||
{
|
||||
Id = id;
|
||||
Name = columnName;
|
||||
Name = name;
|
||||
}
|
||||
public ColumnProperty(string columnName) : this(Guid.NewGuid(), columnName)
|
||||
public ColumnFileProperty(string columnName) : this(Guid.NewGuid(), columnName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var cloneLogic = new ColumnPropertyCloningStrategy();
|
||||
var cloneLogic = new ColumnFilePropertyCloningStrategy();
|
||||
return cloneLogic.GetClone(this);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <inheritdoc/>
|
||||
public double GlobalFactor { get; set; } = 1d;
|
||||
/// <inheritdoc/>
|
||||
public List<IColumnProperty> ColumnProperties { get; } = new();
|
||||
public List<IColumnFileProperty> ColumnProperties { get; } = new();
|
||||
|
||||
public ColumnedFileProperty(Guid id)
|
||||
{
|
||||
|
||||
@@ -7,11 +7,27 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public class FactoredCombinationProperty : IFactoredCombinationProperty
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
public CalcTerms CalcTerm { get; set; } = CalcTerms.ShortTerm;
|
||||
/// <inheritdoc/>
|
||||
public LimitStates LimitState { get; set; } = LimitStates.SLS;
|
||||
/// <inheritdoc/>
|
||||
public double LongTermFactor { get; set; } = 1d;
|
||||
/// <inheritdoc/>
|
||||
public double ULSFactor { get; set; } = 1.2d;
|
||||
|
||||
public FactoredCombinationProperty(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
public FactoredCombinationProperty() : this(Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
if (propertyType == FilePropertyType.Forces)
|
||||
{
|
||||
ColumnedFileProperty fileProperty = new();
|
||||
List<IColumnProperty> columnProperties = GetForceColumns();
|
||||
List<IColumnFileProperty> columnProperties = GetForceColumns();
|
||||
fileProperty.ColumnProperties.AddRange(columnProperties);
|
||||
return fileProperty;
|
||||
}
|
||||
@@ -28,12 +28,12 @@ namespace StructureHelperCommon.Models.Forces
|
||||
}
|
||||
}
|
||||
|
||||
private static List<IColumnProperty> GetForceColumns()
|
||||
private static List<IColumnFileProperty> GetForceColumns()
|
||||
{
|
||||
List<IColumnProperty> columnProperties = new();
|
||||
columnProperties.Add(new ColumnProperty("Nz") { SearchingName = "N", Index = 6 });
|
||||
columnProperties.Add(new ColumnProperty("Mx") { SearchingName = "My", Index = 8 });
|
||||
columnProperties.Add(new ColumnProperty("My") { SearchingName = "Mz", Index = 10 });
|
||||
List<IColumnFileProperty> columnProperties = new();
|
||||
columnProperties.Add(new ColumnFileProperty("Nz") { SearchingName = "N", Index = 6 });
|
||||
columnProperties.Add(new ColumnFileProperty("Mx") { SearchingName = "My", Index = 8 });
|
||||
columnProperties.Add(new ColumnFileProperty("My") { SearchingName = "Mz", Index = 10 });
|
||||
return columnProperties;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,24 @@ namespace StructureHelperCommon.Models.Forces
|
||||
IGetTuplesFromFileLogic getTupleFromFileLogic;
|
||||
|
||||
private IForceFactoredList factoredCombination;
|
||||
public Guid Id { get; set; }
|
||||
public Guid Id { get; }
|
||||
|
||||
public ForceCombinationFromFile(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public ForceCombinationFromFile() : this(Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public List<IColumnedFileProperty> ForceFiles { get; set; } = new();
|
||||
public bool SetInGravityCenter { get; set; } = true;
|
||||
public IPoint2D ForcePoint { get; set; } = new Point2D();
|
||||
|
||||
public IFactoredCombinationProperty CombinationProperty { get; } = new FactoredCombinationProperty();
|
||||
public IFactoredCombinationProperty CombinationProperty { get; set; } = new FactoredCombinationProperty();
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <inheritdoc/>
|
||||
public List<IForceTuple> ForceTuples { get; } = new() { new ForceTuple()};
|
||||
/// <inheritdoc/>
|
||||
public IFactoredCombinationProperty CombinationProperty { get; } = new FactoredCombinationProperty();
|
||||
public IFactoredCombinationProperty CombinationProperty { get; set; }= new FactoredCombinationProperty();
|
||||
|
||||
|
||||
public ForceFactoredList(Guid id)
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <summary>
|
||||
/// Settingth for column reading from MSExcel file
|
||||
/// </summary>
|
||||
public interface IColumnProperty : ISaveable, ICloneable
|
||||
public interface IColumnFileProperty : ISaveable, ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of column
|
||||
@@ -28,6 +28,6 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <summary>
|
||||
/// Collection of column's properties which will be imported
|
||||
/// </summary>
|
||||
List<IColumnProperty> ColumnProperties { get; }
|
||||
List<IColumnFileProperty> ColumnProperties { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,7 +11,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <summary>
|
||||
/// Properties of factored combination of forces
|
||||
/// </summary>
|
||||
public interface IFactoredCombinationProperty
|
||||
public interface IFactoredCombinationProperty : ISaveable
|
||||
{
|
||||
/// <summary>
|
||||
/// Term of calculation for assigned combination
|
||||
|
||||
@@ -10,6 +10,6 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <summary>
|
||||
/// Properties of factored combination of forces
|
||||
/// </summary>
|
||||
IFactoredCombinationProperty CombinationProperty { get; }
|
||||
IFactoredCombinationProperty CombinationProperty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,28 +8,28 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ColumnPropertyCloningStrategy : ICloneStrategy<IColumnProperty>
|
||||
public class ColumnFilePropertyCloningStrategy : ICloneStrategy<IColumnFileProperty>
|
||||
{
|
||||
private IUpdateStrategy<IColumnProperty> updateStrategy;
|
||||
private IUpdateStrategy<IColumnFileProperty> updateStrategy;
|
||||
|
||||
public ColumnPropertyCloningStrategy(IUpdateStrategy<IColumnProperty> updateStrategy)
|
||||
public ColumnFilePropertyCloningStrategy(IUpdateStrategy<IColumnFileProperty> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
|
||||
public ColumnPropertyCloningStrategy()
|
||||
public ColumnFilePropertyCloningStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IColumnProperty GetClone(IColumnProperty sourceObject)
|
||||
public IColumnFileProperty GetClone(IColumnFileProperty sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (updateStrategy is null)
|
||||
{
|
||||
updateStrategy = new ColumnPropertyUpdateStrategy();
|
||||
updateStrategy = new ColumnFilePropertyUpdateStrategy();
|
||||
}
|
||||
ColumnProperty newItem = new(sourceObject.Name);
|
||||
ColumnFileProperty newItem = new(sourceObject.Name);
|
||||
updateStrategy.Update(newItem, sourceObject);
|
||||
return newItem;
|
||||
}
|
||||
@@ -8,9 +8,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ColumnPropertyUpdateStrategy : IUpdateStrategy<IColumnProperty>
|
||||
public class ColumnFilePropertyUpdateStrategy : IUpdateStrategy<IColumnFileProperty>
|
||||
{
|
||||
public void Update(IColumnProperty targetObject, IColumnProperty sourceObject)
|
||||
public void Update(IColumnFileProperty targetObject, IColumnFileProperty sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
@@ -31,7 +31,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
targetObject.ColumnProperties.Clear();
|
||||
foreach (var item in sourceObject.ColumnProperties)
|
||||
{
|
||||
IColumnProperty clone = (IColumnProperty)item.Clone();
|
||||
IColumnFileProperty clone = (IColumnFileProperty)item.Clone();
|
||||
targetObject.ColumnProperties.Add(clone);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user