This commit is contained in:
2025-10-20 19:39:17 +08:00
parent 01adc11be7
commit 7ad1b7d5e1
29 changed files with 113 additions and 140 deletions

View File

@@ -5,6 +5,7 @@ using DMS.Application.Interfaces.Database;
using DMS.Core.Enums;
using DMS.Core.Interfaces;
using DMS.Core.Models;
using System.ComponentModel;
namespace DMS.Application.Services.Database;
@@ -61,59 +62,38 @@ public class DeviceAppService : IDeviceAppService
{
await _repoManager.BeginTranAsync();
var addDevice = await _repoManager.Devices.AddAsync(dto.Device);
if (addDevice == null || addDevice.Id == 0)
{
throw new InvalidOperationException($"添加设备失败:{addDevice}");
}
dto.Device = await _repoManager.Devices.AddAsync(dto.Device);
_mapper.Map(addDevice,dto.Device);
MenuBean addDeviceMenu = null;
// 假设有设备菜单
if (dto.DeviceMenu != null)
if (dto.DeviceMenu is not null)
{
var deviceMenu = _mapper.Map<MenuBean>(dto.DeviceMenu);
deviceMenu.ParentId = 2; // 假设父菜单ID为2
deviceMenu.MenuType = MenuType.DeviceMenu;
deviceMenu.TargetId = addDevice.Id;
addDeviceMenu = await _repoManager.Menus.AddAsync(deviceMenu);
if (addDeviceMenu == null || addDeviceMenu.Id == 0)
{
throw new InvalidOperationException($"添加设备菜单失败:{addDeviceMenu}");
}
_mapper.Map(addDeviceMenu,dto.DeviceMenu);
dto.DeviceMenu = await _repoManager.Menus.AddAsync(dto.DeviceMenu);
}
// 假设 CreateDeviceWithDetailsDto 包含了变量表和菜单信息
if (dto.VariableTable != null)
if (dto.VariableTable is not null)
{
var variableTable = _mapper.Map<VariableTable>(dto.VariableTable);
variableTable.DeviceId = dto.Device.Id; // 关联新设备ID
variableTable.Protocol = dto.Device.Protocol;
var addVariableTable = await _repoManager.VariableTables.AddAsync(variableTable);
if (addVariableTable == null || addVariableTable.Id == 0)
dto.VariableTable.DeviceId = dto.Device.Id; // 关联新设备ID
dto.VariableTable.Protocol = dto.Device.Protocol;
dto.VariableTable = await _repoManager.VariableTables.AddAsync(dto.VariableTable);
if (dto.VariableTable == null || dto.VariableTable.Id == 0)
{
throw new InvalidOperationException($"添加设备变量表失败,设备:{dto.Device.Name},变量表:{variableTable.Name}");
throw new InvalidOperationException($"添加设备变量表失败,设备:{dto.Device.Name},变量表:{dto?.VariableTable?.Name}");
}
_mapper.Map(addVariableTable,dto.VariableTable);
dto.VariableTable.Device = dto.Device;
// 假设有设备菜单
if (dto.VariableTableMenu != null)
if (dto.VariableTableMenu is not null && dto.VariableTableMenu is not null)
{
var menu = _mapper.Map<MenuBean>(dto.VariableTableMenu);
menu.ParentId = addDeviceMenu.Id; // 关联设备菜单作为父级
menu.MenuType = MenuType.VariableTableMenu;
menu.TargetId = addVariableTable.Id;
var addVariableTableMenu = await _repoManager.Menus.AddAsync(menu);
if (addVariableTableMenu == null || addVariableTableMenu.Id == 0)
dto.VariableTableMenu.ParentId = dto.DeviceMenu.Id; // 关联设备菜单作为父级
dto.VariableTableMenu.TargetId = dto.VariableTable.Id;
dto.VariableTableMenu = await _repoManager.Menus.AddAsync(dto.VariableTableMenu);
if (dto.VariableTableMenu == null || dto.VariableTableMenu.Id == 0)
{
throw new InvalidOperationException(
$"添加设备变量表菜单失败,变量表:{variableTable.Name},变量表菜单:{menu.Header}");
$"添加设备变量表菜单失败,变量表:{dto.VariableTable.Name},变量表菜单:{dto.VariableTableMenu.Header}");
}
_mapper.Map(menu,dto.VariableTableMenu);
}
}

