IoTGateway.ViewModel/BasicData/DeviceConfigVMs/DeviceConfigVM.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using IoTGateway.Model;
using Plugin;
using System.Text.Json;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Primitives;
namespace IoTGateway.ViewModel.BasicData.DeviceConfigVMs
{
public partial class DeviceConfigVM : BaseCRUDVM<DeviceConfig>
{
public List<ComboSelectListItem> AllDevices { get; set; }
public List<ComboSelectListItem> AllTypes { get; set; }
public DeviceConfigVM()
{
SetInclude(x => x.Device);
}
protected override void InitVM()
{
AllDevices = DC.Set<Device>().AsNoTracking().Where(x => x.DeviceTypeEnum == DeviceTypeEnum.Device)
.OrderBy(x => x.Parent.Index).ThenBy(x => x.Parent.DeviceName)
.OrderBy(x => x.Index).ThenBy(x => x.DeviceName)
.GetSelectListItems(Wtm, y => y.DeviceName);
if (Entity.DeviceId != null)
{
if (Entity.EnumInfo != null)
{
AllTypes = new List<ComboSelectListItem>();
var EnumInfos = JsonSerializer.Deserialize<Dictionary<string, int>>(Entity.EnumInfo);
foreach (var EnumInfo in EnumInfos)
{
var item = new ComboSelectListItem
{
Text = EnumInfo.Key,
Value = EnumInfo.Key,
Selected = Entity.Value == EnumInfo.Key ? true : false
};
AllTypes.Add(item);
}
}
}
else if (IoTBackgroundService.ConfigSelectDeviceId != null)
{
Entity.DeviceId = IoTBackgroundService.ConfigSelectDeviceId;
}
}
public override void DoAdd()
{
base.DoAdd();
UpdateConfig();
}
后面还有 31 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
