public void Dispose() { if (m_objThread != null) { m_objThread.Abort(); } if (m_indexer != null) { m_indexer.Close(); } }
private string DoSearchResult() { string strSearchTerm = m_queryString["search"]; string strStartAt = m_queryString["page"]; int iStartAt = 0; if (strStartAt != null) { try { iStartAt = Int32.Parse(strStartAt) * 10; } catch { } } // Lock the index before starting search. This is to prevent FileExplorer from // moving/deleting index while a search operation is in progress Synchronizer.Instance.LockIndex(this); Indexer m_indexer = new Indexer(OpenDesktop.Properties.Settings.Instance.IndexPath, IndexMode.SEARCH); string strReturnVal = string.Empty; SearchInfo[] sinfo = m_indexer.Search(strSearchTerm); if (sinfo != null && sinfo.Length > 0) { StringBuilder sb = new StringBuilder(); int iEndAt = iStartAt + 10; if (iEndAt > sinfo.Length) { iEndAt = sinfo.Length; } // Display: Results 0 - 10 of about 44 for killing+work sb.Append("<div class=\"search-nav\">" + string.Format(Properties.Resources.SearchResultsHeader, (iStartAt + 1).ToString(), iEndAt.ToString(), sinfo.Length.ToString(), strSearchTerm) + "</div>"); sb.Append("<div class=\"search-results\"><ol>"); for (int i = iStartAt; i < iEndAt; i++) { string strDisplayText = GetExcerpt(sinfo[i].Text, strSearchTerm); sb.Append("<li value=\"" + (i + 1).ToString() + "\"><a href=\"" + sinfo[i].Launcher + "\"><span style=\"font-size:12pt\">" + sinfo[i].Title + "</span></a><br />" + strDisplayText + "</li>"); } sb.Append("</ol></div>"); int iCurPageNum = (iStartAt / 10); string strPrevUrl = string.Empty; string strNextUrl = string.Empty; if (iCurPageNum > 0) { strPrevUrl = string.Format("<a href=\"search.html?search={0}&page={1}\">", m_queryString["search"], (iCurPageNum - 1).ToString()) + Properties.Resources.SearchResultsPrev + "</a>"; } if (iEndAt != sinfo.Length) { strNextUrl = string.Format("<a href=\"search.html?search={0}&page={1}\">", m_queryString["search"], (iCurPageNum + 1).ToString()) + Properties.Resources.SearchResultsNext + "</a>"; } sb.Append("<div class=\"search-nav\">" + strPrevUrl + " | " + strNextUrl + "</div>"); strReturnVal = sb.ToString(); } else { strReturnVal = "<div class=\"no-search-results\">" + Properties.Resources.NoSearchResults + "</div>"; } m_indexer.Close(); Synchronizer.Instance.ReleaseIndex(this); return(strReturnVal); }
private string DoSearchResult() { string strSearchTerm = m_queryString["search"]; string strStartAt = m_queryString["page"]; int iStartAt = 0; if (strStartAt != null) { try { iStartAt = Int32.Parse(strStartAt) * 10; } catch { } } // Lock the index before starting search. This is to prevent FileExplorer from // moving/deleting index while a search operation is in progress Synchronizer.Instance.LockIndex(this); Indexer m_indexer = new Indexer(OpenDesktop.Properties.Settings.Instance.IndexPath, IndexMode.SEARCH); string strReturnVal = string.Empty; SearchInfo[] sinfo = m_indexer.Search(strSearchTerm); if (sinfo != null && sinfo.Length > 0) { StringBuilder sb = new StringBuilder(); int iEndAt = iStartAt + 10; if (iEndAt > sinfo.Length) { iEndAt = sinfo.Length; } // Display: Results 0 - 10 of about 44 for killing+work sb.Append("<div class=\"search-nav\">" + string.Format(Properties.Resources.SearchResultsHeader, (iStartAt + 1).ToString(), iEndAt.ToString(), sinfo.Length.ToString(), strSearchTerm) + "</div>"); sb.Append("<div class=\"search-results\"><ol>"); for (int i = iStartAt; i < iEndAt; i++) { string strDisplayText = GetExcerpt(sinfo[i].Text, strSearchTerm); sb.Append("<li value=\"" + (i+1).ToString() + "\"><a href=\"" + sinfo[i].Launcher + "\"><span style=\"font-size:12pt\">" + sinfo[i].Title + "</span></a><br />" + strDisplayText + "</li>"); } sb.Append("</ol></div>"); int iCurPageNum = (iStartAt/10); string strPrevUrl = string.Empty; string strNextUrl = string.Empty; if (iCurPageNum > 0) { strPrevUrl = string.Format("<a href=\"search.html?search={0}&page={1}\">", m_queryString["search"], (iCurPageNum - 1).ToString()) + Properties.Resources.SearchResultsPrev + "</a>"; } if (iEndAt != sinfo.Length) { strNextUrl = string.Format("<a href=\"search.html?search={0}&page={1}\">", m_queryString["search"], (iCurPageNum + 1).ToString()) + Properties.Resources.SearchResultsNext + "</a>"; } sb.Append("<div class=\"search-nav\">" + strPrevUrl + " | " + strNextUrl + "</div>"); strReturnVal = sb.ToString(); } else { strReturnVal = "<div class=\"no-search-results\">" + Properties.Resources.NoSearchResults + "</div>"; } m_indexer.Close(); Synchronizer.Instance.ReleaseIndex(this); return strReturnVal; }