예제 #1
0
        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);
        }
예제 #2
0
        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;
        }