Esempio n. 1
0
        /// <summary>
        /// Creates the segment progress tracker.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        /// <returns></returns>
        private IProgress <SegmentUploadProgress> CreateSegmentProgressTracker(UploadMetadata metadata)
        {
            if (_progressTracker == null)
            {
                return(null);
            }

            var overallProgress = new UploadProgress(metadata);

            return(new Progress <SegmentUploadProgress>(
                       (sup) =>
            {
                //update the overall progress and report it back
                overallProgress.SetSegmentProgress(sup);
                _progressTracker.Report(overallProgress);
            }));
        }
Esempio n. 2
0
        /// <summary>
        /// Populates the specified metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        private void Populate(UploadFolderMetadata metadata)
        {
            this.TotalFileLength = metadata.TotalFileBytes;
            this.TotalFileCount  = metadata.FileCount;
            _fileProgress        = new List <UploadProgress>(this.TotalFileCount);
            _progressBacklog     = new ConcurrentQueue <UploadProgress>();

            foreach (var fileMetadata in metadata.Files)
            {
                var toAdd = new UploadProgress(fileMetadata);
                if (fileMetadata.Status == SegmentUploadStatus.Complete)
                {
                    this.UploadedByteCount += fileMetadata.FileLength;
                    this.UploadedFileCount++;
                    toAdd.UploadedByteCount = toAdd.TotalFileLength;
                    foreach (var segment in toAdd._segmentProgress)
                    {
                        segment.UploadedByteCount = segment.Length;
                    }
                }

                _fileProgress.Add(toAdd);
            }
        }
Esempio n. 3
0
 internal void SetSegmentProgress(UploadProgress segmentProgress)
 {
     _progressBacklog.Enqueue(segmentProgress);
 }
        /// <summary>
        /// Creates the segment progress tracker.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        /// <returns></returns>
        private IProgress<SegmentUploadProgress> CreateSegmentProgressTracker(UploadMetadata metadata)
        {
            if (_progressTracker == null)
            {
                return null;
            }
         
            var overallProgress = new UploadProgress(metadata);
            return new Progress<SegmentUploadProgress>(
                (sup) =>
                {
                    //update the overall progress and report it back
                    overallProgress.SetSegmentProgress(sup);
                    _progressTracker.Report(overallProgress);
                });

        }