예제 #1
0
 void m_currentQueryInfo_ExtantEntriesCompleted(object sender, EventArgs e)
 {
     if (sender != m_currentQueryInfo)
     {
         // We ended some obsolete query. We do NOT want to cancel the
         // search-in-progress thing!
         (sender as ExtantEntryInfo).Cleanup();
         return;
     }
     if (m_fonts == null)
     {
         // disposed...dialog has closed...don't try to reset!
         // This can easily happen if the search thread is still running
         // when the dialog is closed.
         return;
     }
     try
     {
         ResetSearch();
         if (m_fResetSearchAborted)
         {
             return;                     // we did not complete the reset, will try again.
         }
         ClearResetTimer();
         m_fResetSearchInProgress = false;
     }
     finally
     {
         // Any exit path from here means we're done searching.
         m_currentQueryInfo.Cleanup();
         m_currentQueryInfo = null;
         RaiseSearchingChanged();
     }
 }
예제 #2
0
        private void DoResetSearch()
        {
            if (m_currentQueryInfo != null)
            {
                m_currentQueryInfo.Cancel();
                m_currentQueryInfo = null;
            }
            if (!m_fResetSearchInProgress)
            {
                return;                 // last reset succeeded, nothing to do.
            }
            m_fResetSearchAborted = false;
            ClearResetTimer();

            if (ShouldAbort())
            {
                return;
            }

            m_currentQueryInfo = new ExtantEntryInfo();
            m_currentQueryInfo.ExtantEntriesCompleted += new EventHandler(m_currentQueryInfo_ExtantEntriesCompleted);
            // This should come before we call StartGetting...because the Completed call
            // can happen DURING the StartGettting call.
            RaiseSearchingChanged();
            m_currentQueryInfo.StartGettingExtantEntries(m_cacheSearch, m_currentID,
                                                         m_wantExactMatch,
                                                         m_vernWs, m_cf, m_uf, m_af,
                                                         m_analWs, m_gl);
        }
예제 #3
0
		void m_currentQueryInfo_ExtantEntriesCompleted(object sender, EventArgs e)
		{
			if (sender != m_currentQueryInfo)
			{
				// We ended some obsolete query. We do NOT want to cancel the
				// search-in-progress thing!
				(sender as ExtantEntryInfo).Cleanup();
				return;
			}
				if (m_fonts == null)
				{
					// disposed...dialog has closed...don't try to reset!
					// This can easily happen if the search thread is still running
					// when the dialog is closed.
					return;
				}
			try
			{
				ResetSearch();
				if (m_fResetSearchAborted)
					return; // we did not complete the reset, will try again.

				ClearResetTimer();
				m_fResetSearchInProgress = false;
			}
			finally
			{
				// Any exit path from here means we're done searching.
				m_currentQueryInfo.Cleanup();
				m_currentQueryInfo = null;
				RaiseSearchingChanged();
			}
		}
예제 #4
0
		private void DoResetSearch()
		{
			if (m_currentQueryInfo != null)
			{
				m_currentQueryInfo.Cancel();
				m_currentQueryInfo = null;
			}
			if (!m_fResetSearchInProgress)
				return; // last reset succeeded, nothing to do.
			m_fResetSearchAborted = false;
			ClearResetTimer();

			if (ShouldAbort())
				return;

			m_currentQueryInfo = new ExtantEntryInfo();
			m_currentQueryInfo.ExtantEntriesCompleted += new EventHandler(m_currentQueryInfo_ExtantEntriesCompleted);
			// This should come before we call StartGetting...because the Completed call
			// can happen DURING the StartGettting call.
			RaiseSearchingChanged();
			m_currentQueryInfo.StartGettingExtantEntries(m_cacheSearch, m_currentID,
				m_wantExactMatch,
				m_vernWs, m_cf, m_uf, m_af,
				m_analWs, m_gl);
		}
예제 #5
0
		void m_currentQueryInfo_ExtantEntriesCompleted(object sender, EventArgs e)
		{
			if (sender != m_currentQueryInfo)
			{
				// We ended some obsolete query. We do NOT want to cancel the
				// search-in-progress thing!
				(sender as ExtantEntryInfo).Cleanup();
				return;
			}
			// if disposed...dialog has closed...don't try to reset!
			// This can easily happen if the search thread is still running
			// when the dialog is closed.
			if (IsDisposed)
				return;
			try
			{
				ResetSearch();
				if (m_fResetSearchAborted)
					return; // we did not complete the reset, will try again.
				ClearResetTimer();
				m_fResetSearchInProgress = false;
			}
			finally
			{
				// Any exit path from here means we're done searching.
				// (The Reset Timer may have fired before we could stop it above...
				// See LT-7576 and LT-7507.)
				if (m_currentQueryInfo != null)
				{
					m_currentQueryInfo.Cleanup();
					m_currentQueryInfo = null;
				}
				RaiseSearchingChanged();
			}
		}
