public void Initialize() { m_backupSettings = new DummyBackupProjectSettings(m_testProjectsRoot, TestProjectName, null, FDOBackendProviderType.kXML) { Comment = "Test comment", }; m_backupProjectService = new ProjectBackupService(Cache, m_backupSettings); }
public void Initialize() { m_backupSettings = new DummyBackupProjectSettings(m_testProjectsRoot, TestProjectName, m_linkedFilesRootDir, FDOBackendProviderType.kXML) { Comment = "Test comment", }; SetupCacheToTestAgainst(); m_backupProjectService = new ProjectBackupService(Cache, m_backupSettings); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Backs up the project. /// </summary> /// <returns>The path to the backup file, or <c>null</c></returns> /// ------------------------------------------------------------------------------------ internal string BackupProject(IThreadedProgress progressDlg) { BackupProjectSettings settings = new BackupProjectSettings(m_cache, m_backupProjectView, FwDirectoryFinder.DefaultBackupDirectory); settings.DestinationFolder = m_backupProjectView.DestinationFolder; settings.AppAbbrev = m_appAbbrev; ProjectBackupService backupService = new ProjectBackupService(m_cache, settings); string backupFile; if (!backupService.BackupProject(progressDlg, out backupFile)) { string msg = string.Format(FwCoreDlgs.ksCouldNotBackupSomeFiles, backupService.FailedFiles.ToString(", ", Path.GetFileName)); if (MessageBox.Show(msg, FwCoreDlgs.ksWarning, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) File.Delete(backupFile); backupFile = null; } return backupFile; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Backs up the project that is about to be restored. /// </summary> /// <param name="restoreSettings">The restore settings.</param> /// <param name="existingCache">The existing cache for the project to backup, or null /// to create a new cache for the project defined in the restore settings.</param> /// <param name="dialogOwner">A form that can be used as an owner for progress dialog/ /// message box.</param> /// <returns><c>true</c> to indicate that it is okay to proceed with the restore; /// <c>false</c> to indicate that the backup failed and the user wasn't comfortable /// with just blindly going ahead with a restore that could potentially leave him in /// tears.</returns> /// ------------------------------------------------------------------------------------ private static bool BackupProjectForRestore(FwRestoreProjectSettings restoreSettings, FdoCache existingCache, Form dialogOwner) { using (var progressDlg = new ProgressDialogWithTask(dialogOwner)) { FdoCache cache = existingCache ?? FdoCache.CreateCacheFromExistingData( new ProjectId(restoreSettings.Settings.FullProjectPath, null), s_sWsUser, s_ui, FwDirectoryFinder.FdoDirectories, CreateFdoSettings(), progressDlg); try { var backupSettings = new BackupProjectSettings(cache, restoreSettings.Settings, FwDirectoryFinder.DefaultBackupDirectory); backupSettings.DestinationFolder = FwDirectoryFinder.DefaultBackupDirectory; backupSettings.AppAbbrev = restoreSettings.FwAppCommandLineAbbrev; var backupService = new ProjectBackupService(cache, backupSettings); string backupFile; if (!backupService.BackupProject(progressDlg, out backupFile)) { string msg = string.Format(FwCoreDlgs.FwCoreDlgs.ksCouldNotBackupSomeFiles, backupService.FailedFiles.ToString(", ", Path.GetFileName)); if (MessageBox.Show(msg, FwCoreDlgs.FwCoreDlgs.ksWarning, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) File.Delete(backupFile); } } catch (FwBackupException e) { if (MessageBox.Show(dialogOwner, string.Format(FwCoreDlgs.FwCoreDlgs.ksBackupErrorCreatingZipfile, e.ProjectName, e.Message) + Environment.NewLine + Environment.NewLine + Properties.Resources.ksBackupErrorDuringRestore, FwCoreDlgs.FwCoreDlgs.ksBackupErrorCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return false; } } finally { if (existingCache == null) // We created a new cache so we need to dispose of it cache.Dispose(); } } return true; }