using IceImportDAL.DTO.RemoteFileSources; namespace IceImportDAL.CustomCode.RemoteFileSources; // Plugin/strategy dispatch precedent: DI-scanned IEnumerable, selected by // ConnectionType — same style as GB5Solution.Admin.AdminBLL.BulkIceImport.IPostImportAction and // this module's own IIceFieldValueResolver (ValueType discriminator). ScheduledImportService // resolves the right implementation with // _sources.Single(s => s.ConnectionType == config.ConnectionType). // // Credentials always arrive already resolved (RemoteFileSourceConfigDTO.Host/Username/Credential) // — an IRemoteFileSource implementation must NEVER touch Vault directly; that stays the BLL-layer // orchestrator's job (via IIceImportSecretResolver), keeping this DAL-layer contract simple, // testable, and free of any secret-fetching side effects. public interface IRemoteFileSource { // ConnectionType: 0=FTP, 1=SFTP — matches MICEMAPFTPSOURCE.CONNECTIONTYPE / // RemoteFileSourceConfigDTO.ConnectionType. byte ConnectionType { get; } // Lists remote files under config.RemoteFolderPath, already filtered against // config.FileNamePattern (glob-style, via WildcardPatternMatcher). Directories are excluded. // Opens and closes its own connection — never leaves a socket open past this call. Task> ListFilesAsync(RemoteFileSourceConfigDTO config, CancellationToken ct); // Downloads one file (file.RemoteFullPath, as returned by ListFilesAsync) into a fresh // in-memory stream positioned at 0. Caller owns and disposes the returned stream. Opens and // closes its own connection — never leaves a socket open past this call. Task DownloadAsync(RemoteFileSourceConfigDTO config, RemoteFileInfoDTO file, CancellationToken ct); // Applies config.PostProcessAction (0=None, 1=Delete, 2=Archive) to the remote file after a // successful import. Archive moves the file to config.ArchiveFolderPath on the same server. // Best-effort by design — a post-process failure must never be allowed to undo a completed // import; callers log-and-continue rather than propagate. Task PostProcessAsync(RemoteFileSourceConfigDTO config, RemoteFileInfoDTO file, CancellationToken ct); }