Change open and save file logic

This commit is contained in:
Evgeny Redikultsev
2024-11-09 21:52:05 +05:00
parent a8d570713d
commit 0a2934a1ea
68 changed files with 1049 additions and 373 deletions

View File

@@ -77,7 +77,7 @@ namespace DataAccess.DTOs.Converters
versionProcessorConvertStrategy.ReferenceDictionary = ReferenceDictionary;
versionProcessorConvertStrategy.TraceLogger = TraceLogger;
IVersionProcessor versionProcessor = versionProcessorConvertStrategy.Convert(source);
TraceLogger?.AddMessage("Version processor converting has been finished succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Version processor converting has been finished successfully", TraceLogStatuses.Service);
return versionProcessor;
}
@@ -89,7 +89,7 @@ namespace DataAccess.DTOs.Converters
convertCrossSectionNdmAnalysisStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ICrossSectionNdmAnalysis, ICrossSectionNdmAnalysis>(this, convertCrossSectionNdmAnalysisStrategy);
ICrossSectionNdmAnalysis crossSectionNdmAnalysis = convertLogic.Convert(source);
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been finished succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Cross-Section Ndm Analysis converting has been finished successfully", TraceLogStatuses.Service);
return crossSectionNdmAnalysis;
}

View File

@@ -28,7 +28,7 @@ namespace DataAccess.DTOs
TraceLogger?.AddMessage("Concrete library material converting is started", TraceLogStatuses.Service);
ConcreteLibMaterial newItem = new(source.Id);
updateStrategy.Update(newItem, source);
TraceLogger?.AddMessage("Concrete library material converting has been finished succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Concrete library material converting has been finished successfully", TraceLogStatuses.Service);
return newItem;
}
}

View File

@@ -49,7 +49,7 @@ namespace DataAccess.DTOs
convertStrategy.ReferenceDictionary = ReferenceDictionary;
convertStrategy.TraceLogger = TraceLogger;
newItem.SectionRepository = GetNewCrossSectionRepository(source.SectionRepository);
TraceLogger?.AddMessage("Cross-Section converting has been finished succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Cross-Section converting has been finished successfully", TraceLogStatuses.Service);
return newItem;
}

View File

@@ -51,7 +51,7 @@ namespace DataAccess.DTOs.Converters
TraceLogger?.AddMessage("Cross-section sonverting is started");
CrossSectionNdmAnalysis newItem = new(source.Id);
updateStrategy.Update(newItem, source);
TraceLogger?.AddMessage("Cross-section analysis was obtained succesfully");
TraceLogger?.AddMessage("Cross-section analysis was obtained successfully");
return newItem;
}

View File

@@ -68,7 +68,7 @@ namespace DataAccess.DTOs.Converters
};
TraceLogger?.AddMessage("Convert version processor is started", TraceLogStatuses.Service);
newItem.VersionProcessor = convertLogic.Convert(source.VersionProcessor);
TraceLogger?.AddMessage("Cross-section ndm analysis has been converted succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Cross-section ndm analysis has been converted successfully", TraceLogStatuses.Service);
return newItem;
}

View File

@@ -20,7 +20,7 @@ namespace DataAccess.DTOs
public class CrossSectionRepositoryFromDTOConvertStrategy : ConvertStrategy<ICrossSectionRepository, ICrossSectionRepository>
{
private const string convertStarted = " converting is started";
private const string convertFinished = " converting has been finished succesfully";
private const string convertFinished = " converting has been finished successfully";
private CrossSectionRepository newRepository;
private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic();

View File

@@ -28,7 +28,7 @@ namespace DataAccess.DTOs
TraceLogger?.AddMessage("Elastic material converting is started", TraceLogStatuses.Service);
ElasticMaterial newItem = new(source.Id);
updateStrategy.Update(newItem, source);
TraceLogger?.AddMessage("Elastic material converting has been finished succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Elastic material converting has been finished successfully", TraceLogStatuses.Service);
return newItem;
}
}

View File

@@ -28,7 +28,7 @@ namespace DataAccess.DTOs
TraceLogger?.AddMessage("Fiber reinforcement material converting is started", TraceLogStatuses.Service);
FRMaterial newItem = new(source.MaterialType, source.Id);
updateStrategy.Update(newItem, source);
TraceLogger?.AddMessage("FiberReinforcement material converting has been finished succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("FiberReinforcement material converting has been finished successfully", TraceLogStatuses.Service);
return newItem;
}
}

View File

@@ -57,7 +57,7 @@ namespace DataAccess.DTOs
TraceLogger?.AddMessage($"Mx = {newDesignTuple.ForceTuple.Mx}, My = {newDesignTuple.ForceTuple.My}, Nz = {newDesignTuple.ForceTuple.Nz}");
newItem.DesignForces.Add(newDesignTuple);
}
TraceLogger?.AddMessage($"Force combination list name = {newItem.Name} has been finished succesfully");
TraceLogger?.AddMessage($"Force combination list name = {newItem.Name} has been finished successfully");
return newItem;
}
}

View File

@@ -12,7 +12,7 @@ namespace DataAccess.DTOs
public class HasForceActionsProcessLogic : IHasForceActionsProcessLogic
{
private const string convertStarted = " converting is started";
private const string convertFinished = " converting has been finished succesfully";
private const string convertFinished = " converting has been finished successfully";
public IShiftTraceLogger TraceLogger { get; set; }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }

View File

@@ -12,7 +12,7 @@ namespace DataAccess.DTOs.Converters
public class HasPrimitivesProcessLogic : IHasPrimitivesProcessLogic
{
private const string convertStarted = " converting is started";
private const string convertFinished = " converting has been finished succesfully";
private const string convertFinished = " converting has been finished successfully";
public IHasPrimitives Source { get; set; }
public IHasPrimitives Target { get; set; }

View File

@@ -40,7 +40,7 @@ namespace DataAccess.DTOs
IHelperMaterial helperMaterial = GetHelperMaterial(source.HelperMaterial);
newItem.HelperMaterial = helperMaterial;
//GlobalRepository
TraceLogger?.AddMessage($"Head material Name = {newItem.Name} converting has been finished succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Head material Name = {newItem.Name} converting has been finished successfully", TraceLogStatuses.Service);
return newItem;
}

View File

@@ -91,7 +91,7 @@ namespace DataAccess.DTOs
rebarConvertStrategy.ReferenceDictionary = ReferenceDictionary;
rebarConvertStrategy.TraceLogger = TraceLogger;
RebarNdmPrimitive newItem = rebarConvertStrategy.Convert(rebar);
TraceLogger?.AddMessage($"Primtive has been obtained succesfully, Name = {newItem.Name}");
TraceLogger?.AddMessage($"Primtive has been obtained successfully, Name = {newItem.Name}");
newItem.HostPrimitive = GetHostPrimitive(rebar);
return newItem;
}
@@ -115,7 +115,7 @@ namespace DataAccess.DTOs
pointConvertStrategy.ReferenceDictionary = ReferenceDictionary;
pointConvertStrategy.TraceLogger = TraceLogger;
PointNdmPrimitive newItem = pointConvertStrategy.Convert(point);
TraceLogger?.AddMessage($"Primtive has been obtained succesfully, Name = {newItem.Name}");
TraceLogger?.AddMessage($"Primtive has been obtained successfully, Name = {newItem.Name}");
return newItem;
}
@@ -125,7 +125,7 @@ namespace DataAccess.DTOs
ellipseConvertStrategy.ReferenceDictionary = ReferenceDictionary;
ellipseConvertStrategy.TraceLogger = TraceLogger;
EllipseNdmPrimitive newItem = ellipseConvertStrategy.Convert(ellipse);
TraceLogger?.AddMessage($"Primtive has been obtained succesfully, Name = {newItem.Name}");
TraceLogger?.AddMessage($"Primtive has been obtained successfully, Name = {newItem.Name}");
return newItem;
}
@@ -135,7 +135,7 @@ namespace DataAccess.DTOs
rectangleConvertStrategy.ReferenceDictionary = ReferenceDictionary;
rectangleConvertStrategy.TraceLogger = TraceLogger;
RectangleNdmPrimitive newItem = rectangleConvertStrategy.Convert(rectangle);
TraceLogger?.AddMessage($"Primtive has been obtained succesfully, Name = {newItem.Name}");
TraceLogger?.AddMessage($"Primtive has been obtained successfully, Name = {newItem.Name}");
return newItem;
}
}

