Exemple #1
0
        // show FTP file transfer progress
        public void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            int percent = (int)(e.FileProgress * 100);

            // New line for every new file
            if ((_lastFileName != null) && (_lastFileName != e.FileName))
            {
                Debug.WriteLine("");
            }
            // Print transfer progress
            Debug.WriteLine("\r{0} ({1:P0})", e.FileName, e.FileProgress);
            this.progressBar1.Value = percent;
            // Manage the label
            if (downloading == 1)
            {
                this.toolStripStatusLabel1.Text = "Downloading: " + percent.ToString() + " %";
            }
            else
            {
                this.toolStripStatusLabel1.Text = "Uploading: " + percent.ToString() + " %";
            }
            this.toolStripStatusLabel1.Text = e.FileName.ToString();
            // Remember a name of the last file reported
            _lastFileName = e.FileName;
        }
Exemple #2
0
        internal static async Task HandleAsync(FileTransferProgressEventArgs e)
        {
#if NOTIFICATIONHANDLER_DEBUGINFO
            Debug.WriteLine("Notification received: " + e.CurrentPart + " / " + e.Total + " (" + e.State.ToString() + ")");
#endif
            bool UISuccess = false;
            if ((CoreApplication.MainView.CoreWindow?.Dispatcher != null) && (MainPage.Current != null))
            {
                UISuccess = true;
#if NOTIFICATIONHANDLER_DEBUGINFO
                Debug.WriteLine("Dispatcher present and MainPage exists.");
#endif
                await DispatcherEx.RunTaskAsync(CoreApplication.MainView.CoreWindow.Dispatcher, async() =>
                {
                    //If app is minimized, send notifications but update the title too.
                    if (!Window.Current.Visible)
                    {
                        UISuccess = false;
                    }

#if NOTIFICATIONHANDLER_DEBUGINFO
                    Debug.WriteLine("Window.Current.Visible is true");
#endif

                    await MainPage.Current.FileTransferProgress(e);
                });
            }
        }
Exemple #3
0
 private void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
 {
     // Print transfer progress
     Dispatcher.Invoke(() =>
     {
         lbStatus.Content = $"Downloading: {e.FileName} - ({e.FileProgress:P0})";
     });
 }
        private void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            // Print transfer progress
            LOG.InfoFormat("\r{0} ({1:P0} CPS = {2})", e.FileName, e.FileProgress, e.CPS);

            // Remember a name of the last file reported
            m_lastFileName = e.FileName;
        }
Exemple #5
0
 //ce déclenche quand il y a du progrès dans le téléchargement
 //met à jour la barre de progression
 private void Session_FileTransferProgress(object sender, FileTransferProgressEventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         PB_Progress.Value = e.OverallProgress;
         L_Main.Content    = "[" + ct + "/" + ctmax + "]" + System.IO.Path.GetFileName(e.FileName) + "[" + e.FileProgress * 100 + "%] @" + (e.CPS / 1000) + "Kb/s";
     });
 }
Exemple #6
0
        /// <summary>
        /// Listener for the file transfer progress event which logs upload progress to the console.
        /// </summary>
        void LogProgress(object sender, FileTransferProgressEventArgs e)
        {
            if (lastFileName != e.FileName)
            {
                Console.WriteLine("Uploading {0}...", e.FileName);
            }

            lastFileName = e.FileName;
        }
Exemple #7
0
        protected virtual void OnFileTransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            //Console.WriteLine(e.FileName + ": " + e.FileProgress.ToString());   //e.FileProgress: percent
            var localCopy = OnTransferProgress;

            if (localCopy != null)
            {
                localCopy(this, new PassingValueByEventArgs((long)(e.FileProgress * 100), (long)100, e.FileName));
            }
        }
Exemple #8
0
 private void m_xmppClient_FileTransferProgress(object sender, FileTransferProgressEventArgs e)
 {
     if ((e.Transfer.Transferred / e.Transfer.Size) == 1L)
     {
         this.m_boolSendFileResult = true;
         Monitor.Enter(this.m_lock);
         Monitor.Pulse(this.m_lock);
         Monitor.Exit(this.m_lock);
         CommonConfig.Logger.WriteInfo("文件已发送完成100%");
     }
 }
