fix: resolve Plant project context diagnostics
This commit is contained in:
@@ -8,6 +8,7 @@ public sealed record RuntimeDiagnostic
|
||||
}
|
||||
|
||||
public enum OrthoDetectionStatus { Confirmed, NotOrtho, Ambiguous, Unsupported, Failed }
|
||||
public enum PlantProjectDetectionStatus { NotFound, FoundWithName, FoundWithoutDisplayName, Ambiguous, Failed }
|
||||
|
||||
public sealed record OrthoDetectionResult
|
||||
{
|
||||
@@ -66,6 +67,7 @@ public sealed record PlantRuntimeContext
|
||||
public bool IsOrthoDrawing { get; init; }
|
||||
public string? DrawingName { get; init; }
|
||||
public string? ProjectDisplayName { get; init; }
|
||||
public PlantProjectDetectionStatus ProjectDetectionStatus { get; init; } = PlantProjectDetectionStatus.NotFound;
|
||||
public IReadOnlyList<OrthoViewportInfo> Viewports { get; init; } = Array.Empty<OrthoViewportInfo>();
|
||||
public IReadOnlyList<RuntimeDiagnostic> Diagnostics { get; init; } = Array.Empty<RuntimeDiagnostic>();
|
||||
public OrthoDetectionResult Detection { get; init; } = new() { Status = OrthoDetectionStatus.Unsupported, Evidence = Array.Empty<string>(), Diagnostics = Array.Empty<RuntimeDiagnostic>() };
|
||||
|
||||
@@ -32,6 +32,9 @@ internal sealed class PlantRuntimeContextReader : IPlantRuntimeContextReader
|
||||
return Empty(true, false, "NO_PLANT_PROJECT", "Активный Plant 3D-проект не найден.");
|
||||
}
|
||||
|
||||
var displayName = string.IsNullOrWhiteSpace(project.Name) ? null : project.Name.Trim();
|
||||
var projectStatus = displayName is null ? PlantProjectDetectionStatus.FoundWithoutDisplayName : PlantProjectDetectionStatus.FoundWithName;
|
||||
|
||||
OrthoProject? orthoProject;
|
||||
try { orthoProject = PlantApplication.ProjectPart("Ortho") as OrthoProject; }
|
||||
catch (Exception exception)
|
||||
@@ -60,9 +63,10 @@ internal sealed class PlantRuntimeContextReader : IPlantRuntimeContextReader
|
||||
HasPlantProject = true,
|
||||
IsOrthoDrawing = true,
|
||||
DrawingName = Path.GetFileName(document.Name),
|
||||
ProjectDisplayName = project.Name,
|
||||
ProjectDisplayName = displayName ?? "display name unavailable",
|
||||
ProjectDetectionStatus = projectStatus,
|
||||
Viewports = viewports,
|
||||
Diagnostics = Array.Empty<RuntimeDiagnostic>(),
|
||||
Diagnostics = displayName is null ? new[] { new RuntimeDiagnostic { Code = "PLANT_PROJECT_DISPLAY_NAME_EMPTY", Message = "Plant project is open but no display name is available.", Severity = "Warning" } } : Array.Empty<RuntimeDiagnostic>(),
|
||||
Detection = new OrthoDetectionResult
|
||||
{
|
||||
Status = OrthoDetectionStatus.Confirmed,
|
||||
@@ -82,6 +86,8 @@ internal sealed class PlantRuntimeContextReader : IPlantRuntimeContextReader
|
||||
HasActiveDocument = hasDocument,
|
||||
HasPlantProject = hasProject,
|
||||
IsOrthoDrawing = false,
|
||||
ProjectDisplayName = hasProject ? "display name unavailable" : null,
|
||||
ProjectDetectionStatus = hasProject ? PlantProjectDetectionStatus.Ambiguous : PlantProjectDetectionStatus.NotFound,
|
||||
Diagnostics = new[] { new RuntimeDiagnostic { Code = code, Message = message } },
|
||||
Detection = new OrthoDetectionResult { Status = status, Evidence = evidence, Diagnostics = new[] { new RuntimeDiagnostic { Code = code, Message = message } } }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user