fix: 新增设备后变量页面打开报错
This commit is contained in:
parent
5ab6c3e190
commit
2bc9fcc357
@ -23,7 +23,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVMs
|
|||||||
protected override void InitVM()
|
protected override void InitVM()
|
||||||
{
|
{
|
||||||
AllDrivers = DC.Set<Driver>().GetSelectListItems(Wtm, y => y.FileName);
|
AllDrivers = DC.Set<Driver>().GetSelectListItems(Wtm, y => y.FileName);
|
||||||
AllParents = DC.Set<Device>().Where(x=>x.DeviceTypeEnum== DeviceTypeEnum.Group).GetSelectListItems(Wtm, y => y.DeviceName);
|
AllParents = DC.Set<Device>().Where(x => x.DeviceTypeEnum == DeviceTypeEnum.Group).GetSelectListItems(Wtm, y => y.DeviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DoAdd()
|
public override void DoAdd()
|
||||||
@ -36,7 +36,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVMs
|
|||||||
{
|
{
|
||||||
var deviceService = Wtm.ServiceProvider.GetService(typeof(DeviceService)) as DeviceService;
|
var deviceService = Wtm.ServiceProvider.GetService(typeof(DeviceService)) as DeviceService;
|
||||||
deviceService.DrvierManager.AddConfigs(this.Entity.ID, this.Entity.DriverId);
|
deviceService.DrvierManager.AddConfigs(this.Entity.ID, this.Entity.DriverId);
|
||||||
var device = DC.Set<Device>().Where(x => x.ID == Entity.ID).Include(x=>x.Parent).Include(x => x.Driver).SingleOrDefault();
|
var device = DC.Set<Device>().Where(x => x.ID == Entity.ID).Include(x => x.Parent).Include(x => x.Driver).Include(x => x.DeviceVariables).SingleOrDefault();
|
||||||
deviceService.CreateDeviceThread(device);
|
deviceService.CreateDeviceThread(device);
|
||||||
|
|
||||||
var myMqttClient = Wtm.ServiceProvider.GetService(typeof(MyMqttClient)) as MyMqttClient;
|
var myMqttClient = Wtm.ServiceProvider.GetService(typeof(MyMqttClient)) as MyMqttClient;
|
||||||
|
@ -116,7 +116,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs
|
|||||||
var threadDeviceIds = deviceService?.DeviceThreads.Select(x => x.Device.ID).Distinct(x => x);
|
var threadDeviceIds = deviceService?.DeviceThreads.Select(x => x.Device.ID).Distinct(x => x);
|
||||||
//设备线程中的变量
|
//设备线程中的变量
|
||||||
var threadVariables =
|
var threadVariables =
|
||||||
deviceService?.DeviceThreads.SelectMany(deviceThread => deviceThread.Device.DeviceVariables);
|
deviceService?.DeviceThreads.Where(x => x.Device.DeviceVariables != null).SelectMany(deviceThread => deviceThread.Device.DeviceVariables);
|
||||||
//查找数据库中额外的变量
|
//查找数据库中额外的变量
|
||||||
var dcVariables = DC.Set<DeviceVariable>().AsNoTracking().Include(x => x.Device)
|
var dcVariables = DC.Set<DeviceVariable>().AsNoTracking().Include(x => x.Device)
|
||||||
.Where(x => !threadDeviceIds.Contains((Guid)x.DeviceId)).AsEnumerable();
|
.Where(x => !threadDeviceIds.Contains((Guid)x.DeviceId)).AsEnumerable();
|
||||||
@ -127,30 +127,30 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs
|
|||||||
{
|
{
|
||||||
var ids = UpdateDevices.FC2Guids(FC);
|
var ids = UpdateDevices.FC2Guids(FC);
|
||||||
|
|
||||||
return variables.Where(x=> ids.Contains(x.ID)).Select(x => new DeviceVariable_View
|
return variables.Where(x => ids.Contains(x.ID)).Select(x => new DeviceVariable_View
|
||||||
{
|
{
|
||||||
ID = x.ID,
|
ID = x.ID,
|
||||||
DeviceId = x.DeviceId,
|
DeviceId = x.DeviceId,
|
||||||
Name = x.Name,
|
Name = x.Name,
|
||||||
Index = x.Index,
|
Index = x.Index,
|
||||||
Description = x.Description,
|
Description = x.Description,
|
||||||
Method = x.Method,
|
Method = x.Method,
|
||||||
DeviceAddress = x.DeviceAddress,
|
DeviceAddress = x.DeviceAddress,
|
||||||
DataType = x.DataType,
|
DataType = x.DataType,
|
||||||
IsTrigger = x.IsTrigger,
|
IsTrigger = x.IsTrigger,
|
||||||
EndianType = x.EndianType,
|
EndianType = x.EndianType,
|
||||||
Expressions = x.Expressions,
|
Expressions = x.Expressions,
|
||||||
IsUpload = x.IsUpload,
|
IsUpload = x.IsUpload,
|
||||||
ProtectType = x.ProtectType,
|
ProtectType = x.ProtectType,
|
||||||
DeviceName_view = x.Device.DeviceName,
|
DeviceName_view = x.Device.DeviceName,
|
||||||
Alias = x.Alias,
|
Alias = x.Alias,
|
||||||
Device = x.Device,
|
Device = x.Device,
|
||||||
Value = x.Value,
|
Value = x.Value,
|
||||||
CookedValue = x.CookedValue,
|
CookedValue = x.CookedValue,
|
||||||
StatusType = x.StatusType,
|
StatusType = x.StatusType,
|
||||||
Timestamp = x.Timestamp,
|
Timestamp = x.Timestamp,
|
||||||
Message = x.Message,
|
Message = x.Message,
|
||||||
})
|
})
|
||||||
.OrderBy(x => x.Index).ThenBy(x => x.DeviceName_view).ThenBy(x => x.Alias).ThenBy(x => x.Method)
|
.OrderBy(x => x.Index).ThenBy(x => x.DeviceName_view).ThenBy(x => x.Alias).ThenBy(x => x.Method)
|
||||||
.ThenBy(x => x.DeviceAddress);
|
.ThenBy(x => x.DeviceAddress);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user