添加了事件服务,并完成了设备状态改变后写入数据库
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace DMS.WPF.Events;
|
namespace DMS.Application.Events;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备状态改变事件参数
|
/// 设备状态改变事件参数
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace DMS.WPF.Events;
|
namespace DMS.Application.Events;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MQTT连接状态改变事件参数
|
/// MQTT连接状态改变事件参数
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace DMS.WPF.Events;
|
namespace DMS.Application.Events;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 变量值改变事件参数
|
/// 变量值改变事件参数
|
||||||
11
DMS.Application/Interfaces/IDeviceMonitoringService.cs
Normal file
11
DMS.Application/Interfaces/IDeviceMonitoringService.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using DMS.Application.Events;
|
||||||
|
|
||||||
|
namespace DMS.Application.Interfaces;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备监视服务接口,用于监视设备的状态变化
|
||||||
|
/// </summary>
|
||||||
|
public interface IDeviceMonitoringService
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using DMS.WPF.Events;
|
using DMS.Application.Events;
|
||||||
|
|
||||||
namespace DMS.WPF.Interfaces;
|
namespace DMS.Application.Interfaces;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 事件服务接口,用于统一管理应用程序中的各种事件
|
/// 事件服务接口,用于统一管理应用程序中的各种事件
|
||||||
@@ -13,7 +13,7 @@ public interface IEventService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备状态改变事件
|
/// 设备状态改变事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler<DeviceActiveChangedEventArgs> DeviceStatusChanged;
|
event EventHandler<DeviceActiveChangedEventArgs> OnDeviceActiveChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 触发设备状态改变事件
|
/// 触发设备状态改变事件
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using DMS.WPF.Events;
|
using DMS.Application.Events;
|
||||||
using DMS.WPF.Interfaces;
|
using DMS.Application.Interfaces;
|
||||||
|
|
||||||
namespace DMS.WPF.Services;
|
namespace DMS.Application.Services;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 事件服务实现类,用于统一管理应用程序中的各种事件
|
/// 事件服务实现类,用于统一管理应用程序中的各种事件
|
||||||
@@ -14,7 +14,7 @@ public class EventService : IEventService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备状态改变事件
|
/// 设备状态改变事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<DeviceActiveChangedEventArgs> DeviceStatusChanged;
|
public event EventHandler<DeviceActiveChangedEventArgs> OnDeviceActiveChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 触发设备状态改变事件
|
/// 触发设备状态改变事件
|
||||||
@@ -23,7 +23,7 @@ public class EventService : IEventService
|
|||||||
/// <param name="e">设备状态改变事件参数</param>
|
/// <param name="e">设备状态改变事件参数</param>
|
||||||
public void RaiseDeviceStatusChanged(object sender, DeviceActiveChangedEventArgs e)
|
public void RaiseDeviceStatusChanged(object sender, DeviceActiveChangedEventArgs e)
|
||||||
{
|
{
|
||||||
DeviceStatusChanged?.Invoke(sender, e);
|
OnDeviceActiveChanged?.Invoke(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DMS.Application.Events;
|
||||||
|
using DMS.Application.Interfaces;
|
||||||
|
using DMS.Core.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace DMS.Application.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备监视服务实现类,用于监视设备的状态变化
|
||||||
|
/// </summary>
|
||||||
|
public class DeviceMonitoringService : IDeviceMonitoringService, IDisposable
|
||||||
|
{
|
||||||
|
private readonly ILogger<DeviceMonitoringService> _logger;
|
||||||
|
private readonly IEventService _eventService;
|
||||||
|
private readonly IAppDataStorageService _appDataStorageService;
|
||||||
|
private readonly IAppDataCenterService _appDataCenterService;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化DeviceMonitoringService类的新实例
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">日志记录器</param>
|
||||||
|
/// <param name="deviceAppService">设备应用服务</param>
|
||||||
|
public DeviceMonitoringService(ILogger<DeviceMonitoringService> logger, IEventService eventService,
|
||||||
|
IAppDataStorageService appDataStorageService,
|
||||||
|
IAppDataCenterService appDataCenterService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_eventService = eventService;
|
||||||
|
_appDataStorageService = appDataStorageService;
|
||||||
|
_appDataCenterService = appDataCenterService;
|
||||||
|
_eventService.OnDeviceActiveChanged += OnDeviceActiveChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDeviceActiveChanged(object? sender, DeviceActiveChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (_appDataStorageService.Devices.TryGetValue(e.DeviceId, out var device))
|
||||||
|
{
|
||||||
|
if (device.IsActive != e.NewStatus)
|
||||||
|
{
|
||||||
|
device.IsActive = e.NewStatus;
|
||||||
|
_appDataCenterService.DeviceManagementService.UpdateDeviceAsync(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_eventService.OnDeviceActiveChanged -= OnDeviceActiveChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ using DMS.WPF.Logging;
|
|||||||
using DMS.WPF.Services;
|
using DMS.WPF.Services;
|
||||||
using DMS.WPF.ViewModels;
|
using DMS.WPF.ViewModels;
|
||||||
using DMS.WPF.ViewModels.Dialogs;
|
using DMS.WPF.ViewModels.Dialogs;
|
||||||
|
using DMS.WPF.ViewModels.Items;
|
||||||
using DMS.WPF.Views;
|
using DMS.WPF.Views;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
@@ -44,14 +45,8 @@ public partial class App : System.Windows.Application
|
|||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
Host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder()
|
Host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder()
|
||||||
.ConfigureServices((context, services) =>
|
.ConfigureServices((context, services) => { ConfigureServices(services); })
|
||||||
{
|
.ConfigureLogging(loggingBuilder => { ConfigureLogging(loggingBuilder); })
|
||||||
ConfigureServices(services);
|
|
||||||
})
|
|
||||||
.ConfigureLogging(loggingBuilder =>
|
|
||||||
{
|
|
||||||
ConfigureLogging(loggingBuilder);
|
|
||||||
})
|
|
||||||
.Build();
|
.Build();
|
||||||
Services = Host.Services;
|
Services = Host.Services;
|
||||||
_logger = Host.Services.GetRequiredService<ILogger<App>>();
|
_logger = Host.Services.GetRequiredService<ILogger<App>>();
|
||||||
@@ -67,10 +62,8 @@ public partial class App : System.Windows.Application
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Host.Services.GetRequiredService<GrowlNotificationService>();
|
Host.Services.GetRequiredService<GrowlNotificationService>();
|
||||||
|
Host.Services.GetRequiredService<IDeviceMonitoringService>();
|
||||||
// 初始化设备监控服务
|
DeviceItemViewModel.EventService = Host.Services.GetRequiredService<IEventService>();
|
||||||
Host.Services.GetRequiredService<DeviceMonitoringService>();
|
|
||||||
|
|
||||||
// 初始化数据处理链
|
// 初始化数据处理链
|
||||||
var dataProcessingService = Host.Services.GetRequiredService<IDataProcessingService>();
|
var dataProcessingService = Host.Services.GetRequiredService<IDataProcessingService>();
|
||||||
dataProcessingService.AddProcessor(Host.Services.GetRequiredService<CheckValueChangedProcessor>());
|
dataProcessingService.AddProcessor(Host.Services.GetRequiredService<CheckValueChangedProcessor>());
|
||||||
@@ -161,7 +154,8 @@ public partial class App : System.Windows.Application
|
|||||||
{
|
{
|
||||||
// 最终解决方案:根据异常信息的建议,设置此标记以忽略重复的Profile加载。
|
// 最终解决方案:根据异常信息的建议,设置此标记以忽略重复的Profile加载。
|
||||||
// 注意:此属性位于 Internal() 方法下。
|
// 注意:此属性位于 Internal() 方法下。
|
||||||
cfg.Internal().AllowAdditiveTypeMapCreation = true;
|
cfg.Internal()
|
||||||
|
.AllowAdditiveTypeMapCreation = true;
|
||||||
|
|
||||||
cfg.AddProfile(new DMS.Application.Profiles.MappingProfile());
|
cfg.AddProfile(new DMS.Application.Profiles.MappingProfile());
|
||||||
cfg.AddProfile(new DMS.Infrastructure.Profiles.MappingProfile());
|
cfg.AddProfile(new DMS.Infrastructure.Profiles.MappingProfile());
|
||||||
@@ -183,7 +177,8 @@ public partial class App : System.Windows.Application
|
|||||||
|
|
||||||
|
|
||||||
services.AddSingleton<IDataProcessingService, DataProcessingService>();
|
services.AddSingleton<IDataProcessingService, DataProcessingService>();
|
||||||
services.AddHostedService(provider => (DataProcessingService)provider.GetRequiredService<IDataProcessingService>());
|
services.AddHostedService(provider =>
|
||||||
|
(DataProcessingService)provider.GetRequiredService<IDataProcessingService>());
|
||||||
services.AddSingleton<CheckValueChangedProcessor>();
|
services.AddSingleton<CheckValueChangedProcessor>();
|
||||||
services.AddSingleton<LoggingProcessor>();
|
services.AddSingleton<LoggingProcessor>();
|
||||||
services.AddSingleton<UpdateDbVariableProcessor>();
|
services.AddSingleton<UpdateDbVariableProcessor>();
|
||||||
@@ -235,6 +230,7 @@ public partial class App : System.Windows.Application
|
|||||||
|
|
||||||
services.AddSingleton<IDataLoaderService, DataLoaderService>();
|
services.AddSingleton<IDataLoaderService, DataLoaderService>();
|
||||||
services.AddSingleton<INlogAppService, NlogAppService>();
|
services.AddSingleton<INlogAppService, NlogAppService>();
|
||||||
|
services.AddSingleton<IDeviceMonitoringService, DeviceMonitoringService>();
|
||||||
|
|
||||||
// 注册MQTT服务管理器
|
// 注册MQTT服务管理器
|
||||||
services.AddSingleton<IMqttServiceManager, MqttServiceManager>();
|
services.AddSingleton<IMqttServiceManager, MqttServiceManager>();
|
||||||
@@ -245,10 +241,7 @@ public partial class App : System.Windows.Application
|
|||||||
services.AddSingleton<IMqttAppService, MqttAppService>();
|
services.AddSingleton<IMqttAppService, MqttAppService>();
|
||||||
|
|
||||||
// 注册事件服务
|
// 注册事件服务
|
||||||
services.AddSingleton<IEventService, EventService>();
|
services.AddSingleton<DMS.Application.Interfaces.IEventService, DMS.Application.Services.EventService>();
|
||||||
|
|
||||||
// 注册设备监控服务
|
|
||||||
services.AddSingleton<DeviceMonitoringService>();
|
|
||||||
|
|
||||||
// 注册新的数据服务
|
// 注册新的数据服务
|
||||||
services.AddSingleton<IDeviceDataService, DeviceDataService>();
|
services.AddSingleton<IDeviceDataService, DeviceDataService>();
|
||||||
@@ -261,30 +254,7 @@ public partial class App : System.Windows.Application
|
|||||||
services.AddSingleton<IDataStorageService, DataStorageService>();
|
services.AddSingleton<IDataStorageService, DataStorageService>();
|
||||||
|
|
||||||
// 注册主数据服务
|
// 注册主数据服务
|
||||||
services.AddSingleton<IWPFDataService>(provider =>
|
services.AddSingleton<IWPFDataService, WPFDataService>();
|
||||||
new WPFDataService(
|
|
||||||
provider.GetRequiredService<IMapper>(),
|
|
||||||
provider.GetRequiredService<IAppDataCenterService>(),
|
|
||||||
provider.GetRequiredService<IDeviceDataService>(),
|
|
||||||
provider.GetRequiredService<IVariableDataService>(),
|
|
||||||
provider.GetRequiredService<IMenuDataService>(),
|
|
||||||
provider.GetRequiredService<IMqttDataService>(),
|
|
||||||
provider.GetRequiredService<ILogDataService>(),
|
|
||||||
provider.GetRequiredService<IVariableTableDataService>(),
|
|
||||||
provider.GetRequiredService<IEventService>()
|
|
||||||
));
|
|
||||||
|
|
||||||
// 保留原DataServices以保证现有代码兼容性(可选,建议逐步移除)
|
|
||||||
// services.AddSingleton<DataServices>(provider =>
|
|
||||||
// new DataServices(
|
|
||||||
// provider.GetRequiredService<IMapper>(),
|
|
||||||
// provider.GetRequiredService<IAppDataCenterService>(),
|
|
||||||
// provider.GetRequiredService<IMqttAppService>()
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 注册视图模型
|
// 注册视图模型
|
||||||
@@ -332,7 +302,8 @@ public partial class App : System.Windows.Application
|
|||||||
|
|
||||||
private void ConfigureLogging(ILoggingBuilder loggingBuilder)
|
private void ConfigureLogging(ILoggingBuilder loggingBuilder)
|
||||||
{
|
{
|
||||||
LogManager.Setup().LoadConfigurationFromFile("Configurations/nlog.config");
|
LogManager.Setup()
|
||||||
|
.LoadConfigurationFromFile("Configurations/nlog.config");
|
||||||
loggingBuilder.ClearProviders();
|
loggingBuilder.ClearProviders();
|
||||||
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
|
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
|
||||||
// loggingBuilder.addn; // 添加NLog作为日志提供者
|
// loggingBuilder.addn; // 添加NLog作为日志提供者
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using DMS.WPF.Interfaces;
|
using DMS.Application.Interfaces;
|
||||||
|
|
||||||
namespace DMS.WPF.Interfaces;
|
namespace DMS.WPF.Interfaces;
|
||||||
|
|
||||||
@@ -36,9 +36,4 @@ public interface IWPFDataService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
ILogDataService LogDataService { get; }
|
ILogDataService LogDataService { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 事件服务。
|
|
||||||
/// </summary>
|
|
||||||
IEventService EventService { get; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
using System;
|
|
||||||
using DMS.WPF.Events;
|
|
||||||
using DMS.WPF.Interfaces;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace DMS.WPF.Services;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设备监控服务,用于监听设备状态改变事件并进行相应处理
|
|
||||||
/// </summary>
|
|
||||||
public class DeviceMonitoringService
|
|
||||||
{
|
|
||||||
private readonly ILogger<DeviceMonitoringService> _logger;
|
|
||||||
private readonly IEventService _eventService;
|
|
||||||
private readonly INotificationService _notificationService;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化DeviceMonitoringService类的新实例
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="logger">日志服务</param>
|
|
||||||
/// <param name="eventService">事件服务</param>
|
|
||||||
/// <param name="notificationService">通知服务</param>
|
|
||||||
public DeviceMonitoringService(
|
|
||||||
ILogger<DeviceMonitoringService> logger,
|
|
||||||
IEventService eventService,
|
|
||||||
INotificationService notificationService)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_eventService = eventService;
|
|
||||||
_notificationService = notificationService;
|
|
||||||
|
|
||||||
// 订阅设备状态改变事件
|
|
||||||
_eventService.DeviceStatusChanged += OnDeviceStatusChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 处理设备状态改变事件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender">事件发送者</param>
|
|
||||||
/// <param name="e">设备状态改变事件参数</param>
|
|
||||||
private void OnDeviceStatusChanged(object sender, DeviceActiveChangedEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// 记录设备状态改变日志
|
|
||||||
_logger.LogInformation($"设备 {e.DeviceName}(ID: {e.DeviceId}) 状态改变: {e.OldStatus} -> {e.NewStatus}");
|
|
||||||
|
|
||||||
// 根据设备状态改变发送通知
|
|
||||||
string message = e.NewStatus
|
|
||||||
? $"设备 {e.DeviceName} 已启动"
|
|
||||||
: $"设备 {e.DeviceName} 已停止";
|
|
||||||
|
|
||||||
_notificationService.ShowInfo(message);
|
|
||||||
|
|
||||||
// 在这里可以添加更多处理逻辑,例如:
|
|
||||||
// 1. 更新数据库中的设备状态历史记录
|
|
||||||
// 2. 发送邮件或短信通知
|
|
||||||
// 3. 触发其他相关操作
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, $"处理设备 {e.DeviceName} 状态改变事件时发生错误");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 释放资源
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
// 取消订阅事件
|
|
||||||
_eventService.DeviceStatusChanged -= OnDeviceStatusChanged;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -45,11 +45,6 @@ public class WPFDataService : IWPFDataService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ILogDataService LogDataService { get; }
|
public ILogDataService LogDataService { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 事件服务。
|
|
||||||
/// </summary>
|
|
||||||
public IEventService EventService { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WPFDataService 构造函数。
|
/// WPFDataService 构造函数。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -61,8 +56,7 @@ public class WPFDataService : IWPFDataService
|
|||||||
IMenuDataService menuDataService,
|
IMenuDataService menuDataService,
|
||||||
IMqttDataService mqttDataService,
|
IMqttDataService mqttDataService,
|
||||||
ILogDataService logDataService,
|
ILogDataService logDataService,
|
||||||
IVariableTableDataService variableTableDataService,
|
IVariableTableDataService variableTableDataService)
|
||||||
IEventService eventService)
|
|
||||||
{
|
{
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_appDataCenterService = appDataCenterService;
|
_appDataCenterService = appDataCenterService;
|
||||||
@@ -72,6 +66,5 @@ public class WPFDataService : IWPFDataService
|
|||||||
MqttDataService = mqttDataService;
|
MqttDataService = mqttDataService;
|
||||||
LogDataService = logDataService;
|
LogDataService = logDataService;
|
||||||
VariableTableDataService = variableTableDataService;
|
VariableTableDataService = variableTableDataService;
|
||||||
EventService = eventService;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,9 +64,6 @@ public partial class DevicesViewModel : ViewModelBase, INavigatable
|
|||||||
_deviceAppService = deviceAppService;
|
_deviceAppService = deviceAppService;
|
||||||
_notificationService = notificationService;
|
_notificationService = notificationService;
|
||||||
Devices = _dataStorageService.Devices;
|
Devices = _dataStorageService.Devices;
|
||||||
|
|
||||||
// 设置DeviceItemViewModel的静态服务引用
|
|
||||||
DeviceItemViewModel.EventService = wpfDataService.EventService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using DMS.Application.Events;
|
||||||
|
using DMS.Application.Interfaces;
|
||||||
using DMS.Core.Enums;
|
using DMS.Core.Enums;
|
||||||
using DMS.WPF.Events;
|
|
||||||
using DMS.WPF.Interfaces;
|
using DMS.WPF.Interfaces;
|
||||||
|
|
||||||
namespace DMS.WPF.ViewModels.Items;
|
namespace DMS.WPF.ViewModels.Items;
|
||||||
@@ -83,7 +84,7 @@ public partial class DeviceItemViewModel : ObservableObject
|
|||||||
partial void OnIsActiveChanged(bool oldValue, bool newValue)
|
partial void OnIsActiveChanged(bool oldValue, bool newValue)
|
||||||
{
|
{
|
||||||
// 只有当设备ID有效且事件服务已初始化时才发布事件
|
// 只有当设备ID有效且事件服务已初始化时才发布事件
|
||||||
if (Id > 0 && EventService != null)
|
if (Id > 0 && EventService != null )
|
||||||
{
|
{
|
||||||
// 发布设备状态改变事件
|
// 发布设备状态改变事件
|
||||||
EventService.RaiseDeviceStatusChanged(this, new DeviceActiveChangedEventArgs(Id, Name, oldValue, newValue));
|
EventService.RaiseDeviceStatusChanged(this, new DeviceActiveChangedEventArgs(Id, Name, oldValue, newValue));
|
||||||
|
|||||||
Reference in New Issue
Block a user