void UserCmd_End(IAsyncResult ar) { Login_SO stateObj = (Login_SO)ar.AsyncState; try { stateObj.UpdateContext(); FtpResponse response = _cc.EndSendCommandEx(ar); if (!response.IsCompletionReply && !response.IsIntermediateReply) { throw GetLoginFailedException(response); } if (response.IsCompletionReply) { stateObj.SetCompleted(); } else { _cc.BeginSendCommandEx(stateObj.Timeout, "PASS " + stateObj.Password, new AsyncCallback(PasswordCmd_End), stateObj); } } catch (Exception e) { stateObj.Exception = e; stateObj.SetCompleted(); } }
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); }
void AccountCmd_End(IAsyncResult ar) { Login_SO stateObj = (Login_SO)ar.AsyncState; try { stateObj.UpdateContext(); FtpResponse response = _cc.EndSendCommandEx(ar); if (!response.IsCompletionReply) { throw GetLoginFailedException(response); } } catch (Exception e) { stateObj.Exception = e; } stateObj.SetCompleted(); }
void PasswordCmd_End(IAsyncResult ar) { Login_SO stateObj = (Login_SO)ar.AsyncState; try { stateObj.UpdateContext(); FtpResponse response = _cc.EndSendCommandEx(ar); if (!response.IsCompletionReply && !response.IsIntermediateReply) { throw GetLoginFailedException(response); } if (response.IsCompletionReply) { stateObj.SetCompleted(); } else { if (null == stateObj.Account) { throw new FtpAccountRequiredException("Unable to login, account is required.", response); } _cc.BeginSendCommandEx(stateObj.Timeout, "ACCT " + stateObj.Account, new AsyncCallback(AccountCmd_End), stateObj); } } catch (Exception e) { stateObj.Exception = e; stateObj.SetCompleted(); } }