@model List @{ this.HtmlTitle = "设备列表"; var index = 0; }
@foreach (var item in Model) { var deviceId = Convert.ToInt32(item.Data.FirstOrDefault(o => o.Key == "DeviceId").Value); var address = item.Data.FirstOrDefault(o => o.Key == "Address").Value; var voltage = item.Data.FirstOrDefault(o => o.Key == "Voltage")?.Value; var state = item.Data.FirstOrDefault(o => o.Key == "State")?.Value; var battery = item.Data.FirstOrDefault(o => o.Key == "Battery")?.Value; }
编号 名称 类别 地址 电量 在线状态 设备状态 连接Id 操作 删除
@(++index) @item.Number @item.Name @deviceId @address @voltage/@battery @Html.DisplayFor(o => item.IsOnline) @if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(deviceId)) { @state } @if (deviceId == 0x0106) { @item.Data.FirstOrDefault(o => o.Key == "Light")?.Value } else if (deviceId == 0x0402) { @item.Data.FirstOrDefault(o => o.Key == "Warning")?.Value } else if (deviceId == 0x0309) { 温度:@item.Data.FirstOrDefault(o => o.Key == "Temperature")?.Value 湿度:@item.Data.FirstOrDefault(o => o.Key == "Humidity")?.Value
PM 1.0:@item.Data.FirstOrDefault(o => o.Key == "PM10")?.Value PM 2.5:@item.Data.FirstOrDefault(o => o.Key == "PM25")?.Value PM 10:@item.Data.FirstOrDefault(o => o.Key == "PM100")?.Value } else if (deviceId == 0x0302) { 温度:@item.Data.FirstOrDefault(o => o.Key == "Temperature")?.Value 湿度:@item.Data.FirstOrDefault(o => o.Key == "Humidity")?.Value } else if (deviceId == 0x0220) { 亮度:@item.Data.FirstOrDefault(o => o.Key == "Brightness")?.Value
色调: @item.Data.FirstOrDefault(o => o.Key == "Hue")?.Value 饱和度: @item.Data.FirstOrDefault(o => o.Key == "Saturation")?.Value
色温:@item.Data.FirstOrDefault(o => o.Key == "ColorTemperature")?.Value } else if (deviceId == 0x0163) { var version = item.Data.FirstOrDefault(o => o.Key == "Version")?.Value; if (!string.IsNullOrEmpty(version)) { 版本:@version } } else if (deviceId == 0x0051) { var electricity = item.Data.FirstOrDefault(o => o.Key == "Electricity")?.Value; if (!string.IsNullOrEmpty(electricity)) { 电量:@electricity } }
@item.ConnectId @if (new int[] { 0x0002, 0x0009, 0x0081, 0x0202, 0x0220, 0x0051 }.Contains(deviceId)) { } @if (deviceId == 0x0202) { } @if (deviceId == 0x0163) { 版本 } @if (deviceId == 0x0220) {
} @if (deviceId == 0x0163) {

发射:

空调:

开关:
模式
风向
风量

电视:

@{ var tvKeys = new string[] { "POWR","AV","1","2","3","4","5","6","7","8","9","0", "返回","退出","静音","菜单","音量+","音量-","上","下","左","右", "OK","CH+>>|","CH-|<<","快退","快进","录像","暂停","停止","红","绿","黄","蓝", "自定义","自定义","自定义","自定义","自定义","自定义","自定义","自定义"}; } @for (int i = 0; i < tvKeys.Length; i++) { @if (i % 5 == 0) {
} }

学习:

}
删除设备
@section scripts{ }