View File

@@ -1,82 +1,69 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class ProjectFromDTOConvertStrategy : IConvertStrategy<Project, ProjectDTO>
public class ProjectFromDTOConvertStrategy : ConvertStrategy<Project, ProjectDTO>
{
private IUpdateStrategy<IProject> updateStrategy;
private IConvertStrategy<IVisualAnalysis, IVisualAnalysis> visualAnalysisConvertStrategy = new VisualAnaysisFromDTOConvertStrategy();
private IUpdateStrategy<IProject> _updateStrategy;
private IConvertStrategy<IVisualAnalysis, IVisualAnalysis> _convertLogic;
public ProjectFromDTOConvertStrategy(IUpdateStrategy<IProject> updateStrategy)
public ProjectFromDTOConvertStrategy(IUpdateStrategy<IProject> updateStrategy,
IConvertStrategy<IVisualAnalysis, IVisualAnalysis> convertLogic,
Dictionary<(Guid id, Type type), ISaveable> refDictinary,
IShiftTraceLogger? traceLogger)
{
this.updateStrategy = updateStrategy;
_updateStrategy = updateStrategy;
_convertLogic = convertLogic;
ReferenceDictionary = refDictinary;
TraceLogger = traceLogger;
}
public ProjectFromDTOConvertStrategy() : this (new ProjectUpdateStrategy())
{
}
public ProjectFromDTOConvertStrategy(
Dictionary<(Guid id, Type type), ISaveable> refDictinary,
IShiftTraceLogger? traceLogger)
: this(
new ProjectUpdateStrategy(),
new DictionaryConvertStrategy<IVisualAnalysis, IVisualAnalysis>(
refDictinary,
new VisualAnaysisFromDTOConvertStrategy(refDictinary, traceLogger),
traceLogger),
refDictinary,
traceLogger)
{ }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public Project Convert(ProjectDTO source)
{
Check();
TraceLogger?.AddMessage("Converting project is started", TraceLogStatuses.Info);
try
{
Project newItem = GetProject(source);
return newItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
}
private Project GetProject(ProjectDTO source)
{
TraceLogger?.AddMessage("Converting of project is started", TraceLogStatuses.Service);
Project newItem = new();
updateStrategy.Update(newItem, source);
visualAnalysisConvertStrategy.ReferenceDictionary = ReferenceDictionary;
visualAnalysisConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<IVisualAnalysis, IVisualAnalysis>(this, visualAnalysisConvertStrategy);
public override Project GetNewItem(ProjectDTO source)
{
TraceLogger?.AddMessage("Converting of project is started");
Project newItem = new(source.Id);
List<IVisualAnalysis> analyses = GetAnalyses(source, newItem);
newItem.VisualAnalyses.Clear();
TraceLogger?.AddMessage($"Source project has {source.VisualAnalyses.Count()} analyses", TraceLogStatuses.Service);
foreach (var item in source.VisualAnalyses)
{
var visualAnalysis = convertLogic.Convert(item);
newItem.VisualAnalyses.Add(visualAnalysis);
}
newItem.VisualAnalyses.AddRange(analyses);
if (newItem.VisualAnalyses.Any())
{
TraceLogger?.AddMessage($"Totaly {newItem.VisualAnalyses.Count()} were(was) obtained", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Totaly {newItem.VisualAnalyses.Count} were(was) obtained");
}
else
{
TraceLogger?.AddMessage($"Project does not have any analyses", TraceLogStatuses.Warning);
TraceLogger?.AddMessage($"Project does not have any analyses, it is possible to work with project", TraceLogStatuses.Warning);
}
TraceLogger?.AddMessage("Converting of project has completed succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Converting of project has been finished successfully");
return newItem;
}
private void Check()
public List<IVisualAnalysis> GetAnalyses(ProjectDTO source, Project newItem)
{
var checkLogic = new CheckConvertLogic<Project, ProjectDTO>(this);
checkLogic.Check();
_updateStrategy.Update(newItem, source);
TraceLogger?.AddMessage($"Source project has {source.VisualAnalyses.Count} analyses");
List<IVisualAnalysis> analyses = new();
foreach (var item in source.VisualAnalyses)
{
var visualAnalysis = _convertLogic.Convert(item);
analyses.Add(visualAnalysis);
}
return analyses;
}
}
}

View File

@@ -28,7 +28,7 @@ namespace DataAccess.DTOs
TraceLogger?.AddMessage("Reinforcement library material converting is started", TraceLogStatuses.Service);
ReinforcementLibMaterial newItem = new(source.Id);
updateStrategy.Update(newItem, source);
TraceLogger?.AddMessage("Reinforcement library material converting has been finished succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Reinforcement library material converting has been finished successfully", TraceLogStatuses.Service);
return newItem;
}
}

View File

@@ -64,7 +64,7 @@ namespace DataAccess.DTOs
crossSectionConvertStrategy.TraceLogger = TraceLogger;
var convertLogic = new DictionaryConvertStrategy<ICrossSection, ICrossSection>(this, crossSectionConvertStrategy);
ICrossSection newItem = convertLogic.Convert(source);
TraceLogger?.AddMessage("Cross-Section converting has been finished succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Cross-Section converting has been finished successfully", TraceLogStatuses.Service);
return newItem;
}

View File

@@ -59,7 +59,7 @@ namespace DataAccess.DTOs
newItem.Versions.Add(dateVersion);
}
TraceLogger?.AddMessage($"Totaly {newItem.Versions.Count} version(s) was(were) obtained", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Version processor has been converted succesfully", TraceLogStatuses.Service);
TraceLogger?.AddMessage("Version processor has been converted successfully", TraceLogStatuses.Service);
return newItem;
}

View File

@@ -12,42 +12,37 @@ using System.Threading.Tasks;
namespace DataAccess.DTOs
{
public class VisualAnaysisFromDTOConvertStrategy : IConvertStrategy<IVisualAnalysis, IVisualAnalysis>
public class VisualAnaysisFromDTOConvertStrategy : ConvertStrategy<IVisualAnalysis, IVisualAnalysis>
{
private IConvertStrategy<IAnalysis, IAnalysis> analysisConvertStrategy = new AnalysisFromDTOConvertStrategy();
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
private IConvertStrategy<IAnalysis, IAnalysis> analysisConvertStrategy;
public IVisualAnalysis Convert(IVisualAnalysis source)
public VisualAnaysisFromDTOConvertStrategy(IConvertStrategy<IAnalysis, IAnalysis> analysisConvertStrategy,
Dictionary<(Guid id, Type type), ISaveable> refDictinary,
IShiftTraceLogger? traceLogger)
{
Check();
try
{
VisualAnalysis newItem = GetAnalysis(source);
return newItem;
}
catch (Exception ex)
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Error);
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
throw;
}
this.analysisConvertStrategy = analysisConvertStrategy;
ReferenceDictionary = refDictinary;
TraceLogger = traceLogger;
}
private VisualAnalysis GetAnalysis(IVisualAnalysis source)
public VisualAnaysisFromDTOConvertStrategy(
Dictionary<(Guid id, Type type), ISaveable> refDictinary,
IShiftTraceLogger? traceLogger)
: this(
new AnalysisFromDTOConvertStrategy(),
refDictinary,
traceLogger)
{ }
public override VisualAnalysis GetNewItem(IVisualAnalysis source)
{
TraceLogger?.AddMessage($"Visual Analysis Name = {source.Analysis.Name} converting is started");
analysisConvertStrategy.ReferenceDictionary = ReferenceDictionary;
analysisConvertStrategy.TraceLogger = TraceLogger;
IAnalysis analysis = analysisConvertStrategy.Convert(source.Analysis);
VisualAnalysis newItem = new(source.Id, analysis);
TraceLogger?.AddMessage($"Visual Analysis was obtained succesfully", TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Visual Analysis Name = {newItem.Analysis.Name} was obtained successfully");
return newItem;
}
private void Check()
{
var checkLogic = new CheckConvertLogic<IVisualAnalysis, IVisualAnalysis>(this);
checkLogic.Check();
}
}
}

