static void Main(string[] args) { FileModel file = new FileModel(); // Load the files from SFTP server var sftpService = new SFTPService(); var files = sftpService.Execute(); // Save file name in database //Using SQLite //var storeService = new DataServices("C:\\ProgramData\\FTPApp\\FTPApp.sqlite"); //storeService.SaveFileInfos(files); //Using SQL var service = new DataServices(); service.SaveFileInfos(files); // Get the filesname from DB //---- // // Download the file var result = sftpService.ExecuteDownLoad(files); // Change the status in DB // Create admin dash info }
/// <summary> /// Backs up the world folders /// </summary> static void backupWorlds() { string fileLocation = $"minecraft-backup-{DateTime.Now.ToFileTimeUtc()}.zip"; SSHService sshService = new SSHService(loggerFactory.CreateLogger <SSHService>(), _config.SshConfig); sshService.OpenConnection(); sshService.ZipFolders(_config.BackupFolders, $"{_config.TempFileLocation}/{fileLocation}"); sshService.CloseConnection(); SFTPService sftpService = new SFTPService(loggerFactory.CreateLogger <SFTPService>(), _config.SshConfig); sftpService.OpenConnection(); sftpService.DownloadFile($"{_config.TempFileLocation}/{fileLocation}", $"{_config.BackupFolderLocation}/{fileLocation}"); sftpService.DeleteFile($"{_config.TempFileLocation}/{fileLocation}"); sftpService.OpenConnection(); sftpService.CloseConnection(); }