public bool GetFiles() { bool status = false; _sftp = new SFTP(m_sftpUserName, m_sftpKey); _sftp.EnableLogging(); _sftp.HostAddress = m_sftpSite; _sftp.UserName = m_sftpSiteUserName; _sftp.SshKeyFile = m_identityFile; _sftp.SshPassphrase = @"t0y0ta69"; try { try { // connect _sftp.Connect(); } catch (KellermanSoftware.NetSFtpLibrary.Implementation.SftpException ke) { LogMsg("NEXCEPTION:AMSSftpMgr::_sftp.Connect():ECaught:" + ke.Message); return(status); } // get a directory list List <FTPFileInfo> rFiles = _sftp.GetAllFiles(m_sftpSiteRemoteFolder); // process the list foreach (FTPFileInfo file in rFiles) { if (file.Equals(".") || file.Equals("..")) { continue; } string f = this.ParseFileName(file.FileName); // if we got it, don't get it if (this.CheckDb(f)) { continue; } try { // get the file and put in the watch folder to be processed _sftp.DownloadFile(m_moveToProcessFolder + f, file.FileName); // if we're crunching it then do it if (this.m_moveToCrunchFlag) { _sftp.DownloadFile(m_moveToCrunchFolder + f, file.FileName); } string newPlace = m_moveAfterProcessingFolder + f; bool moved = _sftp.MoveFile(file.FileName, newPlace); bool dirDone = _sftp.CreateDirectory("tested"); // update the database to indicate file has been downloaded this.UpdateDb(f); } catch (SystemException se) { LogMsg("NEXCEPTION:AMSSftpMgr::GetFile():ECaught::" + se.Message + se.StackTrace); } } _sftp.Disconnect(); _sftp.Dispose(); status = true; } catch (SystemException se) { LogMsg("NEXCEPTION:AMSSftpMgr::GetFile():ECaught:TryingToGetFile::" + se.Message); } return(status); } // getFile()
public bool GetFiles() { bool status = false; _sftp = new SFTP(m_sftpUserName, m_sftpKey); _sftp.EnableLogging(); _sftp.HostAddress = m_sftpSite; _sftp.UserName = m_sftpSiteUserName; _sftp.SshKeyFile = m_identityFile; _sftp.SshPassphrase = @"t0y0ta69"; try { try { // connect _sftp.Connect(); } catch (KellermanSoftware.NetSFtpLibrary.Implementation.SftpException ke) { LogMsg("NEXCEPTION:AMSSftpMgr::_sftp.Connect():ECaught:" + ke.Message); return status; } // get a directory list List<FTPFileInfo> rFiles = _sftp.GetAllFiles(m_sftpSiteRemoteFolder); // process the list foreach (FTPFileInfo file in rFiles) { if (file.Equals(".") || file.Equals("..")) continue; string f = this.ParseFileName(file.FileName); // if we got it, don't get it if (this.CheckDb(f)) continue; try { // get the file and put in the watch folder to be processed _sftp.DownloadFile(m_moveToProcessFolder + f, file.FileName); // if we're crunching it then do it if( this.m_moveToCrunchFlag ) _sftp.DownloadFile(m_moveToCrunchFolder + f, file.FileName); string newPlace = m_moveAfterProcessingFolder + f; bool moved =_sftp.MoveFile(file.FileName, newPlace ); bool dirDone =_sftp.CreateDirectory("tested"); // update the database to indicate file has been downloaded this.UpdateDb(f); } catch (SystemException se) { LogMsg("NEXCEPTION:AMSSftpMgr::GetFile():ECaught::" + se.Message + se.StackTrace); } } _sftp.Disconnect(); _sftp.Dispose(); status = true; } catch (SystemException se) { LogMsg("NEXCEPTION:AMSSftpMgr::GetFile():ECaught:TryingToGetFile::" + se.Message); } return status; }