mirror of
https://gitee.com/iioter/iotgateway.git
synced 2024-12-02 03:38:01 +08:00
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,7 +127,7 @@ 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,
|
||||||
|
Loading…
Reference in New Issue
Block a user