using GB5Shared.ListQuery; namespace SwDAL.DTO.ClientDatabase; // ── Main entity DTO ──────────────────────────────────────────────────────── public class ClientDatabaseDTO { public int ClientDbId { get; set; } public string ClientDbCode { get; set; } = string.Empty; public string ClientDbName { get; set; } = string.Empty; public int DbServerId { get; set; } public string DatabaseName { get; set; } = string.Empty; public int DbModelId { get; set; } public byte ClientDbStatus { get; set; } = 0; public string? Description { get; set; } /// DatabaseRole enum: 0=Main, 1=Report, 2=Archive. public byte DatabaseRole { get; set; } = 0; /// "DEV" | "QC" | "LIVE" | null — set once at registration, immutable thereafter /// (mirrors DbModelId/DatabaseRole's own "excluded from UPDATE" convention below). Nullable /// by design: rows registered before this column existed (053_ALTER_MSWCLIENTDATABASE_ /// TierColumn.sql) predate the concept and shouldn't be forced to guess. On the shared /// Dev/QC Gb5System this is how the two tiers are told apart within one MSWCLIENTDATABASE /// table; a genuinely separate Live-tier Gb5System doesn't strictly need it populated at /// all, since everything registered there is implicitly Live-tier by which physical control /// plane it lives in. public string? Tier { get; set; } /// 0=Push (default) | 1=Offline — tracker §53. Push is the existing SaaS behavior: /// RolloutCampaignBLL.ProcessDueTargetsAsync applies a due target directly, over a live SQL /// connection, via IProvisioningBLL.ProvisionClientDatabase. Offline means this client /// database has no live connection GB5 can reach (a genuinely disconnected on-prem/BYOC /// install) — a due target for it is marked AwaitingManualApply instead, and delivered via /// the Offline Rollout Package (SW.MSWCLIENTDATABASEKEY + OfflineRolloutExportBLL + /// SwOfflineApply) instead of a direct push. public byte DeliveryMode { get; set; } /// Vault paths for the three contained-user credentials created at provisioning /// time — never plaintext passwords. Null until the database has actually been created. public string? DbaVaultPath { get; set; } public string? AppVaultPath { get; set; } public string? ReadOnlyVaultPath { get; set; } /// FK-by-convention to MSERVERCONFIG.SERVERCONFIGID (a different, framework-level /// ID space — see GB5Framework/FrameworkBLL/ServerConfig) — set once this database is /// registered there via IServerConfigBLL.RegisterDatabaseAsync. Null until then. public int? ServerConfigId { get; set; } // Read-only from JOIN public string? DbServerHostName { get; set; } public string? DbModelName { get; set; } // Standard M-table fields public short Version { get; set; } public byte Status { get; set; } = 1; public short SortOrder { get; set; } = 9999; public int CreatedById { get; set; } public DateTime CreatedOn { get; set; } public int ModifiedById { get; set; } public DateTime ModifiedOn { get; set; } public byte SourceType { get; set; } = 5; public int TenantId { get; set; } public string DBUserName { get; set; } public string DBPassword { get; set; } } // ── Picklist DTO ─────────────────────────────────────────────────────────── public class ClientDatabasePickListDTO { public int ClientDbId { get; set; } public string ClientDbCode { get; set; } = string.Empty; public string ClientDbName { get; set; } = string.Empty; public string DatabaseName { get; set; } public int ClientDBStatus { get; set; } = 0; } // ── List infrastructure ──────────────────────────────────────────────────── public sealed class ClientDatabaseListCriteria : ICriteria { [CriteriaField("ouid")] public int? OUId { get; set; } [CriteriaField("dbserverid")] public int? DbServerId { get; set; } [CriteriaField("dbmodelid")] public int? DbModelId { get; set; } [CriteriaField("clientdbstatus")] public byte? ClientDbStatus { get; set; } [CriteriaField("tier")] public string? Tier { get; set; } [CriteriaField("searchtext")] public string? SearchText { get; set; } [CriteriaField("sortby")] public string? SortBy { get; set; } [CriteriaField("sortdesc")] public bool SortDesc { get; set; } [CriteriaField("pagesize")] public int PageSize { get; set; } = 100; [CriteriaField("pageoffset")] public int PageOffset { get; set; } = 0; } public sealed record ClientDatabaseListQuery(ClientDatabaseListCriteria Criteria) : IListQuery; public sealed class ClientDatabaseListDTO { public int ClientDbId { get; set; } public string ClientDbCode { get; set; } = string.Empty; public string ClientDbName { get; set; } = string.Empty; public int DbServerId { get; set; } public int DbModelId { get; set; } public byte ClientDbStatus { get; set; } public string? Tier { get; set; } public int TotalCount { get; set; } }