private void CancleCommand() { _cmdList.Clear(); _currentCommand = null; }
/// <summary> /// 执行下一条命令 /// </summary> public void ExcuteNextCommand() { if (_cmdList.Count > 0) { FtpCommand cmd = _cmdList[0]; _cmdList.RemoveAt(0); ExcuteCommand(cmd); } else { _currentCommand = null; } }
/// <summary> /// 执行指定命令 /// </summary> /// <param name="command"></param> public void ExcuteCommand(FtpCommand command) { _currentCommand = command; if (_cmdList.Count > 0) { _nextCommand = _cmdList[0]; } else { _nextCommand = null; } CommandNotify(command.GetCommandLine()); _asyncSocket.Send(command.GetCommandLine()); }
/// <summary> /// 准备命令,适宜的添加到执行列表 /// </summary> /// <param name="command"></param> public void PrepareCommand(FtpCommand command) { if (_currentCommand != null || _isConnect == false) { if (command.Command == "RETR" || command.Command == "STOR" || command.Command == "LIST") { AddCommandList(new FtpCommand("PASV", 227));// add pasv //有偏移说明是断点下载 if(command .Offset != 0) { AddCommandList(new FtpCommand("REST",350,command.Offset .ToString ())); } } AddCommandList(command); } else { if (command.Command == "RETR" || command.Command == "STOR" || command.Command == "LIST") { //有偏移说明是断点下载 if (command.Offset != 0) { AddCommandList(new FtpCommand("REST", 350, command.Offset.ToString())); } AddCommandList(command); ExcuteCommand(new FtpCommand("PASV", 227));//add pasv and send the pasv request } else { ExcuteCommand(command); } } }
/// <summary> /// 添加命令到执行列表 /// </summary> /// <param name="command"></param> private void AddCommandList(FtpCommand command) { if (_nextCommand == null) { _nextCommand = command; } _cmdList.Add(command); }
public void PrepareCommand(FtpCommand command) { if (_currentCommand != null || _isConnect == false) { if (command.Command == "RETR" || command.Command == "STOR" || command.Command == "LIST") { AddCommandList(new FtpCommand("PASV", 227));// add pasv } AddCommandList(command); } else { if (command.Command == "RETR" || command.Command == "STOR" || command.Command == "LIST") { AddCommandList(command); ExcuteCommand(new FtpCommand("PASV", 227));//add pasv and send the pasv request } else { ExcuteCommand(command); } } }