Example #1
0
 public void OnFileUpLoadCommpleted(FtpEventArgs e)
 {
     if (FileUpLoadCommpleted != null)
     {
         FileUpLoadCommpleted(this, e);
     }
 }
Example #2
0
File: Main.cs Project: yqMac/School
 private void CommandCommpleted(FtpEventArgs e)
 {
     AddMessageToObserve(Color.Blue, e.SMessage);
 }
Example #3
0
File: Main.cs Project: yqMac/School
 private void LoginCommpleted(FtpEventArgs e)
 {
     SetSatusInfor(global::MyFtpSoft.Properties.Resources.Wait, "[OPERATE]   Getting DirList! ...");
     ftpHelper1.Dir();
 }
Example #4
0
File: Main.cs Project: yqMac/School
 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! ");
     }
 }
Example #5
0
File: Main.cs Project: yqMac/School
 private void MessageObserve(FtpEventArgs e)
 {
     AddMessageToObserve(Color.Green, e.SMessage);
 }
Example #6
0
 /// <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);
  }
Example #7
0
File: Main.cs Project: yqMac/School
        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;
            }
        }
Example #8
0
 public void OnBaseInfor(FtpEventArgs e)
 {
     if (BaseInfor != null)
     {
         BaseInfor(this, e);
     }
 }
Example #9
0
 public void OnDirCommpleted(FtpEventArgs e)
 {
     if (DirCommpleted != null)
     {
         ParseDirList(e.SMessage);
         DirCommpleted(this, e);
     }
 }
Example #10
0
 public void OnLoginCommpleted(FtpEventArgs e)
 {
     if (LoginCommpleted != null)
     {
         LoginCommpleted(this, e);
     }
 }
Example #11
0
 public void OnCommandCommpleted(FtpEventArgs e)
 {
     if (CommandCommpleted != null)
     {
         CommandCommpleted(this, e);
     }
 }
Example #12
0
 public void OnLoginFailure(FtpEventArgs e)
 {
     if (LoginFailure != null)
     {
         LoginFailure(this, e);
     }
 }
Example #13
0
 public void OnError(FtpEventArgs e)
 {
     if (Error != null)
     {
         Error(this,e);
     }
 }
Example #14
0
 public void OnMessage(FtpEventArgs e)
 {
     if (Message != null)
     {
         Message(this, e);
     }
 }
Example #15
0
         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();
         }
Example #16
0
        /// <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;
            
         }
Example #17
0
        /// <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();
         }
Example #18
0
 public void ErrorNotify(string message,string functionName)
  {
      FtpEventArgs e = new FtpEventArgs();
      e.SMessage = message;
      e.Function = functionName;
      _ftpHelper.OnError(e);
  }
Example #19
0
File: Main.cs Project: yqMac/School
 private void ftpHelper1_ResponseUnexpected(object sender, FtpEventArgs e)
 {
     DelFtpEvent delFtpEvent = new DelFtpEvent(ResponseUnexpected);
     this.Invoke(delFtpEvent, e);
 }
Example #20
0
 private void CommandNotify(string message)
 {
     FtpEventArgs e = new FtpEventArgs();
     e.SMessage = message.Substring(0, message.Length - 2);//????????????
     _ftpHelper.OnCommandCommpleted(e);
 }
Example #21
0
File: Main.cs Project: yqMac/School
 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)  ";
 }
Example #22
0
 private void ResponseUnexpected(string message)
 {
     FtpEventArgs e = new FtpEventArgs();
     e.SMessage = message.Substring(0, message.Length - 2);
     _ftpHelper.OnResponseUnexpected(e);
 }
Example #23
0
File: Main.cs Project: yqMac/School
 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;
 }
Example #24
0
 private void MessageNotify(string message)
 {
     FtpEventArgs e = new FtpEventArgs();
     e.SMessage = message.Substring(0, message.Length - 2);
     _ftpHelper.OnMessage(e);
 }
Example #25
0
File: Main.cs Project: yqMac/School
 private void ErrorObserver(FtpEventArgs e)
 {
     AddMessageToObserve(Color.Red, e.Function + "-" + e.SMessage);
 }
Example #26
0
 private void LoginCommpeleted()
 {
     FtpEventArgs e = new FtpEventArgs();
     e.SMessage = String.Empty;
     _ftpHelper.OnLoginCommpleted(e);
 }
Example #27
0
File: Main.cs Project: yqMac/School
 private void BaseInfor(FtpEventArgs e)
 {
     AddMessageToObserve(Color.Black, e.SMessage);
 }
Example #28
0
 private void LoginFailure()
 {
     CancleCommand();
     FtpEventArgs e = new FtpEventArgs();
     e.SMessage = String.Empty;
     _ftpHelper.OnLoginFailure(e);
 }
Example #29
0
File: Main.cs Project: yqMac/School
        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;
            }
        }
Example #30
0
 public void OnFilePassProgressCommpleted(FtpEventArgs e)
 {
     if (FileDownLoadCommpleted != null)
     {
         FilePassProgressCommpleted(this, e);
     }
 }