View File

@@ -20,7 +20,7 @@ namespace DataAccess.DTOs
public bool IsActual { get; set; }
[JsonProperty("VisualAnalyses")]
public List<IVisualAnalysis> VisualAnalyses { get; private set; } = new();
public List<IVisualAnalysis> VisualAnalyses { get; set; } = new();
[JsonIgnore]
public string FileName { get; set; }

View File

@@ -0,0 +1,75 @@
using DataAccess.DTOs;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public class CheckRootObjectLogic : ICheckEntityLogic<IRootObjectDTO>
{
public IRootObjectDTO Entity { get; set; }
public string CheckResult { get; private set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckRootObjectLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public bool Check()
{
bool result = true;
string checkResult = string.Empty;
var checkRootResult = CheckRootObject();
if (checkRootResult.checkResult = false)
{
checkResult += checkRootResult.errorString;
result = false;
}
CheckResult = checkResult;
return result;
}
private (bool checkResult, string errorString) CheckRootObject()
{
bool checkRootResult = true;
string errorString = string.Empty;
if (Entity.FileVersion is null)
{
checkRootResult = false;
errorString += "Section of file version is damaged";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
return (checkRootResult, errorString);
}
var fileVersion = Entity.FileVersion;
var checkLogic = new CheckFileVersionLogic()
{
FileVersion = fileVersion,
TraceLogger = TraceLogger
};
var checkResult = checkLogic.Check();
if (checkResult == false)
{
checkRootResult = false;
errorString += checkLogic.CheckResult;
return (checkRootResult, errorString);
}
if (Entity.Project is null)
{
checkRootResult = false;
errorString += "Section of project is damaged";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
return (checkRootResult, errorString);
}
return (checkRootResult, errorString);
}
}
}

View File

@@ -16,10 +16,41 @@ namespace DataAccess.Infrastructures
public class FileOpenLogic : IFileOpenLogic
{
private string fileName;
private Dictionary<(Guid id, Type type), ISaveable> refDictinary;
private IGetProjectLogic getProjectLogic;
public IShiftTraceLogger? TraceLogger { get; set; }
public OpenProjectResult OpenFile()
{
var result = new OpenProjectResult()
{
IsValid = true
};
if (GetFilePath() == false)
{
result.IsValid = false;
return result;
}
return OpenFile(fileName);
}
public OpenProjectResult OpenFile(string fileName)
{
var result = new OpenProjectResult()
{
IsValid = true
};
if (!File.Exists(fileName))
{
result.IsValid = false;
TraceLogger?.AddMessage($"File {fileName} does not exists", TraceLogStatuses.Error);
return result;
}
getProjectLogic = new GetProjectLogic(TraceLogger);
getProjectLogic.TraceLogger = TraceLogger;
getProjectLogic.FileName = fileName;
return getProjectLogic.GetProject();
}
private bool GetFilePath()
{
var inputData = new OpenFileInputData()
@@ -37,106 +68,6 @@ namespace DataAccess.Infrastructures
return true;
}
public OpenProjectResult OpenFile()
{
var result = new OpenProjectResult()
{
IsValid = true
};
if (GetFilePath() == false)
{
result.IsValid = false;
return result;
}
if (!File.Exists(fileName))
{
result.IsValid = false;
TraceLogger?.AddMessage($"File {fileName} does not exists", TraceLogStatuses.Error);
return result;
}
string jsonData = File.ReadAllText(fileName);
RootObjectDTO? rootObject = GetRootObject(jsonData);
if (rootObject.FileVersion is null)
{
var errorString = "Section of file version is damaged";
result.Description += errorString;
result.IsValid = false;
return result;
}
var fileVersion = rootObject.FileVersion;
var checkLogic = new CheckFileVersionLogic()
{
FileVersion = fileVersion,
TraceLogger = TraceLogger
};
var checkResult = checkLogic.Check();
if (checkResult == false)
{
result.IsValid = false;
result.Description += checkLogic.CheckResult;
}
else
{
if (rootObject.Project is null)
{
var errorString = "Section of project is damaged";
result.Description += errorString;
result.IsValid = false;
return result;
}
Project project = GetProject(rootObject);
project.FullFileName = fileName;
result.Project = project;
}
return result;
}
private Project GetProject(RootObjectDTO? rootObject)
{
if (rootObject.Project is null)
{
}
var currentVersion = ProgramSetting.GetCurrentFileVersion();
IFileVersion fileVersion = rootObject.FileVersion;
TraceLogger?.AddMessage($"File version is {fileVersion.VersionNumber}.{fileVersion.SubVersionNumber}, current version is {currentVersion.VersionNumber}.{currentVersion.SubVersionNumber}");
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
IConvertStrategy<Project, ProjectDTO> convertStrategy = new ProjectFromDTOConvertStrategy()
{
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
Project project = convertStrategy.Convert(rootObject.Project);
return project;
}
private RootObjectDTO? GetRootObject(string jsonData)
{
JsonSerializerSettings settings = GetSettings();
RootObjectDTO rootObject = JsonConvert.DeserializeObject<RootObjectDTO>(jsonData, settings);
return rootObject;
}
private JsonSerializerSettings GetSettings()
{
List<(Type type, string name)> typesNames = TypeBinderListFactory.GetTypeNameList(TypeFileVersion.version_v1);
TypeBinder typeBinder = new(typesNames);
var settings = new JsonSerializerSettings
{
Converters = new List<JsonConverter>
{
new FileVersionDTOJsonConverter(TraceLogger), // Add the specific converter
new ProjectDTOJsonConverter(TraceLogger)
},
SerializationBinder = typeBinder,
Formatting = Formatting.Indented,
PreserveReferencesHandling = PreserveReferencesHandling.All,
MissingMemberHandling = MissingMemberHandling.Ignore,
TypeNameHandling = TypeNameHandling.All,
NullValueHandling = NullValueHandling.Include
};
return settings;
}
}
}

View File