Exemple #9
0
        private static void SessionFileTransferProgress(
            object sender, FileTransferProgressEventArgs e)
        {
            if ((_lastFileName != null) && (_lastFileName != e.FileName))
            {
                Console.WriteLine();
            }

            Console.Write("\r{0} ({1:P0})", e.FileName, e.FileProgress);

            _lastFileName = e.FileName;
        }
        private static void UploadProgress(UploadProgressChangedEventArgs e, string fileName, int id)
        {
            decimal pp      = (decimal)e.BytesSent / (decimal)e.TotalBytesToSend;
            int     percent = (int)Math.Round(pp * 100);

            if (percent > downloadProgressNextTick)
            {
                FileTransferProgressEventArgs args = new FileTransferProgressEventArgs();
                args.PercentProgress = percent;
                args.ID = id;
                FileUploadProgress?.Invoke(null, args);
                downloadProgressNextTick = percent + downloadProgressTreshold;
            }
        }
Exemple #11
0
        private static void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            // New line for every new file
            if ((_lastFileName != null) && (_lastFileName != e.FileName))
            {
                Console.WriteLine();
            }

            // Print transfer progress
            Console.Write("\r{0} ({1:P0})", e.FileName, e.FileProgress);

            // Remember a name of the last file reported
            _lastFileName = e.FileName;
        }
Exemple #12
0
        private void TransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            DarkFileDisplay dfd = FileDisplayList.Find(x => x.FileStructure.FileID == e.ID);

            if (dfd == null)
            {
                return;
            }


            if (mainForm.InvokeRequired)
            {
                mainForm.Invoke((MethodInvoker) delegate { dfd.UpdateProgress(e.PercentProgress); });
            }
        }
Exemple #13
0
        private void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            Dispatcher.Invoke(new Action(() =>
            {
                if (_lastFileProcessed != null && _lastFileProcessed != e.FileName)
                {
                    fileName.Content = String.Format("File [{0}] processed.", e.FileName);
                }
                fileProgress.Value     = e.FileProgress * 100;
                filePercentage.Content = String.Format("{0:P0}", e.FileProgress);
            }));

            // Remember a name of the last file reported
            _lastFileProcessed = e.FileName;
        }
Exemple #14
0
        internal void FileTransferProgress(FileTransferProgressEventArgs e)
        {
            if (e.State == FileTransferState.Finished)
            {
                Finish();
                return;
            }

            ViewModel.ProgressIsIndeterminate            = false;
            ViewModel.ProgressPercentIndicatorVisibility = Visibility.Visible;
            ViewModel.ReceiveStatus = "Receiving...";

            ViewModel.ProgressValue   = (int)e.CurrentPart;
            ViewModel.ProgressMaximum = (int)e.Total;
        }
Exemple #15
0
        private void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            // Print transfer progress
            this.progressBar1.Maximum = 100;
            this.progressBar1.Minimum = 0;
            var a = e.OverallProgress * 100;
            int i = Convert.ToInt32(a.ToString());

            this.progressBar1.Value = i;
            txt_progress.Text       = a.ToString() + " % ";

            // New line for every new file
            if ((_lastFileName != null) && (_lastFileName != e.FileName))
            {
            }

            // Print transfer progress

            // Remember a name of the last file reported
            _lastFileName = e.FileName;
        }
Exemple #16
0
        internal void FileTransferProgress(FileTransferProgressEventArgs e)
        {
            if (e.State == FileTransferState.Finished || e.State == FileTransferState.Error)
            {
                Finish();
                return;
            }

            if (e.Total == 0)
            {
                return;
            }

            ViewModel.ProgressIsIndeterminate            = false;
            ViewModel.ProgressPercentIndicatorVisibility = Visibility.Visible;
            ViewModel.ReceiveStatus = "Receiving...";

            ViewModel.ProgressValue   = (int)e.CurrentPart;
            ViewModel.ProgressMaximum = (int)e.Total;

            ViewModel.ProgressCaption = StringFunctions.GetSizeString(e.TotalBytesTransferred);
        }
        // Temporarily checked out because of it's direct relation to ConfigR
        //public void Open()
        //{
        //    Process.Start("explorer.exe", GlobalParameters.ConfigurationFolder);
        //}

        private void FileTransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            var attr = File.GetAttributes(e.FileName);

            if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                return;

            Application.Current.Dispatcher.Invoke(() =>
            {
                var info = FileStatusInformations.FirstOrDefault(x => x.Path == e.FileName);
                if (info == null)
                {
                    info = new Status() {Path = e.FileName};
                    FileStatusInformations.Add(info);
                }

                info.Progress = (int) (e.FileProgress * 100);
            });

            CPS = e.CPS;
            OverallProgress = e.OverallProgress * 100;
        }
