/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor. /// </summary> /// ------------------------------------------------------------------------------------ public MissingOldFieldWorksDlg(RestoreProjectSettings settings, bool fHaveFw60, bool fHaveSqlSvr) : this() { Debug.Assert(!fHaveFw60 || !fHaveSqlSvr); if (fHaveFw60) { m_labelFwDownload.Visible = false; m_lnkFw60.Visible = false; } if (fHaveSqlSvr) { m_labelSqlDownload.Visible = false; m_lnkSqlSvr.Visible = false; } m_lblBackupFile.Text = settings.Backup.File; if (!IsWindows7OrEarlier()) { // No point in downloading SqlServer 2005 and dependencies; hide the relevant links m_labelSqlDownload.Visible = false; m_labelFwDownload.Visible = false; m_lnkSqlSvr.Visible = false; m_lnkFw60.Visible = false; m_labelAfterDownload.Visible = false; m_clickDownloadPicture.Visible = false; m_label6OrEarlier.Text = Properties.Resources.kstidCantMigrateWrongOS; m_label6OrEarlier.Height *= 4; m_btnOK.Enabled = false; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor /// </summary> /// <param name="settings">The restore settings.</param> /// <param name="ui">The UI service.</param> /// <param name="converterConsolePath"></param> /// <param name="dbPath"></param> /// ------------------------------------------------------------------------------------ public ProjectRestoreService(RestoreProjectSettings settings, IFdoUI ui, string converterConsolePath, string dbPath) { m_restoreSettings = settings; m_ui = ui; m_converterConsolePath = converterConsolePath; m_dbPath = dbPath; }
public void RestoreProjectSettings_VerifyExistenceOfProject() { string restoreTestsZipFileDir = Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO/FDOTests/BackupRestore/RestoreServiceTestsZipFileDir"); RestoreProjectSettings restoreSettings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory) { Backup = new BackupFileSettings(Path.Combine(restoreTestsZipFileDir, Path.ChangeExtension("TestRestoreFWProject", FdoFileHelper.ksFwBackupFileExtension))), IncludeConfigurationSettings = false, IncludeLinkedFiles = false, IncludeSupportingFiles = true, IncludeSpellCheckAdditions = false, ProjectName = "TestRestoreFWProject 01", BackupOfExistingProjectRequested = false, }; ProjectRestoreServiceTests.RemoveAnyFilesAndFoldersCreatedByTests(restoreSettings); ProjectRestoreService restoreProjectService = new ProjectRestoreService(restoreSettings, new DummyFdoUI(), FwDirectoryFinder.ConverterConsoleExe, FwDirectoryFinder.DbExe); Assert.False(restoreSettings.ProjectExists, "Project exists but it should not."); try { // Restore the project and check to ensure that it exists. restoreProjectService.RestoreProject(new DummyProgressDlg()); Assert.True(restoreSettings.ProjectExists, "Project does not exist but it should."); } finally { ProjectRestoreServiceTests.RemoveAnyFilesAndFoldersCreatedByTests(restoreSettings); } }
public void DefaultRestoreSettings() { var settings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory); Assert.IsNull(settings.Backup); Assert.True(string.IsNullOrEmpty(settings.ProjectName)); Assert.Throws(typeof(InvalidOperationException), () => { bool b = settings.CreateNewProject; }); Assert.AreEqual(false, settings.IncludeConfigurationSettings); Assert.AreEqual(false, settings.IncludeSupportingFiles); Assert.AreEqual(false, settings.IncludeLinkedFiles); Assert.AreEqual(false, settings.IncludeSpellCheckAdditions); }
public void Initialize() { var restoreTestsZipFileDir = Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO", "FDOTests", "BackupRestore","RestoreServiceTestsZipFileDir"); m_restoreSettings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory) { Backup = new BackupFileSettings(Path.Combine(restoreTestsZipFileDir, Path.ChangeExtension("TestRestoreFWProject", FdoFileHelper.ksFwBackupFileExtension))), IncludeConfigurationSettings = false, IncludeLinkedFiles = false, IncludeSupportingFiles = false, IncludeSpellCheckAdditions = false, ProjectName = "TestRestoreFWProject", BackupOfExistingProjectRequested = false, }; }
internal static void RemoveAnyFilesAndFoldersCreatedByTests(RestoreProjectSettings settings) { RemoveAllFilesFromFolderAndSubfolders(FdoFileHelper.GetBackupSettingsDir(settings.ProjectPath)); RemoveAllFilesFromFolderAndSubfolders(settings.ProjectSupportingFilesPath); RemoveAllFilesFromFolderAndSubfolders(settings.FlexConfigurationSettingsPath); RemoveAllFilesFromFolderAndSubfolders(settings.PicturesPath); RemoveAllFilesFromFolderAndSubfolders(settings.MediaPath); RemoveAllFilesFromFolderAndSubfolders(settings.OtherExternalFilesPath); RemoveAllFilesFromFolderAndSubfolders(settings.LinkedFilesPath); RemoveAllFilesFromFolderAndSubfolders(settings.WritingSystemStorePath); RemoveAllFilesFromFolderAndSubfolders(Path.Combine(settings.ProjectPath, FdoFileHelper.ksSortSequenceTempDir)); //Remove this one last of all because the other folders need to be removed first. RemoveAllFilesFromFolderAndSubfolders(settings.ProjectPath); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor used in Tests where we do not need to have a helpTopicProvider. /// </summary> /// <param name="settings">The restore settings.</param> /// ------------------------------------------------------------------------------------ public ProjectRestoreService(RestoreProjectSettings settings) { m_restoreSettings = settings; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor /// </summary> /// <param name="settings">The restore settings.</param> /// <param name="helpTopicProvider"></param> /// ------------------------------------------------------------------------------------ public ProjectRestoreService(RestoreProjectSettings settings, IHelpTopicProvider helpTopicProvider) { m_restoreSettings = settings; m_helpTopicProvider = helpTopicProvider; }
private bool SetupRestore() { try { var backupSettings = new BackupFileSettings(m_restoreFileFullPath); m_restoreSettings = new RestoreProjectSettings(ParatextLexiconPluginDirectoryFinder.ProjectsDirectory) { Backup = backupSettings, IncludeConfigurationSettings = backupSettings.IncludeConfigurationSettings, IncludeLinkedFiles = backupSettings.IncludeLinkedFiles, IncludeSupportingFiles = backupSettings.IncludeSupportingFiles, IncludeSpellCheckAdditions = backupSettings.IncludeSpellCheckAdditions, BackupOfExistingProjectRequested = false }; } catch (InvalidBackupFileException ibfe) { MessageBox.Show(ibfe.Message, Strings.ksBackupFileProblemCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } catch { MessageBox.Show(Strings.ksBackupFileProblemText, Strings.ksBackupFileProblemCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } return true; }
public void RestoreProjectSettings_VerifyExistenceOfHgRepo() { string restoreTestsZipFileDir = Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO/FDOTests/BackupRestore/RestoreServiceTestsZipFileDir"); RestoreProjectSettings restoreSettings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory) { Backup = new BackupFileSettings(Path.Combine(restoreTestsZipFileDir, Path.ChangeExtension("TestRestoreFWProject", FdoFileHelper.ksFwBackupFileExtension))), IncludeConfigurationSettings = false, IncludeLinkedFiles = false, IncludeSupportingFiles = true, IncludeSpellCheckAdditions = false, ProjectName = "TestRestoreFWProject 01", BackupOfExistingProjectRequested = false, }; ProjectRestoreService restoreProjectService = new ProjectRestoreService(restoreSettings, new DummyFdoUI(), FwDirectoryFinder.ConverterConsoleExe, FwDirectoryFinder.DbExe); try { // Restore the project and check to ensure that it exists, but is not using Send/Receive. restoreProjectService.RestoreProject(new DummyProgressDlg()); Assert.True(restoreSettings.ProjectExists, "Project does not exist but it should."); Assert.False(restoreSettings.UsingSendReceive, "Project is using S/R but it should not be."); string otherReposDir = Path.Combine(restoreSettings.ProjectPath, FdoFileHelper.OtherRepositories); // Create a non-repository folder in OtherRepositories and verify the project is not using Send/Receive Directory.CreateDirectory(Path.Combine(otherReposDir, "NotARepo_LIFT", "RandomSubdir")); Assert.False(restoreSettings.UsingSendReceive, "Project should not be using S/R if there is no hg repo in OtherRepositories."); // Create a hg repository in OtherRepositories and verify the project is using Send/Receive Directory.CreateDirectory(Path.Combine(otherReposDir, "IsARepo_ButNotNecessarilyLIFT", ".hg")); Assert.True(restoreSettings.UsingSendReceive, "Project should be using S/R if there is a hg repo in OtherRepositories."); Directory.Delete(otherReposDir, true); Assert.False(restoreSettings.UsingSendReceive, "Project should not be using S/R if there is no hg repo. Deletion failed?"); // Make the project directory a hg repo Directory.CreateDirectory(Path.Combine(restoreSettings.ProjectPath, ".hg")); Assert.True(restoreSettings.UsingSendReceive, "Project should be using S/R if the project directory is a hg repo."); } finally { ProjectRestoreServiceTests.RemoveAnyFilesAndFoldersCreatedByTests(restoreSettings); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="RestoreProjectDlg"/> class. /// </summary> /// <param name="appName">Name of the application (for showing in message box captions).</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ private RestoreProjectDlg(string appName, IHelpTopicProvider helpTopicProvider) : this() { m_appName = appName; m_helpTopicProvider = helpTopicProvider; m_lblOtherBackupIncludes.Text = String.Empty; m_lblDefaultBackupIncludes.Text = String.Empty; m_lblBackupZipFile.Text = String.Empty; m_lblBackupProjectName.Text = String.Empty; m_lblBackupDate.Text = String.Empty; m_lblBackupComment.Text = String.Empty; m_fmtUseOriginalName = m_rdoUseOriginalName.Text; m_rdoUseOriginalName.Text = String.Format(m_fmtUseOriginalName, String.Empty); m_settings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory); m_txtOtherProjectName.KeyPress += m_txtOtherProjectName_KeyPress; m_txtOtherProjectName.TextChanged += m_txtOtherProjectName_TextChanged; GetIllegalProjectNameChars(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the settings. /// </summary> /// <param name="settings">The settings.</param> /// <param name="c">expected value of IncludeConfigurationSettings.</param> /// <param name="f">expected value of IncludeSupportingFiles.</param> /// <param name="l">expected value of IncludeLinkedFiles.</param> /// <param name="s">expected value of IncludeSpellCheckAdditions.</param> /// ------------------------------------------------------------------------------------ private void CheckSettings(RestoreProjectSettings settings, bool c, bool f, bool l, bool s) { Assert.AreEqual(c, settings.IncludeConfigurationSettings); Assert.AreEqual(f, settings.IncludeSupportingFiles); Assert.AreEqual(l, settings.IncludeLinkedFiles); Assert.AreEqual(s, settings.IncludeSpellCheckAdditions); }
public void RestoreProjectSettings_CreateFromCommandLineOptions() { RestoreProjectSettings settings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory, "project", "notThere.fwbackup", string.Empty); CheckSettings(settings, false, false, false, false); settings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory, "project", "notThere.fwbackup", "fl"); CheckSettings(settings, false, true, true, false); settings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory, "project", "notThere.fwbackup", "cls"); CheckSettings(settings, true, false, true, true); settings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory, "project", "notThere.fwbackup", "cfls"); CheckSettings(settings, true, true, true, true); settings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory, "project", "notThere.fwbackup", "CFLS"); CheckSettings(settings, true, true, true, true); }
public void RestoreProjectSettings_CommandLineOptions() { RestoreProjectSettings settings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory); Assert.AreEqual(string.Empty, settings.CommandLineOptions); settings.IncludeConfigurationSettings = true; Assert.AreEqual("c", settings.CommandLineOptions.ToLower()); settings.IncludeSupportingFiles = true; Assert.AreEqual("cf", settings.CommandLineOptions.ToLower()); settings.IncludeLinkedFiles = true; Assert.AreEqual("cfl", settings.CommandLineOptions.ToLower()); settings.IncludeSpellCheckAdditions = true; Assert.AreEqual("cfls", settings.CommandLineOptions.ToLower()); settings.IncludeSupportingFiles = false; Assert.AreEqual("cls", settings.CommandLineOptions.ToLower()); settings.IncludeSpellCheckAdditions = false; Assert.AreEqual("cl", settings.CommandLineOptions.ToLower()); settings.IncludeConfigurationSettings = false; Assert.AreEqual("l", settings.CommandLineOptions.ToLower()); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Launches a restore project when requested from the command-line. /// </summary> /// <param name="appArgs">The application command-line arguments.</param> /// ------------------------------------------------------------------------------------ private static void LaunchRestoreFromCommandLine(FwAppArgs appArgs) { if (string.IsNullOrEmpty(appArgs.AppName)) // ENHANCE: Consider a more robust (less cryptic) way of doing this. { RestoreProject(null, appArgs.BackupFile); return; } // Command-line most likely came from a restore in another process. // There is no need to re-show the dialog since the user has already chosen // the options and confirmed to overwrite any existing database. Logger.WriteEvent("Restoring project: " + appArgs.BackupFile); RestoreProjectSettings restoreSettings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory, appArgs.Database, appArgs.BackupFile, appArgs.RestoreOptions); RestoreCurrentProject(new FwRestoreProjectSettings(appArgs.AppAbbrev, restoreSettings), null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="FwRestoreProjectSettings"/> class. /// </summary> /// <param name="fwAppCommandLineAbbrev">The FW application command line abbrev (TE or /// FLEx), case-insensitive.</param> /// <param name="settings">The restore settings (as saved by the dialog).</param> /// ------------------------------------------------------------------------------------ internal FwRestoreProjectSettings(string fwAppCommandLineAbbrev, RestoreProjectSettings settings) { m_fwAppCommandLineAbbrev = fwAppCommandLineAbbrev; m_settings = settings; }
/// <summary> /// Provide a version of the basic ProjectRestoreService that overrides some UI /// we don't want to show up in tests (a dialog). /// </summary> /// <param name="settings"></param> public ProjectRestoreTestService(RestoreProjectSettings settings) : base(settings, new DummyFdoUI(), FwDirectoryFinder.ConverterConsoleExe, FwDirectoryFinder.DbExe) { PutFilesInProject = false; SimulateOKResult = true; }