示例#1
0
        private static void TransferCallback(FTPSClient sender, ETransferActions action, string localObjectName, string remoteObjectName, ulong fileTransmittedBytes, ulong?fileTransferSize, ref bool cancel)
        {
            switch (action)
            {
            case ETransferActions.FileDownloaded:
            case ETransferActions.FileUploaded:
                OnFileTransferCompleted(fileTransmittedBytes, fileTransferSize);
                break;

            case ETransferActions.FileDownloadingStatus:
            case ETransferActions.FileUploadingStatus:
                OnFileTransferStatus(action, localObjectName, remoteObjectName, fileTransmittedBytes, fileTransferSize);
                break;

            case ETransferActions.RemoteDirectoryCreated:
                if (options.verbose)
                {
                    Console.WriteLine();
                    Console.WriteLine("Remote directory created: " + remoteObjectName);
                }
                break;

            case ETransferActions.LocalDirectoryCreated:
                if (options.verbose)
                {
                    Console.WriteLine();
                    Console.WriteLine("Local directory created: " + localObjectName);
                }
                break;
            }
        }
示例#2
0
        private static void OnFileTransferStatus(ETransferActions action, string localObjectName, string remoteObjectName, ulong fileTransmittedBytes, ulong?fileTransferSize)
        {
            if (fileTransmittedBytes == 0)
            {
                // Download / upload start

                watch.Reset();
                watch.Start();

                lastCharPos = 0;

                Console.WriteLine();

                if (action == ETransferActions.FileDownloadingStatus)
                {
                    Console.WriteLine("Source (remote): " + remoteObjectName);
                    Console.WriteLine("Dest (local): " + localObjectName);
                }
                else
                {
                    Console.WriteLine("Source (local): " + localObjectName);
                    Console.WriteLine("Dest (remote): " + remoteObjectName);
                }

                Console.Write("File Size: ");
                if (fileTransferSize != null)
                {
                    Console.WriteLine(fileTransferSize.Value.ToString("N0") + " Byte");
                    Console.WriteLine();
                    Console.WriteLine("0%".PadRight(consoleFormatWidth - 4, ' ') + "100%");
                }
                else
                {
                    Console.WriteLine("Unknown");
                }
            }
            else if (fileTransferSize != null)
            {
                // Download / upload progress

                int charPos = (int)(fileTransmittedBytes * (ulong)consoleFormatWidth / fileTransferSize);

                if (charPos - lastCharPos > 0)
                {
                    Console.Write(new String('.', charPos - lastCharPos));
                    lastCharPos = charPos;
                }
            }
        }
示例#3
0
 private void CallTransferCallback(FileTransferCallback transferCallback, ETransferActions transferAction, 
                                   string localObjectName, string remoteObjectName,
                                   ulong fileTransmittedBytes, ulong? fileTransferSize)
 {
     if (transferCallback != null)
     {
         bool cancel = false;
         transferCallback(this, transferAction, localObjectName, remoteObjectName, fileTransmittedBytes, fileTransferSize, ref cancel);
         if (cancel)
             throw new FTPOperationCancelledException("Operation cancelled by the user");
     }
 }
示例#4
0
文件: Upload.cs 项目: mard/Uploader
 private static void TransferCallback(FTPSClient sender, ETransferActions action, string localObjectName, string remoteObjectName, ulong fileTransmittedBytes, ulong? fileTransferSize, ref bool cancel)
 {
     switch (action)
     {
         case ETransferActions.FileDownloaded:
         case ETransferActions.FileUploaded:
             //OnFileTransferCompleted(fileTransmittedBytes, fileTransferSize);
             break;
         case ETransferActions.FileDownloadingStatus:
         case ETransferActions.FileUploadingStatus:
             //OnFileTransferStatus(action, localObjectName, remoteObjectName, fileTransmittedBytes, fileTransferSize);
             break;
         case ETransferActions.RemoteDirectoryCreated:
             //if (options.verbose)
             {
                 Console.WriteLine();
                 Console.WriteLine("Remote directory created: " + remoteObjectName);
             }
             break;
         case ETransferActions.LocalDirectoryCreated:
             //if (options.verbose)
             {
                 Console.WriteLine();
                 Console.WriteLine("Local directory created: " + localObjectName);
             }
             break;
     }
 }
示例#5
0
        private static void OnFileTransferStatus(ETransferActions action, string localObjectName, string remoteObjectName, ulong fileTransmittedBytes, ulong? fileTransferSize)
        {
            if (fileTransmittedBytes == 0)
            {
                // Download / upload start

                watch.Reset();
                watch.Start();

                lastCharPos = 0;

                Console.WriteLine();

                if (action == ETransferActions.FileDownloadingStatus)
                {
                    Console.WriteLine("Source (remote): " + remoteObjectName);
                    Console.WriteLine("Dest (local): " + localObjectName);
                }
                else
                {
                    Console.WriteLine("Source (local): " + localObjectName);
                    Console.WriteLine("Dest (remote): " + remoteObjectName);
                }

                Console.Write("File Size: ");
                if (fileTransferSize != null)
                {
                    Console.WriteLine(fileTransferSize.Value.ToString("N0") + " Byte");
                    Console.WriteLine();
                    Console.WriteLine("0%".PadRight(consoleFormatWidth - 4, ' ') + "100%");
                }
                else
                    Console.WriteLine("Unknown");
            }
            else if (fileTransferSize != null)
            {
                // Download / upload progress

                int charPos = (int)(fileTransmittedBytes * (ulong)consoleFormatWidth / fileTransferSize);

                if (charPos - lastCharPos > 0)
                {
                    Console.Write(new String('.', charPos - lastCharPos));
                    lastCharPos = charPos;
                }
            }
        }