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);
            }
        }
Beispiel #2
0
        public void MTThread_SFTPTransfer()
        {
            string host = "159.224.194.27";
            int    port = 222;
            string user = "******";
            string psw  = "$fh#ER2J63"; // Fjt8Fyeq45

            SFTPTransfer csftp = new SFTPTransfer(host, port, user, psw, service.Null);

            List <TransferProperty> listProperty = new List <TransferProperty>();

            listProperty.Add(new TransferProperty()
            {
                pathHost         = ConfigurationManager.AppSettings["fromPathHostTransferApproaches"].ToString(),
                filtrHost        = ConfigurationManager.AppSettings["FileFiltrHostTransferApproaches"].ToString(),
                pathReceiver     = ConfigurationManager.AppSettings["toDirPathTransferApproaches"].ToString(),
                pathTempReceiver = ConfigurationManager.AppSettings["toTMPDirPathTransferApproaches"].ToString(),
                receiverDelete   = bool.Parse(ConfigurationManager.AppSettings["DeleteFileHostTransferApproaches"].ToString()),
                receiverRewrite  = bool.Parse(ConfigurationManager.AppSettings["RewriteFileTransferApproaches"].ToString())
            });
            listProperty.Add(new TransferProperty()
            {
                pathHost         = ConfigurationManager.AppSettings["fromPathHostTransferArrival"].ToString(),
                filtrHost        = ConfigurationManager.AppSettings["FileFiltrHostTransferArrival"].ToString(),
                pathReceiver     = ConfigurationManager.AppSettings["toDirPathTransferArrival"].ToString(),
                pathTempReceiver = ConfigurationManager.AppSettings["toTMPDirPathTransferArrival"].ToString(),
                receiverDelete   = bool.Parse(ConfigurationManager.AppSettings["DeleteFileHostTransferArrival"].ToString()),
                receiverRewrite  = bool.Parse(ConfigurationManager.AppSettings["RewriteFileTransferArrival"].ToString())
            });

            List <int> count_copy = csftp.CopyToDir(listProperty);
        }
Beispiel #3
0
        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);
            }
        }