View File

@@ -302,16 +302,16 @@ public partial class App : System.Windows.Application
services.AddSingleton<DMS.Application.Interfaces.IEventService, DMS.Application.Services.EventService>();
// 注册新的数据服务
services.AddSingleton<IDeviceDataService, DeviceDataService>();
services.AddSingleton<IDeviceDataService, DeviceWpfService>();
services.AddSingleton<IVariableDataService, VariableDataService>();
services.AddSingleton<IVariableTableDataService, VariableTableDataService>();
services.AddSingleton<IMenuDataService, MenuDataService>();
services.AddSingleton<IMenuWpfService, MenuWpfService>();
services.AddSingleton<IMqttDataService, MqttDataService>();
services.AddSingleton<IMqttAliasDataService, MqttAliasDataService>();
services.AddSingleton<ILogDataService, LogDataService>();
services.AddSingleton<ITriggerDataService, TriggerDataService>(); // 注册触发器数据服务
services.AddSingleton<IDataEventService, DataEventService>();
services.AddSingleton<IDataStorageService, DataStorageService>();
services.AddSingleton<IWpfDataService, WpfDataService>();
services.AddSingleton<IEmailDataService, EmailDataService>();
// 注册主数据服务

View File

@@ -33,4 +33,5 @@ public interface IDeviceDataService
/// 更新设备。
/// </summary>
Task<bool> UpdateDevice(DeviceItem device);
Task<CreateDeviceWithDetailsDto?> AddDevice(CreateDeviceWithDetailsDto dto);
}

View File