@@ -12,24 +12,33 @@ namespace DataAccess.Infrastructures
{
public class FileSaveLogic : IFileSaveLogic
{
private IFileVersion version;
private Dictionary<(Guid id, Type type), ISaveable> refDictinary;
public IShiftTraceLogger? TraceLogger { get; set; }
public void SaveFile(IProject project)
public SaveFileResult SaveFile(IProject project)
{
SaveFileResult result = new();
if (project.FullFileName == string.Empty || project.FullFileName == "")
{
var result = SelectFileName(project);
if (result.IsValid == false)
var selectResult = SelectFileName(project);
if (selectResult.IsValid == false)
{
TraceLogger?.AddMessage(result.Description);
return;
TraceLogger?.AddMessage(selectResult.Description);
result.IsValid = false;
return result;
}
project.FullFileName = result.FileName;
project.FullFileName = selectResult.FileName;
}
SaveToFile(project);
result.FileName = project.FullFileName;
try
{
SaveToFile(project);
}
catch (Exception ex)
{
result.IsValid = false;
result.Description += ex.Message;
}
return result;
}
private SaveFileResult SelectFileName(IProject project)
@@ -47,115 +56,24 @@ namespace DataAccess.Infrastructures
private void SaveToFile(IProject project)
{
try
ISaveProjectToFileLogic saveProjectLogic = new SaveProjectToFileLogic(TraceLogger)
{
version = ProgramSetting.GetCurrentFileVersion();
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
FileVersionDTO versionDTO = GetVersionDTO();
var versionString = Serialize(versionDTO, TraceLogger);
File.Delete(project.FullFileName);
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
ProjectDTO projectDTO = GetProjectDTO(project);
RootObjectDTO rootObject = new()
{
FileVersion = versionDTO,
Project = projectDTO
};
var rootString = Serialize(rootObject, TraceLogger);
SaveStringToFile(project, rootString);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
}
}
private void SaveStringToFile(IProject project, string versionString)
{
try
{
File.WriteAllText(project.FullFileName, versionString);
TraceLogger?.AddMessage($"File {project.FullFileName} was saved successfully", TraceLogStatuses.Service);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
}
}
private ProjectDTO GetProjectDTO(IProject project)
{
ProjectToDTOConvertStrategy convertStrategy = new()
{
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
Project = project
};
DictionaryConvertStrategy<ProjectDTO, IProject> dictionaryConvertStrategy = new()
{
ConvertStrategy = convertStrategy,
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
ProjectDTO projectDTO = dictionaryConvertStrategy.Convert(project);
return projectDTO;
saveProjectLogic.SaveProject();
}
private FileVersionDTO GetVersionDTO()
{
FileVersionToDTOConvertStrategy fileVersionDTOConvertStrategy = new()
{
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
DictionaryConvertStrategy<FileVersionDTO,IFileVersion> dictionaryConvertStrategy = new()
{
ConvertStrategy = fileVersionDTOConvertStrategy,
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
var versionDTO = dictionaryConvertStrategy.Convert(version);
return versionDTO;
}
private static string Serialize(object obj, IShiftTraceLogger logger)
{
JsonSerializerSettings settings = GetSerializingSettings(logger);
string serializedObject = JsonConvert.SerializeObject(obj, settings);
return serializedObject;
}
private static JsonSerializerSettings GetSerializingSettings(IShiftTraceLogger logger)
{
List<(Type type, string name)> typesNames = TypeBinderListFactory.GetTypeNameList(TypeFileVersion.version_v1);
TypeBinder typeBinder = new(typesNames);
List<JsonConverter> jsonConverters = new List<JsonConverter>
{
new FileVersionDTOJsonConverter(logger),
new ProjectDTOJsonConverter(logger)
};
var settings = new JsonSerializerSettings
{
Converters = jsonConverters,
SerializationBinder = typeBinder,
Formatting = Formatting.Indented,
PreserveReferencesHandling = PreserveReferencesHandling.All,
MissingMemberHandling = MissingMemberHandling.Ignore,
TypeNameHandling = TypeNameHandling.All,
NullValueHandling = NullValueHandling.Include
};
return settings;
}
public void SaveFileAs(IProject project)
public SaveFileResult SaveFileAs(IProject project)
{
var tmpFullFileName = project.FullFileName;
SaveFile(project);
if (project.FullFileName == string.Empty)
project.FullFileName = string.Empty;
var result = SaveFile(project);
if (result.IsValid == false)
{
project.FullFileName = tmpFullFileName;
}
return result;
}
}
}

View File

@@ -0,0 +1,42 @@
using DataAccess.DTOs;
using Newtonsoft.Json;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public class GetJsonDataByRootObjectLogic : IGetJsonDataByRootObjectLogic
{
private IGetJsonSettingsLogic getJsonSettingsLogic;
public GetJsonDataByRootObjectLogic(IGetJsonSettingsLogic getJsonSettingsLogic)
{
this.getJsonSettingsLogic = getJsonSettingsLogic;
}
public GetJsonDataByRootObjectLogic(IShiftTraceLogger traceLogger) : this (new GetJsonSettingsLogic(traceLogger))
{
}
public IRootObjectDTO RootObject { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public string GetJsonData()
{
var rootString = Serialize(RootObject);
return rootString;
}
private string Serialize(object obj)
{
JsonSerializerSettings settings = getJsonSettingsLogic.GetSettings();
string serializedObject = JsonConvert.SerializeObject(obj, settings);
return serializedObject;
}
}
}

View File

@@ -0,0 +1,51 @@
using DataAccess.DTOs;
using DataAccess.JsonConverters;
using Newtonsoft.Json;
using NLog;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public class GetJsonSettingsLogic : IGetJsonSettingsLogic
{
public IShiftTraceLogger? TraceLogger { get; set; }
public GetJsonSettingsLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public JsonSerializerSettings GetSettings()
{
List<(Type type, string name)> typesNames = TypeBinderListFactory.GetTypeNameList(TypeFileVersion.version_v1);
TypeBinder typeBinder = new(typesNames);
List<JsonConverter> jsonConverters = GetConverters();
var settings = new JsonSerializerSettings
{
Converters = jsonConverters,
SerializationBinder = typeBinder,
Formatting = Formatting.Indented,
PreserveReferencesHandling = PreserveReferencesHandling.All,
MissingMemberHandling = MissingMemberHandling.Ignore,
TypeNameHandling = TypeNameHandling.All,
NullValueHandling = NullValueHandling.Include
};
return settings;
}
private List<JsonConverter> GetConverters()
{
return new List<JsonConverter>
{
new FileVersionDTOJsonConverter(TraceLogger),
new ProjectDTOJsonConverter(TraceLogger)
};
}
}
}

View File

@@ -0,0 +1,79 @@
using DataAccess.DTOs;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public class GetProjectLogic : IGetProjectLogic
{
private IGetRootObjectByJsonDataLogic getRootObjectLogic;
private RootObjectDTO? rootObject;
private ICheckEntityLogic<IRootObjectDTO> checkEntityLogic;
private OpenProjectResult result;
public GetProjectLogic(IGetRootObjectByJsonDataLogic getRootObjectLogic,
ICheckEntityLogic<IRootObjectDTO> checkEntityLogic,
IShiftTraceLogger traceLogger)
{
this.getRootObjectLogic = getRootObjectLogic;
this.checkEntityLogic = checkEntityLogic;
TraceLogger = traceLogger;
}
public GetProjectLogic(IShiftTraceLogger traceLogger) : this (
new GetRootObjectLogic(traceLogger),
new CheckRootObjectLogic(traceLogger),
traceLogger)
{
}
public string FileName { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public OpenProjectResult GetProject()
{
result = new OpenProjectResult()
{
IsValid = true
};
string jsonData = File.ReadAllText(FileName);
getRootObjectLogic.JsonData = jsonData;
rootObject = getRootObjectLogic.GetRootObject();
checkEntityLogic.Entity = rootObject;
var checkResult = checkEntityLogic.Check();
if (checkResult == false)
{
TraceLogger?.AddMessage(checkEntityLogic.CheckResult, TraceLogStatuses.Error);
result.Description += checkEntityLogic.CheckResult;
result.IsValid = false;
return result;
}
Project project = GetProjectByRootObject(rootObject);
project.FullFileName = FileName;
result.Project = project;
return result;
}
private Project GetProjectByRootObject(RootObjectDTO? rootObject)
{
var currentVersion = ProgramSetting.GetCurrentFileVersion();
IFileVersion fileVersion = rootObject.FileVersion;
TraceLogger?.AddMessage($"File version is {fileVersion.VersionNumber}.{fileVersion.SubVersionNumber}, current version is {currentVersion.VersionNumber}.{currentVersion.SubVersionNumber}");
Dictionary<(Guid id, Type type), ISaveable> refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
IConvertStrategy<Project, ProjectDTO> convertStrategy = new ProjectFromDTOConvertStrategy(refDictinary, TraceLogger);
Project project = convertStrategy.Convert(rootObject.Project);
return project;
}
}
}

View File

@@ -0,0 +1,69 @@
using DataAccess.DTOs;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public class GetRootObjectByProjectLogic : IGetRootObjectByProjectLogic
{
private readonly IFileVersion version = ProgramSetting.GetCurrentFileVersion();
private Dictionary<(Guid id, Type type), ISaveable> refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
public IShiftTraceLogger? TraceLogger { get; set; }
public GetRootObjectByProjectLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public IProject Project { get; set; }
public RootObjectDTO? GetRootObject()
{
FileVersionDTO fileVersion = GetVersionDTO();
ProjectDTO project = GetProjectDTO();
return new RootObjectDTO() { FileVersion = fileVersion, Project = project };
}
private FileVersionDTO GetVersionDTO()
{
FileVersionToDTOConvertStrategy fileVersionDTOConvertStrategy = new()
{
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
DictionaryConvertStrategy<FileVersionDTO, IFileVersion> dictionaryConvertStrategy = new()
{
ConvertStrategy = fileVersionDTOConvertStrategy,
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
var versionDTO = dictionaryConvertStrategy.Convert(version);
return versionDTO;
}
private ProjectDTO GetProjectDTO()
{
ProjectToDTOConvertStrategy convertStrategy = new()
{
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
DictionaryConvertStrategy<ProjectDTO, IProject> dictionaryConvertStrategy = new()
{
ConvertStrategy = convertStrategy,
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
ProjectDTO projectDTO = dictionaryConvertStrategy.Convert(Project);
return projectDTO;
}
}
}

View File

@@ -0,0 +1,53 @@
using DataAccess.DTOs;
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public class GetRootObjectLogic : IGetRootObjectByJsonDataLogic
{
private IGetJsonSettingsLogic jsonSettingsLogic;
public GetRootObjectLogic(
IGetJsonSettingsLogic jsonSettingsLogic,
IShiftTraceLogger traceLogger)
{
this.jsonSettingsLogic = jsonSettingsLogic;
TraceLogger = traceLogger;
}
public GetRootObjectLogic(IShiftTraceLogger traceLogger) : this (new GetJsonSettingsLogic(traceLogger), traceLogger)
{
}
public string JsonData { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public RootObjectDTO? GetRootObject()
{
jsonSettingsLogic.TraceLogger = TraceLogger;
JsonSerializerSettings settings = jsonSettingsLogic.GetSettings();
TraceLogger?.AddMessage("Deserialization of data is started");
RootObjectDTO rootObject;
try
{
rootObject = JsonConvert.DeserializeObject<RootObjectDTO>(JsonData, settings);
}
catch (Exception ex)
{
string errorString = "Error of deserialization of json data" + ex.Message;
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
TraceLogger?.AddMessage("Deserialization of data has been finished successfully");
return rootObject;
}
}
}

View File

@@ -6,5 +6,6 @@ namespace DataAccess.Infrastructures
public interface IFileOpenLogic : ILogic
{
OpenProjectResult OpenFile();
OpenProjectResult OpenFile(string fileName);
}
}

View File

@@ -1,5 +1,6 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Projects;
using StructureHelperCommon.Services.FileServices;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,7 +11,7 @@ namespace DataAccess.Infrastructures
{
public interface IFileSaveLogic : ILogic
{
void SaveFile(IProject project);
void SaveFileAs(IProject project);
SaveFileResult SaveFile(IProject project);
SaveFileResult SaveFileAs(IProject project);
}
}

View File

@@ -0,0 +1,12 @@
using DataAccess.DTOs;
using StructureHelperCommon.Infrastructures.Interfaces;
namespace DataAccess.Infrastructures
{
public interface IGetJsonDataByRootObjectLogic : ILogic
{
IRootObjectDTO RootObject { get; set; }
string GetJsonData();
}
}

View File

@@ -0,0 +1,15 @@
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public interface IGetJsonSettingsLogic : ILogic
{
JsonSerializerSettings GetSettings();
}
}

View File

@@ -0,0 +1,18 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public interface IGetProjectLogic : ILogic
{
string FileName { get; set; }
IShiftTraceLogger TraceLogger { get; set; }
OpenProjectResult GetProject();
}
}

View File

@@ -0,0 +1,16 @@
using DataAccess.DTOs;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public interface IGetRootObjectByJsonDataLogic : IGetRootObjectLogic
{
string JsonData { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public interface IGetRootObjectByProjectLogic : IGetRootObjectLogic
{
IProject Project { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
using DataAccess.DTOs;
using StructureHelperCommon.Infrastructures.Interfaces;
namespace DataAccess.Infrastructures
{
public interface IGetRootObjectLogic : ILogic
{
RootObjectDTO? GetRootObject();
}
}

View File

@@ -12,7 +12,8 @@ namespace DataAccess.Infrastructures
public interface IProjectAccessLogic : ILogic
{
OpenProjectResult OpenProject();
void SaveProject(IProject project);
void SaveProjectAs(IProject project);
OpenProjectResult OpenProject(string fileName);
SaveFileResult SaveProject(IProject project);
SaveFileResult SaveProjectAs(IProject project);
}
}

View File

@@ -0,0 +1,12 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Projects;
namespace DataAccess.Infrastructures
{
public interface ISaveProjectToFileLogic : ILogic
{
IProject Project { get; set; }
void SaveProject();
}
}

View File

@@ -32,16 +32,24 @@ namespace DataAccess.Infrastructures
return openLogic.OpenFile();
}
public void SaveProject(IProject project)
public OpenProjectResult OpenProject(string fileName)
{
saveLogic.TraceLogger = TraceLogger;
saveLogic.SaveFile(project);
openLogic.TraceLogger = TraceLogger;
return openLogic.OpenFile(fileName);
}
public void SaveProjectAs(IProject project)
public SaveFileResult SaveProject(IProject project)
{
saveLogic.TraceLogger = TraceLogger;
saveLogic.SaveFileAs(project);
var result = saveLogic.SaveFile(project);
return result;
}
public SaveFileResult SaveProjectAs(IProject project)
{
saveLogic.TraceLogger = TraceLogger;
var result = saveLogic.SaveFileAs(project);
return result;
}
}
}

View File

@@ -0,0 +1,61 @@
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Projects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccess.Infrastructures
{
public class SaveProjectToFileLogic : ISaveProjectToFileLogic
{
private IGetRootObjectByProjectLogic getRootObjectLogic;
private IGetJsonDataByRootObjectLogic getJsonDataLogic;
public SaveProjectToFileLogic(
IGetRootObjectByProjectLogic getRootObjectLogic,
IGetJsonDataByRootObjectLogic getJsonDataLogic,
IShiftTraceLogger traceLogger)
{
this.getRootObjectLogic = getRootObjectLogic;
this.getJsonDataLogic = getJsonDataLogic;
TraceLogger = traceLogger;
}
public SaveProjectToFileLogic(IShiftTraceLogger traceLogger) : this (
new GetRootObjectByProjectLogic(traceLogger),
new GetJsonDataByRootObjectLogic(traceLogger),
traceLogger
)
{
}
public IProject Project { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public void SaveProject()
{
getRootObjectLogic.Project = Project;
var rootObject = getRootObjectLogic.GetRootObject();
getJsonDataLogic.RootObject = rootObject;
var jsonData = getJsonDataLogic.GetJsonData();
SaveStringToFile(jsonData);
}
private void SaveStringToFile(string jsonData)
{
try
{
File.Delete(Project.FullFileName);
File.WriteAllText(Project.FullFileName, jsonData);
TraceLogger?.AddMessage($"File {Project.FullFileName} was saved successfully", TraceLogStatuses.Service);
}
catch (Exception ex)
{
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
}
}
}
}

View File

@@ -6,8 +6,6 @@ using System.Reflection;
namespace DataAccess.JsonConverters
{
public abstract class BaseJsonConverter<T> : JsonConverter<T>
{
private IWriteJsonLogic<T> writeJsonLogic;

View File

@@ -4,6 +4,8 @@ using StructureHelper.Windows.MainWindow;
using StructureHelperLogics.Services.NdmCalculations;
using System.Windows;
using Autofac;
using System;
using System.IO;
namespace StructureHelper
{
@@ -31,9 +33,40 @@ namespace StructureHelper
Container = builder.Build();
Scope = Container.Resolve<ILifetimeScope>();
// Get the command-line arguments
string[] args = Environment.GetCommandLineArgs();
var window = Scope.Resolve<AnalysesManagerView>();
window.Show();
// Check if there is an argument provided for a file
if (args.Length > 1) // args[0] is the application path
{
OpenSpecifiedFile(args);
}
else
{
// No file specified, open normally
var window = new AnalysesManagerView();
window.Show();
}
}
private static void OpenSpecifiedFile(string[] args)
{
string filePath = args[1];
// Optional: Validate the file path
if (File.Exists(filePath))
{
// Pass the file path to your main window or handling logic
var vm = new AnalysesManagerViewModel();
vm.FileLogic.OpenNewFile(filePath);
//var window = Scope.Resolve<AnalysesManagerView>(vm);
var window = new AnalysesManagerView(vm);
window.Show();
}
else
{
MessageBox.Show("File does not exist.");
}
}
protected override void OnExit(ExitEventArgs e)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -9,6 +9,7 @@
<ImplicitUsings>disable</ImplicitUsings>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<ApplicationIcon>Infrastructure\UI\Icons\SH_лого_16.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
@@ -53,6 +54,10 @@
<None Remove="Windows\MainWindow\СarbonMaterial32.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Infrastructure\UI\Icons\SH_лого_16.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="8.1.0" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />

View File

@@ -7,7 +7,7 @@
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculatorVMs"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:GeometryCalculatorResultViewModel}"
Title="Geometry Properies" Height="450" Width="850" WindowStartupLocation="CenterScreen">
Title="Geometry Properties" Height="450" Width="850" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
@@ -27,7 +27,7 @@
<DataGridCheckBoxColumn Header="Valid" Binding="{Binding Path=IsValid}"/>
<DataGridTextColumn Header="Name" Width="100" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Short" Width="50" Binding="{Binding ShortName}"/>
<DataGridTextColumn Header="Unit" Width="100" Binding="{Binding MeasurementUnit}"/>
<DataGridTextColumn Header="Unit" Width="100" Binding="{Binding Text}"/>
<DataGridTextColumn Header="Value" Width="150" Binding="{Binding Value}"/>
<DataGridTextColumn Header="Description" Width="400" Binding="{Binding Description}"/>
</DataGrid.Columns>

View File

@@ -101,6 +101,10 @@ namespace StructureHelper.Windows.MainWindow
SelectedAnalysis.Analysis.Name = name;
SelectedAnalysis.Analysis.Tags = tags;
}
else
{
ProgramSetting.SetCurrentProjectToNotActual();
}
}
}
private void DeleteAnalysis()
@@ -111,6 +115,7 @@ namespace StructureHelper.Windows.MainWindow
if (dialogResult == DialogResult.Yes)
{
ProgramSetting.CurrentProject.VisualAnalyses.Remove(SelectedAnalysis);
ProgramSetting.SetCurrentProjectToNotActual();
}
}
}
@@ -119,6 +124,7 @@ namespace StructureHelper.Windows.MainWindow
if (SelectedAnalysis is null) { return; }
SelectedAnalysis.ActionToRun = ActionToRun;
SelectedAnalysis?.Run();
ProgramSetting.SetCurrentProjectToNotActual();
}
private void AddCrossSectionNdmAnalysis()
{
@@ -127,7 +133,7 @@ namespace StructureHelper.Windows.MainWindow
analysis.Tags = "#New group";
var visualAnalysis = new VisualAnalysis(analysis);
ProgramSetting.CurrentProject.VisualAnalyses.Add(visualAnalysis);
//ProgramSetting.SetCurrentProjectToNotActual();
ProgramSetting.SetCurrentProjectToNotActual();
}
private void ActionToRun()

