using GB5Shared.DTO.Framework.Login; using SwDAL.DTO.RefDataSource; namespace SwBLL.RefDataSource; public interface IRefDataSourceBLL { Task GetById(int refDataSourceId, LoginDTO loginDTO, CancellationToken ct); Task> GetByDbModel(int dbModelId, LoginDTO loginDTO, CancellationToken ct); Task Save(RefDataSourceDTO dto, LoginDTO loginDTO, CancellationToken ct); /// Soft delete (STATUS=0) — deregisters a table from this DbModel's reference-data /// generation without touching any DdlScript/UpgradePackage already generated from it. Task Delete(int refDataSourceId, LoginDTO loginDTO, CancellationToken ct); /// Resolves a registry row's table/filter, generates the seed script via /// IReferenceDataScriptGenerator against the given source server+database (resolved /// server-side into a real connection string via IDbServerBLL/ITargetDbExecutor — a raw /// connection string is never accepted as a parameter), and saves the result as a new, plain /// Draft SW.MSWDDLSCRIPT unconditionally — category (SchemaChange/DataMigration/etc.) is a /// ChangeRequest-level concept, not a DdlScript one, and isn't decided here. The script is NOT /// attached to any package either; that remains a deliberate, separate governance step via /// the already-existing IUpgradePackageBLL.AttachDdlScript, same as any hand-authored script. /// Prefer RegenerateIfChangedAsync for repeat runs — this method always creates a new script, /// even if nothing changed since the last release. Task GenerateAndRegisterAsync( int refDataSourceId, int sourceDbServerId, string sourceDatabaseName, int branchId, LoginDTO loginDTO, CancellationToken ct); /// Same generation as GenerateAndRegisterAsync, but first checks whether the /// content actually changed since the DbModel's current Released chain (tracker §36.4): /// generates the script, computes its checksum, walks the chain the same way /// IUpgradePackageBLL.GetProvisioningChain already resolves for real onboarding (Released, /// not-superseded, Universal-scope packages), and compares against the checksum of whichever /// linked script in that chain targets the same table. Identical → skip, no new Draft script, /// no needless re-review. Different (or no prior release touches this table yet) → creates /// the new Draft script exactly like GenerateAndRegisterAsync. Task RegenerateIfChangedAsync( int refDataSourceId, int sourceDbServerId, string sourceDatabaseName, int branchId, LoginDTO loginDTO, CancellationToken ct); } public class RefDataRegenerationResultDTO { public bool Changed { get; set; } public int? NewDdlScriptId { get; set; } public string? PriorChecksum { get; set; } public string NewChecksum { get; set; } = string.Empty; }