コード例 #1
0
ファイル: LexTextApp.cs プロジェクト: sillsdev/WorldPad
		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;
		}
コード例 #2
0
ファイル: TeScrInitializer.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Ensures all of the project components are valid.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="existingProgressDlg">The existing progress dialog.</param>
		/// ------------------------------------------------------------------------------------
		public static void EnsureProjectComponentsValid(FdoCache cache, IAdvInd4 existingProgressDlg)
		{
			EnsureProjectValid(cache, existingProgressDlg);

			// TE-8621: Don't try to upgrade the database unless we're the project server and no one is connected
			if (!MiscUtils.IsServerLocal(cache.ServerName) || cache.GetNumberOfRemoteClients() > 0)
				return;

			ILangProject lp = cache.LangProject;

			TePublicationsInit.EnsureFactoryPublications(lp, existingProgressDlg);
			TeStylesXmlAccessor.EnsureCurrentStylesheet(lp, existingProgressDlg);
			TeScrNoteCategoriesInit.EnsureCurrentScrNoteCategories(lp, existingProgressDlg);
			TeKeyTermsInit.EnsureCurrentKeyTerms(lp, existingProgressDlg);
			cache.Save();
		}