View File

@@ -6,6 +6,7 @@ using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Projects;
using StructureHelperCommon.Services.FileServices;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Linq;
@@ -63,20 +64,26 @@ namespace StructureHelper.Windows.MainWindow
ProgramSetting.Projects.Add(newProject);
return newProject;
}
private void SaveAsFile()
private SaveFileResult SaveAsFile()
{
var project = ProgramSetting.CurrentProject;
traceLogger = new ShiftTraceLogger();
projectAccessLogic.TraceLogger = traceLogger;
projectAccessLogic.SaveProjectAs(project);
var result = projectAccessLogic.SaveProjectAs(project);
ShowEntries();
return result;
}
private void ExitProgram()
public bool ExitProgram()
{
foreach (var project in ProgramSetting.Projects)
var collection = ProgramSetting.Projects.ToList();
foreach (var project in collection)
{
CloseFile(project);
if (CloseFile(project) == false)
{
return false;
};
}
return true;
}
public bool CloseFile()
{
@@ -95,10 +102,20 @@ namespace StructureHelper.Windows.MainWindow
ProgramSetting.Projects.Remove(project);
return true;
}
var dialogResult = MessageBox.Show($"Save file?", $"File {project.FullFileName} is not saved", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
DialogResult dialogResult = GetDialog(project);
if (dialogResult == DialogResult.Yes)
{
SaveFile(project);
var result = SaveFile(project);
if (result.IsValid = false)
{
return false;
}
}
else if (dialogResult == DialogResult.No)
{
project.IsActual = true;
ProgramSetting.Projects.Remove(project);
return true;
}
else if (dialogResult == DialogResult.Cancel)
{
@@ -108,17 +125,24 @@ namespace StructureHelper.Windows.MainWindow
CloseFile(project);
return true;
}
private static DialogResult GetDialog(IProject project)
{
return MessageBox.Show($"File {project.FullFileName} has unsaved changes", $"StructureHelper: Save file?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
}
private void SaveFile()
{
var project = ProgramSetting.CurrentProject;
SaveFile(project);
}
private void SaveFile(IProject project)
private SaveFileResult SaveFile(IProject project)
{
traceLogger = new ShiftTraceLogger();
projectAccessLogic.TraceLogger = traceLogger;
projectAccessLogic.SaveProject(project);
var result = projectAccessLogic.SaveProject(project);
ShowEntries();
return result;
}
private void OpenFile()
{
@@ -128,29 +152,47 @@ namespace StructureHelper.Windows.MainWindow
{
return;
}
OpenNewFile(currentProject);
}
private void OpenNewFile(IProject currentProject)
{
traceLogger = new ShiftTraceLogger();
projectAccessLogic.TraceLogger = traceLogger;
try
var result = projectAccessLogic.OpenProject();
if (result.IsValid == true)
{
var result = projectAccessLogic.OpenProject();
if (result.IsValid == true)
{
result.Project.IsActual = true;
ProgramSetting.Projects.Clear();
ProgramSetting.Projects.Add(result.Project);
}
else
{
ProgramSetting.Projects.Add(currentProject);
}
result.Project.IsActual = true;
ProgramSetting.Projects.Clear();
ProgramSetting.Projects.Add(result.Project);
}
catch (Exception ex)
else
{
traceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
ProgramSetting.Projects.Add(currentProject);
}
ShowEntries();
ParentVM.AnalysesLogic.Refresh();
}
public void OpenNewFile(string fileName)
{
traceLogger = new ShiftTraceLogger();
projectAccessLogic.TraceLogger = traceLogger;
var result = projectAccessLogic.OpenProject(fileName);
if (result.IsValid == true)
{
result.Project.IsActual = true;
ProgramSetting.Projects.Clear();
ProgramSetting.Projects.Add(result.Project);
}
else
{
ProgramSetting.Projects.Add(new Project());
}
ShowEntries();
ParentVM.AnalysesLogic.Refresh();
}
private void ShowEntries()
{
var filteredEntries = traceLogger.TraceLoggerEntries.Where(x => x.Priority < 300);

View File

@@ -40,7 +40,26 @@
</Button>
</ToolBar>
<ToolBar ToolTip="Cross-sections">
<Button Style="{DynamicResource ToolButton}" Command="{Binding AnalysesLogic.AddAnalysisCommand}" ToolTip="NDM Analysis">
<Button Style="{DynamicResource ToolButton}" Command="{Binding AnalysesLogic.AddAnalysisCommand}">
<Button.ToolTip>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<TextBlock Text="NDM Cross-Section Analysis" FontWeight="Bold" Background="LightGray"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<Viewbox Stretch="Fill">
<ContentControl ContentTemplate="{DynamicResource NdmCrossSection}"/>
</Viewbox>
<TextBlock Grid.Column="1" TextWrapping="Wrap" Text="Extended analysis of cross-section of bar elements for strength, strain and cracks" FontStyle="Italic"/>
</Grid>
</Grid>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource NdmCrossSection}"/>
</Viewbox>

View File

@@ -21,17 +21,22 @@ namespace StructureHelper.Windows.MainWindow
public partial class AnalysesManagerView : Window
{
private AnalysesManagerViewModel viewModel;
public AnalysesManagerView()
public AnalysesManagerView(AnalysesManagerViewModel viewModel)
{
this.viewModel = new();
this.viewModel = viewModel;
this.DataContext = viewModel;
InitializeComponent();
this.Closing += AnalysesManagerView_Closing;
}
public AnalysesManagerView() : this (new AnalysesManagerViewModel())
{
}
private void AnalysesManagerView_Closing(object? sender, CancelEventArgs e)
{
if (viewModel.FileLogic.CloseFile() == true)
if (viewModel.FileLogic.ExitProgram() == false)
{
e.Cancel = true;
};

View File

@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow"
d:DataContext="{d:DesignInstance local:AxisCanvasVM}"
mc:Ignorable="d"
Title="Grid properies" Height="200" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
Title="Grid properties" Height="200" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>

View File

@@ -1,9 +1,9 @@
<Window x:Class="StructureHelper.Windows.PrimitiveProperiesWindow.PrimitivePropertiesView"
<Window x:Class="StructureHelper.Windows.PrimitivePropertiesWindow.PrimitivePropertiesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.PrimitiveProperiesWindow"
xmlns:local="clr-namespace:StructureHelper.Windows.PrimitivePropertiesWindow"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.PrimitiveProperties"
d:DataContext="{d:DesignInstance vm:PrimitivePropertiesViewModel}"
mc:Ignorable="d"

View File

@@ -10,7 +10,7 @@ using System.Windows.Data;
using PointViewPrimitive = StructureHelper.Infrastructure.UI.DataContexts.PointViewPrimitive;
using RectangleViewPrimitive = StructureHelper.Infrastructure.UI.DataContexts.RectangleViewPrimitive;
namespace StructureHelper.Windows.PrimitiveProperiesWindow
namespace StructureHelper.Windows.PrimitivePropertiesWindow
{
/// <summary>
/// Логика взаимодействия для PrimitiveProperties.xaml

View File

@@ -10,7 +10,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Calculations.CalculationProperies
namespace StructureHelper.Windows.ViewModels.Calculations.CalculationProperties
{
public class CalculationPropertyViewModel : ViewModelBase, IDataErrorInfo
{

View File

@@ -1,7 +1,7 @@
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Windows.PrimitiveProperiesWindow;
using StructureHelper.Windows.PrimitivePropertiesWindow;
using StructureHelper.Windows.Services;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Calculators;

View File

@@ -15,12 +15,11 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
/// </summary>
/// <typeparam name="T">Type of target object</typeparam>
/// <typeparam name="V">Type of source object</typeparam>
public class DictionaryConvertStrategy<T, V> : IConvertStrategy<T, V>
where T : ISaveable
public class DictionaryConvertStrategy<T, V> : IDictionaryConvertStrategy<T, V> where T : ISaveable
where V : ISaveable
{
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 DictionaryConvertStrategy(IBaseConvertStrategy baseConvertStrategy, IConvertStrategy<T, V> convertStrategy)
@@ -31,7 +30,16 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
}
public DictionaryConvertStrategy()
{
}
public DictionaryConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary,
IConvertStrategy<T, V> convertStrategy,
IShiftTraceLogger traceLogger)
{
ReferenceDictionary = referenceDictionary;
ConvertStrategy = convertStrategy;
TraceLogger = traceLogger;
}
public T Convert(V source)
@@ -56,7 +64,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
}
private void CheckInputData()
{
if(ReferenceDictionary is null)
if (ReferenceDictionary is null)
{
string errorString = ErrorStrings.ParameterIsNull + ": Reference Dictionary";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);

View File

@@ -0,0 +1,13 @@
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IDictionaryConvertStrategy<T, V> : IConvertStrategy<T, V>
where T : ISaveable
where V : ISaveable
{
IConvertStrategy<T, V> ConvertStrategy { get; set; }
}
}

View File

@@ -11,7 +11,7 @@ namespace StructureHelperCommon.Models.Loggers
public static string DimensionLess => "(dimensionless)";
public static string MethodBasedOn => "Method of calculation based on ";
public static string CalculationError => "Some errors happened during calculations: ";
public static string CalculationHasDone => "Calculation has done succesfully";
public static string CalculationHasDone => "Calculation has done successfully";
public static string Summary => "Summary";
public static string Maximum => "Maximum";
public static string Minimum => "Minimum";

View File

@@ -157,7 +157,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
};
}
string message = string.Intern("Result of second order was obtained succesfully, new force combination was obtained");
string message = string.Intern("Result of second order was obtained successfully, new force combination was obtained");
TraceLogger?.AddMessage(message);
tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
return tupleResult;

View File

@@ -88,7 +88,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
TraceLogger = TraceLogger
};
var ndms = triangulateLogic.GetNdms();
TraceLogger?.AddMessage($"Number of elementary parts N={ndms.Count()} were obtainded succesfully");
TraceLogger?.AddMessage($"Number of elementary parts N={ndms.Count()} were obtainded successfully");
TraceLogger?.AddMessage($"Summary area of elementary parts Asum={ndms.Sum(x=>x.Area * x.StressScale)}", TraceLogStatuses.Debug);
foreach (var predicateEntry in InputData.PredicateEntries)
{

View File

@@ -25,7 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
{
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Logic of analisys based on calculating sum of secant stifness of elementary parts EA,i = A,i * Esec,i");
TraceLogger?.AddMessage($"Calculating geometry properies for strains");
TraceLogger?.AddMessage($"Calculating geometry properties for strains");
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(StrainTuple));
var loaderStainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(StrainTuple);
var (MxFactor, MyFactor, NzFactor) = GeometryOperations.GetSofteningsFactors(NdmCollection, loaderStainMatrix);

View File

@@ -74,9 +74,9 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
CrackWidthRebarTupleResult longRebarResult = ProcessLongTermCalculations();
CrackWidthRebarTupleResult shortRebarResult = ProcessShortTermCalculations();
result.LongTermResult = longRebarResult;
TraceLogger?.AddMessage("Long term result has been obtained succesfully", TraceLogStatuses.Debug);
TraceLogger?.AddMessage("Long term result has been obtained successfully", TraceLogStatuses.Debug);
result.ShortTermResult = shortRebarResult;
TraceLogger?.AddMessage("Short term result has been obtained succesfully", TraceLogStatuses.Debug);
TraceLogger?.AddMessage("Short term result has been obtained successfully", TraceLogStatuses.Debug);
}
private CrackWidthRebarTupleResult ProcessShortTermCalculations()

View File

@@ -84,7 +84,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
throw new StructureHelperException(errorString);
return false;
}
TraceLogger?.AddMessage($"Checking parameters has done succefully", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Checking parameters has done successfully", TraceLogStatuses.Service);
return true;
}
}