@@ -6,14 +6,14 @@ namespace DMS.WPF.Interfaces;
/// <summary>
/// 菜单数据服务接口。
/// </summary>
public interface IMenuDataService
public interface IMenuWpfService
{
/// <summary>
/// 添加菜单项。
/// </summary>
Task AddMenuItem(MenuItem MenuItem);
void AddMenuToView(MenuItem MenuItem);
/// <summary>
/// 删除菜单项。

View File

@@ -24,7 +24,7 @@ public interface IWPFDataService
/// <summary>
/// 菜单数据服务。
/// </summary>
IMenuDataService MenuDataService { get; }
IMenuWpfService MenuDataService { get; }
/// <summary>
/// MQTT数据服务。

View File

@@ -5,7 +5,7 @@ using ObservableCollections;
namespace DMS.WPF.Interfaces;
public interface IDataStorageService
public interface IWpfDataService
{
/// <summary>
/// 设备列表。

View File

@@ -21,7 +21,7 @@ namespace DMS.WPF.Services;
public class DataEventService : IDataEventService
{
private readonly IMapper _mapper;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IEventService _eventService;
private readonly INotificationService _notificationService;
private readonly IAppCenterService _appCenterService;
@@ -32,7 +32,7 @@ public class DataEventService : IDataEventService
/// DataEventService类的构造函数。
/// </summary>
public DataEventService(IMapper mapper,
IDataStorageService dataStorageService,
IWpfDataService dataStorageService,
IEventService eventService,
INotificationService notificationService,
IAppCenterService appCenterService,

View File

@@ -15,16 +15,16 @@ namespace DMS.WPF.Services;
/// <summary>
/// 设备数据服务类,负责管理设备相关的数据和操作。
/// </summary>
public class DeviceDataService : IDeviceDataService
public class DeviceWpfService : IDeviceDataService
{
private readonly IMapper _mapper;
private readonly IAppCenterService _appCenterService;
private readonly IAppStorageService _appStorageService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IVariableTableDataService _variableTableDataService;
private readonly IEventService _eventService;
private readonly INotificationService _notificationService;
private readonly IMenuDataService _menuDataService;
private readonly IMenuWpfService _menuDataService;
private readonly IVariableDataService _variableDataService;
private readonly Dispatcher _uiDispatcher;
@@ -33,11 +33,12 @@ public class DeviceDataService : IDeviceDataService
/// </summary>
/// <param name="mapper">AutoMapper 实例。</param>
/// <param name="appCenterService">数据服务中心实例。</param>
public DeviceDataService(IMapper mapper, IAppCenterService appCenterService,
IAppStorageService appStorageService, IDataStorageService dataStorageService,IVariableTableDataService variableTableDataService,
public DeviceWpfService(IMapper mapper, IAppCenterService appCenterService,
IAppStorageService appStorageService, IWpfDataService dataStorageService, IVariableTableDataService variableTableDataService,
IEventService eventService, INotificationService notificationService,
IMenuDataService menuDataService, IVariableDataService variableDataService)
IMenuWpfService menuDataService, IVariableDataService variableDataService)
{
_mapper = mapper;
_appCenterService = appCenterService;
_appStorageService = appStorageService;
@@ -91,19 +92,15 @@ public class DeviceDataService : IDeviceDataService
/// <summary>
/// 添加设备。
/// </summary>
public async Task<CreateDeviceWithDetailsDto> AddDevice(CreateDeviceWithDetailsDto dto)
public async Task<CreateDeviceWithDetailsDto?> AddDevice(CreateDeviceWithDetailsDto dto)
{
// 添加null检查
if (dto == null)
return null;
if (dto is null) return null;
var addDto = await _appCenterService.DeviceManagementService.CreateDeviceWithDetailsAsync(dto);
// 添加null检查
if (addDto == null && addDto.Device == null)
{
return null;
}
if (addDto is null) return null;
//给界面添加设备
_dataStorageService.Devices.Add(addDto.Device.Id, _mapper.Map<DeviceItem>(addDto.Device));
@@ -111,7 +108,7 @@ public class DeviceDataService : IDeviceDataService
// 给界面添加设备菜单
if (addDto.DeviceMenu != null)
{
await _menuDataService.AddMenuItem(_mapper.Map<MenuItem>(addDto.DeviceMenu));
_menuDataService.AddMenuToView(_mapper.Map<MenuItem>(addDto.DeviceMenu));
}
@@ -124,7 +121,7 @@ public class DeviceDataService : IDeviceDataService
if (addDto.VariableTable != null && addDto.VariableTableMenu != null)
{
await _menuDataService.AddMenuItem(_mapper.Map<MenuItem>(addDto.VariableTableMenu));
_menuDataService.AddMenuToView(_mapper.Map<MenuItem>(addDto.VariableTableMenu));
}
@@ -152,13 +149,13 @@ public class DeviceDataService : IDeviceDataService
var variableTablesCopy = device.VariableTables.ToList();
foreach (var variableTable in variableTablesCopy)
{
await _variableTableDataService.DeleteVariableTable(variableTable);
await _variableTableDataService.DeleteVariableTable(variableTable);
}
var deviceMenu= _dataStorageService.Menus.FirstOrDefault(m => m.MenuType == MenuType.DeviceMenu && m.TargetId == device.Id);
var deviceMenu = _dataStorageService.Menus.FirstOrDefault(m => m.MenuType == MenuType.DeviceMenu && m.TargetId == device.Id);
if (deviceMenu != null)
{
await _menuDataService.DeleteMenuItem(deviceMenu);
await _menuDataService.DeleteMenuItem(deviceMenu);
}
_dataStorageService.Devices.Remove(device.Id);

View File

@@ -16,7 +16,7 @@ namespace DMS.WPF.Services;
public class LogDataService : ILogDataService
{
private readonly IMapper _mapper;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IAppStorageService _appStorageService;
@@ -26,7 +26,7 @@ public class LogDataService : ILogDataService
/// </summary>
/// <param name="mapper">AutoMapper 实例。</param>
/// <param name="appStorageService">数据服务中心实例。</param>
public LogDataService(IMapper mapper,IDataStorageService dataStorageService, IAppStorageService appStorageService)
public LogDataService(IMapper mapper,IWpfDataService dataStorageService, IAppStorageService appStorageService)
{
_mapper = mapper;
_dataStorageService = dataStorageService;

View File

@@ -13,10 +13,10 @@ namespace DMS.WPF.Services;
/// <summary>
/// 菜单数据服务类,负责管理菜单相关的数据和操作。
/// </summary>
public class MenuDataService : IMenuDataService
public class MenuWpfService : IMenuWpfService
{
private readonly IMapper _mapper;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _wpfDataService;
private readonly IAppStorageService _appStorageService;
private readonly IMenuManagementService _menuManagementService;
@@ -27,17 +27,17 @@ public class MenuDataService : IMenuDataService
/// </summary>
/// <param name="mapper">AutoMapper 实例。</param>
/// <param name="appStorageService">数据服务中心实例。</param>
public MenuDataService(IMapper mapper, IDataStorageService dataStorageService, IAppStorageService appStorageService, IMenuManagementService menuManagementService)
public MenuWpfService(IMapper mapper, IWpfDataService dataStorageService, IAppStorageService appStorageService, IMenuManagementService menuManagementService)
{
_mapper = mapper;
_dataStorageService = dataStorageService;
_wpfDataService = dataStorageService;
_appStorageService = appStorageService;
_menuManagementService = menuManagementService;
}
public void LoadAllMenus()
{
_dataStorageService.Menus = _mapper.Map<ObservableCollection<MenuItem>>(_appStorageService.Menus.Values);
_wpfDataService.Menus = _mapper.Map<ObservableCollection<MenuItem>>(_appStorageService.Menus.Values);
BuildMenuTrees();
}
@@ -46,11 +46,11 @@ public class MenuDataService : IMenuDataService
/// </summary>
public void BuildMenuTrees()
{
_dataStorageService.MenuTrees.Clear();
_wpfDataService.MenuTrees.Clear();
// 遍历所有菜单项,构建树形结构
foreach (var menu in _dataStorageService.Menus)
foreach (var menu in _wpfDataService.Menus)
{
var parentMenu = _dataStorageService.Menus.FirstOrDefault(m => m.Id == menu.ParentId);
var parentMenu = _wpfDataService.Menus.FirstOrDefault(m => m.Id == menu.ParentId);
// 检查是否有父ID并且父ID不为0通常0或null表示根节点
if (parentMenu != null && menu.ParentId != 0)
{
@@ -63,7 +63,7 @@ public class MenuDataService : IMenuDataService
else
{
// 如果没有父ID则这是一个根菜单
_dataStorageService.MenuTrees.Add(menu);
_wpfDataService.MenuTrees.Add(menu);
}
}
}
@@ -71,22 +71,17 @@ public class MenuDataService : IMenuDataService
/// <summary>
/// 添加菜单项。
/// </summary>
public async Task AddMenuItem(MenuItem MenuItem)
public void AddMenuToView(MenuItem MenuItem)
{
if (MenuItem is null) return;
var deviceMenu = _dataStorageService.Menus.FirstOrDefault(m => m.Id == MenuItem.ParentId);
var deviceMenu = _wpfDataService.Menus.FirstOrDefault(m => m.Id == MenuItem.ParentId);
if (deviceMenu is not null)
{
var menuId = await _menuManagementService.CreateMenuAsync(_mapper.Map<MenuBean>(MenuItem));
if (menuId > 0)
{
MenuItem.Id = menuId;
deviceMenu.Children.Add(MenuItem);
_dataStorageService.Menus.Add(MenuItem);
BuildMenuTrees();
}
deviceMenu.Children.Add(MenuItem);
_wpfDataService.Menus.Add(MenuItem);
BuildMenuTrees();
}
}
@@ -98,7 +93,7 @@ public class MenuDataService : IMenuDataService
{
if (MenuItem is null) return;
var menu = _dataStorageService.Menus.FirstOrDefault(m => m.Id == MenuItem.Id);
var menu = _wpfDataService.Menus.FirstOrDefault(m => m.Id == MenuItem.Id);
if (menu is not null)
{
@@ -122,19 +117,19 @@ public class MenuDataService : IMenuDataService
await _menuManagementService.DeleteMenuAsync(MenuItem.Id);
// 从扁平菜单列表中移除
_dataStorageService.Menus.Remove(MenuItem);
_wpfDataService.Menus.Remove(MenuItem);
//// 从树形结构中移除
if (MenuItem.ParentId.HasValue && MenuItem.ParentId.Value != 0)
{
// 如果有父菜单从父菜单的Children中移除
var parentMenu = _dataStorageService.Menus.FirstOrDefault(m => m.Id == MenuItem.ParentId.Value);
var parentMenu = _wpfDataService.Menus.FirstOrDefault(m => m.Id == MenuItem.ParentId.Value);
parentMenu?.Children.Remove(MenuItem);
}
else
{
// 如果是根菜单从MenuTrees中移除
_dataStorageService.MenuTrees.Remove(MenuItem);
_wpfDataService.MenuTrees.Remove(MenuItem);
}
//BuildMenuTrees();

View File

@@ -15,7 +15,7 @@ public class MqttAliasDataService : IMqttAliasDataService
private readonly IMapper _mapper;
private readonly IAppStorageService _appStorageService;
private readonly IMqttAliasManagementService _mqttAliasManagementService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
/// <summary>
/// MqttAliasDataService类的构造函数。
@@ -27,7 +27,7 @@ public class MqttAliasDataService : IMqttAliasDataService
public MqttAliasDataService(IMapper mapper,
IAppStorageService appStorageService,
IMqttAliasManagementService mqttAliasManagementService,
IDataStorageService dataStorageService)
IWpfDataService dataStorageService)
{
_mapper = mapper;
_appStorageService = appStorageService;

View File

@@ -19,9 +19,9 @@ public class MqttDataService : IMqttDataService
private readonly IMapper _mapper;
private readonly IAppStorageService _appStorageService;
private readonly IMqttManagementService _mqttManagementService;
private readonly IMenuDataService _menuDataService;
private readonly IMenuWpfService _menuDataService;
private readonly IMenuManagementService _menuManagementServiceImpl;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
/// <summary>
@@ -29,7 +29,7 @@ public class MqttDataService : IMqttDataService
/// </summary>
/// <param name="mapper">AutoMapper 实例。</param>
/// <param name="mqttAppService">MQTT应用服务实例。</param>
public MqttDataService(IMapper mapper, IAppStorageService appStorageService, IMqttManagementService mqttManagementService, IMenuDataService menuDataService, IMenuManagementService menuManagementServiceImpl, IDataStorageService dataStorageService)
public MqttDataService(IMapper mapper, IAppStorageService appStorageService, IMqttManagementService mqttManagementService, IMenuWpfService menuDataService, IMenuManagementService menuManagementServiceImpl, IWpfDataService dataStorageService)
{
_mapper = mapper;
_appStorageService = appStorageService;
@@ -87,7 +87,7 @@ public class MqttDataService : IMqttDataService
MenuType = MenuType.MqttServerMenu,
TargetViewKey = nameof(MqttServerDetailViewModel),
};
await _menuDataService.AddMenuItem(_mapper.Map<MenuItem>(mqttServerMenu));
await _menuDataService.AddMenuToView(_mapper.Map<MenuItem>(mqttServerMenu));
}
return mqttServerItem;

View File

@@ -24,9 +24,9 @@ public class TriggerDataService : ITriggerDataService
{
private readonly IMapper _mapper;
private readonly IAppCenterService _appCenterService;
private readonly IMenuDataService _menuDataService;
private readonly IMenuWpfService _menuDataService;
private readonly IAppStorageService _appStorageService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IEventService _eventService;
private readonly INotificationService _notificationService;
private readonly Dispatcher _uiDispatcher;
@@ -41,8 +41,8 @@ public class TriggerDataService : ITriggerDataService
/// <param name="eventService">事件服务实例。</param>
/// <param name="notificationService">通知服务实例。</param>
public TriggerDataService(IMapper mapper, IAppCenterService appCenterService,
IMenuDataService menuDataService,
IAppStorageService appStorageService, IDataStorageService dataStorageService,
IMenuWpfService menuDataService,
IAppStorageService appStorageService, IWpfDataService dataStorageService,
IEventService eventService, INotificationService notificationService)
{
_mapper = mapper;
@@ -111,7 +111,7 @@ public class TriggerDataService : ITriggerDataService
Icon = "\uE945", // 使用触发器图标
TargetViewKey = nameof(TriggerDetailViewModel),
};
await _menuDataService.AddMenuItem(menuItem);
await _menuDataService.AddMenuToView(menuItem);
}

View File

@@ -16,7 +16,7 @@ namespace DMS.WPF.Services;
public class VariableDataService : IVariableDataService
{
private readonly IMapper _mapper;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IAppCenterService _appCenterService;
@@ -26,7 +26,7 @@ public class VariableDataService : IVariableDataService
/// </summary>
/// <param name="mapper">AutoMapper 实例。</param>
/// <param name="appCenterService">数据服务中心实例。</param>
public VariableDataService(IMapper mapper, IDataStorageService dataStorageService, IAppCenterService appCenterService)
public VariableDataService(IMapper mapper, IWpfDataService dataStorageService, IAppCenterService appCenterService)
{
_mapper = mapper;
_dataStorageService = dataStorageService;

View File

@@ -12,14 +12,14 @@ namespace DMS.WPF.Services;
public class VariableTableDataService : IVariableTableDataService
{
private readonly IMapper _mapper;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IAppCenterService _appCenterService;
private readonly IMenuDataService _menuDataService;
private readonly IMenuWpfService _menuDataService;
public VariableTableDataService(IMapper mapper, IDataStorageService dataStorageService, IAppCenterService appCenterService,
IMenuDataService menuDataService)
public VariableTableDataService(IMapper mapper, IWpfDataService dataStorageService, IAppCenterService appCenterService,
IMenuWpfService menuDataService)
{
_mapper = mapper;
_dataStorageService = dataStorageService;
@@ -53,7 +53,7 @@ public class VariableTableDataService : IVariableTableDataService
createDto.Menu = menuDto;
var resDto = await _appCenterService.VariableTableManagementService.CreateVariableTableAsync(createDto);
await _menuDataService.AddMenuItem(_mapper.Map<MenuItem>(resDto.Menu));
await _menuDataService.AddMenuToView(_mapper.Map<MenuItem>(resDto.Menu));
return resDto.VariableTable.Id;
}

View File

@@ -32,7 +32,7 @@ public class WPFDataService : IWPFDataService
/// <summary>
/// 菜单数据服务。
/// </summary>
public IMenuDataService MenuDataService { get; }
public IMenuWpfService MenuDataService { get; }
/// <summary>
/// MQTT数据服务。
@@ -62,7 +62,7 @@ public class WPFDataService : IWPFDataService
IAppCenterService appCenterService,
IDeviceDataService deviceDataService,
IVariableDataService variableDataService,
IMenuDataService menuDataService,
IMenuWpfService menuDataService,
IMqttDataService mqttDataService,
ILogDataService logDataService,
IVariableTableDataService variableTableDataService,

View File

@@ -6,7 +6,7 @@ using ObservableCollections;
namespace DMS.WPF.Services;
public class DataStorageService : IDataStorageService
public class WpfDataService : IWpfDataService
{
@@ -56,7 +56,7 @@ public class DataStorageService : IDataStorageService
/// </summary>
public ObservableDictionary<int, TriggerItem> Triggers { get; set; }
public DataStorageService()
public WpfDataService()
{
Devices=new ObservableDictionary<int,DeviceItem>();
VariableTables = new ObservableDictionary<int,VariableTableItem>();

View File

@@ -20,7 +20,7 @@ public partial class DeviceDetailViewModel : ViewModelBase
{
private readonly IMapper _mapper;
private readonly IDialogService _dialogService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly INavigationService _navigationService;
private readonly IWPFDataService _wpfDataService;
@@ -36,7 +36,7 @@ public partial class DeviceDetailViewModel : ViewModelBase
private readonly INotificationService _notificationService;
public DeviceDetailViewModel(IMapper mapper, IDialogService dialogService, IDataStorageService dataStorageService,
public DeviceDetailViewModel(IMapper mapper, IDialogService dialogService, IWpfDataService dataStorageService,
INavigationService navigationService,
IWPFDataService wpfDataService, INotificationService notificationService)
{
@@ -207,7 +207,7 @@ public partial class DeviceDetailViewModel : ViewModelBase
public void NavigateToVariableTable()
{
if (SelectedVariableTable == null) return;
// var menu = _dataStorageService.Menus.FirstOrDefault(m => m.MenuType == MenuType.VariableTableMenu &&
// var menu = _wpfDataService.Menus.FirstOrDefault(m => m.MenuType == MenuType.VariableTableMenu &&
// m.TargetId == SelectedVariableTable.Id);
// if (menu == null) return;
_navigationService.NavigateToAsync(

View File

@@ -24,7 +24,7 @@ public partial class DevicesViewModel : ViewModelBase, INavigatable
private readonly IWPFDataService _wpfDataService;
private readonly IDeviceAppService _deviceAppService;
private readonly IMapper _mapper;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IDialogService _dialogService;
private readonly INavigationService _navigationService;
@@ -54,7 +54,7 @@ public partial class DevicesViewModel : ViewModelBase, INavigatable
/// <param name="wpfDataService">主数据服务。</param>
/// <param name="deviceAppService">设备应用服务。</param>
/// <param name="notificationService">通知服务。</param>
public DevicesViewModel(IMapper mapper, IDataStorageService dataStorageService,
public DevicesViewModel(IMapper mapper, IWpfDataService dataStorageService,
IDialogService dialogService, INavigationService navigationService,
IWPFDataService wpfDataService, IDeviceAppService deviceAppService,
INotificationService notificationService)

View File

@@ -21,7 +21,7 @@ namespace DMS.WPF.ViewModels.Dialogs
{
private readonly IDialogService _dialogService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly INotificationService _notificationService;
[ObservableProperty]
@@ -39,7 +39,7 @@ namespace DMS.WPF.ViewModels.Dialogs
public TriggerDialogViewModel(
IDialogService dialogService,
IDataStorageService dataStorageService,
IWpfDataService dataStorageService,
INotificationService notificationService)
{
_dialogService = dialogService ?? throw new ArgumentNullException(nameof(dialogService));

View File

@@ -26,11 +26,11 @@ public partial class VariableDialogViewModel : DialogViewModelBase<VariableItem>
private bool _hasError;
private readonly IWPFDataService _wpfDataService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IVariableAppService _variableAppService;
private readonly IMapper _mapper;
public VariableDialogViewModel(IWPFDataService wpfDataService,IDataStorageService dataStorageService, IVariableAppService variableAppService, IMapper mapper)
public VariableDialogViewModel(IWPFDataService wpfDataService,IWpfDataService dataStorageService, IVariableAppService variableAppService, IMapper mapper)
{
Variable = new VariableItem();

View File

@@ -28,7 +28,7 @@ partial class LogHistoryViewModel : ViewModelBase,IDisposable
private readonly IMapper _mapper;
private readonly INlogAppService _nlogAppService;
private readonly IDialogService _dialogService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly INotificationService _notificationService;
private readonly IAppCenterService _appCenterService;
@@ -50,7 +50,7 @@ partial class LogHistoryViewModel : ViewModelBase,IDisposable
public ObservableCollection<string> LogLevels { get; } = new ObservableCollection<string> { "Trace", "Debug", "Info", "Warn", "Error", "Fatal" };
public LogHistoryViewModel(IMapper mapper, INlogAppService nlogAppService, IDialogService dialogService, IDataStorageService dataStorageService
public LogHistoryViewModel(IMapper mapper, INlogAppService nlogAppService, IDialogService dialogService, IWpfDataService dataStorageService
, INotificationService notificationService, IWPFDataService wpfDataService, IAppCenterService appCenterService)
{
_mapper = mapper;

View File

@@ -22,7 +22,7 @@ public partial class MainViewModel : ViewModelBase
{
private readonly IDialogService _dialogService;
private readonly IWPFDataService _wpfDataService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly INavigationService _navigationService;
private readonly ILogger<MainViewModel> _logger;
@@ -46,7 +46,7 @@ public partial class MainViewModel : ViewModelBase
/// <param name="dialogService">对话框服务。</param>
/// <param name="logger">日志记录器。</param>
/// <param name="wpfDataService"></param>
public MainViewModel(IWPFDataService wpfDataService ,IDataStorageService dataStorageService,INavigationService navigationService,
public MainViewModel(IWPFDataService wpfDataService ,IWpfDataService dataStorageService,INavigationService navigationService,
ILogger<MainViewModel> logger)
{
_wpfDataService = wpfDataService;

View File

@@ -26,7 +26,7 @@ namespace DMS.WPF.ViewModels
private readonly IMqttManagementService _mqttManagementService;
private readonly IMqttAliasDataService _mqttAliasDataService;
private readonly IWPFDataService _wpfDataService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly INavigationService _navigationService;
/// <summary>
@@ -61,7 +61,7 @@ namespace DMS.WPF.ViewModels
IMqttManagementService mqttManagementService,
IMqttAliasDataService mqttAliasDataService,
IWPFDataService wpfDataService,
IDataStorageService dataStorageService,
IWpfDataService dataStorageService,
INavigationService navigationService)
{
_logger = logger;

View File

@@ -23,7 +23,7 @@ public partial class MqttsViewModel : ViewModelBase
{
private readonly IWPFDataService _wpfDataService;
private readonly IMqttAppService _mqttAppService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IMapper _mapper;
private readonly IDialogService _dialogService;
private readonly INavigationService _navigationService;
@@ -49,7 +49,7 @@ public partial class MqttsViewModel : ViewModelBase
IDialogService dialogService,
IWPFDataService wpfDataService,
IMqttAppService mqttAppService,
IDataStorageService dataStorageService,
IWpfDataService dataStorageService,
IMapper mapper,
INavigationService navigationService,
INotificationService notificationService

View File

@@ -24,7 +24,7 @@ namespace DMS.WPF.ViewModels
private readonly INotificationService _notificationService;
private readonly ITriggerManagementService _triggerManagementService;
private readonly ITriggerDataService _triggerDataService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly INavigationService _navigationService;
/// <summary>
@@ -52,7 +52,7 @@ namespace DMS.WPF.ViewModels
INotificationService notificationService,
ITriggerManagementService triggerManagementService,
ITriggerDataService triggerDataService,
IDataStorageService dataStorageService,
IWpfDataService dataStorageService,
INavigationService navigationService)
{
_logger = logger;

View File

@@ -21,7 +21,7 @@ namespace DMS.WPF.ViewModels
{
private readonly IMapper _mapper;
private readonly ITriggerDataService _triggerDataService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IDialogService _dialogService;
private readonly INotificationService _notificationService;
private readonly INavigationService _navigationService;
@@ -38,7 +38,7 @@ namespace DMS.WPF.ViewModels
public TriggersViewModel(
IMapper mapper,
ITriggerDataService triggerDataService,
IDataStorageService dataStorageService,
IWpfDataService dataStorageService,
IDialogService dialogService,
INotificationService notificationService,
INavigationService navigationService)

View File

@@ -27,7 +27,7 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable
private readonly IDialogService _dialogService;
private readonly IHistoryAppService _historyAppService;
private readonly IWPFDataService _wpfDataService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly IEventService _eventService;
private readonly INotificationService _notificationService;
private readonly INavigationService _navigationService;
@@ -85,7 +85,7 @@ partial class VariableHistoryViewModel : ViewModelBase, INavigatable
private List<VariableHistoryDto> _allVariableHistories;
public VariableHistoryViewModel(IMapper mapper, IDialogService dialogService, IHistoryAppService historyAppService,
IWPFDataService wpfDataService, IDataStorageService dataStorageService,
IWPFDataService wpfDataService, IWpfDataService dataStorageService,
IEventService eventService, INotificationService notificationService,
INavigationService navigationService)
{

View File

@@ -85,7 +85,7 @@ partial class VariableTableViewModel : ViewModelBase, INavigatable
/// <param name="dialogService">对话服务接口的实例。</param>
private readonly IWPFDataService _wpfDataService;
private readonly IDataStorageService _dataStorageService;
private readonly IWpfDataService _dataStorageService;
private readonly ObservableList<VariableItem> _variableItemList;
private readonly ISynchronizedView<VariableItem, VariableItem> _synchronizedView;
@@ -99,7 +99,7 @@ partial class VariableTableViewModel : ViewModelBase, INavigatable
public VariableTableViewModel(IMapper mapper, IDialogService dialogService, IVariableManagementService variableManagementService,
IEventService eventService,
IMqttAliasAppService mqttAliasAppService, IMqttAppService mqttAppService,
IWPFDataService wpfDataService, IDataStorageService dataStorageService,
IWPFDataService wpfDataService, IWpfDataService dataStorageService,
INotificationService notificationService, ITriggerAppService triggerAppService,
ITriggerVariableAppService triggerVariableAppService)
{