예제 #6
0
		public List<ExtantEntryInfo> Results()
		{
			List<ExtantEntryInfo> al = new List<ExtantEntryInfo>();
			Debug.WriteLine("Getting results");
			if (m_sqlreader == null || m_sqlreader.IsClosed)
			{
				// Cancelled, or didn't get any results, whatever
				return al;
			}
			/* The results have these columns:
				EntryID int,						-- 1/0
				UFTxt nvarchar(4000) default '***',	-- 2/1
				UFWs int,							-- 3/2
				CFTxt nvarchar(4000) default '***',	-- 4/3
				CFWs int,							-- 5/4
				AFTxt nvarchar(4000) default '***',	-- 6/5
				AFWs int,							-- 7/6
				GLTxt nvarchar(4000) default '***',	-- 8/7
				GLWs int							-- 9/8
				*/
			int uiWs = m_cache.DefaultUserWs;
			while (true)
			{
				try
				{
					if (!m_sqlreader.Read())
						break;
				}
				catch (SqlException ex)
				{
					Debug.WriteLine(ex.Message);
					continue;
				}
				int id = m_sqlreader.GetInt32(0);
				if (id != m_currentID)
				{
					ExtantEntryInfo eei = new ExtantEntryInfo();
					string ksStars = SIL.FieldWorks.LexText.Controls.LexTextControls.ksStars;
					// NB: The dummy ID in col 0 is not used here.
					eei.ID = id;
					eei.LexemeForm = m_sqlreader.GetString(1);
					if (eei.LexemeForm == ksStars)
					{
						eei.LexemeForm = String.Empty;
						eei.LexemeFormWs = uiWs;
					}
					else
						eei.LexemeFormWs = m_sqlreader.GetInt32(2);
					eei.CitationForm = m_sqlreader.GetString(3);
					if (eei.CitationForm == ksStars)
					{
						eei.CitationForm = String.Empty;
						eei.CitationFormWs = uiWs;
					}
					else
						eei.CitationFormWs = m_sqlreader.GetInt32(4);
					eei.AlternateForms = m_sqlreader.GetString(5);
					if (eei.AlternateForms == ksStars)
					{
						eei.AlternateForms = String.Empty;
						eei.AlternateFormsWs = uiWs;
					}
					else
						eei.AlternateFormsWs = m_sqlreader.GetInt32(6);
					eei.Glosses = m_sqlreader.GetString(7);
					if (eei.Glosses == ksStars)
					{
						eei.Glosses = String.Empty;
						eei.GlossesWs = uiWs;
					}
					else
						eei.GlossesWs = m_sqlreader.GetInt32(8);
					al.Add(eei);
				}
			}
			Debug.WriteLine("Got results");
			return al;
		}
예제 #7
0
        public List <ExtantEntryInfo> Results()
        {
            List <ExtantEntryInfo> al = new List <ExtantEntryInfo>();

            Debug.WriteLine("Getting results");
            if (m_sqlreader == null || m_sqlreader.IsClosed)
            {
                // Cancelled, or didn't get any results, whatever
                return(al);
            }

            /* The results have these columns:
             *      EntryID int,						-- 1/0
             *      UFTxt nvarchar(4000) default '***',	-- 2/1
             *      UFWs int,							-- 3/2
             *      CFTxt nvarchar(4000) default '***',	-- 4/3
             *      CFWs int,							-- 5/4
             *      AFTxt nvarchar(4000) default '***',	-- 6/5
             *      AFWs int,							-- 7/6
             *      GLTxt nvarchar(4000) default '***',	-- 8/7
             *      GLWs int							-- 9/8
             */
            int uiWs = m_cache.DefaultUserWs;

            while (true)
            {
                try
                {
                    if (!m_sqlreader.Read())
                    {
                        break;
                    }
                }
                catch (SqlException ex)
                {
                    Debug.WriteLine(ex.Message);
                    continue;
                }
                int id = m_sqlreader.GetInt32(0);
                if (id != m_currentID)
                {
                    ExtantEntryInfo eei     = new ExtantEntryInfo();
                    string          ksStars = SIL.FieldWorks.LexText.Controls.LexTextControls.ksStars;
                    // NB: The dummy ID in col 0 is not used here.
                    eei.ID         = id;
                    eei.LexemeForm = m_sqlreader.GetString(1);
                    if (eei.LexemeForm == ksStars)
                    {
                        eei.LexemeForm   = String.Empty;
                        eei.LexemeFormWs = uiWs;
                    }
                    else
                    {
                        eei.LexemeFormWs = m_sqlreader.GetInt32(2);
                    }
                    eei.CitationForm = m_sqlreader.GetString(3);
                    if (eei.CitationForm == ksStars)
                    {
                        eei.CitationForm   = String.Empty;
                        eei.CitationFormWs = uiWs;
                    }
                    else
                    {
                        eei.CitationFormWs = m_sqlreader.GetInt32(4);
                    }
                    eei.AlternateForms = m_sqlreader.GetString(5);
                    if (eei.AlternateForms == ksStars)
                    {
                        eei.AlternateForms   = String.Empty;
                        eei.AlternateFormsWs = uiWs;
                    }
                    else
                    {
                        eei.AlternateFormsWs = m_sqlreader.GetInt32(6);
                    }
                    eei.Glosses = m_sqlreader.GetString(7);
                    if (eei.Glosses == ksStars)
                    {
                        eei.Glosses   = String.Empty;
                        eei.GlossesWs = uiWs;
                    }
                    else
                    {
                        eei.GlossesWs = m_sqlreader.GetInt32(8);
                    }
                    al.Add(eei);
                }
            }
            Debug.WriteLine("Got results");
            return(al);
        }