using System.Text.Json.Serialization; namespace YD_TrainingCompetition_Api.Models; /// /// 报警记录,包含 JSON/XML 数据和图片信息 /// public sealed class AlarmRecord { [JsonPropertyName("id")] public string Id { get; set; } = Guid.NewGuid().ToString("N"); [JsonPropertyName("deviceId")] public string DeviceId { get; set; } = string.Empty; [JsonPropertyName("ip")] public string Ip { get; set; } = string.Empty; [JsonPropertyName("dataType")] public string DataType { get; set; } = string.Empty; // "xml" or "json" /// /// 原始报警数据(JSON 或 XML 字符串) /// [JsonPropertyName("rawData")] public string RawData { get; set; } = string.Empty; /// /// 报警数据长度(字节) /// [JsonPropertyName("dataLength")] public uint DataLength { get; set; } /// /// 附带图片数量 /// [JsonPropertyName("pictureCount")] public int PictureCount { get; set; } /// /// 图片数据(Base64 编码,仅保留最新报警的图片) /// [JsonPropertyName("pictures")] public List Pictures { get; set; } = new(); [JsonPropertyName("timestamp")] public DateTimeOffset Timestamp { get; set; } = DateTimeOffset.UtcNow; } /// /// 报警附带图片 /// public sealed class AlarmPicture { [JsonPropertyName("fileName")] public string FileName { get; set; } = string.Empty; [JsonPropertyName("length")] public uint Length { get; set; } [JsonPropertyName("base64")] public string Base64 { get; set; } = string.Empty; }