Пример #1
0
        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);
            }
        }
Пример #2
0
        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);

            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;
            }
        }