梳理了所有的Db,DTO,ItemViewModel的属性
This commit is contained in:
@@ -16,6 +16,9 @@ public partial class DeviceItemViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _name;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _description;
|
||||
|
||||
[ObservableProperty]
|
||||
private ProtocolType _protocol;
|
||||
|
||||
@@ -31,42 +34,66 @@ public partial class DeviceItemViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private int _slot;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _cpuType;
|
||||
|
||||
[ObservableProperty]
|
||||
private DeviceType _deviceType;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _opcUaServerUrl;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isActive;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isRunning;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _status;
|
||||
|
||||
public List<VariableTableItemViewModel> VariableTables { get; set; }
|
||||
|
||||
public DeviceItemViewModel(DeviceDto dto)
|
||||
{
|
||||
Id = dto.Id;
|
||||
_name = dto.Name;
|
||||
_description = dto.Description;
|
||||
_protocol = dto.Protocol;
|
||||
_ipAddress = dto.IpAddress;
|
||||
_port = dto.Port;
|
||||
_rack = dto.Rack;
|
||||
_slot = dto.Slot;
|
||||
_cpuType = dto.CpuType;
|
||||
_deviceType = dto.DeviceType;
|
||||
_opcUaServerUrl = dto.OpcUaServerUrl;
|
||||
_isActive = dto.IsActive;
|
||||
_isRunning = dto.IsRunning;
|
||||
_status = dto.Status;
|
||||
}
|
||||
|
||||
public DeviceItemViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DeviceDto ToDto()
|
||||
{
|
||||
return new DeviceDto
|
||||
{
|
||||
Id = this.Id,
|
||||
Name = this.Name,
|
||||
Description = this.Description,
|
||||
Protocol = this.Protocol,
|
||||
IpAddress = this.IpAddress,
|
||||
Port = this.Port,
|
||||
Rack = this.Rack,
|
||||
Slot = this.Slot,
|
||||
CpuType = this.CpuType,
|
||||
DeviceType = this.DeviceType,
|
||||
OpcUaServerUrl = this.OpcUaServerUrl,
|
||||
IsActive = this.IsActive,
|
||||
IsRunning = this.IsRunning,
|
||||
Status = this.Status
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using DMS.Application.DTOs;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace DMS.WPF.ViewModels.Items;
|
||||
|
||||
@@ -47,6 +49,9 @@ public partial class MqttServerItemViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _messageFormat;
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<VariableMqttAliasItemViewModel> _variableAliases = new();
|
||||
|
||||
public MqttServerItemViewModel(MqttServerDto dto)
|
||||
{
|
||||
Id = dto.Id;
|
||||
@@ -63,5 +68,6 @@ public partial class MqttServerItemViewModel : ObservableObject
|
||||
_connectedAt = dto.ConnectedAt;
|
||||
_connectionDuration = dto.ConnectionDuration;
|
||||
_messageFormat = dto.MessageFormat;
|
||||
_variableAliases = new ObservableCollection<VariableMqttAliasItemViewModel>(dto.VariableAliases.Select(va => new VariableMqttAliasItemViewModel(va)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public partial class VariableItemViewModel : ObservableObject
|
||||
private List<VariableMqttAliasDto>? _mqttAliases;
|
||||
|
||||
[ObservableProperty]
|
||||
private SignalType _dataType;
|
||||
private SignalType _signalType;
|
||||
|
||||
[ObservableProperty]
|
||||
private PollLevelType _pollLevel;
|
||||
@@ -85,6 +85,10 @@ public partial class VariableItemViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _description;
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
private OpcUaUpdateType _opcUaUpdateType;
|
||||
|
||||
public VariableItemViewModel(VariableDto dto)
|
||||
{
|
||||
Id = dto.Id;
|
||||
@@ -94,7 +98,7 @@ public partial class VariableItemViewModel : ObservableObject
|
||||
_displayValue = dto.DisplayValue;
|
||||
_variableTable = dto.VariableTable;
|
||||
_mqttAliases = dto.MqttAliases;
|
||||
_dataType = dto.DataType;
|
||||
_signalType = dto.SignalType;
|
||||
_pollLevel = dto.PollLevel;
|
||||
_isActive = dto.IsActive;
|
||||
_variableTableId = dto.VariableTableId;
|
||||
@@ -113,5 +117,6 @@ public partial class VariableItemViewModel : ObservableObject
|
||||
_updatedBy = dto.UpdatedBy;
|
||||
_isModified = dto.IsModified;
|
||||
_description = dto.Description;
|
||||
_opcUaUpdateType = dto.OpcUaUpdateType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using DMS.Application.DTOs;
|
||||
using DMS.Core.Enums;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace DMS.WPF.ViewModels.Items;
|
||||
|
||||
@@ -23,6 +25,9 @@ public partial class VariableTableItemViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private ProtocolType _protocol;
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<VariableItemViewModel> _variables = new();
|
||||
|
||||
public VariableTableItemViewModel(VariableTableDto dto)
|
||||
{
|
||||
Id = dto.Id;
|
||||
@@ -31,5 +36,6 @@ public partial class VariableTableItemViewModel : ObservableObject
|
||||
_isActive = dto.IsActive;
|
||||
_deviceId = dto.DeviceId;
|
||||
_protocol = dto.Protocol;
|
||||
_variables = new ObservableCollection<VariableItemViewModel>(dto.Variables.Select(v => new VariableItemViewModel(v)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user