Exemple #18
0
        private void _xmppClient_FileTransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            i++;

            if (e.Transfer.From == xmppClient.Jid)
            {
                //direct = TVFileTransferEventArgs.DirectionEnum.Outgoing;
            }
            else
            {
                // direct = TVFileTransferEventArgs.DirectionEnum.Incoming;
            }

            int progress = (int)((100.0 * e.Transfer.Transferred) / e.Transfer.Size);

            //Check if file has finished transfer
            if (e.Transfer.Transferred == e.Transfer.Size)
            {
                //if (FileEnded != null)
                //{
                //}
            }
            else //else file has not finished transfer
            {
                //Displays information only every 5% of progress
                //if (fileTransferProgress / e.Transfer.Size >= 0.05)
                if (i > 9)
                {
                    i = 0;
                    uiDispatcher.multiDebug("File progress continued from" + e.ToString() + " " + e.Transfer.Transferred + " bytes out of" + "transferred" + e.Transfer.Size);
                    // = e.Transfer.Size;
                }
                else
                {
                    //fileTransferProgress = e.Transfer.Transferred - fileTransferProgress;
                }
            }
        }
Exemple #19
0
        /// <summary>
        /// Sends a packet with the new chunk
        /// </summary>
        private void SendChunk()
        {
            // Update progress
            //decimal pp = (decimal)ReadIndex / (decimal)FileBuffer.Length;
            decimal pp      = (decimal)ReadIndex / (decimal)SelectedFileStructure.FileSize;
            int     percent = (int)Math.Round(pp * 100);

            if (percent > DownloadProgressNextTick)
            {
                FileTransferProgressEventArgs args = new FileTransferProgressEventArgs();
                args.PercentProgress = percent;
                args.ID       = LocalTransferID;
                args.FileName = SelectedFileStructure.FullName;
                OutTransferProgress?.Invoke(null, args);
                DownloadProgressNextTick = percent + DownloadProgressTreshold;
            }

            DataCarryPacket dcp = CreateDataPacket();

            NetComm.SendByteArray(dcp.ToByteArray(), TargetEndPoint);
            LastActionSnapshot = timer.ElapsedMilliseconds;
            //DataCarryPacket dcp = new DataCarryPacket(NextBlockNumber, TransferID, )
        }
Exemple #20
0
        private void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
        {
            string _lastFileName = "";
            int    currentindex  = 0;

            // Grab file name
            string[] filename_array = e.FileName.Split('/');

            // New line for every new file
            if (_lastFileName != e.FileName)
            {
                foreach (ListViewItem theitem in Transfer_Progress_List.Items)
                {
                    if (theitem.SubItems[0].Text.Split('(')[0] == filename_array[filename_array.Length - 1])
                    {
                        currentindex = theitem.Index;
                        Transfer_Progress_List.Items[currentindex].EnsureVisible();
                    }
                }
            }

            // Print transfer progress
            double progess_percent = e.FileProgress * 100;

            // Use "Done" instead of 100%
            if (progess_percent == 100)
            {
                Transfer_Progress_List.Items[currentindex].SubItems[1].Text = "Done";
            }
            else
            {
                Transfer_Progress_List.Items[currentindex].SubItems[1].Text = progess_percent + "%";
            }

            // Remember a name of the last file reported
            _lastFileName = e.FileName;
        }
