Esempio n. 1
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Check to see if the given cache is already being used.
		/// Use the one that we have, if available,
		/// which will reset the 'cache' parameter.
		/// Deprecated--(JohnT)...this approach involves creating and destroying a cache
		/// unnecessarily and this seems to cause problems (see LT-7176). Better to use
		/// the overload that takes a server and database name.
		/// </summary>
		/// <param name="cache">Reference to an FdoCache.</param>
		/// <returns>True if the cache is not already being used, otherwise false.</returns>
		/// -----------------------------------------------------------------------------------
		protected bool GetCache(ref FdoCache cache)
		{
			Debug.Assert(cache != null);

			bool isNewCache = false;
			string key = MakeKey(cache.ServerName, cache.DatabaseName);
			if (m_caches.ContainsKey(key))
			{
				// Use extant one.
				cache.Dispose();
				cache = m_caches[key];
			}
			else
			{
				// Cache the new cache in the hash.
				m_caches[key] = cache;
				isNewCache = true;
			}
			SetCacheProgressBar(cache);
			return isNewCache;
		}
Esempio n. 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Looks to see whether the sample DB is available and, if so, displays a message box
		/// asking the user whether or not he wants to open it.
		/// (TE-3473)
		/// </summary>
		/// <param name="cache">(output)</param>
		/// <returns><c>true</c> if a connection to the sample DB is made; <c>false</c>
		/// otherwise</returns>
		/// ------------------------------------------------------------------------------------
		protected bool ShowFirstTimeMessage(out FdoCache cache)
		{
			cache = null;
			// Need to set this in case the user starts up a new main window from the
			// Advertisement prompt or welcome dialog.
			FwRegistrySettings.StartupSuccessfulSetting = true;

			if (string.IsNullOrEmpty(SampleDatabase) || !FwRegistrySettings.FirstTimeAppHasBeenRun)
				return false;

			// First, attempt a connection to the sample DB before offering the user the
			// option of opening it.
			if (CheckDbVerCompatibility(MiscUtils.LocalServerName, SampleDatabase))
				cache = FdoCache.Create(SampleDatabase);
			if (cache != null && ShowFirstTimeMessageDlg())
				return true;

			if (cache != null)
				cache.Dispose();

			cache = null;
			return false;
		}
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();
			}
		}