ImportDialog - gather information for a data import
Наследование: System.Windows.Forms.Form, IFWDisposable
Пример #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get settings for and perform the Standard Format import
        /// </summary>
        /// <returns><c>true</c> if something got imported; <c>false</c> otherwise</returns>
        /// ------------------------------------------------------------------------------------
        protected bool ImportSf()
        {
            IScrImportSet importSettings;

            if (m_fParatextStreamlinedImport)
            {
                importSettings = m_cache.LangProject.TranslatedScriptureOA.FindImportSettings(TypeOfImport.Paratext6);
                if (importSettings == null)
                {
                    throw new InvalidOperationException("Caller must set import settings before attempting a streamlined Paratext import");
                }
            }
            else
            {
                using (new WaitCursor(m_mainWnd))
                {
                    importSettings = GetImportSettings();
                }
                if (importSettings == null)                 // User cancelled in import wizard
                {
                    return(false);
                }

                // Display ImportDialog
                using (ImportDialog importDlg = new ImportDialog(m_styleSheet, m_cache,
                                                                 importSettings, m_helpTopicProvider, m_app))
                {
                    importDlg.ShowDialog(m_mainWnd);
                    if (importDlg.DialogResult == DialogResult.Cancel)
                    {
                        Logger.WriteEvent("User canceled import dialog");
                        return(false);
                    }
                    // Settings could have changed if the user went into the wizard.
                    importSettings = importDlg.ImportSettings;
                }
            }

            return(DoImport(importSettings, "ImportStandardFormat"));
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get settings for and perform the Standard Format import
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void ImportSf()
        {
            ScrImportSet importSettings = null;

            // Prevent creation of undo task.
            using (new SuppressSubTasks(m_cache))
            {
                using (new WaitCursor(m_mainWnd))
                {
                    importSettings = GetImportSettings();
                }
                if (importSettings == null)                 // User cancelled in import wizard
                {
                    return;
                }

                // Display ImportDialog
                using (ImportDialog importDlg = new ImportDialog(m_styleSheet, m_cache,
                                                                 importSettings, FwApp.App.HelpFile))
                {
                    importDlg.ShowDialog(m_mainWnd);
                    if (importDlg.DialogResult == DialogResult.Cancel)
                    {
                        Logger.WriteEvent("User canceled import dialog");
                        return;
                    }
                    // Settings could have changed if the user went into the wizard.
                    importSettings = importDlg.ImportSettings;
                }
                if (!m_importCallbacks.EncourageBackup())
                {
                    Logger.WriteEvent("Import canceled in encourage backup dialog");
                    return;
                }
            }

            DoImport(importSettings, "ImportStandardFormat");
        }
Пример #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get the settings for Import, either from database or from wizard
        /// </summary>
        /// <returns>Import settings, or <c>null</c> if user canceled dialog.</returns>
        /// ------------------------------------------------------------------------------------
        protected ScrImportSet GetImportSettings()
        {
            ILangProject proj           = m_cache.LangProject;
            Scripture    scr            = (Scripture)proj.TranslatedScriptureOA;
            ScrImportSet importSettings = new ScrImportSet(m_cache, scr.DefaultImportSettingsHvo,
                                                           m_styleSheet, FwApp.App.HelpFile);

            importSettings.OverlappingFileResolver = new ConfirmOverlappingFileReplaceDialog();
            if (!importSettings.BasicSettingsExist)
            {
                // REVIEW DavidO: Should I use AnalysisDefaultWritingSystem or
                // VernacularDefaultWritingSystem or something else.
                using (ImportWizard importWizard = new ImportWizard(proj.Name.UserDefaultWritingSystem,
                                                                    scr, m_styleSheet, m_cache, FwApp.App.HelpFile))
                {
                    if (importWizard.ShowDialog() == DialogResult.Cancel)
                    {
                        return(null);
                    }
                    // Scripture reference range may have changed
                    ImportDialog.ClearDialogReferences(m_cache);
                    importSettings = (ScrImportSet)scr.DefaultImportSettings;
                }
            }
            else
            {
                StringCollection sInvalidFiles;
                bool             fCompletedWizard = false;
                while (!importSettings.ImportProjectIsAccessible(out sInvalidFiles))
                {
                    // Display the "Project Not Found" message box
                    using (ScrImportSetMessage dlg = new ScrImportSetMessage())
                    {
                        string[] files = new string[sInvalidFiles.Count];
                        sInvalidFiles.CopyTo(files, 0);
                        dlg.InvalidFiles       = files;
                        dlg.HelpURL            = FwApp.App.HelpFile;
                        dlg.HelpTopic          = "/Beginning_Tasks/Import_Standard_Format/Project_Files_Unavailable.htm";
                        dlg.DisplaySetupOption = true;
                        switch (dlg.ShowDialog())
                        {
                        case DialogResult.OK:                                 // Setup...
                        {
                            using (ImportWizard importWizard = new ImportWizard(
                                       proj.Name.UserDefaultWritingSystem, scr, m_styleSheet, m_cache,
                                       FwApp.App.HelpFile))
                            {
                                if (importWizard.ShowDialog() == DialogResult.Cancel)
                                {
                                    return(null);
                                }
                                // Scripture reference range may have changed
                                ImportDialog.ClearDialogReferences(m_cache);
                                importSettings   = (ScrImportSet)scr.DefaultImportSettings;
                                fCompletedWizard = true;
                            }
                            break;
                        }

                        case DialogResult.Cancel:
                            return(null);

                        case DialogResult.Retry:
                            // Loop around until user gets tired.
                            break;
                        }
                    }
                }
                if (!fCompletedWizard)
                {
                    if (ParatextProjHasUnmappedMarkers(importSettings))
                    {
                        // TODO: Show message box and then bring up import wizard
                    }
                }
            }

            return(importSettings);
        }
Пример #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get settings for and perform the Standard Format import
		/// </summary>
		/// <returns><c>true</c> if something got imported; <c>false</c> otherwise</returns>
		/// ------------------------------------------------------------------------------------
		protected bool ImportSf()
		{
			IScrImportSet importSettings;

			if (m_fParatextStreamlinedImport)
			{
				importSettings = m_cache.LangProject.TranslatedScriptureOA.FindImportSettings(TypeOfImport.Paratext6);
				if (importSettings == null)
					throw new InvalidOperationException("Caller must set import settings before attempting a streamlined Paratext import");
			}
			else
			{
				using (new WaitCursor(m_mainWnd))
				{
					importSettings = GetImportSettings();
				}
				if (importSettings == null) // User cancelled in import wizard
					return false;

				// Display ImportDialog
				using (ImportDialog importDlg = new ImportDialog(m_styleSheet, m_cache,
					importSettings, m_helpTopicProvider, m_app))
				{
					importDlg.ShowDialog(m_mainWnd);
					if (importDlg.DialogResult == DialogResult.Cancel)
					{
						Logger.WriteEvent("User canceled import dialog");
						return false;
					}
					// Settings could have changed if the user went into the wizard.
					importSettings = importDlg.ImportSettings;
				}
			}

			return DoImport(importSettings, "ImportStandardFormat");
		}
Пример #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get the settings for Import, either from database or from wizard
        /// </summary>
        /// <returns>Import settings, or <c>null</c> if user canceled dialog.</returns>
        /// ------------------------------------------------------------------------------------
        protected IScrImportSet GetImportSettings()
        {
            ILangProject  proj           = m_cache.LangProject;
            IScripture    scr            = proj.TranslatedScriptureOA;
            IScrImportSet importSettings = null;

            NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () =>
            {
                importSettings =
                    scr.FindOrCreateDefaultImportSettings(TypeOfImport.Unknown);
            });
            importSettings.StyleSheet = m_styleSheet;

            importSettings.OverlappingFileResolver = new ConfirmOverlappingFileReplaceDialog(m_helpTopicProvider);
            if (!importSettings.BasicSettingsExist)
            {
                using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(
                           m_cache.ServiceLocator.GetInstance <IActionHandler>()))
                {
                    using (ImportWizard importWizard = new ImportWizard(m_cache.ProjectId.Name,
                                                                        scr, m_styleSheet, m_helpTopicProvider, m_app))
                    {
                        if (importWizard.ShowDialog() == DialogResult.Cancel)
                        {
                            return(null);
                        }
                        // Scripture reference range may have changed
                        ImportDialog.ClearDialogReferences();
                        importSettings = scr.DefaultImportSettings;
                    }
                    undoHelper.RollBack = false;
                }
            }
            else
            {
                StringCollection sInvalidFiles;
                bool             fCompletedWizard = false;
                while (!importSettings.ImportProjectIsAccessible(out sInvalidFiles))
                {
                    // Display the "Project Not Found" message box
                    using (ScrImportSetMessage dlg = new ScrImportSetMessage())
                    {
                        string[] files = new string[sInvalidFiles.Count];
                        sInvalidFiles.CopyTo(files, 0);
                        dlg.InvalidFiles       = files;
                        dlg.HelpURL            = m_helpTopicProvider.HelpFile;
                        dlg.HelpTopic          = "/Beginning_Tasks/Import_Standard_Format/Project_Files_Unavailable.htm";
                        dlg.DisplaySetupOption = true;
                        switch (dlg.ShowDialog())
                        {
                        case DialogResult.OK:                                 // Setup...
                        {
                            using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(
                                       m_cache.ServiceLocator.GetInstance <IActionHandler>()))
                            {
                                using (ImportWizard importWizard = new ImportWizard(
                                           m_cache.ProjectId.Name, scr, m_styleSheet, m_helpTopicProvider, m_app))
                                {
                                    if (importWizard.ShowDialog() == DialogResult.Cancel)
                                    {
                                        return(null);
                                    }
                                    // Scripture reference range may have changed
                                    ImportDialog.ClearDialogReferences();
                                    importSettings   = scr.DefaultImportSettings;
                                    fCompletedWizard = true;
                                }
                                undoHelper.RollBack = false;
                            }
                            break;
                        }

                        case DialogResult.Cancel:
                            return(null);

                        case DialogResult.Retry:
                            // Loop around until user gets tired.
                            break;
                        }
                    }
                }
                if (!fCompletedWizard)
                {
                    if (ParatextProjHasUnmappedMarkers(importSettings))
                    {
                        // TODO: Show message box and then bring up import wizard
                    }
                }
            }

            return(importSettings);
        }
Пример #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get settings for and perform the Standard Format import
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void ImportSf()
		{
			ScrImportSet importSettings = null;

			// Prevent creation of undo task.
			using (new SuppressSubTasks(m_cache))
			{
				using (new WaitCursor(m_mainWnd))
				{
					importSettings = GetImportSettings();
				}
				if (importSettings == null) // User cancelled in import wizard
					return;

				// Display ImportDialog
				using (ImportDialog importDlg = new ImportDialog(m_styleSheet, m_cache,
					importSettings, FwApp.App.HelpFile))
				{
					importDlg.ShowDialog(m_mainWnd);
					if (importDlg.DialogResult == DialogResult.Cancel)
					{
						Logger.WriteEvent("User canceled import dialog");
						return;
					}
					// Settings could have changed if the user went into the wizard.
					importSettings = importDlg.ImportSettings;
				}
				if (!m_importCallbacks.EncourageBackup())
				{
					Logger.WriteEvent("Import canceled in encourage backup dialog");
					return;
				}
			}

			DoImport(importSettings, "ImportStandardFormat");
		}