Ejemplo n.º 1
0
		/// <summary>
		/// Start a thread to get the matching entries.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="currentID"></param>
		/// <param name="wantExactMatch"></param>
		/// <param name="vernWs"></param>
		/// <param name="cf"></param>
		/// <param name="uf"></param>
		/// <param name="af"></param>
		/// <param name="analWs"></param>
		/// <param name="gl"></param>
		/// <returns></returns>
		public void StartGettingExtantEntries(FdoCache cache, int currentID,
			bool wantExactMatch,
			int vernWs, string cf, string uf, string af,
			int analWs, string gl)
		{
			Debug.WriteLine("Starting to get entries for " + cf + " and " + gl);
			m_currentID = currentID;
			m_cache = cache;
			if (cf == null || cf == String.Empty)
				cf = "!";
			if (uf == null || uf == String.Empty)
				uf = "!";
			if (af == null || af == String.Empty)
				af = "!";
			if (gl == null || gl == String.Empty)
				gl = "!";

			if (cf == "!"
				&& uf == "!"
				&& af == "!"
				&& gl == "!")
			{
				RaiseCompleted(); // invoke anything waiting for us to be done.
				return; // Nothing to search on, so quit.
			}

			s_cf = cf;
			s_lf = uf;
			s_af = af;
			s_gl = gl;

			m_sqlCon = new SqlConnection(
				string.Format("Server={0}; Database={1}; User ID=FWDeveloper;"
				+ "Password=careful; Pooling=false;", cache.ServerName, cache.DatabaseName));
			m_sqlCon.Open();
			try
			{
				SqlCommand sqlComm = m_sqlCon.CreateCommand();
				string sSql;
				if (uf != "!")
				{
					sSql =
						@"SELECT EntryId, " +
						@"ISNULL(LexicalForm, N'***') AS LexicalForm, " +
						@"LexicalFormWS, " +
						@"ISNULL(CitationForm, N'***') AS CitationForm, " +
						@"CitationFormWS, " +
						@"ISNULL(AlternateForm, N'***') AS AlternateForm, " +
						@"AlternateFormWS, " +
						@"ISNULL(Gloss, N'***') AS Gloss, " +
						@"GlossWS " +
						@"FROM fnMatchEntries(@exactMatch, @uf, @cf, @af, @gl, @wsv, @wsa, @maxSize) " +
						@"ORDER BY LexicalForm, CitationForm, AlternateForm, Gloss ";
				}
				else
				{
					sSql =
						@"SELECT EntryId, " +
						@"ISNULL(LexicalForm, N'***') AS LexicalForm, " +
						@"LexicalFormWS, " +
						@"ISNULL(CitationForm, N'***') AS CitationForm, " +
						@"CitationFormWS, " +
						@"ISNULL(AlternateForm, N'***') AS AlternateForm, " +
						@"AlternateFormWS, " +
						@"ISNULL(Gloss, N'***') AS Gloss, " +
						@"GlossWS " +
						@"FROM fnMatchEntries(@exactMatch, @uf, @cf, @af, @gl, @wsv, @wsa, @maxSize) " +
						@"ORDER BY Gloss, LexicalForm, CitationForm, AlternateForm";
				}
				sqlComm.CommandText = sSql;
				sqlComm.Parameters.AddWithValue("@exactMatch", wantExactMatch ? 1 : 0);
				sqlComm.Parameters.AddWithValue("@uf", uf);
				sqlComm.Parameters.AddWithValue("@cf", cf);
				sqlComm.Parameters.AddWithValue("@af", af);
				sqlComm.Parameters.AddWithValue("@gl", gl);
				sqlComm.Parameters.AddWithValue("@wsv", vernWs);
				sqlComm.Parameters.AddWithValue("@wsa", analWs);
				sqlComm.Parameters.AddWithValue("@maxSize", 256);	// 256 seem good to SteveMc :-)
				sqlComm.CommandTimeout = 60; // seconds timeout; this query runs slower on MSDE than SqlServer developer.
				m_queryRunner = new BackgroundQueryRunner(sqlComm);
				m_queryRunner.CommandCompleted += new EventHandler(m_queryRunner_CommandCompleted);
				Debug.WriteLine("Running the reader");
				m_queryRunner.Run();
				//sqlreader =	sqlComm.ExecuteReader(System.Data.CommandBehavior.SingleResult);
			}
			catch(Exception)
			{
				Cleanup();
				throw;
			}
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Start a thread to get the matching entries.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="currentID"></param>
        /// <param name="wantExactMatch"></param>
        /// <param name="vernWs"></param>
        /// <param name="cf"></param>
        /// <param name="uf"></param>
        /// <param name="af"></param>
        /// <param name="analWs"></param>
        /// <param name="gl"></param>
        /// <returns></returns>
        public void StartGettingExtantEntries(FdoCache cache, int currentID,
                                              bool wantExactMatch,
                                              int vernWs, string cf, string uf, string af,
                                              int analWs, string gl)
        {
            Debug.WriteLine("Starting to get entries for " + cf + " and " + gl);
            m_currentID = currentID;
            m_cache     = cache;
            if (cf == null || cf == String.Empty)
            {
                cf = "!";
            }
            if (uf == null || uf == String.Empty)
            {
                uf = "!";
            }
            if (af == null || af == String.Empty)
            {
                af = "!";
            }
            if (gl == null || gl == String.Empty)
            {
                gl = "!";
            }

            if (cf == "!" &&
                uf == "!" &&
                af == "!" &&
                gl == "!")
            {
                RaiseCompleted();       // invoke anything waiting for us to be done.
                return;                 // Nothing to search on, so quit.
            }

            s_cf = cf;
            s_lf = uf;
            s_af = af;
            s_gl = gl;

            m_sqlCon = new SqlConnection(
                string.Format("Server={0}; Database={1}; User ID=FWDeveloper;"
                              + "Password=careful; Pooling=false;", cache.ServerName, cache.DatabaseName));
            m_sqlCon.Open();
            try
            {
                SqlCommand sqlComm = m_sqlCon.CreateCommand();
                string     sSql;
                if (uf != "!")
                {
                    sSql =
                        @"SELECT EntryId, " +
                        @"ISNULL(LexicalForm, N'***') AS LexicalForm, " +
                        @"LexicalFormWS, " +
                        @"ISNULL(CitationForm, N'***') AS CitationForm, " +
                        @"CitationFormWS, " +
                        @"ISNULL(AlternateForm, N'***') AS AlternateForm, " +
                        @"AlternateFormWS, " +
                        @"ISNULL(Gloss, N'***') AS Gloss, " +
                        @"GlossWS " +
                        @"FROM fnMatchEntries(@exactMatch, @uf, @cf, @af, @gl, @wsv, @wsa, @maxSize) " +
                        @"ORDER BY LexicalForm, CitationForm, AlternateForm, Gloss ";
                }
                else
                {
                    sSql =
                        @"SELECT EntryId, " +
                        @"ISNULL(LexicalForm, N'***') AS LexicalForm, " +
                        @"LexicalFormWS, " +
                        @"ISNULL(CitationForm, N'***') AS CitationForm, " +
                        @"CitationFormWS, " +
                        @"ISNULL(AlternateForm, N'***') AS AlternateForm, " +
                        @"AlternateFormWS, " +
                        @"ISNULL(Gloss, N'***') AS Gloss, " +
                        @"GlossWS " +
                        @"FROM fnMatchEntries(@exactMatch, @uf, @cf, @af, @gl, @wsv, @wsa, @maxSize) " +
                        @"ORDER BY Gloss, LexicalForm, CitationForm, AlternateForm";
                }
                sqlComm.CommandText = sSql;
                sqlComm.Parameters.AddWithValue("@exactMatch", wantExactMatch ? 1 : 0);
                sqlComm.Parameters.AddWithValue("@uf", uf);
                sqlComm.Parameters.AddWithValue("@cf", cf);
                sqlComm.Parameters.AddWithValue("@af", af);
                sqlComm.Parameters.AddWithValue("@gl", gl);
                sqlComm.Parameters.AddWithValue("@wsv", vernWs);
                sqlComm.Parameters.AddWithValue("@wsa", analWs);
                sqlComm.Parameters.AddWithValue("@maxSize", 256); // 256 seem good to SteveMc :-)
                sqlComm.CommandTimeout          = 60;             // seconds timeout; this query runs slower on MSDE than SqlServer developer.
                m_queryRunner                   = new BackgroundQueryRunner(sqlComm);
                m_queryRunner.CommandCompleted += new EventHandler(m_queryRunner_CommandCompleted);
                Debug.WriteLine("Running the reader");
                m_queryRunner.Run();
                //sqlreader =	sqlComm.ExecuteReader(System.Data.CommandBehavior.SingleResult);
            }
            catch (Exception)
            {
                Cleanup();
                throw;
            }
        }