2026-07-02 10:05:51 +08:00

64 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Text.Json.Serialization;
namespace YD_TrainingCompetition_Api.Models;
/// <summary>
/// 报警记录,包含 JSON/XML 数据和图片信息
/// </summary>
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"
/// <summary>
/// 原始报警数据(JSON 或 XML 字符串)
/// </summary>
[JsonPropertyName("rawData")]
public string RawData { get; set; } = string.Empty;
/// <summary>
/// 报警数据长度(字节)
/// </summary>
[JsonPropertyName("dataLength")]
public uint DataLength { get; set; }
/// <summary>
/// 附带图片数量
/// </summary>
[JsonPropertyName("pictureCount")]
public int PictureCount { get; set; }
/// <summary>
/// 图片数据(Base64 编码,仅保留最新报警的图片)
/// </summary>
[JsonPropertyName("pictures")]
public List<AlarmPicture> Pictures { get; set; } = new();
[JsonPropertyName("timestamp")]
public DateTimeOffset Timestamp { get; set; } = DateTimeOffset.UtcNow;
}
/// <summary>
/// 报警附带图片
/// </summary>
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;
}