//turn this into some kind of interface public GatherResults DownloadQtyFiles(IVendorDirectory dir) { var files = new List<File>(); using (var ftp = new FtpLib.FtpConnection(_config.QtyFileHost, _config.QtyFilePort, _config.QtyFileUsername, _config.QtyFilePassword)) { ftp.Open(); ftp.Login(); dir.EnsureExists(); var localFile = dir.GetNewRawFile(FileTypes.Qty); ftp.GetFile(_config.QtyFileName, localFile.Name.GetPath(), true); files.Add(localFile); ftp.Close(); } return new GatherResults { VendorHandle = dir.VendorHandle, Files = files }; }
//turn this into some kind of interface public GatherResults DownloadQtyFiles(IVendorDirectory dir) { dir.EnsureExists(); var localFile = dir.GetNewRawFile(FileTypes.Qty); var files = new List<File>(); var loginToken = getLoginToken(); writeFile(loginToken, localFile); files.Add(localFile); return new GatherResults { VendorHandle = dir.VendorHandle, Files = files }; }
//turn this into some kind of interface public GatherResults DownloadQtyFiles(IVendorDirectory dir) { var files = new List<File>(); using (var sftp = new SftpClient(_config.QtyFileHost, _config.QtyFilePort, _config.QtyFileUsername, _config.QtyFilePassword)) { sftp.Connect(); dir.EnsureExists(); var localFile = dir.GetNewRawFile(FileTypes.Qty); using (var stream = new FileStream(localFile.Name.GetPath(), FileMode.Create)) { sftp.DownloadFile(_config.QtyFileName, stream); } files.Add(localFile); sftp.Disconnect(); } return new GatherResults { VendorHandle = dir.VendorHandle, Files = files }; }