iotgateway/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableBatchVM.cs

78 lines
2.4 KiB
C#
Raw Normal View History

2021-12-12 06:55:48 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using IoTGateway.Model;
using PluginInterface;
using Plugin;
2024-07-28 14:05:35 +00:00
using Microsoft.Extensions.Primitives;
2021-12-12 06:55:48 +00:00
namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs
{
public partial class DeviceVariableBatchVM : BaseBatchVM<DeviceVariable, DeviceVariable_BatchEdit>
{
public DeviceVariableBatchVM()
{
ListVM = new DeviceVariableListVM();
LinkedVM = new DeviceVariable_BatchEdit();
}
public override bool DoBatchDelete()
{
2024-07-28 14:05:35 +00:00
//先获取id
var id = UpdateDevices.FC2Guids(FC);
var deviceId = DC.Set<DeviceVariable>().Where(x => id.Contains(x.ID)).Select(x => x.DeviceId).FirstOrDefault();
FC["Entity.DeviceId"] = (StringValues)deviceId.ToString();
2021-12-12 06:55:48 +00:00
var ret = base.DoBatchDelete();
if (ret)
{
var deviceService = Wtm.ServiceProvider.GetService(typeof(DeviceService)) as DeviceService;
2024-07-28 14:05:35 +00:00
2021-12-12 06:55:48 +00:00
UpdateDevices.UpdateVaribale(DC, deviceService, FC);
}
return ret;
}
public override bool DoBatchEdit()
{
var ret = base.DoBatchEdit();
if (ret)
{
var deviceService = Wtm.ServiceProvider.GetService(typeof(DeviceService)) as DeviceService;
UpdateDevices.UpdateVaribale(DC, deviceService, FC);
}
return ret;
}
}
/// <summary>
/// Class to define batch edit fields
/// </summary>
public class DeviceVariable_BatchEdit : BaseVM
{
[Display(Name = "变量名")]
public String Name { get; set; }
[Display(Name = "地址")]
public String DeviceAddress { get; set; }
[Display(Name = "数据类型")]
public DataTypeEnum? DataType { get; set; }
2022-12-06 14:39:28 +00:00
[Display(Name = "大小端")]
public EndianEnum? EndianType { get; set; }
[Display(Name = "表达式")]
2023-05-21 13:54:08 +00:00
public string Expressions { get; set; }
2021-12-12 06:55:48 +00:00
[Display(Name = "权限")]
public ProtectTypeEnum? ProtectType { get; set; }
[Display(Name = "设备别名")]
public String Alias { get; set; }
2021-12-12 06:55:48 +00:00
protected override void InitVM()
{
}
}
}