Inheritance: System.Windows.Forms.Form
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor for normal mode where the user can pick a backup to restore
		/// </summary>
		/// <param name="restoreProjectView">The restore project view.</param>
		/// <param name="defaultProjectName">Default name of the project.</param>
		/// ------------------------------------------------------------------------------------
		public RestoreProjectPresenter(RestoreProjectDlg restoreProjectView,
			string defaultProjectName) : this(restoreProjectView)
		{
			m_backupFiles = new BackupFileRepository(FwDirectoryFinder.DefaultBackupDirectory);
			m_defaultProjectName = defaultProjectName;
			m_fEmptyProjectName = false;
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Constructor for normal mode where the user can pick a backup to restore
 /// </summary>
 /// <param name="restoreProjectView">The restore project view.</param>
 /// <param name="defaultProjectName">Default name of the project.</param>
 /// ------------------------------------------------------------------------------------
 public RestoreProjectPresenter(RestoreProjectDlg restoreProjectView,
                                string defaultProjectName) : this(restoreProjectView)
 {
     m_backupFiles        = new BackupFileRepository();
     m_defaultProjectName = defaultProjectName;
     m_fEmptyProjectName  = false;
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// General constructor (use for constrained mode where the backup file settings are
 /// pre-determined)
 /// </summary>
 /// <param name="restoreProjectView">The restore project view.</param>
 /// ------------------------------------------------------------------------------------
 public RestoreProjectPresenter(RestoreProjectDlg restoreProjectView)
 {
     m_restoreProjectView = restoreProjectView;
 }
		public void RestoreToName_GetSuggestedNewProjectName()
		{
			// Add three project files, one being a copy of another.
			string proj1 = Path.Combine(Path.Combine(FwDirectoryFinder.ProjectsDirectory, "AAA"), "AAA.fwdata");
			m_fileOs.AddExistingFile(proj1);
			string proj2 = Path.Combine(Path.Combine(FwDirectoryFinder.ProjectsDirectory, "BBB"), "BBB.fwdata");
			m_fileOs.AddExistingFile(proj2);
			string proj3 = Path.Combine(Path.Combine(FwDirectoryFinder.ProjectsDirectory, "AAA-01"), "AAA-01.fwdata");
			m_fileOs.AddExistingFile(proj3);

			BackupProjectSettings backupSettings = new BackupProjectSettings(Cache, null, FwDirectoryFinder.DefaultBackupDirectory);
			backupSettings.ProjectName = "AAA";
			string backupFileName1 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName1);
			using (RestoreProjectDlg dlg1 = new RestoreProjectDlg("AAA", "Test", null))
			{
			dlg1.Settings.ProjectName = "AAA";
			RestoreProjectPresenter presenter1 = new RestoreProjectPresenter(dlg1, "AAA");
			string suggestion1 = presenter1.GetSuggestedNewProjectName();
			Assert.AreEqual("AAA-02", suggestion1);
			}

			backupSettings.ProjectName = "BBB";
			string backupFileName2 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName2);
			using (RestoreProjectDlg dlg2 = new RestoreProjectDlg("BBB", "Test", null))
			{
			dlg2.Settings.ProjectName = "BBB";
			RestoreProjectPresenter presenter2 = new RestoreProjectPresenter(dlg2, "BBB");
			string suggestion2 = presenter2.GetSuggestedNewProjectName();
			Assert.AreEqual("BBB-01", suggestion2);
			}

			backupSettings.ProjectName = "CCC";
			string backupFileName3 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName3);
			using (RestoreProjectDlg dlg3 = new RestoreProjectDlg("CCC", "Test", null))
			{
			dlg3.Settings.ProjectName = "CCC";
			RestoreProjectPresenter presenter3 = new RestoreProjectPresenter(dlg3, "CCC");
			string suggestion3 = presenter3.GetSuggestedNewProjectName();
			Assert.AreEqual("CCC-01", suggestion3);
		}
	}
Example #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Restore a project.
		/// </summary>
		/// <param name="dialogOwner">The dialog owner.</param>
		/// <param name="fwApp">The FieldWorks application.</param>
		/// ------------------------------------------------------------------------------------
		internal static void RestoreProject(Form dialogOwner, FwApp fwApp)
		{
			string databaseName = (Cache != null) ? Cache.ProjectId.Name : string.Empty;
			using (RestoreProjectDlg dlg = new RestoreProjectDlg(databaseName, fwApp.ApplicationName, fwApp))
			{
				if (dlg.ShowDialog(dialogOwner) != DialogResult.OK)
					return;

				HandleRestoreRequest(dialogOwner, new FwRestoreProjectSettings(GetCommandLineAbbrevForAppName(fwApp.ApplicationName),
					dlg.Settings));
			}
		}
Example #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Restore a project.
		/// </summary>
		/// <param name="dialogOwner">The dialog owner.</param>
		/// <param name="backupFile">The file to restore from.</param>
		/// ------------------------------------------------------------------------------------
		internal static void RestoreProject(Form dialogOwner, string backupFile)
		{
			BackupFileSettings settings = null;
			if (!RestoreProjectDlg.HandleRestoreFileErrors(null, FwUtils.ksSuiteName, backupFile,
				() => settings = new BackupFileSettings(backupFile, true)))
			{
				return;
			}

			using (RestoreProjectDlg dlg = new RestoreProjectDlg(settings, FwUtils.ksSuiteName,
				GetHelpTopicProvider(settings.AppAbbrev)))
			{
				dlg.ShowInTaskbar = true;
				if (dlg.ShowDialog(dialogOwner) != DialogResult.OK)
					return;

				HandleRestoreRequest(dialogOwner, new FwRestoreProjectSettings(settings.AppAbbrev, dlg.Settings));
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// General constructor (use for constrained mode where the backup file settings are
		/// pre-determined)
		/// </summary>
		/// <param name="restoreProjectView">The restore project view.</param>
		/// ------------------------------------------------------------------------------------
		public RestoreProjectPresenter(RestoreProjectDlg restoreProjectView)
		{
			m_restoreProjectView = restoreProjectView;
		}