EnsureCurrentStylesheet() public static method

If the current stylesheet version in the Db doesn't match that of the current XML file, update the DB.
public static EnsureCurrentStylesheet ( ILangProject lp, IThreadedProgress progressDlg ) : void
lp ILangProject The language project
progressDlg IThreadedProgress The progress dialog.
return void
Example #1
0
 private void SafelyEnsureStyleSheetPostTERemoval(IThreadedProgress progressDlg)
 {
     // Ensure that we have up-to-date versification information so that projects with old TE styles
     // will be able to migrate them from the Scripture area to the LanguageProject model
     ScrReference.InitializeVersification(FwDirectoryFinder.EditorialChecksDirectory, false);
     // Make sure this DB uses the current stylesheet version
     // Suppress adjusting scripture sections since isn't safe to do so at this point
     SectionAdjustmentSuppressionHelper.Do(() => FlexStylesXmlAccessor.EnsureCurrentStylesheet(Cache.LangProject, progressDlg));
 }
Example #2
0
        /// <summary>
        ///	App-specific initialization of the cache.
        /// </summary>
        /// <param name="progressDlg">The progress dialog.</param>
        /// <returns>True if the initialize was successful, false otherwise</returns>
        public override bool InitCacheForApp(IProgress progressDlg)
        {
            Cache.ServiceLocator.DataSetup.LoadDomainAsync(BackendBulkLoadDomain.All);
            AddDefaultWordformingOverridesIfNeeded();

            // The try-catch block is modeled after that used by TeScrInitializer.Initialize(),
            // as the suggestion for fixing LT-8797.
            try
            {
                // Make sure this DB uses the current stylesheet version.
                if (Cache.ProjectId.IsLocal && Cache.NumberOfRemoteClients == 0)
                {
                    FlexStylesXmlAccessor.EnsureCurrentStylesheet(Cache.LangProject, progressDlg);
                }
            }
            catch (WorkerThreadException e)
            {
                MessageBox.Show(Form.ActiveForm, e.InnerException.Message,
                                ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
Example #3
0
        protected override Form NewMainAppWnd(FdoCache cache, bool isNewCache, Form wndCopyFrom,
                                              bool fOpeningNewProject)
        {
            WriteSplashScreen(String.Format(LexTextStrings.ksCreatingWindowForX, cache.DatabaseName));

            // The try-catch block is modeled after that used by TeScrInitializer.Initialize(),
            // as the suggestion for fixing LT-8797.
            try
            {
                // Make sure this DB uses the current stylesheet version.
                if (MiscUtils.IsServerLocal(cache.ServerName) && cache.GetNumberOfRemoteClients() == 0)
                {
                    FlexStylesXmlAccessor.EnsureCurrentStylesheet(cache.LangProject);
                }
            }
            catch (WorkerThreadException e)
            {
                UndoResult ures;
                while (cache.Undo(out ures))
                {
                    ;                                          // Enhance JohnT: make use of ures?
                }
                MessageBox.Show(Form.ActiveForm, e.InnerException.Message,
                                LexTextStrings.ksFieldWorksLanguageExplorer,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
            Form form = base.NewMainAppWnd(cache, isNewCache, wndCopyFrom, fOpeningNewProject);

            // Ensure that all the relevant writing systems are installed.
            if (isNewCache)
            {
                ILangProject lp = cache.LangProject;
                // Loop through the Vernacular WS and initialize them
                foreach (ILgWritingSystem ws in lp.VernWssRC)
                {
                    cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws.Hvo);
                }
                // Loop through the Analysis WS and initialize them
                foreach (ILgWritingSystem ws in lp.AnalysisWssRC)
                {
                    cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws.Hvo);
                }
            }
            cache.Save();

            if (form != null && form is FwXWindow)
            {
                FwXWindow wnd = form as FwXWindow;
                wnd.Mediator.BroadcastPendingItems();
                IFwCheckAnthroList fcal  = FwCheckAnthroListClass.Create();
                string             sDesc = wnd.Mediator.StringTbl.GetString("AnthroListUse", "DialogStrings");
                fcal.Description = sDesc;
                string sHelpFile = HelpFile;
                fcal.HelpFilename = sHelpFile;
                fcal.CheckAnthroList(wnd.Cache.DatabaseAccessor, (uint)form.Handle,
                                     wnd.Cache.LangProject.Name.UserDefaultWritingSystem, wnd.Cache.DefaultUserWs);
                m_activeMainWindow = form;
            }
            if (isNewCache && form != null)
            {
                InitializePartInventories(cache, true);
            }
            return(form);
        }