private void TestConnectionButton_Click(object sender, EventArgs e) { TransferBase transferUtil = new FTPTransfer(); if (logViaFTP.Checked) { transferUtil = new FTPTransfer(); } if (logViaSFTP.Checked) { transferUtil = new SFTPTransfer(); } transferUtil.Host = remoteHostTextBox.Text; transferUtil.Port = Int32.Parse(remotePortTextBox.Text); transferUtil.Username = usernameTextBox.Text; transferUtil.Password = passwordTextBox.Text; transferUtil.SourceDirectory = "C:\\"; transferUtil.DestinationDirectory = remoteDirTextBox.Text; if (transferUtil.TestConnection()) { MessageBox.Show("Connection is successful", "Connection Test", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Unable to connect, please check settings", "Connection Test", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void TransferManager(string logFile) { if (currentDataLoggerConfig.IsLogRemote()) { TransferBase transferUtil = new FTPTransfer(); if (currentDataLoggerConfig.IsLogToFTP()) { transferUtil = new FTPTransfer(); } if (currentDataLoggerConfig.IsLogToSFTP()) { transferUtil = new SFTPTransfer(); } transferUtil.Host = currentDataLoggerConfig.RemoteHost; transferUtil.Port = currentDataLoggerConfig.RemotePort; transferUtil.Username = currentDataLoggerConfig.Username; transferUtil.Password = currentDataLoggerConfig.Password; transferUtil.SourceDirectory = currentDataLoggerConfig.LocalDirectory; transferUtil.DestinationDirectory = currentDataLoggerConfig.RemoteDirectory; transferUtil.UploadFile(logFile); } }