You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/Platform/Application/Models/IoTCenter/EditIoTCommandModel.cs

75 lines
2.3 KiB

using Infrastructure.Application;
using Microsoft.AspNetCore.Mvc;
using Platform.Areas.IoTCenter.Controllers;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace IoT.Shared.Application.Models
{
[Display(Name = "命令")]
public class EditIoTCommandModel : EditModel
{
[Display(Name = "机构")]
[SelectList(nameof(BuildingId),nameof(AjaxController.GetBuilding))]
[ReadOnlyForEdit]
public Guid? OrganId { get; set; }
[Display(Name = "建筑")]
[SelectList(nameof(IoTGatewayId), nameof(AjaxController.GetIoTGateway))]
[ReadOnlyForEdit]
public Guid? BuildingId { get; set; }
[SelectList(nameof(DeviceId), nameof(AjaxController.GetIoTDevice))]
[Display(Name = "网关")]
[Required(ErrorMessage = nameof(RequiredAttribute))]
public Guid? IoTGatewayId { get; set; }
[SelectList(nameof(ApiId), nameof(AjaxController.GetIoTApiByDevice))]
[Display(Name = "设备")]
[Required(ErrorMessage = nameof(RequiredAttribute))]
public Guid? DeviceId { get; set; }
[SelectList]
[Display(Name = "Api")]
[Required(ErrorMessage = nameof(RequiredAttribute))]
public Guid? ApiId { get; set; }
[Display(Name = "命令名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
public string Name { get; set; }
[Display(Name = "序号")]
public int DisplayOrder { get; set; }
[Display(Name = "隐藏")]
public bool? Disabled { get; set; }
[Display(Name = "延迟")]
public int? Delay { get; set; }
[DisplayOnly]
[Display(Name = "参数")]
public string QueryString { get; set; }
[Display(Name = "参数", Order = 50)]
[ScaffoldColumn(false)]
public List<EditApiParameterModel> Parameters { get; set; } = new List<EditApiParameterModel>();
public string GetQueryString()
{
if (this.Parameters.Any())
{
var queryString = string.Empty;
foreach (var item in this.Parameters)
{
queryString += $"&{item.Name}={item.Value}";
}
return queryString.TrimStart('&');
}
return null;
}
}
}