@namespace ZB.MOM.WW.ScadaBridge.CentralUI.Components.Forms
@using ZB.MOM.WW.ScadaBridge.CentralUI.Services
@using ZB.MOM.WW.ScadaBridge.Commons.Messages.Management
@using ZB.MOM.WW.ScadaBridge.Commons.Types.DataConnections
@using ZB.MOM.WW.ScadaBridge.Commons.Types.Flattening
@inject IEndpointVerificationService VerificationService
@Title
@if (IsLegacy)
{
This connection was migrated from a legacy format.
Review the settings and Save to update.
}
@if (_verifyResult is { } result)
{
@if (result.Success)
{
✓ Endpoint reachable
}
else
{
@result.FailureKind: @result.Error
}
@if (result.FailureKind == VerifyFailureKind.UntrustedCertificate
&& result.Cert is { } cert)
{
Untrusted server certificate
- Subject
@cert.Subject
- Issuer
@cert.Issuer
- Thumbprint
@cert.Thumbprint
- Not before
- @cert.NotBeforeUtc.ToString("u")
- Not after
- @cert.NotAfterUtc.ToString("u")
Use cert management to trust this certificate.
}
}
Authentication
@if (Config.UserIdentity is null)
{
}
else
{
}
Timing
Subscription
Advanced subscription
Deadband filter
@if (Config.Deadband is null)
{
}
else
{
@RenderFieldError("Deadband.Value")
}
Heartbeat
@if (Config.Heartbeat is null)
{
}
else
{
}
@code {
[Parameter, EditorRequired] public OpcUaEndpointConfig Config { get; set; } = default!;
[Parameter] public string Title { get; set; } = "Endpoint";
[Parameter] public string IdPrefix { get; set; } = "endpoint";
[Parameter] public bool IsLegacy { get; set; }
[Parameter] public ValidationResult? Errors { get; set; }
// Verify-endpoint context (M7 T17): the site + connection identity the verify
// probe targets. Supplied by DataConnectionForm (_formSiteId → SiteIdentifier,
// _formName, _protocol). When SiteIdentifier is blank the connection has not been
// assigned a site yet, so verification is unavailable.
[Parameter] public string SiteIdentifier { get; set; } = string.Empty;
[Parameter] public string ConnectionName { get; set; } = string.Empty;
[Parameter] public string Protocol { get; set; } = "OpcUa";
private bool _verifying;
private VerifyEndpointResult? _verifyResult;
private async Task VerifyEndpoint()
{
_verifying = true;
_verifyResult = null;
try
{
_verifyResult = await VerificationService.VerifyAsync(
SiteIdentifier, ConnectionName, Protocol, Config);
}
catch (Exception ex)
{
_verifyResult = new VerifyEndpointResult(
false, VerifyFailureKind.ServerError, ex.Message, null);
}
finally
{
_verifying = false;
}
}
private void EnableHeartbeat() =>
Config.Heartbeat = new OpcUaHeartbeatConfig();
private void EnableAuthentication() =>
Config.UserIdentity = new OpcUaUserIdentityConfig();
private void EnableDeadband() =>
Config.Deadband = new OpcUaDeadbandConfig();
private RenderFragment? RenderFieldError(string field)
{
var match = Errors?.Errors.FirstOrDefault(e =>
e.EntityName != null
&& (e.EntityName == field || e.EntityName.EndsWith("." + field)));
return match is null
? null
: @