feat: add p-rec-annot datalinks line-number read path

This commit is contained in:
codex
2026-08-07 08:18:55 +03:00
parent 8e197cdcde
commit b6a2cd06af
4 changed files with 57 additions and 0 deletions
@@ -0,0 +1,20 @@
using Autodesk.ProcessPower.DataLinks;
using PRecAnnot.Abstractions;
namespace PRecAnnot.Plant3D2026;
internal sealed class PlantDataLinksPropertyReader(DataLinksManager dataLinks) : IDataLinksPropertyReader
{
public DataLinksPropertyReadResult ReadProperties(long rowId)
{
if (rowId <= 0) return new(false, new Dictionary<string, string?>(), "DATALINKS_ROW_ID_INVALID");
try
{
var values = dataLinks.GetAllProperties((int)rowId, true)
.GroupBy(x => x.Key, StringComparer.OrdinalIgnoreCase)
.ToDictionary(x => x.Key, x => (string?)x.Last().Value, StringComparer.OrdinalIgnoreCase);
return new(true, values);
}
catch (DLException) { return new(false, new Dictionary<string, string?>(), "DATALINKS_PROPERTY_READ_FAILED"); }
catch (Exception) { return new(false, new Dictionary<string, string?>(), "DATALINKS_PROPERTY_READ_FAILED"); }
}
}