using Furion.DataValidation;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Waste.Domain;
namespace Waste.Application
{
public class DeviceList : W_Device
{
///
/// 商户名称
///
public string BusinessName { get; set; }
///
/// ICCID
///
public string ICCID { get; set; } = "";
///
/// IMEI
///
public string IMEI { get; set; } = "";
///
/// IMSI
///
public string IMSI { get; set; } = "";
///
/// 今日测量次数
///
public int TodayCount { get; set; } = 0;
///
/// 累计测量次数
///
public int TotalCount { get; set; } = 0;
///
/// 今日测量重量
///
public decimal TodayWeight { get; set; } = 0;
///
/// 累计测量重量
///
public decimal TotalWeight { get; set; } = 0;
///
/// 最近心跳时间
///
public DateTime? LastBeatTime { get; set; }
///
/// 网络状态,0-离线,1-在线,规则:最新测量时间、最近心跳时间在16分钟之内则是在线
///
public int NetStatus { get; set; } = 0;
///
/// 信号强度,分为5格信号,算法为:31/6
///
public string sign { get; set; }
///
/// 经度
///
public string Longitude { get; set; } = "";
///
/// 纬度
///
public string Latitude { get; set; } = "";
}
///
/// 设备批量操作
///
public class DeviceBatchModel
{
///
/// 服务商ID
///
public Guid BusinessId { get; set; }
///
/// 操作类型,1-分配,2-回收
///
public int type { get; set; }
///
/// 设备ID列表
///
public List codes { get; set; }
}
///
/// 设备信息提交
///
public class DeviceSubmit : W_Device
{
///
/// 设备对应的SecretHash
///
public string SecretHash { get; set; }
///
/// 设备对应的DevId
///
public string DevId { get; set; }
///
/// 设备对应的Secret
///
public string Secret { get; set; }
}
///
/// 设备详情
///
public class DeviceDetailS2Dto : W_Device
{
///
/// 最近心跳时间
///
public string LastBeatTime { get; set; }
///
/// 最近开机时间
///
public string LastStartTime { get; set; }
///
/// 纬度
///
public string Latitude { get; set; }
///
/// 经度
///
public string Longitude { get; set; }
///
/// 使用的版本号
///
public string version { get; set; }
}
///
/// 设备配置
///
public class DeviceConfigC2SDto : IValidatableObject
{
///
/// 设备ID
///
public Guid Id { get; set; }
///
/// 推送地址,支持http/https
///
[Required(ErrorMessage = "推送地址不可为空")]
[MaxLength(200, ErrorMessage = "推送地址最多200个字")]
public string Url { get; set; }
///
/// 额外推送信息,推送时固定以body参数传递
///
[DataValidation(AllowNullValue = true)]
[MaxLength(100, ErrorMessage = "额外推送信息最多100个字")]
public string Body { get; set; }
///
/// 验证
///
///
///
public IEnumerable Validate(ValidationContext validationContext)
{
if (!string.IsNullOrEmpty(Body) && (Body.Contains("&") || Body.Contains("?")))
{
yield return new ValidationResult("额外推送信息不可包含特殊字符&、?", new[] { nameof(Body) });
}
if(!Regex.IsMatch(Url.ToLower(), @"[http][a-zA-z]+://[^\s]*"))
{
yield return new ValidationResult("推送地址格式不正确", new[] { nameof(Url) });
}
}
}
}