RobotStatusChangedDomainEventHandler.cs
1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Microsoft.Extensions.Logging;
using Rcs.Application.Services;
using Rcs.Domain.Entities.DomainEvents.Robot;
namespace Rcs.Infrastructure.MessageBus.Handlers.Events.Robot;
/// <summary>
/// 机器人状态变更领域事件处理器。
/// </summary>
public class RobotStatusChangedDomainEventHandler
{
private readonly ILogger<RobotStatusChangedDomainEventHandler> _logger;
private readonly IChargingFlowService _chargingFlowService;
public RobotStatusChangedDomainEventHandler(
ILogger<RobotStatusChangedDomainEventHandler> logger,
IChargingFlowService chargingFlowService)
{
_logger = logger;
_chargingFlowService = chargingFlowService;
}
public async Task Handle(RobotStatusChangedDomainEvent domainEvent)
{
try
{
await _chargingFlowService.HandleRobotStatusChangedAsync(domainEvent);
}
catch (Exception ex)
{
_logger.LogError(
ex,
"Handle RobotStatusChangedDomainEvent failed. RobotId={RobotId}, RobotCode={RobotCode}",
domainEvent.RobotId,
domainEvent.RobotCode);
throw;
}
}
}