using GB5Shared.ListQuery; namespace SwDAL.DTO.UpgradePackage; // ── Main entity DTO ──────────────────────────────────────────────────────── public class UpgradePackageDTO { public int PackageId { get; set; } public int DbModelId { get; set; } public string? DbModelName { get; set; } // read-only JOIN public string PackageName { get; set; } = string.Empty; public string? PackageCode { get; set; } public byte PkgStatus { get; set; } // 0=Draft, 1=Testing, 2=Released, 3=Deprecated public string? Description { get; set; } public string? ReleaseNotes { get; set; } // Package-chain fields (039_ALTER_MSWUPGRADEPACKAGE_PackageChain.sql) — see PackageScopeType. public short SequenceInChain { get; set; } = 1; public int? SupersedesPackageId { get; set; } public byte ScopeType { get; set; } // 0=Universal 1=PartnerProduct 2=Industry 3=Country 4=Client public string? ScopeValue { get; set; } // Release-boundary identity (040_ALTER_MSWUPGRADEPACKAGE_ReleaseVersion.sql). Null on the // majority of packages — only set on packages representing a real release boundary. public string? ReleaseVersion { get; set; } // Rollout axis (042_ALTER_MSWUPGRADEPACKAGE_RolloutType.sql) — see PackageRolloutType. How // widely this package version is rolled out, independent of ScopeType/ScopeValue. public byte RolloutType { get; set; } // 0=Global 1=Beta 2=SelClients 4=Percentage public byte RolloutPercent { get; set; } = 100; // Entitlement-aware gating (050_ALTER_MSWUPGRADEPACKAGE_ContentType.sql, tracker §40) — see // PackageContentType. Schema packages are always delivered in full, never feature-gated; // MetadataOrStandardData packages are subject to Gate B via RequiredFeatureCode. public byte PackageContentType { get; set; } // 0=Schema 1=MetadataOrStandardData public string? RequiredFeatureCode { get; set; } // Gate B — null = universal/core content // 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; } } // ── Detail DTOs ──────────────────────────────────────────────────────────── public class UpgradePackageDdlDTO { public int PackageDdlId { get; set; } public int PackageId { get; set; } public int DdlScriptId { get; set; } public string? ObjectName { get; set; } // read-only JOIN public short Sequence { get; set; } public int TenantId { get; set; } } public class UpgradePackageMetaDTO { public int PackageMetaId { get; set; } public int PackageId { get; set; } public int MetaVersionId { get; set; } public string? VersionLabel { get; set; } // read-only JOIN public int TenantId { get; set; } } // ── Attach/Detach requests ────────────────────────────────────────────────── // ReplaceDdlLines(...) replaces a package's ENTIRE ddl-line set — there is no // single-row "attach one script" operation at the DAL level. These DTOs carry // just the one script being added/removed; the BLL loads the current line set, // applies the change, and calls ReplaceDdlLines with the full updated list. public class AttachDdlScriptRequestDTO { public int PackageId { get; set; } public int DdlScriptId { get; set; } public short Sequence { get; set; } // 0 = append at the end (BLL assigns max+1) } public class DetachDdlScriptRequestDTO { public int PackageId { get; set; } public int DdlScriptId { get; set; } } // ── Provisioning-chain resolution ─────────────────────────────────────────── // GetProvisioningChain resolves, for one DbModel, the ordered list of Released // packages a new client's database should apply: every Universal package plus any // overlay package whose SCOPETYPE/SCOPEVALUE matches the caller-supplied filter — // always picking only the package nobody supersedes within each chain (i.e. the // latest version). All four filter fields are optional; a null field simply means // no overlay package of that scope type can ever match (SQL NULL never equals a // bound parameter), so passing no filter at all resolves to Universal packages only. public class PackageScopeFilterDTO { public string? PartnerProductCode { get; set; } public string? IndustryCode { get; set; } public string? CountryCode { get; set; } public string? ClientCode { get; set; } } public class PackageChainItemDTO { public int PackageId { get; set; } public string PackageCode { get; set; } = string.Empty; public string PackageName { get; set; } = string.Empty; public short SequenceInChain { get; set; } public byte ScopeType { get; set; } public byte RolloutType { get; set; } public byte RolloutPercent { get; set; } = 100; // Entitlement-aware gating (tracker §40) — carried through so a caller resolving a // provisioning chain (or a rollout campaign resolving targets) can apply Gate B without a // second round-trip back to UpgradePackage. public byte PackageContentType { get; set; } public string? RequiredFeatureCode { get; set; } } // ── Lineage walk (for ProvisioningBLL.GetCurrentVersion) ─────────────────── // A whole-DbModel package list, unfiltered by STATUS/PKGSTATUS/scope, so the walk can find // a ReleaseVersion on an ancestor even if that ancestor package has since been Deprecated. public class LineageNodeDTO { public int PackageId { get; set; } public string? PackageCode { get; set; } public string? ReleaseVersion { get; set; } public int? SupersedesPackageId { get; set; } } // ── Picklist DTO ─────────────────────────────────────────────────────────── public class UpgradePackagePickListDTO { public int PackageId { get; set; } public string PackageName { get; set; } = string.Empty; } // ── List infrastructure ──────────────────────────────────────────────────── public sealed class UpgradePackageListCriteria : ICriteria { [CriteriaField("ouid")] public int? OUId { get; set; } [CriteriaField("dbmodelid")] public int? DbModelId { get; set; } [CriteriaField("pkgstatus")] public byte? PkgStatus { 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 UpgradePackageListQuery(UpgradePackageListCriteria Criteria) : IListQuery; public sealed class UpgradePackageListDTO { public int PackageId { get; set; } public string PackageName { get; set; } = string.Empty; public string? PackageCode { get; set; } public byte PkgStatus { get; set; } public int DbModelId { get; set; } public int TotalCount { get; set; } }