예제 #1
0
        private void Report7ZipProgress(IVssWMComponent component, IDictionary <string, string> volumeMap,
                                        BackupProgressEventArgs ebp)
        {
            if (ebp == null)
            {
                return;
            }

            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);

            if (ebp.Cancel)
            {
                _cancel = true;
            }
        }
예제 #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;
            }
        }
예제 #3
0
        public static string GetFullPath(this IVssWMComponent component, IUIHost host)
        {
            string fullPath = AppendBackslash(component.LogicalPath) + component.ComponentName;

            if (!fullPath.StartsWith("\\"))
            {
                fullPath = "\\" + fullPath;
            }
            return(fullPath);
        }
예제 #4
0
        public VssComponentDescriptor(IUIHost host, string writerName, IVssWMComponent component)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component", "component is null.");
            }

            WriterName = writerName;

            FullPath = ExtensionMethods.AppendBackslash(component.LogicalPath) + component.ComponentName;
            if (!FullPath.StartsWith("\\"))
            {
                FullPath = "\\" + FullPath;
            }

            HashSet <string> affectedPaths   = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            HashSet <string> affectedVolumes = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (VssWMFileDescriptor file in component.Files)
            {
                affectedPaths.Add(file.GetExpandedPath());
                affectedVolumes.Add(file.GetAffectedVolume(host));
            }

            foreach (VssWMFileDescriptor file in component.DatabaseFiles)
            {
                affectedPaths.Add(file.GetExpandedPath());
                affectedVolumes.Add(file.GetAffectedVolume(host));
            }

            foreach (VssWMFileDescriptor file in component.DatabaseLogFiles)
            {
                affectedPaths.Add(file.GetExpandedPath());
                affectedVolumes.Add(file.GetAffectedVolume(host));
            }

            m_affectedPaths        = new List <string>(affectedPaths.OrderBy(path => path, StringComparer.OrdinalIgnoreCase));
            m_affectedVolumes      = new List <string>(affectedVolumes.OrderBy(path => path, StringComparer.OrdinalIgnoreCase));
            Caption                = component.Caption;
            ComponentName          = component.ComponentName;
            LogicalPath            = component.LogicalPath;
            RestoreMetadata        = component.RestoreMetadata;
            IsSelectable           = component.Selectable;
            ComponentType          = component.Type;
            NotifyOnBackupComplete = component.NotifyOnBackupComplete;

            Files            = new List <VssWMFileDescriptor>(component.Files);
            DatabaseFiles    = new List <VssWMFileDescriptor>(component.DatabaseFiles);
            DatabaseLogFiles = new List <VssWMFileDescriptor>(component.DatabaseLogFiles);
            Dependencies     = new List <VssWMDependency>(component.Dependencies);
        }
      public VssComponentDescriptor(IUIHost host, string writerName, IVssWMComponent component)
      {
         if (component == null)
            throw new ArgumentNullException("component", "component is null.");
         
         WriterName = writerName;

         FullPath = ExtensionMethods.AppendBackslash(component.LogicalPath) + component.ComponentName;
         if (!FullPath.StartsWith("\\"))
            FullPath = "\\" + FullPath;

         HashSet<string> affectedPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
         HashSet<string> affectedVolumes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

         foreach (VssWMFileDescriptor file in component.Files)
         {
            affectedPaths.Add(file.GetExpandedPath());
            affectedVolumes.Add(file.GetAffectedVolume(host));
         }

         foreach (VssWMFileDescriptor file in component.DatabaseFiles)
         {
            affectedPaths.Add(file.GetExpandedPath());
            affectedVolumes.Add(file.GetAffectedVolume(host));
         }

         foreach (VssWMFileDescriptor file in component.DatabaseLogFiles)
         {
            affectedPaths.Add(file.GetExpandedPath());
            affectedVolumes.Add(file.GetAffectedVolume(host));
         }

         m_affectedPaths = new List<string>(affectedPaths.OrderBy(path => path, StringComparer.OrdinalIgnoreCase));
         m_affectedVolumes = new List<string>(affectedVolumes.OrderBy(path => path, StringComparer.OrdinalIgnoreCase));
         Caption = component.Caption;
         ComponentName = component.ComponentName;
         LogicalPath = component.LogicalPath;
         RestoreMetadata = component.RestoreMetadata;
         IsSelectable = component.Selectable;
         ComponentType = component.Type;
         NotifyOnBackupComplete = component.NotifyOnBackupComplete;
         
         Files = new List<VssWMFileDescriptor>(component.Files);
         DatabaseFiles = new List<VssWMFileDescriptor>(component.DatabaseFiles);
         DatabaseLogFiles = new List<VssWMFileDescriptor>(component.DatabaseLogFiles);
         Dependencies = new List<VssWMDependency>(component.Dependencies);
      }      
예제 #6
0
        private List <string> GetPathsFromComponent(IVssWMComponent component)
        {
            var paths = new List <string>();

            foreach (var file in component.Files)
            {
                if (file.FileSpecification.Contains("*"))
                {
                    if (Directory.Exists(Util.AppendDirSeparator(file.Path)))
                    {
                        paths.Add(Util.AppendDirSeparator(file.Path));
                    }
                }
                else
                {
                    var fileWithSpec = SystemIO.IO_WIN.PathCombine(file.Path, file.FileSpecification);
                    if (File.Exists(fileWithSpec))
                    {
                        paths.Add(fileWithSpec);
                    }
                }
            }
            return(paths);
        }
예제 #7
0
        private void Report7ZipProgress(IVssWMComponent component, IDictionary<string, string> volumeMap, BackupProgressEventArgs ebp)
        {
            if (ebp == null)
                return;

            ebp.Components = new Dictionary<string, string>();
            ebp.Components.Add(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);

            if (ebp.Cancel)
            {
                cancel = true;
            }
        }