refactor:完成变量表的重构添加,删除,更新

This commit is contained in:
2025-10-23 16:25:22 +08:00
parent 54d040b45f
commit 125348486a
15 changed files with 329 additions and 419 deletions

View File

@@ -49,8 +49,6 @@ public class DeviceManagementService : IDeviceManagementService
public async Task<CreateDeviceWithDetailsDto> CreateDeviceWithDetailsAsync(CreateDeviceWithDetailsDto dto)
{
var result = await _deviceAppService.CreateDeviceWithDetailsAsync(dto);
// 创建成功后,将设备添加到内存中
@@ -71,29 +69,31 @@ public class DeviceManagementService : IDeviceManagementService
}
}
//关联菜单
if (result.DeviceMenu is not null)
{
var deviceRootMenu = _appDataService.Menus.Values.FirstOrDefault(m => m.TargetViewKey == "DevicesViewModel" && m.TargetId == 0);
if (deviceRootMenu is not null)
{
_appDataService.Menus.TryAdd(result.DeviceMenu.Id, result.DeviceMenu);
//将设备菜单添加到根菜单中
deviceRootMenu.Children.Add(result.DeviceMenu);
if (result.VariableTableMenu is not null)
{
_appDataService.Menus.TryAdd(result.VariableTableMenu.Id, result.VariableTableMenu);
//将变量表菜单添加到设备菜单中
result.DeviceMenu.Children.Add(result.VariableTableMenu);
}
}
}
_eventService.RaiseDeviceChanged(this, new DeviceChangedEventArgs(DataChangeType.Added, result.Device));
}
//关联菜单
if (result.DeviceMenu is not null)
{
var deviceRootMenu = _appDataService.Menus.Values.FirstOrDefault(m => m.TargetViewKey == "DevicesViewModel" && m.TargetId == 0);
if (deviceRootMenu is not null)
{
_appDataService.Menus.TryAdd(result.DeviceMenu.Id, result.DeviceMenu);
//将设备菜单添加到根菜单中
deviceRootMenu.Children.Add(result.DeviceMenu);
if (result.VariableTableMenu is not null)
{
_appDataService.Menus.TryAdd(result.VariableTableMenu.Id, result.VariableTableMenu);
//将变量表菜单添加到设备菜单中
result.DeviceMenu.Children.Add(result.VariableTableMenu);
}
}
}