Ejemplo n.º 1
0
		/// <summary>
		/// Get the matching entries.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="currentID"></param>
		/// <param name="form"></param>
		/// <param name="ws"></param>
		/// <returns></returns>
		public static List<ExtantWfiWordformInfo> ExtantWordformInfo(FdoCache cache, string form, int ws)
		{
			List<ExtantWfiWordformInfo> al = new List<ExtantWfiWordformInfo>();
			if (form == null || form == String.Empty)
				return al;

			s_form = form;

			SqlConnection sqlCon = new SqlConnection(
				string.Format("Server={0}; Database={1}; User ID=FWDeveloper;"
				+ "Password=careful; Pooling=false;", cache.ServerName, cache.DatabaseName));
			sqlCon.Open();
			SqlDataReader sqlreader = null;
			try
			{
				SqlCommand sqlComm = sqlCon.CreateCommand();
				sqlComm.CommandText = "SELECT Obj, Txt"
					+ " FROM WfiWordform_Form"
					+ " WHERE LOWER(RTRIM(LTRIM(Txt))) LIKE LOWER(RTRIM(LTRIM(@form))) + '%'"
					+ "		AND Ws = @ws"
					+ "	ORDER BY Obj, Txt";
				sqlComm.Parameters.AddWithValue("@form", form);
				sqlComm.Parameters.AddWithValue("@ws", ws.ToString());
				sqlreader =	sqlComm.ExecuteReader(System.Data.CommandBehavior.Default);
				while (sqlreader.Read())
				{
					ExtantWfiWordformInfo ewi = new ExtantWfiWordformInfo();
					ewi.ID = sqlreader.GetInt32(0);
					ewi.Form = sqlreader.GetString(1);
					al.Add(ewi);
				}
			}
			catch (Exception err)
			{
				Debug.WriteLine(err.Message);
			}
			finally
			{
				try
				{
					if (sqlreader != null && !sqlreader.IsClosed)
						sqlreader.Close();
				}
				finally
				{
					try
					{
						sqlCon.Close();
					}
					catch
					{
					}
				}
			}

			return al;
		}
Ejemplo n.º 2
0
		public void SetDlgInfo(Mediator mediator, WindowParams wp, List<IWfiWordform> filteredEntries)
		{
			CheckDisposed();

			Debug.Assert(filteredEntries != null && filteredEntries.Count > 0);

			foreach (IWfiWordform ww in filteredEntries)
			{
				if (ww != null)	// assignment of ww.Hvo will crash: LT-4951
				{
					ExtantWfiWordformInfo ewi = new ExtantWfiWordformInfo();
					ewi.ID = ww.Hvo;
					m_filteredEntries.Add(ewi);
				}
			}
			base.SetDlgInfo((FdoCache)mediator.PropertyTable.GetValue("cache"), wp, mediator);
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Get the matching entries.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="currentID"></param>
        /// <param name="form"></param>
        /// <param name="ws"></param>
        /// <returns></returns>
        public static List <ExtantWfiWordformInfo> ExtantWordformInfo(FdoCache cache, string form, int ws)
        {
            List <ExtantWfiWordformInfo> al = new List <ExtantWfiWordformInfo>();

            if (form == null || form == String.Empty)
            {
                return(al);
            }

            s_form = form;

            SqlConnection sqlCon = new SqlConnection(
                string.Format("Server={0}; Database={1}; User ID=FWDeveloper;"
                              + "Password=careful; Pooling=false;", cache.ServerName, cache.DatabaseName));

            sqlCon.Open();
            SqlDataReader sqlreader = null;

            try
            {
                SqlCommand sqlComm = sqlCon.CreateCommand();
                sqlComm.CommandText = "SELECT Obj, Txt"
                                      + " FROM WfiWordform_Form"
                                      + " WHERE LOWER(RTRIM(LTRIM(Txt))) LIKE LOWER(RTRIM(LTRIM(@form))) + '%'"
                                      + "		AND Ws = @ws"
                                      + "	ORDER BY Obj, Txt";
                sqlComm.Parameters.AddWithValue("@form", form);
                sqlComm.Parameters.AddWithValue("@ws", ws.ToString());
                sqlreader = sqlComm.ExecuteReader(System.Data.CommandBehavior.Default);
                while (sqlreader.Read())
                {
                    ExtantWfiWordformInfo ewi = new ExtantWfiWordformInfo();
                    ewi.ID   = sqlreader.GetInt32(0);
                    ewi.Form = sqlreader.GetString(1);
                    al.Add(ewi);
                }
            }
            catch (Exception err)
            {
                Debug.WriteLine(err.Message);
            }
            finally
            {
                try
                {
                    if (sqlreader != null && !sqlreader.IsClosed)
                    {
                        sqlreader.Close();
                    }
                }
                finally
                {
                    try
                    {
                        sqlCon.Close();
                    }
                    catch
                    {
                    }
                }
            }

            return(al);
        }