public bool StartFTP(IPEndPoint ie, string receiverId, string fileName, long fileSize) { FtpClientManager ftpManager = new FtpClientManager(ie, mKey, fileName, fileSize, receiverId); ftpManager.FTPStatusChanged += ProcessOnFTPStatusChanged; ftpManager.FTPConnectionError += ProcessOnFTPConnectionError; if (!ftpManager.IsConnected()) { if (ftpManager.Connect()) { OnManagerStatusChanged("[SERVER_CONNECT]Server Connected."); } else { OnManagerStatusChanged("[SERVER_CONNECT]Server Not Connected."); ftpManager.ForceClose(); return(false); } } else { OnManagerStatusChanged("[SERVER_CONNECT]Server Already Connected."); } lock (ftpManagersLock) { if (ftpManagers.ContainsKey(ftpManager.GetKey())) { ftpManagers.Remove(ftpManager.GetKey()); } ftpManagers.Add(ftpManager.GetKey(), ftpManager); } return(true); }
public bool StartFTP(IPEndPoint ie, string receiverId, string fileName, long fileSize) { FtpClientManager ftpManager = new FtpClientManager(ie, mKey, fileName,fileSize, receiverId); ftpManager.FTPStatusChanged += ProcessOnFTPStatusChanged; ftpManager.FTPConnectionError += ProcessOnFTPConnectionError; if (!ftpManager.IsConnected()) { if (ftpManager.Connect()) OnManagerStatusChanged("[SERVER_CONNECT]Server Connected."); else { OnManagerStatusChanged("[SERVER_CONNECT]Server Not Connected."); ftpManager.ForceClose(); return false; } } else OnManagerStatusChanged("[SERVER_CONNECT]Server Already Connected."); lock (ftpManagersLock) { if (ftpManagers.ContainsKey(ftpManager.GetKey())) ftpManagers.Remove(ftpManager.GetKey()); ftpManagers.Add(ftpManager.GetKey(), ftpManager); } return true; }