internal static Version GetFtpHighestVersionFromDir(Uri uriRemoteDirPath, string ftpUser, string ftpPassword, NLog.Logger logger) { string version = "0.0.0.0"; Version highest = new Version(version); try { string[] dirContents = SecureFtpRepoUpdate.ListDirectory(uriRemoteDirPath, ftpUser, ftpPassword, false /*details*/, true /*enableSSL*/); for (int i = 0; i < dirContents.Length; ++i) { if (dirContents[i] == "Latest") { continue; } Version ver = new Version(dirContents[i]); if (ver > highest) { highest = ver; } } } catch (Exception e) { logger.ErrorException("Failed to retrieve the latest version from remote ftp server", e); } return(highest); }
internal static bool IsFtpBinaryVersionPresent(Uri uriRemoteDirPath, string version, string ftpUser, string ftpPassword, NLog.Logger logger) { bool present = false; Version versionCheck = new Version(version); try { string[] dirContents = SecureFtpRepoUpdate.ListDirectory(uriRemoteDirPath, ftpUser, ftpPassword, false /*details*/, true /*enableSSL*/); for (int i = 0; i < dirContents.Length; ++i) { if (dirContents[i] == version) { continue; } Version ver = new Version(dirContents[i]); if (ver == versionCheck) { present = true; break; } } } catch (Exception e) { logger.ErrorException("Failed to retrieve the latest version from remote ftp server", e); } return(present); }
internal static bool IsFtpRemoteDirectoryPresent(Uri uriRemoteDirPath, string ftpUser, string ftpPassword) { bool present = false; try { string[] dirContents = SecureFtpRepoUpdate.ListDirectory(uriRemoteDirPath, ftpUser, ftpPassword, false /*details*/, true /*enableSSL*/); present = true; } catch (Exception) { } return(present); }
private bool IsValidRepositoryAccountPresent() { bool valid = true; try { string[] directories = SecureFtpRepoUpdate.ListDirectory(new Uri(this.formRepoAccountInfo.RepoAccountHost + ":" + this.formRepoAccountInfo.RepoAccountPort), this.formRepoAccountInfo.RepoAccountLogin, this.formRepoAccountInfo.RepoAccountPassword, false, true ); } catch (Exception ex) { logger.ErrorException("Failed to list directories on the ftp server", ex); valid = false; } return(valid); }
public void SecureFtpRepoUpdateTest_ListDirectoryDetails_UsingFtps() { string[] files = SecureFtpRepoUpdate.ListDirectory(uriDir, remoteUsername, remoteUserPassword, true /*details*/, true /*enableSSL*/); Assert.IsTrue(files.GetLength(0) > 0); }