SIL.FieldWorks.FieldWorks.BackupProjectForRestore C# (CSharp) Méthode

BackupProjectForRestore() private static méthode

Backs up the project that is about to be restored.
private static BackupProjectForRestore ( SIL.FieldWorks.FwRestoreProjectSettings restoreSettings, SIL.FieldWorks.FDO.FdoCache existingCache, Form dialogOwner ) : bool
restoreSettings SIL.FieldWorks.FwRestoreProjectSettings The restore settings.
existingCache SIL.FieldWorks.FDO.FdoCache The existing cache for the project to backup, or null /// to create a new cache for the project defined in the restore settings.
dialogOwner System.Windows.Forms.Form A form that can be used as an owner for progress dialog/ /// message box.
Résultat bool
		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;
		}
FieldWorks