using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Threading; using System.Threading.Tasks; using AdminDAL.DTO.BulkIceImport; using GB5Shared.DTO.Framework.Login; namespace AdminDAL.CustomCode.BulkIceImport { public interface IBulkIceImportDAL { // Returns one row per MBULKICEDETAIL, ordered by SLNO. Task> GetBulkIceConfigAsync( int bulkIceId, LoginDTO login, CancellationToken ct = default); // Creates the staging table DDL from DataTable schema then bulk-inserts rows. // Runs OUTSIDE a transaction so IBulkInsertService can use its own connection. Task DumpFileToStagingAsync( string stagingTableName, DataTable data, LoginDTO login, CancellationToken ct = default); // Drops + recreates the persistent temp table and copies staging rows into it. // Runs OUTSIDE any transaction — DDL auto-commits in SQL Server. Task CopyToTempTableAsync( string tempTableName, string stagingTableName, LoginDTO login, CancellationToken ct = default); // Executes the fully-built stored procedure call string (table names already substituted). Task ExecuteImportProcedureAsync( string procedureCall, LoginDTO login, DbTransaction tx, CancellationToken ct = default); // Reads the OUTPUT_{guid} table into a DataTable after the procedure has run. Task GetOutputTableDataAsync( string guid, LoginDTO login, CancellationToken ct = default); // Runs DB validation via PROC_BULK_ICE_DATA_VALIDATE and returns typed result. // Never throws for expected validation failures — returns HasErrors = true instead. Task RunValidationAsync( int bulkIceId, int userId, LoginDTO login, DbTransaction tx, CancellationToken ct = default); // Drops all created staging tables. Each drop is independent — failure is logged, not rethrown. Task DropStagingTablesAsync( string guid, bool[] tablesCreated, LoginDTO login, CancellationToken ct = default); // Drops the output table. Failure is logged, not rethrown. Task DropOutputTableAsync( string guid, LoginDTO login, CancellationToken ct = default); } }