refactor(admin): use CorrelationId wrapper for alarm ack/shelve commands
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Types;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Admin;
|
||||
|
||||
/// <summary>
|
||||
@@ -16,7 +18,7 @@ public sealed record AcknowledgeAlarmCommand(
|
||||
string AlarmId,
|
||||
string User,
|
||||
string? Comment,
|
||||
Guid CorrelationId);
|
||||
CorrelationId CorrelationId);
|
||||
|
||||
/// <summary>Reply for <see cref="AcknowledgeAlarmCommand"/>.</summary>
|
||||
/// <param name="Ok">True iff the command was published without error.</param>
|
||||
@@ -25,4 +27,4 @@ public sealed record AcknowledgeAlarmCommand(
|
||||
public sealed record AcknowledgeAlarmResult(
|
||||
bool Ok,
|
||||
string? Message,
|
||||
Guid CorrelationId);
|
||||
CorrelationId CorrelationId);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Types;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Admin;
|
||||
|
||||
/// <summary>
|
||||
@@ -40,7 +42,7 @@ public sealed record ShelveAlarmCommand(
|
||||
ShelveKind Kind,
|
||||
DateTime? UnshelveAtUtc,
|
||||
string? Comment,
|
||||
Guid CorrelationId);
|
||||
CorrelationId CorrelationId);
|
||||
|
||||
/// <summary>Reply for <see cref="ShelveAlarmCommand"/>.</summary>
|
||||
/// <param name="Ok">True iff the command was published without error.</param>
|
||||
@@ -49,4 +51,4 @@ public sealed record ShelveAlarmCommand(
|
||||
public sealed record ShelveAlarmResult(
|
||||
bool Ok,
|
||||
string? Message,
|
||||
Guid CorrelationId);
|
||||
CorrelationId CorrelationId);
|
||||
|
||||
@@ -46,7 +46,7 @@ public sealed class AdminOperationsClient : IAdminOperationsClient
|
||||
public async Task<AcknowledgeAlarmResult> AcknowledgeAlarmAsync(
|
||||
string alarmId, string user, string? comment, CancellationToken ct)
|
||||
{
|
||||
var msg = new AcknowledgeAlarmCommand(alarmId, user, comment, Guid.NewGuid());
|
||||
var msg = new AcknowledgeAlarmCommand(alarmId, user, comment, CorrelationId.NewId());
|
||||
using var linked = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||
linked.CancelAfter(AskTimeout);
|
||||
return await _proxy.Ask<AcknowledgeAlarmResult>(msg, AskTimeout, linked.Token);
|
||||
@@ -63,7 +63,7 @@ public sealed class AdminOperationsClient : IAdminOperationsClient
|
||||
public async Task<ShelveAlarmResult> ShelveAlarmAsync(
|
||||
string alarmId, string user, ShelveKind kind, DateTime? unshelveAtUtc, string? comment, CancellationToken ct)
|
||||
{
|
||||
var msg = new ShelveAlarmCommand(alarmId, user, kind, unshelveAtUtc, comment, Guid.NewGuid());
|
||||
var msg = new ShelveAlarmCommand(alarmId, user, kind, unshelveAtUtc, comment, CorrelationId.NewId());
|
||||
using var linked = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||
linked.CancelAfter(AskTimeout);
|
||||
return await _proxy.Ask<ShelveAlarmResult>(msg, AskTimeout, linked.Token);
|
||||
|
||||
Reference in New Issue
Block a user