refactor:将AppDataCenterService改为AppCenterService,将AppDataStorageService改为AppStorageService,将触发器的增删改成合并
This commit is contained in:
@@ -17,8 +17,8 @@ public class DeviceMonitoringService : IDeviceMonitoringService, IDisposable
|
||||
{
|
||||
private readonly ILogger<DeviceMonitoringService> _logger;
|
||||
private readonly IEventService _eventService;
|
||||
private readonly IAppDataStorageService _appDataStorageService;
|
||||
private readonly IAppDataCenterService _appDataCenterService;
|
||||
private readonly IAppStorageService _appStorageService;
|
||||
private readonly IAppCenterService _appCenterService;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -27,13 +27,13 @@ public class DeviceMonitoringService : IDeviceMonitoringService, IDisposable
|
||||
/// <param name="logger">日志记录器</param>
|
||||
/// <param name="deviceAppService">设备应用服务</param>
|
||||
public DeviceMonitoringService(ILogger<DeviceMonitoringService> logger, IEventService eventService,
|
||||
IAppDataStorageService appDataStorageService,
|
||||
IAppDataCenterService appDataCenterService)
|
||||
IAppStorageService appStorageService,
|
||||
IAppCenterService appCenterService)
|
||||
{
|
||||
_logger = logger;
|
||||
_eventService = eventService;
|
||||
_appDataStorageService = appDataStorageService;
|
||||
_appDataCenterService = appDataCenterService;
|
||||
_appStorageService = appStorageService;
|
||||
_appCenterService = appCenterService;
|
||||
_eventService.OnDeviceStateChanged += OnDeviceStateChanged;
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ public class DeviceMonitoringService : IDeviceMonitoringService, IDisposable
|
||||
// 只处理激活状态变化事件
|
||||
if (e.StateType == Core.Enums.DeviceStateType.Active)
|
||||
{
|
||||
if (_appDataStorageService.Devices.TryGetValue(e.DeviceId, out var device))
|
||||
if (_appStorageService.Devices.TryGetValue(e.DeviceId, out var device))
|
||||
{
|
||||
// 更新设备激活状态 - 同时更新数据库和内存
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await _appDataCenterService.DeviceManagementService.UpdateDeviceAsync(device);
|
||||
await _appCenterService.DeviceManagementService.UpdateDeviceAsync(device);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user