fix: tolerate missing Ortho DataLinks rows in DryRun

This commit is contained in:
codex
2026-08-03 07:54:00 +03:00
parent bb44b1b1aa
commit c616188336
@@ -164,34 +164,42 @@ internal sealed class PlantObjectReader : IPlantObjectReader
if (dataLinks is null) return Array.Empty<PlantObjectSnapshot>(); if (dataLinks is null) return Array.Empty<PlantObjectSnapshot>();
var snapshots = new List<PlantObjectSnapshot>(); var snapshots = new List<PlantObjectSnapshot>();
foreach (var rowId in dataLinks.SelectAcPpRowIds(document.Database)) try
{ {
try foreach (var rowId in dataLinks.SelectAcPpRowIds(document.Database))
{ {
cancellationToken.ThrowIfCancellationRequested(); try
var className = dataLinks.GetObjectClassname(rowId);
var properties = dataLinks.GetAllProperties(rowId, true)
.GroupBy(x => x.Key, StringComparer.OrdinalIgnoreCase)
.ToDictionary(x => x.Key, x => x.Last().Value, StringComparer.OrdinalIgnoreCase);
string? Value(params string[] names) => properties.FirstOrDefault(x => names.Any(name => string.Equals(name, x.Key, StringComparison.OrdinalIgnoreCase))).Value;
snapshots.Add(new PlantObjectSnapshot
{ {
SnapshotId = StableId(Path.GetFileName(document.Name), rowId, className), cancellationToken.ThrowIfCancellationRequested();
ObjectClass = className ?? string.Empty, var className = dataLinks.GetObjectClassname(rowId);
Tag = Value("Tag", "TAG"), var properties = dataLinks.GetAllProperties(rowId, true)
LineNumber = Value("Line Number", "LineNumber", "LINENUMBER"), .GroupBy(x => x.Key, StringComparer.OrdinalIgnoreCase)
SupportNumber = Value("Support Number", "SupportNumber"), .ToDictionary(x => x.Key, x => x.Last().Value, StringComparer.OrdinalIgnoreCase);
EquipmentNumber = Value("Equipment Number", "EquipmentNumber"), string? Value(params string[] names) => properties.FirstOrDefault(x => names.Any(name => string.Equals(name, x.Key, StringComparison.OrdinalIgnoreCase))).Value;
Geometry = new GeometrySnapshot(), snapshots.Add(new PlantObjectSnapshot
Properties = properties.ToDictionary(x => x.Key, x => (string?)x.Value, StringComparer.OrdinalIgnoreCase), {
Diagnostics = new[] { "GEOMETRY_NOT_MAPPED" } SnapshotId = StableId(Path.GetFileName(document.Name), rowId, className),
}); ObjectClass = className ?? string.Empty,
} Tag = Value("Tag", "TAG"),
catch LineNumber = Value("Line Number", "LineNumber", "LINENUMBER"),
{ SupportNumber = Value("Support Number", "SupportNumber"),
// Keep the read path best-effort; no write operation is attempted. EquipmentNumber = Value("Equipment Number", "EquipmentNumber"),
Geometry = new GeometrySnapshot(),
Properties = properties.ToDictionary(x => x.Key, x => (string?)x.Value, StringComparer.OrdinalIgnoreCase),
Diagnostics = new[] { "GEOMETRY_NOT_MAPPED" }
});
}
catch
{
// Keep the read path best-effort; no write operation is attempted.
}
} }
} }
catch (DLException)
{
// An Ortho sheet can have no direct Piping DataLinks rows. The caller
// receives an empty read-only result rather than a command failure.
}
return snapshots.OrderBy(x => x.SnapshotId, StringComparer.Ordinal).ToArray(); return snapshots.OrderBy(x => x.SnapshotId, StringComparer.Ordinal).ToArray();
} }