| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System.Text.Encodings.Web;
- using System.Text.Json;
- using System.Text.Json.Serialization;
- namespace Admin.NET.Plugin.AiDOP.DataPlatform.Inbound;
- internal static class MdpInboundJson
- {
- public static readonly JsonSerializerOptions Options = new()
- {
- PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
- DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
- Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
- };
- }
- public sealed class MdpInboundReceiveArgs
- {
- public string EntityCode { get; init; } = string.Empty;
- public byte[] RawBody { get; init; } = [];
- public string AccessKey { get; init; } = string.Empty;
- public long TenantId { get; init; }
- public string IdempotencyKey { get; init; } = string.Empty;
- public string ClientIp { get; init; } = string.Empty;
- public string Path { get; init; } = string.Empty;
- public IReadOnlyDictionary<string, string> Headers { get; init; }
- = new Dictionary<string, string>();
- }
- public sealed class MdpInboundOutcome
- {
- public int HttpStatus { get; init; }
- public object Body { get; init; }
- }
- public sealed class MdpInboundReceiptData
- {
- public string EntityCode { get; set; } = string.Empty;
- public int Accepted { get; set; }
- public int Rejected { get; set; }
- public List<MdpInboundRejectedRow> RejectedRows { get; set; } = [];
- public bool IdempotentReplay { get; set; }
- public string SyncBatchId { get; set; } = string.Empty;
- public long RequestId { get; set; }
- public bool TransformEnqueued { get; set; }
- public int StaleRejected { get; set; }
- public int EqualTsOverride { get; set; }
- }
- public sealed class MdpInboundRejectedRow
- {
- public string BizKey { get; set; }
- public string Reason { get; set; } = string.Empty;
- }
- public sealed class MdpInboundSchemaField
- {
- public string Name { get; set; } = string.Empty;
- public string RawKey { get; set; } = string.Empty;
- public bool Required { get; set; }
- }
- public sealed class MdpInboundSchemaData
- {
- public string EntityCode { get; set; } = string.Empty;
- public string BizKeyExpr { get; set; }
- public List<MdpInboundSchemaField> Fields { get; set; } = [];
- }
- internal sealed class MdpInboundParsedBatch
- {
- public List<JsonElement> Rows { get; init; } = [];
- public string SnapshotId { get; init; }
- public int? Seq { get; init; }
- }
- public sealed class MdpInboundPreparedRow
- {
- public Dictionary<string, object?> Dict { get; init; } = new(StringComparer.OrdinalIgnoreCase);
- public string RawJson { get; init; } = string.Empty;
- public string BizKey { get; init; } = string.Empty;
- public string SourceUpdatedAt { get; init; }
- public string SourceVersion { get; init; }
- }
- internal sealed class MdpInboundStgGuardRow
- {
- public long Id { get; set; }
- public string SourceSystem { get; set; }
- public string SourceRowId { get; set; }
- public string SourceUpdatedAt { get; set; }
- public string SourceVersion { get; set; }
- public string RawData { get; set; }
- }
- internal sealed class MdpInboundBatchException : Exception
- {
- public int HttpStatus { get; }
- public string ErrorCode { get; }
- public MdpInboundBatchException(int httpStatus, string message, string errorCode = null)
- : base(message)
- {
- HttpStatus = httpStatus;
- ErrorCode = errorCode ?? message;
- }
- }
|