Exemple #21
0
 static void ProgressChanged(object sender, FileTransferProgressEventArgs e)
 {
     currentBar.Report(e.FileProgress);
 }
        public async static Task <bool> DownloadFile(string fileName, int id, string authToken)
        {
            string tempfile = Path.Combine(Constants.API_FILE_DOWNLOAD_FOLDER, fileName);

            var request = new HttpRequestMessage(HttpMethod.Get, Constants.API_FILEHOST_GET_FILE);

            request.Headers.Add("File-Name", fileName);
            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authToken);


            HttpResponseMessage response = await ApiClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);


            if (response.StatusCode != HttpStatusCode.OK)
            {
                // Something wrong
                FileDownloadResultEventArgs result_args = new FileDownloadResultEventArgs();
                result_args.Successful = false;
                result_args.FileName   = fileName;
                result_args.Reason     = response.ReasonPhrase;
                FileDownloadFailure?.Invoke(null, result_args);
                return(false);
            }

            var totalBytes = 0L;

            if (response.Headers.Contains("File-Size"))
            {
                totalBytes = Convert.ToInt64(response.Headers.GetValues("File-Size").FirstOrDefault());
            }

            Stream contentStream = await response.Content.ReadAsStreamAsync();

            FileStream fileStream = new FileStream(tempfile, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true);


            var totalRead    = 0L;
            var totalReads   = 0L;
            var buffer       = new byte[8192];
            var isMoreToRead = true;

            do
            {
                var read = await contentStream.ReadAsync(buffer, 0, buffer.Length);

                if (read == 0)
                {
                    isMoreToRead = false;
                }
                else
                {
                    await fileStream.WriteAsync(buffer, 0, read);

                    totalRead  += read;
                    totalReads += 1;

                    if (totalReads % 2000 == 0)
                    {
                        FileTransferProgressEventArgs progress_args = new FileTransferProgressEventArgs();
                        progress_args.FileName = fileName;
                        progress_args.ID       = id;
                        decimal pp = (decimal)totalRead / (decimal)totalBytes;

                        progress_args.PercentProgress = (int)Math.Round(pp * 100);

                        FileDownloadProgress?.Invoke(null, progress_args);


                        //Console.WriteLine(string.Format("total bytes downloaded so far: {0:n0}", totalRead));
                    }
                }
            }while (isMoreToRead);



            FileDownloadResultEventArgs args = new FileDownloadResultEventArgs();

            args.Successful = true;
            args.FileName   = fileName;
            args.ID         = id;

            FileDownloadSuccessful?.Invoke(null, args);

            return(true);
        }
Exemple #23
0
 public void OnFileTransferProgress(object sender, FileTransferProgressEventArgs e)
 {
     // Print out the progress of the file-transfer operation.
     Invoke(new AddMessageDelegate(LogAdd), new object[] { ("Transferring " + e.Transfer.Name + "..." +
                                                            e.Transfer.Transferred + "/" + e.Transfer.Size + " Bytes") });
 }
Exemple #24
0
 private static void OutTransferProgress(object sender, FileTransferProgressEventArgs e)
 {
     OutboundTransferProgress?.Invoke(null, e);
 }
Exemple #25
0
 private void UploadProgress(object sender, FileTransferProgressEventArgs e)
 {
     throw new NotImplementedException();
 }
Exemple #26
0
 private void sessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
 {
     onProgress(Convert.ToInt32(e.OverallProgress * 100), e.CPS);
 }
 private void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
 {
     bpLoadFile.Value = Convert.ToInt32(e.FileProgress * 100);
     bpLoadFile.Update();
 }
Exemple #28
0
 private void SessionFileTransferProgress(object sender, FileTransferProgressEventArgs e)
 {
     Console.Write("\r{0} ({1:P0})", e.FileName, e.FileProgress);
 }
Exemple #29
0
 void session_FileTransferProgress(object sender, FileTransferProgressEventArgs e)
 {
     log.Info(string.Format("檔案傳輸進度: {0}檔案傳輸進度 {1} %", e.FileName, e.FileProgress * 100));
 }
Exemple #30
0
 private void DownloadProgress_StateChanged(object sender, FileTransferProgressEventArgs e)
 {
     OnDataDownloadProgress?.Invoke(this, e);
 }