public void SetProgress(ZipProgressEventArgs e)
        {
            switch (e.EventType)
            {
            case ZipProgressEventType.Saving_AfterWriteEntry:
            case ZipProgressEventType.Extracting_AfterExtractEntry:
                entryNo++;
                break;

            case ZipProgressEventType.Saving_Started:
            case ZipProgressEventType.Saving_BeforeWriteEntry:
            case ZipProgressEventType.Saving_AfterSaveTempArchive:
            case ZipProgressEventType.Saving_BeforeRenameTempArchive:
            case ZipProgressEventType.Saving_AfterRenameTempArchive:
            case ZipProgressEventType.Saving_Completed:
            case ZipProgressEventType.Extracting_BeforeExtractAll:
            case ZipProgressEventType.Extracting_BeforeExtractEntry:
            case ZipProgressEventType.Extracting_AfterExtractAll:
                break;

            default:
                if (buff++ % 100 != 0)
                {
                    return;
                }
                long progress = e.BytesTransferred * 100 / e.TotalBytesToTransfer;

                Console.WriteLine("Saving {0} ({1}%) ({2}/{3})", e.CurrentEntry.FileName, progress, entryNo, e.EntriesTotal);
                break;
            }
        }
Exemple #2
0
        private void ReportZipProgress(IVssWMComponent component, IDictionary <string, string> volumeMap,
                                       ZipProgressEventArgs e)
        {
            BackupProgressEventArgs ebp = null;

            if (e.EventType == ZipProgressEventType.Saving_Started)
            {
                ebp = new BackupProgressEventArgs()
                {
                    AcrhiveFileName = e.ArchiveName,
                    Action          = EventAction.StartingArchive
                };
            }
            else if (e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry ||
                     e.EventType == ZipProgressEventType.Saving_EntryBytesRead)
            {
                var action = e.EventType == ZipProgressEventType.Saving_BeforeWriteEntry
                    ? EventAction.StartingEntry
                    : EventAction.SavingEntry;

                ebp = new BackupProgressEventArgs()
                {
                    AcrhiveFileName      = e.ArchiveName,
                    Action               = action,
                    CurrentEntry         = e.CurrentEntry.FileName,
                    EntriesTotal         = e.EntriesTotal,
                    TotalBytesToTransfer = e.TotalBytesToTransfer,
                    BytesTransferred     = e.BytesTransferred
                };
            }
            else if (e.EventType == ZipProgressEventType.Saving_Completed)
            {
                ebp = new BackupProgressEventArgs()
                {
                    AcrhiveFileName = e.ArchiveName,
                    Action          = EventAction.ArchiveDone
                };
            }

            if (ebp != null)
            {
                ebp.Components = new Dictionary <string, string>
                {
                    { component.ComponentName, component.Caption }
                };
                ebp.VolumeMap = new Dictionary <string, string>();
                foreach (var volume in volumeMap)
                {
                    ebp.VolumeMap.Add(volume.Key, volume.Value);
                }

                BackupProgress(this, ebp);

                // Close the zip file operation neatly and throw the exception afterwards
                e.Cancel = ebp.Cancel;
            }
        }
Exemple #3
0
        void _zipFile_Progress(object sender, ZipProgressEventArgs e)
        {
            var pct = (int)(e.PositionLong * 100 / (e.FileLengthLong + 1));

            if (pct != _lastProgress)
            {
                _progressBar.Value   = pct;
                _progressBar.Visible = true;
                _lastProgress        = pct;
                Application.DoEvents();
            }
        }