using System; using System.Collections.Generic; using System.Threading.Tasks; using rgbc_sds.dal.DB; namespace rgbc_sds.services.Services { /// /// Service interface for handling shipment import operations /// public interface IImportService { /// /// Creates a new import session and validates the uploaded file /// /// Excel file stream /// Original filename /// File size in bytes /// Import strategy to use /// User initiating the import /// Import session with validation results Task CreateImportSessionAsync( Stream fileStream, string fileName, long fileSize, string importMode, string createdBy); /// /// Gets a summary of the import session /// /// Import session ID /// Import session summary Task GetImportSessionAsync(Guid sessionId); /// /// Gets staging data for preview before import /// /// Import session ID /// Page number for pagination /// Number of records per page /// Paged staging data Task<(List Data, int TotalCount)> GetStagingDataForPreviewAsync( Guid sessionId, int pageNumber = 1, int pageSize = 50); /// /// Gets validation errors for the import session /// /// Import session ID /// List of validation errors Task> GetValidationErrorsAsync(Guid sessionId); /// /// Executes the import process for validated data /// /// Import session ID /// Optional progress callback for real-time updates /// Import result with success/failure details Task ExecuteImportAsync( Guid sessionId, IProgress? progressCallback = null); /// /// Cancels an import session /// /// Import session ID /// User cancelling the import /// Success status Task CancelImportSessionAsync(Guid sessionId, string cancelledBy); /// /// Gets recent import sessions for the current user /// /// User to get sessions for /// Maximum number of results /// List of recent import sessions Task> GetRecentImportSessionsAsync(string createdBy, int maxResults = 10); /// /// Cleans up old import sessions and staging data /// /// Number of days to keep data /// Number of records cleaned up Task CleanupOldImportSessionsAsync(int daysToKeep = 30); } /// /// Result of an import operation /// public class ImportResult { public bool IsSuccess { get; set; } public string Message { get; set; } = string.Empty; public int RecordsProcessed { get; set; } public int RecordsSkipped { get; set; } public int RecordsFailed { get; set; } public List Errors { get; set; } = new List(); public TimeSpan ProcessingTime { get; set; } } /// /// Progress information during import processing /// public class ImportProgress { public int CurrentRecord { get; set; } public int TotalRecords { get; set; } public string CurrentOperation { get; set; } = string.Empty; public decimal PercentageComplete => TotalRecords > 0 ? (decimal)CurrentRecord / TotalRecords * 100 : 0; } }