Exemple #1
0
        void ClearAtEnd(RunDTP_SO stateObj)
        {
            stateObj.SetCompleted();

            //----------------------------------------
            //Clear context
            _client.CurrentDTP = null;
            _currentDC         = null;

            //----------------------------------------
            //Unlock control connection, now the command
            //like abort, stat, quit could be issued
            UnlockCC(stateObj);
        }
Exemple #2
0
        void HandleCatch(Exception e,
                         RunDTP_SO stateObj)
        {
            //----------------------------------------
            //Clear context before unlocking
            _client.CurrentDTP = null;

            //----------------------------------------
            //Unlock control connection, now the command
            //like abort, stat, quit could be issued
            try
            {
                UnlockCC(stateObj);
            }
            catch (Exception ex)
            {
                NSTrace.WriteLineError("UnlockCC exception: " + ex.ToString());
            }
            catch
            {
                NSTrace.WriteLineError("UnlockCC non-cls exception: " + Environment.StackTrace);
            }

            if (_disposed)
            {
                stateObj.Exception = GetDisposedException();
            }
            else if (null != e)
            {
                NSTrace.WriteLineError("DTP exception: " + e.ToString());
                stateObj.Exception = e;
            }
            else
            {
                NSTrace.WriteLineError("DTP non cls exception: " + Environment.StackTrace);
            }

            //Do not set completed in case we
            //have non-cls exception
            if (null != stateObj.Exception)
            {
                stateObj.SetCompleted();
            }
        }
Exemple #3
0
        void SendCommandEx_End(IAsyncResult ar)
        {
            RunDTP_SO stateObj = (RunDTP_SO)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();
                FtpResponse response = _cc.EndSendCommandEx(ar);
                if (response.IsCompletionReply)
                {
                    NSTrace.WriteLineWarning("Executing DTP: receive completion as first reply.");
                    UnlockCC(stateObj);
                    stateObj.SetCompleted();
                }
                else
                {
                    FtpClient.CheckPreliminaryResponse(response);

                    //establish connection now, if it is inbound
                    if (FtpDataConnectionType.Inbound == _currentDC.Type)
                    {
                        _currentDC.BeginEstablish(stateObj.Timeout,
                                                  new AsyncCallback(this.InboundEstablish_End),
                                                  stateObj);
                    }
                    else
                    {
                        DoRunDTP(stateObj);
                    }
                }
            }
            catch (Exception e)
            {
                HandleCatch(e, stateObj);
            }
            catch
            {
                HandleCatch(null, stateObj);
            }
        }