重构:修改 VariableValueChangedEventArgs 以包含 VariableDto 对象

- 修改 VariableValueChangedEventArgs 类:
     - 移除了 VariableId、VariableName、NewValue 和 UpdateTime 属性
     - 添加了 Variable(VariableDto 类型)和 OldValue 属性
     - 更新了构造函数以接收 VariableDto 对象和旧值

   - 更新事件触发代码:
     - 修改了 UpdateViewProcessor.cs 中的事件触发代码,改为传递 VariableDto 对象和旧值

   - 更新事件处理代码:
     - 修改了 DataEventService.cs 中的事件处理逻辑,改为访问 e.Variable 属性
     - 修改了 VariableHistoryViewModel.cs 中的事件处理逻辑,改为使用 e.Variable 属性
This commit is contained in:
2025-10-02 18:47:45 +08:00
parent e5e2e8de5b
commit 3958275367
8 changed files with 43 additions and 177 deletions

View File

@@ -3,6 +3,7 @@ using AutoMapper;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using DMS.Application.DTOs;
using DMS.Application.Events;
using DMS.Application.Interfaces;
using DMS.Application.Interfaces.Database;
using DMS.Core.Events;
@@ -107,7 +108,7 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable
private void OnVariableValueChanged(object? sender, VariableValueChangedEventArgs e)
{
if (e.VariableId != CurrentVariable.Id)
if (e.Variable.Id != CurrentVariable.Id)
{
return;
}
@@ -116,7 +117,7 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable
{
VariableId = CurrentVariable.Id,
Timestamp = DateTime.Now,
Value = e.NewValue
Value = e.Variable.DataValue
};
_variableHistoryList.Add(variableHistory);