Esempio n. 1
0
		/// ------------------------------------------------------------------------------------
		/// <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();
		}
Esempio n. 2
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;
		}
Esempio n. 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Removes the specified FdoCache cleanly, saving it first.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void RemoveFdoCache(FdoCache wndCache)
		{
			CheckDisposed();

			// To be safe - this method might get called recursively (explicitly and from
			// Application.Exit() below again).
			if (wndCache.IsDisposed)
				return;

			Debug.Assert(wndCache != null);
			wndCache.Save();
			DataUpdateMonitor.RemoveDataAccess(wndCache.MainCacheAccessor);
			m_caches.Remove(MakeKey(wndCache.ServerName, wndCache.DatabaseName));
			wndCache.Dispose();

			// If the last cache was removed, then exit the application
			if ((!m_fSuppressClose) && m_fOkToClose && m_caches.Count == 0)
			{
				EditingHelper.ClearTsStringClipboard();
				Application.Exit();
			}
		}