feat(uns): equipment modal wired into the tree
This commit is contained in:
@@ -148,6 +148,55 @@ public sealed class UnsTreeService(IDbContextFactory<OtOpcUaConfigDbContext> dbF
|
||||
.FirstOrDefaultAsync(ct);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<EquipmentEditDto?> LoadEquipmentAsync(string equipmentId, CancellationToken ct = default)
|
||||
{
|
||||
await using var db = await dbFactory.CreateDbContextAsync(ct);
|
||||
|
||||
return await db.Equipment
|
||||
.AsNoTracking()
|
||||
.Where(e => e.EquipmentId == equipmentId)
|
||||
.Select(e => new EquipmentEditDto(
|
||||
e.EquipmentId,
|
||||
e.Name,
|
||||
e.MachineCode,
|
||||
e.UnsLineId,
|
||||
e.DriverInstanceId,
|
||||
e.ZTag,
|
||||
e.SAPID,
|
||||
e.Manufacturer,
|
||||
e.Model,
|
||||
e.SerialNumber,
|
||||
e.HardwareRevision,
|
||||
e.SoftwareRevision,
|
||||
e.YearOfConstruction,
|
||||
e.AssetLocation,
|
||||
e.ManufacturerUri,
|
||||
e.DeviceManualUri,
|
||||
e.Enabled,
|
||||
e.RowVersion))
|
||||
.FirstOrDefaultAsync(ct);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IReadOnlyList<(string DriverInstanceId, string Display)>> LoadDriversForClusterAsync(
|
||||
string clusterId,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
await using var db = await dbFactory.CreateDbContextAsync(ct);
|
||||
|
||||
var drivers = await db.DriverInstances
|
||||
.AsNoTracking()
|
||||
.Where(d => d.ClusterId == clusterId)
|
||||
.OrderBy(d => d.DriverInstanceId)
|
||||
.Select(d => new { d.DriverInstanceId, d.Name, d.DriverType })
|
||||
.ToListAsync(ct);
|
||||
|
||||
return drivers
|
||||
.Select(d => (d.DriverInstanceId, Display: $"{d.DriverInstanceId} — {d.Name} ({d.DriverType})"))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<UnsMutationResult> CreateAreaAsync(
|
||||
string clusterId,
|
||||
|
||||
Reference in New Issue
Block a user