refactor:完成重构设备的添加,删除,更新。
This commit is contained in:
@@ -9,10 +9,11 @@ using DMS.Core.Models;
|
||||
using DMS.WPF.Interfaces;
|
||||
using DMS.WPF.Services;
|
||||
using DMS.WPF.ItemViewModel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DMS.WPF.ViewModels.Dialogs;
|
||||
|
||||
public partial class ImportExcelDialogViewModel : DialogViewModelBase<List<Variable>>
|
||||
public partial class ImportExcelDialogViewModel : DialogViewModelBase<List<VariableItem>>
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IExcelService _excelService;
|
||||
@@ -57,21 +58,21 @@ public partial class ImportExcelDialogViewModel : DialogViewModelBase<List<Varia
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ImportAll()
|
||||
private async Task ImportAll()
|
||||
{
|
||||
Close(Variables);
|
||||
await Close(VariableItemViewModels.ToList());
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ImportSelected()
|
||||
private async Task ImportSelected()
|
||||
{
|
||||
var selected = SelectedVariables.Cast<VariableItem>().ToList();
|
||||
Close(_mapper.Map<List<Variable>>(selected));
|
||||
await Close(selected);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void CancleButton()
|
||||
private async Task CancleButton()
|
||||
{
|
||||
Close(null);
|
||||
await Close(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace DMS.WPF.ViewModels.Dialogs
|
||||
{
|
||||
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IWpfDataService _dataStorageService;
|
||||
private readonly IViewDataService _viewDataService;
|
||||
private readonly INotificationService _notificationService;
|
||||
|
||||
[ObservableProperty]
|
||||
@@ -39,11 +39,11 @@ namespace DMS.WPF.ViewModels.Dialogs
|
||||
|
||||
public TriggerDialogViewModel(
|
||||
IDialogService dialogService,
|
||||
IWpfDataService dataStorageService,
|
||||
IViewDataService dataStorageService,
|
||||
INotificationService notificationService)
|
||||
{
|
||||
_dialogService = dialogService ?? throw new ArgumentNullException(nameof(dialogService));
|
||||
_dataStorageService = dataStorageService;
|
||||
_viewDataService = dataStorageService;
|
||||
_notificationService = notificationService ?? throw new ArgumentNullException(nameof(notificationService));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,18 @@ public partial class VariableDialogViewModel : DialogViewModelBase<VariableItem>
|
||||
[ObservableProperty]
|
||||
private bool _hasError;
|
||||
|
||||
private readonly IWPFDataService _wpfDataService;
|
||||
private readonly IWpfDataService _dataStorageService;
|
||||
private readonly IViewCenterService _wpfDataService;
|
||||
private readonly IViewDataService _viewDataService;
|
||||
private readonly IVariableAppService _variableAppService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public VariableDialogViewModel(IWPFDataService wpfDataService,IWpfDataService dataStorageService, IVariableAppService variableAppService, IMapper mapper)
|
||||
public VariableDialogViewModel(IViewCenterService wpfDataService,IViewDataService dataStorageService, IVariableAppService variableAppService, IMapper mapper)
|
||||
{
|
||||
|
||||
Variable = new VariableItem();
|
||||
|
||||
_wpfDataService = wpfDataService;
|
||||
_dataStorageService = dataStorageService;
|
||||
_viewDataService = dataStorageService;
|
||||
this._variableAppService = variableAppService;
|
||||
this._mapper = mapper;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public partial class VariableDialogViewModel : DialogViewModelBase<VariableItem>
|
||||
return false;
|
||||
}
|
||||
//检查变量是否存在
|
||||
var existVariables = _dataStorageService.Variables.Where(v => v.Value.Name == Variable.Name || (v.Value.Protocol == ProtocolType.S7 && v.Value.S7Address == Variable.S7Address) || (v.Value.Protocol == ProtocolType.OpcUa && v.Value.OpcUaNodeId == Variable.OpcUaNodeId)).Select(v=>v.Value).ToList();
|
||||
var existVariables = _viewDataService.Variables.Where(v => v.Value.Name == Variable.Name || (v.Value.Protocol == ProtocolType.S7 && v.Value.S7Address == Variable.S7Address) || (v.Value.Protocol == ProtocolType.OpcUa && v.Value.OpcUaNodeId == Variable.OpcUaNodeId)).Select(v=>v.Value).ToList();
|
||||
VariableItem existVariable = null;
|
||||
if (IsAddModel)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user