예제 #1
0
        /// <summary>Open a connection to the specified server.</summary>
        /// <param name="task">The task using this connection</param>
        public void Open(FTPTask task)
        {
            if (_task!=null) {
                throw new FTPTaskException("This connection is already being used by "+_task.ToString());
            }

            if (task==null) {
                throw new FTPTaskException("Must specify the task that will use this connection.");
            }

            _task = task;

            if (IsConnected) {
                throw new FTPTaskException("This connection is already open.");
            }

            _task.Log(Level.Info, "Using '{0}':", ID);

            // ensure this connection object has all the info it needs
            Validate();

            if (!_task.Exec) {
                _task.Log(Level.Info, "-------------- Debugging the ftp queries --------------");
                _task.Log(Level.Info, "Connection will be attempted to scan remotely for <get> sets");
                _task.Log(Level.Info, "but no transfers will be attempted in either direction");
                _task.Log(Level.Info, "and neither local nor remote file trees will be modified.");
                _task.Log(Level.Info, "-------------------------------------------------------\n");
            }

            _task.Log(Level.Info, "Connecting to '{0}' as '{1}' . . .", Server, UserName);

            _task.Log(Level.Verbose, "Instantiating the FTPClient & opening the connection...");
            _client = new FTPClient(Server);

            _task.Log(Level.Verbose, "Authenticating...");

            Login(UserName, Password);

            _task.Log(Level.Verbose, "and setting the connection mode to passive.");
            _client.ConnectMode = ParseConnectMode(ParseConnectMode(_task.ConnectMode));

            return;
        }
예제 #2
0
        /// <summary>Close a connection to a server</summary>
        public void Close()
        {
            if (IsConnected) {
                //throw new FTPTaskException("Connection is already closed");
                _task.Log(Level.Info, "Disconnecting from '{0}'", Server);
                _client.Quit();
                _client = null;
                _task = null;

            }

            return;
        }
 public DirScannerStringCollection(FTPTask conn)
 {
     _conn=conn;
 }
 public RemoteDirectoryScanner(FTPTask supervisor)
 {
     _conn = supervisor;
 }
 public RemoteDirectoryScanner()
 {
     _conn = new FTPTask();
 }
예제 #6
0
        public void Transfer(FTPTask super)
        {
            this.Conn = super;
            InitScanner();
            if (super.Exec) {
                // store the PWD and change to the remote path
                string pwd = super.PWD;
                super.CWD(RemotePathString, CreateDirsOnDemand);

                TransferFiles();

                // and restore the PWD
                super.CWD_Quiet(pwd);
            }
        }