View File

@@ -23,6 +23,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
static string firstAxisName => ProgramSetting.GeometryNames.FstAxisName;
static string secondAxisName => ProgramSetting.GeometryNames.SndAxisName;
static string thirdAxisName => ProgramSetting.GeometryNames.TrdAxisName;
static IEnumerable<IUnit> units = UnitsFactory.GetUnitCollection();
private IEnumerable<INdm> ndms;
private IStrainMatrix strainMatrix;
@@ -38,6 +39,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
parameters.AddRange(GetMomentOfInertia(prefixActual, ndms, strainMatrix));
parameters.AddRange(GetAreaRatio(ndms, strainMatrix));
parameters.AddRange(GetMomentOfInertiaRatio(ndms, strainMatrix));
parameters.AddRange(GetSummaryForces(ndms, strainMatrix));
return parameters;
}
private IEnumerable<IValueParameter<string>> GetSimpleArea(IEnumerable<INdm> ndms)
@@ -257,5 +259,61 @@ namespace StructureHelperLogics.Services.NdmPrimitives
parameters.Add(secondParameter);
return parameters;
}
private List<IValueParameter<string>> GetSummaryForces(IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix)
{
var parameters = new List<IValueParameter<string>>();
var unitType = UnitTypes.Force;
var unit = unitLogic.GetUnit(unitType, "kN");
var unitName = unit.Name;
var unitMultiPlayer = unit.Multiplyer;
var forceSum = new ValueParameter<string>()
{
IsValid = true,
Name = $"Summary force",
ShortName = $"N{thirdAxisName.ToLower()},sum",
Text = unitName,
Description = $"Summary longitudinal force along {thirdAxisName.ToUpper()}-axis"
};
FillForceParameters(locNdms, locStrainMatrix, unitMultiPlayer, PosNegFlag.Both, forceSum);
var forcePositive = new ValueParameter<string>()
{
IsValid = true,
Name = $"Positive force",
ShortName = $"N{thirdAxisName.ToLower()},pos",
Text = unitName,
Description = $"Summary of positive longitudinal force along {thirdAxisName.ToUpper()}-axis"
};
FillForceParameters(locNdms, locStrainMatrix, unitMultiPlayer, PosNegFlag.Positive, forcePositive);
var forceNegative = new ValueParameter<string>()
{
IsValid = true,
Name = $"Negative force",
ShortName = $"N{thirdAxisName.ToLower()},neg",
Text = unitName,
Description = $"Summary of negative longitudinal force along {thirdAxisName.ToUpper()}-axis"
};
FillForceParameters(locNdms, locStrainMatrix, unitMultiPlayer, PosNegFlag.Negative, forceNegative);
parameters.Add(forceSum);
parameters.Add(forcePositive);
parameters.Add(forceNegative);
return parameters;
}
private static void FillForceParameters(IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix, double unitMultiPlayer, PosNegFlag posNegFlag, ValueParameter<string> forceSum)
{
try
{
var sumForceNz = GeometryOperations.GetSummaryForce(locNdms, locStrainMatrix, posNegFlag);
forceSum.Value = (sumForceNz * unitMultiPlayer).ToString();
}
catch (Exception ex)
{
forceSum.IsValid = false;
forceSum.Value = (double.NaN).ToString();
forceSum.Description += $": {ex}";
}
}
}
}

