/// <summary> /// Search Index for String /// </summary> /// <param name="s">Search String</param> /// <returns>AutoCompleteStringCollection</returns> public List <string> BuildAutoCompSrc(string s) { List <string> asc = new List <string>(); try { string sndx = Soundex.EncodeString(s, 4); foreach (string t in sndx.Split('-')) { string sql = String.Format("SELECT content FROM SearchIndex WHERE id IN (SELECT oid FROM WordIndex WHERE wid IN (SELECT wid FROM Words WHERE word GLOB '{0}*' LIMIT 20)) LIMIT 20", t); SQLiteCommand cmd = new SQLiteCommand(sql, conn); SQLiteDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { string g = reader.GetString(0); asc.Add(g); } } } catch (Exception ex) { log.WriteError(ex, "AddressingTools", System.Security.Principal.WindowsIdentity.GetCurrent().Name, null); //IndexError(ex.Message, "BuildAutoCompSrc Error"); //MessageBox.Show(ex.Message, "BuildAutoCompSrc Error"); //System.Diagnostics.EventLog.WriteEntry("AtlasDx", ex.Message + " @ " + ex.TargetSite, System.Diagnostics.EventLogEntryType.Error); } //conn.Close(); return(asc); }
/// <summary> /// Indexes Concantinates multiple fields from an ESRI ITable into a single search field /// </summary> /// <param name="Name"></param> /// <param name="tbl"></param> /// <param name="fields2"></param> private void IndexTableMulti(string Name, ITable tbl, string[] fields2) { try { string status = "Indexing " + Name + " ... "; Message = status; OnHasMessage(new EventArgs()); int i = SetDBIndex(Name); string dbID = i.ToString(); ICursor xCursor = tbl.Search(null, true); int[] flds = new int[fields2.Length]; Dictionary <int, string> fld_Ids = new Dictionary <int, string>(); for (int x = 0; x < fields2.Length; x++) { fld_Ids.Add(xCursor.Fields.FindField(fields2[x]), fields2[x]); } IRow row = xCursor.NextRow(); while (row != null) { try { string oid = row.OID.ToString(); foreach (KeyValuePair <int, string> Kvp in fld_Ids) { string xval = row.get_Value(Kvp.Key).ToString().Trim(); if (!String.IsNullOrEmpty(xval)) { string sval = Soundex.EncodeString(xval); string[] spl = sval.Split('-'); foreach (string s in spl) { if (rIndex.ContainsKey(s)) { rIndex[s].Add(main_count); } else { rIndex[s] = new List <int>(); rIndex[s].Add(main_count); } } List <string> inserts = new List <string>(); inserts.Add(main_count.ToString()); inserts.Add(Kvp.Value); inserts.Add(xval); inserts.Add(dbID); inserts.Add(oid); insertVals.Add(main_count, inserts); } main_count += 1; } row = xCursor.NextRow(); //if (count % 1500 == 0) //{ // Message = status + count.ToString(); // OnHasMessage(new EventArgs()); //} //MobileAVL.SplashScreen.Splasher.Status = status + count.ToString(); } catch (SQLiteException ex) { IndexError(ex.Message, "Error Indexing " + Name); //System.Diagnostics.EventLog.WriteEntry("AtlasDx", ex.Message + " @ " + ex.TargetSite, System.Diagnostics.EventLogEntryType.Error); } } } catch (Exception ex2) { IndexError(ex2.Message, "IndexTable Error"); } Message = "Indexed " + main_count.ToString() + " items"; OnHasMessage(new EventArgs()); }