示例#1
0
 protected override bool InitClient(ConnectEntryData ci, ref SFTPSyncClient client)
 {
     try
     {
         client = SFTPSyncClient.Create(ci.ce);
     }
     catch (Exception eClient)
     {
         ClouderSyncPackage.Log(eClient.Message);
         return(false);
     }
     try
     {
         if (!client.Connect())
         {
             client.Log("Connection has failed" + '\n');
             return(false);
         }
     }
     catch (Exception eConnect)
     {
         ClouderSyncPackage.WriteToOutputWindow(eConnect.Message + '\n');
         string testResult = client.getLogMessages();
         ClouderSyncPackage.WriteToOutputWindow(testResult);
         client.clearLogMessages();
         return(false);
     }
     return(true);
 }
示例#2
0
        protected bool TestConnection(ref SFTPSyncClient client)
        {
//            SFTPSyncClient client = null;
            try
            {
                client = SFTPSyncClient.Create(connectEntry.ce);
            }
            catch (Exception eClient)
            {
                WriteLog(eClient.Message);
                return(false);
            }
            try
            {
                client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(2);
            }
            catch (ObjectDisposedException eDisposed)
            {
                WriteLog(eDisposed.Message);
                return(false);
            }
            try
            {
                client.Connect();
            }
            catch (Exception eConnect)
            {
                WriteLog(eConnect.Message);

                /*
                 * testResult = client.getLogMessages();
                 * WriteLog(testResult);
                 * MessageBox.Show(testResult, "Test Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 * client.clearLogMessages();
                 */
                return(false);
            }

            /*
             * testResult = client.getLogMessages();
             * WriteLog(testResult);
             * MessageBox.Show(testResult, "Test Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
             * client.clearLogMessages();
             */
            return(true);
        }