Ejemplo n.º 1
0
        internal IAsyncResult BeginExecute(int timeout, AsyncCallback cb, object state)
        {
            SetProgress(true);
            GetDC_SO stateObj = null;

            try
            {
                stateObj = new GetDC_SO(timeout, cb, state);
                if (_passiveMode)
                {
                    _cc.BeginSendCommandEx(timeout,
                                           "PASV",
                                           new AsyncCallback(this.GetDC_EndCmd),
                                           stateObj);
                }
                else
                {
                    IPEndPoint ep = GetLocalEndPoint();
                    stateObj.DC = new FtpDataConnectionInbound(_client, ep);
                    stateObj.DC.BeginPrepare(timeout,
                                             _cc.UsedSocket,
                                             new AsyncCallback(Prepare_End),
                                             stateObj);
                }
            }
            finally
            {
                SetProgress(false);
            }
            return(stateObj);
        }
Ejemplo n.º 2
0
        internal IAsyncResult BeginExecute(int timeout,
                                           string user,
                                           string password,
                                           string account,
                                           AsyncCallback callback,
                                           object state)
        {
            Login_SO stateObj = null;

            SetProgress(true);
            try
            {
                stateObj = new Login_SO(timeout,
                                        password,
                                        account,
                                        callback,
                                        state);

                _cc.BeginSendCommandEx(timeout,
                                       "USER " + user,
                                       new AsyncCallback(UserCmd_End),
                                       stateObj);
            }
            catch (Exception e)
            {
                SetProgress(false);
                throw e;
            }
            return(stateObj);
        }
Ejemplo n.º 3
0
        internal IAsyncResult BeginExecute(int timeout, string command, AsyncCallback cb, object state)
        {
            _arType = null;
            IAsyncResult ar = _cc.BeginSendCommandEx(timeout, command, cb, state);

            if (null != ar)
            {
                _arType = ar.GetType();
            }
            return(ar);
        }
Ejemplo n.º 4
0
        void LockFirst_End(object state, bool timedout)
        {
            RunDTP_SO stateObj = (RunDTP_SO)state;

            try
            {
                stateObj.UpdateContext();
                //----------------------------------------
                //Indicate that we lock CC
                stateObj.CCLocked = true;

                //----------------------------------------
                //send transfser type command
                if ((false == _client.IsDataTypeWasCached) ||
                    ((true == _client.IsDataTypeWasCached) && (_client.CachedDataType != stateObj.DataType)))
                {
                    string typeCmd = GetTypeCommand(stateObj.DataType);
                    _cc.BeginSendCommandEx(stateObj.Timeout,
                                           typeCmd,
                                           new AsyncCallback(TypeCmd_End),
                                           stateObj);
                }
                else
                {
                    stateObj.GetDC_Cmd = new Cmd_GetDataConnection(_client);

                    //Initialize data connection
                    stateObj.GetDC_Cmd.BeginExecute(stateObj.Timeout,
                                                    new AsyncCallback(GetDC_End),
                                                    stateObj);
                }
            }
            catch (Exception e)
            {
                HandleCatch(e, stateObj);
            }
            catch
            {
                HandleCatch(null, stateObj);
            }
        }
Ejemplo n.º 5
0
        void Lock_End(object state, bool timedout)
        {
            Abort_SO stateObj = (Abort_SO)state;

            try
            {
                stateObj.UpdateContext();
                //----------------------------------------
                //Indicate that we lock CC
                stateObj.CCLocked = true;

                if (null != _client.CurrentDTP)
                {
                    //----------------------------------------
                    //In case when we have active DTP we delegate
                    //handling responses to it and here only send
                    //abort command
                    _cc.BeginSendCommand(stateObj.Timeout,
                                         "ABOR",
                                         new AsyncCallback(SendCmd_End),
                                         stateObj);
                }
                else
                {
                    //----------------------------------------
                    //In case there is no DTP, but user wants
                    //issue abort command we should dealing with
                    //responses here ...
                    _cc.BeginSendCommandEx(stateObj.Timeout,
                                           "ABOR",
                                           new AsyncCallback(SendCmdEx_End),
                                           stateObj);
                }
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
        }