public void OnFileUpLoadCommpleted(FtpEventArgs e) { if (FileUpLoadCommpleted != null) { FileUpLoadCommpleted(this, e); } }
private void CommandCommpleted(FtpEventArgs e) { AddMessageToObserve(Color.Blue, e.SMessage); }
private void LoginCommpleted(FtpEventArgs e) { SetSatusInfor(global::MyFtpSoft.Properties.Resources.Wait, "[OPERATE] Getting DirList! ..."); ftpHelper1.Dir(); }
private void FileDownLoadCommpleted(FtpEventArgs e) { string msg = "FileDownload Transfered " + e.Totalbytes.ToString() + " bytes in " + ((float)e.Timeelapsed / 1000).ToString() + " seconds" + "\r\n"; AddMessageToObserve(Color.Black, msg); FillLocalView(ftpHelper1.Localfolder); this.Cursor = Cursors.Default; timer1.Enabled = false; lvTransfer.Items.RemoveAt(0); if (lvTransfer.Items.Count > 0) { ExcuteTranfer(); } else { isExcuteTransfering = false; SetSatusInfor(global::MyFtpSoft.Properties.Resources.list, "[OPERATE] DownLoad Commpleted,FileList! "); } }
private void MessageObserve(FtpEventArgs e) { AddMessageToObserve(Color.Green, e.SMessage); }
/// <summary> /// 显示文件传输进度条 /// </summary> /// <param name="fileName"></param> /// <param name="areadyBytes"></param> /// <param name="totleBytes"></param> /// <param name="timeElapsed"></param> public void ShowFilePassProgress(string fileName,int areadyBytes,int totleBytes,int timeElapsed) { FtpEventArgs e = new FtpEventArgs(); e.AreadyBytes = areadyBytes; e.Totalbytes = totleBytes; e.Timeelapsed = timeElapsed; if (fileName.Contains('\\')) { int index = fileName.LastIndexOf('\\'); e.SMessage = fileName.Substring(index + 1); } else { e.SMessage = fileName; } _ftpHelper.OnFilePassProgressCommpleted(e); }
private void ResponseUnexpected(FtpEventArgs e) { string code = e.SMessage.Substring(0, 3); try { int iCode = Convert.ToInt32(code); int index = e.SMessage.LastIndexOf("\n"); unExceptedMessage = e.SMessage.Substring(index + 1); isUnexcept = true; AddMessageToObserve(Color.DarkOrange, e.SMessage.Substring(0, index)); } catch { return; } }
public void OnBaseInfor(FtpEventArgs e) { if (BaseInfor != null) { BaseInfor(this, e); } }
public void OnDirCommpleted(FtpEventArgs e) { if (DirCommpleted != null) { ParseDirList(e.SMessage); DirCommpleted(this, e); } }
public void OnLoginCommpleted(FtpEventArgs e) { if (LoginCommpleted != null) { LoginCommpleted(this, e); } }
public void OnCommandCommpleted(FtpEventArgs e) { if (CommandCommpleted != null) { CommandCommpleted(this, e); } }
public void OnLoginFailure(FtpEventArgs e) { if (LoginFailure != null) { LoginFailure(this, e); } }
public void OnError(FtpEventArgs e) { if (Error != null) { Error(this,e); } }
public void OnMessage(FtpEventArgs e) { if (Message != null) { Message(this, e); } }
private void ConnectionCommpleted() { FtpEventArgs eNew = new FtpEventArgs(); eNew.SMessage = "Connecting " + _ftpHelper.Hostname + ",Port " + _ftpHelper.Port + "\r\n" + "Connected,Waiting for response"; _ftpHelper.OnBaseInfor(eNew); FtpEventArgs e = new FtpEventArgs(); e.SMessage = String.Empty; _ftpHelper.OnConnectCommpleted(e); _isConnect = true; ExcuteNextCommand(); }
/// <summary> /// 数据传输完毕的回调函数 /// </summary> /// <param name="byteTransfered"></param> /// <param name="timeElapsed"></param> /// <param name="_dataAsyncSocket"></param> public void TransferCommpleted(int byteTransfered, int timeElapsed,DataAsyncSocket _dataAsyncSocket ) { string s; if (_dataAsyncSocket == null) { s = String.Empty; } else { s = _dataAsyncSocket.Response; _dataAsyncSocket.DisConnect(); } FtpEventArgs e = new FtpEventArgs(); e.Totalbytes = byteTransfered; e.Timeelapsed = timeElapsed; e.SMessage = s; e.Workid = _dataAsyncSocket.Workid; if (_dataAsyncSocket.CmdData == 0) _ftpHelper.OnDirCommpleted(e); else if (_dataAsyncSocket.CmdData == 1) _ftpHelper.OnFileDownLoadCommpleted(e); else _ftpHelper.OnFileUpLoadCommpleted(e); _dataAsyncSocket = null; }
/// <summary> /// 连接失败 /// </summary> private void ConnectionTerminated() { FtpEventArgs eNew = new FtpEventArgs(); eNew.SMessage = "Connecting " + _ftpHelper.Hostname + ",Port " + _ftpHelper.Port + "\r\n" + "DisConnected,The remote cannot reach!"; _ftpHelper.OnBaseInfor(eNew); DisConnect(); }
public void ErrorNotify(string message,string functionName) { FtpEventArgs e = new FtpEventArgs(); e.SMessage = message; e.Function = functionName; _ftpHelper.OnError(e); }
private void ftpHelper1_ResponseUnexpected(object sender, FtpEventArgs e) { DelFtpEvent delFtpEvent = new DelFtpEvent(ResponseUnexpected); this.Invoke(delFtpEvent, e); }
private void CommandNotify(string message) { FtpEventArgs e = new FtpEventArgs(); e.SMessage = message.Substring(0, message.Length - 2);//???????????? _ftpHelper.OnCommandCommpleted(e); }
private void FilePassProgressCommpleted(FtpEventArgs e) { int precent = (int)(((float)e.AreadyBytes / (float)e.Totalbytes) * 100); barFilePass.Value = precent; labelPrecent.Text = precent.ToString()+"% Finished"; statusBarPanelStatus.Text = "Transfer:" + e.SMessage + " Time: " + ((float)e.Timeelapsed / 1000).ToString()+ " (s) "; }
private void ResponseUnexpected(string message) { FtpEventArgs e = new FtpEventArgs(); e.SMessage = message.Substring(0, message.Length - 2); _ftpHelper.OnResponseUnexpected(e); }
private void ConnectCommpleted(FtpEventArgs e) { #region Set StateBar SetConnetInfor(global::MyFtpSoft.Properties.Resources.StateCon, "Welcome: anonymous State: Connect"); SetSatusInfor(global::MyFtpSoft.Properties.Resources.login, "Now logning! ..."); #endregion SwitchUpDownLoad(true); ftpHelper1.Login(); timerWait.Enabled = true; }
private void MessageNotify(string message) { FtpEventArgs e = new FtpEventArgs(); e.SMessage = message.Substring(0, message.Length - 2); _ftpHelper.OnMessage(e); }
private void ErrorObserver(FtpEventArgs e) { AddMessageToObserve(Color.Red, e.Function + "-" + e.SMessage); }
private void LoginCommpeleted() { FtpEventArgs e = new FtpEventArgs(); e.SMessage = String.Empty; _ftpHelper.OnLoginCommpleted(e); }
private void BaseInfor(FtpEventArgs e) { AddMessageToObserve(Color.Black, e.SMessage); }
private void LoginFailure() { CancleCommand(); FtpEventArgs e = new FtpEventArgs(); e.SMessage = String.Empty; _ftpHelper.OnLoginFailure(e); }
private void DirCommpleted(FtpEventArgs e) { try { int fileCount = 0; int directoryCount = 0; int i = 0; int imageIndex = 0; string isFolder = "0"; #region Add TransferMsg string msg = "\r\nTransfered " + e.Totalbytes.ToString() + " bytes in " + ((float)e.Timeelapsed / 1000).ToString() + " seconds" + "\r\n"; AddMessageToObserve(Color.Black, msg); #endregion if (!ServerRootFlag) { ServerRoot = ftpHelper1.Remotefolder; ServerRootFlag = true; InitializeServerTree(ServerRoot); } lvServer.BeginUpdate(); lvServer.Items.Clear(); imageListServer.Images.Clear(); #region Add Back if (ftpHelper1.Remotefolder != ServerRoot) { Icon icoUp = global::MyFtpSoft.Properties.Resources.up2; imageListServer.Images.Add(icoUp); ListViewItem lvItemUp = new ListViewItem("...", imageIndex++); lvItemUp.Tag = "..."; lvServer.Items.Add(lvItemUp); //FillServerTree(); } #endregion #region Add Folder and Files for (i = 0; i < ftpHelper1.listServerData.Count; i++) { string[] items = new string[4]; items[0] = ftpHelper1.listServerData[i].fileName; items[3] = ftpHelper1.listServerData[i].date; if (ftpHelper1.listServerData[i].isDirectory) { imageListServer.Images.Add(iconFolder); items[1] = String.Empty; items[2] = String.Empty; directoryCount++; isFolder = "1"; } else { imageListServer.Images.Add(ExtractIcon.GetIcon(items[0], false)); items[1] = ftpHelper1.listServerData[i].size.ToString() + "KB"; if (items[0].Contains(".")) { items[2] = items[0].Substring(items[0].LastIndexOf('.'), items[0].Length - items[0].LastIndexOf('.')); } fileCount++; isFolder = "0"; } ListViewItem lvItem = new ListViewItem(items, imageIndex++); lvItem.Tag = isFolder; lvServer.Items.Add(lvItem); } #endregion #region add others ftpListViewServer.SetUrl(ftpHelper1.Remotefolder); lableServer.Text = "0 Disk(s) , " + fileCount + " File(s) , " + directoryCount + " Directories " + e.Totalbytes.ToString() + " bytes offer [*.*]"; ListViewStye(lvServer); timer1.Enabled = false; statusBarPanelSign.Icon = global::MyFtpSoft.Properties.Resources.Gray; #endregion lvServer.EndUpdate(); if (!isUnexcept)//Sucessfully { SetSatusInfor(global::MyFtpSoft.Properties.Resources.list, "[OPERATE] DirList Ready! ..."); } else //Failure unexcepted { SetSatusInfor(global::MyFtpSoft.Properties.Resources.Error, unExceptedMessage); isUnexcept = false; } this.Cursor = Cursors.Default; ftpHelper1.listServerData.Clear(); } catch(Exception ex) { throw ex; } }
public void OnFilePassProgressCommpleted(FtpEventArgs e) { if (FileDownLoadCommpleted != null) { FilePassProgressCommpleted(this, e); } }