完成的变更:
1. 向 VariableTableManagementService 添加了 IEventService 依赖
2. 将内存操作和事件触发逻辑合并到数据库操作方法中:
- CreateVariableTableAsync 现在会在数据库创建后自动添加到内存并触发事件
- UpdateVariableTableAsync 现在会在数据库更新后自动更新内存并触发事件
- DeleteVariableTableAsync 现在会在数据库删除后自动从内存移除并触发事件
3. 从类中删除了独立的内存操作方法
4. 从接口中移除了内存操作方法
5. 更新了所有调用这些服务的代码,使它们不再调用已删除的内存方法
6. 扩展了 IEventService 以支持 VariableTableChanged 事件
This commit is contained in:
52
DMS.Application/Events/DeviceStateChangedEventArgs.cs
Normal file
52
DMS.Application/Events/DeviceStateChangedEventArgs.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using DMS.Core.Enums;
|
||||
|
||||
namespace DMS.Application.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备状态改变事件参数
|
||||
/// 统一处理设备激活状态和连接状态的变更
|
||||
/// </summary>
|
||||
public class DeviceStateChangedEventArgs : System.EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备ID
|
||||
/// </summary>
|
||||
public int DeviceId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
public string DeviceName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态值
|
||||
/// </summary>
|
||||
public bool StateValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态类型 (激活状态或连接状态)
|
||||
/// </summary>
|
||||
public DeviceStateType StateType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态改变时间
|
||||
/// </summary>
|
||||
public DateTime ChangeTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始化DeviceStateChangedEventArgs类的新实例
|
||||
/// </summary>
|
||||
/// <param name="deviceId">设备ID</param>
|
||||
/// <param name="deviceName">设备名称</param>
|
||||
/// <param name="stateValue">状态值</param>
|
||||
/// <param name="stateType">状态类型</param>
|
||||
public DeviceStateChangedEventArgs(int deviceId, string deviceName, bool stateValue, DeviceStateType stateType)
|
||||
{
|
||||
DeviceId = deviceId;
|
||||
DeviceName = deviceName ?? string.Empty;
|
||||
StateValue = stateValue;
|
||||
StateType = stateType;
|
||||
ChangeTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user