コード例 #1
0
ファイル: SFTPUtils.cs プロジェクト: chanhappy/.Net
 public void RenameFileLegacy(SFTPRenameArgument renameArgument, CallbackContext callbackContext)
 {
     try
     {
         var sftpResult = RenameFile(renameArgument);
         _sftpClient.Close();
         _sftpClient = null;
         callbackContext.SendPluginResult(new PluginResult(PluginResult.Status.OK, sftpResult));
     }
     catch (Exception ex)
     {
         m_Logger.Error(ex);
         callbackContext.Error(new
         {
             type    = "Exception",
             code    = "",
             message = ex.Message,
             details = ex.StackTrace
         });
     }
 }
コード例 #2
0
ファイル: SFTPToolbar.cs プロジェクト: stone89son/poderosa
        public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
        {
            ISSHConnection sshConnection = GetSSHConnection(target) as ISSHConnection;

            if (sshConnection == null || sshConnection.SSHProtocol != SSHProtocol.SSH2)
            {
                return(CommandResult.Ignored);
            }

            string connectionName = GetTerminalName(target);

            if (connectionName == null)
            {
                connectionName = SFTPPlugin.Instance.StringResource.GetString("Common.UnknownPeer");
            }

            Form ownerForm = GetForm(target);

            if (!ConfirmToUse(ownerForm, "SFTP"))
            {
                return(CommandResult.Cancelled);
            }

            SFTPClient sftp = null;

            try {
                sftp = SFTPClient.OpenSFTPChannel(sshConnection);

                SFTPForm form = new SFTPForm(ownerForm, sftp, connectionName);
                form.Show();    // Note: don't specify owner to avoid fixed z-order.

                return(CommandResult.Succeeded);
            }
            catch (Exception e) {
                if (sftp != null)
                {
                    try {
                        sftp.Close();
                    }
                    catch (Exception) {
                    }
                    sftp = null;
                }

                RuntimeUtil.ReportException(e);
                return(CommandResult.Failed);
            }
        }
コード例 #3
0
        private void SFTPForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing && !_closedByOwner)
            {
                if (_sftpThread != null && _sftpThread.IsAlive)
                {
                    e.Cancel = true;
                    return;
                }
            }

            _formClosed = true;

            if (_sftpThread != null && _sftpThread.IsAlive)
            {
                _sftpThread.Abort(); // FIXME: we need graceful cancellation
            }
            try {
                _sftp.Close();
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
            }
        }