@using ZB.MOM.WW.OtOpcUa.Admin.Services @using ZB.MOM.WW.OtOpcUa.Configuration.Entities @using ZB.MOM.WW.OtOpcUa.Configuration.Validation @inject EquipmentService EquipmentSvc

Equipment (draft gen @GenerationId)

@if (_equipment is null) {

Loading…

} else if (_equipment.Count == 0 && !_showForm) {

No equipment in this draft yet.

} else if (_equipment.Count > 0) { @foreach (var e in _equipment) { }
EquipmentIdNameMachineCodeZTagSAPID Manufacturer / ModelSerial
@e.EquipmentId @e.Name @e.MachineCode @e.ZTag @e.SAPID @e.Manufacturer / @e.Model @e.SerialNumber
} @if (_showForm) {
New equipment
OPC 40010 Identification
@if (_error is not null) {
@_error
}
} @code { [Parameter] public long GenerationId { get; set; } private List? _equipment; private bool _showForm; private Equipment _draft = NewBlankDraft(); private string? _error; private static Equipment NewBlankDraft() => new() { EquipmentId = string.Empty, DriverInstanceId = string.Empty, UnsLineId = string.Empty, Name = string.Empty, MachineCode = string.Empty, }; protected override async Task OnParametersSetAsync() => await ReloadAsync(); private async Task ReloadAsync() { _equipment = await EquipmentSvc.ListAsync(GenerationId, CancellationToken.None); } private void StartAdd() { _draft = NewBlankDraft(); _error = null; _showForm = true; } private async Task SaveAsync() { _error = null; _draft.EquipmentUuid = Guid.NewGuid(); _draft.EquipmentId = DraftValidator.DeriveEquipmentId(_draft.EquipmentUuid); _draft.GenerationId = GenerationId; try { await EquipmentSvc.CreateAsync(GenerationId, _draft, CancellationToken.None); _showForm = false; await ReloadAsync(); } catch (Exception ex) { _error = ex.Message; } } private async Task DeleteAsync(Guid id) { await EquipmentSvc.DeleteAsync(id, CancellationToken.None); await ReloadAsync(); } }