Skip to content

Commit 0ac191d

Browse files
author
BRUNER Patrick
committed
new choose files dialog for missing logfiles in the project lxp
1 parent 44d603c commit 0ac191d

15 files changed

Lines changed: 1780 additions & 96 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace LogExpert.Core.Classes.Persister;
2+
3+
/// <summary>
4+
/// Represents the result of loading a project file, including validation information.
5+
/// </summary>
6+
public class ProjectLoadResult
7+
{
8+
/// <summary>
9+
/// The loaded project data.
10+
/// </summary>
11+
public ProjectData ProjectData { get; set; }
12+
13+
/// <summary>
14+
/// Validation result containing valid, missing, and alternative file paths.
15+
/// </summary>
16+
public ProjectValidationResult ValidationResult { get; set; }
17+
18+
/// <summary>
19+
/// Indicates whether the project has at least one valid file to load.
20+
/// </summary>
21+
public bool HasValidFiles => ValidationResult?.ValidFiles.Count > 0;
22+
23+
/// <summary>
24+
/// Indicates whether user intervention is needed due to missing files.
25+
/// </summary>
26+
public bool RequiresUserIntervention => ValidationResult?.HasMissingFiles ?? false;
27+
}

src/LogExpert.Core/Classes/Persister/ProjectPersister.cs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ public static class ProjectPersister
1515
#region Public methods
1616

1717
/// <summary>
18-
/// Loads the project session data from a specified file.
18+
/// Loads the project session data from a specified file, including validation of referenced files.
1919
/// </summary>
20-
/// <param name="projectFileName"></param>
21-
/// <returns></returns>
22-
public static ProjectData LoadProjectData (string projectFileName, IPluginRegistry pluginRegistry)
20+
/// <param name="projectFileName">The path to the project file (.lxj)</param>
21+
/// <param name="pluginRegistry">The plugin registry for file system validation</param>
22+
/// <returns>A <see cref="ProjectLoadResult"/> containing the project data and validation results</returns>
23+
public static ProjectLoadResult LoadProjectData (string projectFileName, IPluginRegistry pluginRegistry)
2324
{
2425
try
2526
{
@@ -31,18 +32,37 @@ public static ProjectData LoadProjectData (string projectFileName, IPluginRegist
3132
var json = File.ReadAllText(projectFileName, Encoding.UTF8);
3233
var projectData = JsonConvert.DeserializeObject<ProjectData>(json, settings);
3334

34-
var hasLayout = projectData.TabLayoutXml != null;
35+
// Set project file path for alternative file search
36+
projectData.ProjectFilePath = projectFileName;
37+
38+
// Validate all files referenced in the project
3539
var validationResult = ProjectFileValidator.ValidateProject(projectData, pluginRegistry);
3640

37-
return projectData;
41+
return new ProjectLoadResult
42+
{
43+
ProjectData = projectData,
44+
ValidationResult = validationResult
45+
};
3846
}
3947
catch (Exception ex) when (ex is UnauthorizedAccessException or
4048
IOException or
4149
JsonSerializationException)
4250
{
43-
4451
_logger.Warn($"Error loading persistence data from {projectFileName}, trying old xml version");
45-
return ProjectPersisterXML.LoadProjectData(projectFileName);
52+
53+
var projectData = ProjectPersisterXML.LoadProjectData(projectFileName);
54+
55+
// Set project file path for alternative file search
56+
projectData.ProjectFilePath = projectFileName;
57+
58+
// Validate files from XML fallback as well
59+
var validationResult = ProjectFileValidator.ValidateProject(projectData, pluginRegistry);
60+
61+
return new ProjectLoadResult
62+
{
63+
ProjectData = projectData,
64+
ValidationResult = validationResult
65+
};
4666
}
4767
}
4868

src/LogExpert.Persister.Tests/LogExpert.Persister.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<ItemGroup>
1919
<ProjectReference Include="..\LogExpert.Core\LogExpert.Core.csproj" />
20+
<ProjectReference Include="..\PluginRegistry\LogExpert.PluginRegistry.csproj" />
2021
</ItemGroup>
2122

2223
<ItemGroup>

0 commit comments

Comments
 (0)