View File

@@ -17,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataAccess\DataAccess.csproj" />
<ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj" />
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
<ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj" />

View File

@@ -0,0 +1,119 @@
using DataAccess.DTOs;
using Moq;
using NUnit.Framework;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Projects;
namespace StructureHelperTests.UnitTests.ConvertStrategiesTest
{
[TestFixture]
public class ProjectFromDTOConvertStrategyTests
{
private Mock<IUpdateStrategy<IProject>> _mockUpdateStrategy;
private Mock<IDictionaryConvertStrategy<IVisualAnalysis, IVisualAnalysis>> _mockConvertLogic;
private Mock<IShiftTraceLogger> _mockTraceLogger;
private Dictionary<(Guid id, Type type), ISaveable> _referenceDictionary;
private ProjectFromDTOConvertStrategy _convertStrategy;
[SetUp]
public void SetUp()
{
_mockUpdateStrategy = new Mock<IUpdateStrategy<IProject>>();
_mockConvertLogic = new Mock<IDictionaryConvertStrategy<IVisualAnalysis, IVisualAnalysis>>();
_mockTraceLogger = new Mock<IShiftTraceLogger>();
_referenceDictionary = new Dictionary<(Guid, Type), ISaveable>();
_convertStrategy = new ProjectFromDTOConvertStrategy(
_mockUpdateStrategy.Object,
_mockConvertLogic.Object,
_referenceDictionary,
_mockTraceLogger.Object);
}
[Test]
public void GetNewItem_ShouldLogStartAndEndMessages()
{
// Arrange
var projectDto = new ProjectDTO
{
VisualAnalyses = new List<IVisualAnalysis> { new Mock<IVisualAnalysis>().Object }
};
_mockConvertLogic
.Setup(s => s.Convert(It.IsAny<IVisualAnalysis>()))
.Returns(new Mock<IVisualAnalysis>().Object);
// Act
var result = _convertStrategy.GetNewItem(projectDto);
// Assert
_mockTraceLogger.Verify(logger => logger.AddMessage("Converting of project is started"), Times.Once);
_mockTraceLogger.Verify(logger => logger.AddMessage("Converting of project has been finished successfully"), Times.Once);
}
[Test]
public void GetNewItem_ShouldLogWarningIfNoAnalyses()
{
// Arrange
var projectDto = new ProjectDTO
{
VisualAnalyses = Enumerable.Empty<IVisualAnalysis>().ToList()
};
// Act
var result = _convertStrategy.GetNewItem(projectDto);
// Assert
_mockTraceLogger.Verify(logger => logger.AddMessage("Project does not have any analyses, it is possible to work with project", TraceLogStatuses.Warning), Times.Once);
}
[Test]
public void GetAnalyses_ShouldConvertEachVisualAnalysisAndLogCount()
{
// Arrange
var projectDto = new ProjectDTO
{
VisualAnalyses = new List<IVisualAnalysis> { new Mock<IVisualAnalysis>().Object, new Mock<IVisualAnalysis>().Object }
};
var newItem = new Project();
_mockConvertLogic
.Setup(s => s.Convert(It.IsAny<IVisualAnalysis>()))
.Returns(new Mock<IVisualAnalysis>().Object);
// Act
var analyses = _convertStrategy.GetAnalyses(projectDto, newItem);
// Assert
Assert.AreEqual(projectDto.VisualAnalyses.Count, analyses.Count);
_mockConvertLogic.Verify(s => s.Convert(It.IsAny<IVisualAnalysis>()), Times.Exactly(projectDto.VisualAnalyses.Count));
_mockTraceLogger.Verify(logger => logger.AddMessage($"Source project has {projectDto.VisualAnalyses.Count} analyses"), Times.Once);
}
[Test]
public void GetAnalyses_ShouldLogConvertedAnalysisCount()
{
// Arrange
var projectDto = new ProjectDTO
{
VisualAnalyses = new List<IVisualAnalysis> { new Mock<IVisualAnalysis>().Object }
};
var newItem = new Project();
_mockConvertLogic
.Setup(s => s.Convert(It.IsAny<IVisualAnalysis>()))
.Returns(new Mock<IVisualAnalysis>().Object);
// Act
var result = _convertStrategy.GetNewItem(projectDto);
// Assert
_mockTraceLogger.Verify(logger => logger.AddMessage("Totaly 1 were(was) obtained"), Times.Once);
}
}
}