Path: redb-route/demo/SerialNumbersDemo/SerialNumbers.Core/Services/ArchivePaths.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/demo/SerialNumbersDemo/SerialNumbers.Core/Services/ArchivePaths.cs ---- namespace SerialNumbers.Core.Services; /// Names of files in the archive and in partner folders. public static class ArchivePaths { /// /// {partner}/{yyyy}/{MM}/{dd}/{HHmmssfff}_{file}. The time prefix keeps every delivery, /// including a partner re-sending a file under the same name: nothing is ever overwritten. /// public static string For(string partnerCode, string fileName, DateTimeOffset receivedAt) => $"{Safe(partnerCode)}/{receivedAt:yyyy}/{receivedAt:MM}/{receivedAt:dd}/{receivedAt:HHmmssfff}_{Safe(fileName)}"; /// A file name for a message that arrived over AS2 and has none: its Message-ID. public static string FromAs2MessageId(string? messageId) => Safe(string.IsNullOrWhiteSpace(messageId) ? Guid.NewGuid().ToString("N") : messageId.Trim('<', '>')) + ".xml"; /// /// SNRESP_{requestId}_{responseId}.xml. The request id alone is not enough: a partner that /// sends a request id twice gets two responses, and the rejection of the repeat must not overwrite /// the original acceptance. A delivery retried from the outbox keeps its name. /// public static string ResponseFileName(string requestId, long responseObjectId) => $"SNRESP_{Safe(requestId)}_{responseObjectId}.xml"; private static string Safe(string value) => string.Concat(value.Select(c => char.IsAsciiLetterOrDigit(c) || c is '.' or '-' or '_' ? c : '_')); }