internal List <BackupPathEntry> GetBackupPathEntries(int backupID, string selectedBackupPath) { List <BackupPathEntry> relevantEntries = new List <BackupPathEntry>(); foreach (BackupFileInfo fileEntry in _backupDB.GetBackupFiles(backupID)) { if (string.IsNullOrEmpty(selectedBackupPath) || fileEntry.FileFullPath.StartsWith(selectedBackupPath + Path.DirectorySeparatorChar)) { string remainingPath; if (string.IsNullOrEmpty(selectedBackupPath)) { remainingPath = fileEntry.FileFullPath; } else { remainingPath = fileEntry.FileFullPath.Replace(selectedBackupPath + Path.DirectorySeparatorChar, ""); } string[] remainingPathParts = remainingPath.Split(Path.DirectorySeparatorChar); BackupPathEntry pathEntry = new BackupPathEntry(); if (remainingPathParts.Length > 1) { pathEntry.IsDirectory = true; } else { pathEntry.IsDirectory = false; } pathEntry.Name = remainingPathParts[0]; bool alreadyExists = false; foreach (BackupPathEntry otherEntry in relevantEntries) { if (otherEntry.Name.Equals(pathEntry.Name)) { alreadyExists = true; } } if (!alreadyExists) { relevantEntries.Add(pathEntry); } } } return(relevantEntries); }
private void RestoreSelectedItem() { if (lstV_BrowseList.SelectedItems.Count == 1) { Dictionary <string, string> restoreList = null; if (_selectedBackupID == null) { BackupInfo backup = (BackupInfo)lstV_BrowseList.SelectedItems[0].Tag; restoreList = _restoreManager.GetRestoreFilesByBackupID(backup.EntryID); } else { BackupPathEntry pathEntry = (BackupPathEntry)lstV_BrowseList.SelectedItems[0].Tag; restoreList = _restoreManager.GetRestoreFilesByBackupIDAndPartialPath(_selectedBackupID.Value, Path.Combine(_selectedBackupPath, pathEntry.Name)); } RestoreFilesWithDestinationSelection(restoreList); } }
private void OpenSelectedItem() { if (lstV_BrowseList.SelectedItems.Count == 1) { if (_selectedBackupID == null) { BackupInfo selectedBackup = (BackupInfo)lstV_BrowseList.SelectedItems[0].Tag; _selectedBackupID = selectedBackup.EntryID; } else { BackupPathEntry pathEntry = (BackupPathEntry)lstV_BrowseList.SelectedItems[0].Tag; if (pathEntry.IsDirectory) { _selectedBackupPath = Path.Combine(_selectedBackupPath, pathEntry.Name); } } RenderList(); btn_Up.Enabled = true; } }
private void UpdateButtonStates() { if (lstV_BrowseList.SelectedItems.Count == 1) { if (_selectedBackupID == null) { btn_Open.Enabled = true; } else { BackupPathEntry pathEntry = (BackupPathEntry)lstV_BrowseList.SelectedItems[0].Tag; btn_Open.Enabled = pathEntry.IsDirectory; } btn_Restore.Enabled = true; } else { btn_Open.Enabled = false; btn_Restore.Enabled = false; } }
private void SelectOneItem() { if (lstV_BrowseList.SelectedItems.Count == 1) { if (_selectedBackupID != null) { BackupPathEntry pathEntry = (BackupPathEntry)lstV_BrowseList.SelectedItems[0].Tag; if (!pathEntry.IsDirectory) { DialogResult restoreFileAnswer = MessageBox.Show(_generalResourceManager.GetString("RestoreActionConfirmationText").Replace("{SelectedItem}", pathEntry.Name), _generalResourceManager.GetString("RestoreActionConfirmationTitle"), MessageBoxButtons.YesNo); if (restoreFileAnswer == DialogResult.Yes) { RestoreSelectedItem(); } } else { OpenSelectedItem(); } } OpenSelectedItem(); } }
internal List<BackupPathEntry> GetBackupPathEntries(int backupID, string selectedBackupPath) { List<BackupPathEntry> relevantEntries = new List<BackupPathEntry>(); foreach (BackupFileInfo fileEntry in _backupDB.GetBackupFiles(backupID)) { if (string.IsNullOrEmpty(selectedBackupPath) || fileEntry.FileFullPath.StartsWith(selectedBackupPath + Path.DirectorySeparatorChar)) { string remainingPath; if (string.IsNullOrEmpty(selectedBackupPath)) remainingPath = fileEntry.FileFullPath; else remainingPath = fileEntry.FileFullPath.Replace(selectedBackupPath + Path.DirectorySeparatorChar, ""); string[] remainingPathParts = remainingPath.Split(Path.DirectorySeparatorChar); BackupPathEntry pathEntry = new BackupPathEntry(); if (remainingPathParts.Length > 1) pathEntry.IsDirectory = true; else pathEntry.IsDirectory = false; pathEntry.Name = remainingPathParts[0]; bool alreadyExists = false; foreach (BackupPathEntry otherEntry in relevantEntries) if (otherEntry.Name.Equals(pathEntry.Name)) alreadyExists = true; if (!alreadyExists) relevantEntries.Add(pathEntry); } } return relevantEntries; }