refactor:完成变量表的重构添加,删除,更新
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user