public void DoXmlSearch(bool bOutputKeyID) { textBox_xmlQuery_comment.Text = ""; // 第一阶段 TargetItemCollection targets = treeView_simpleQueryResTree. GetSearchTarget(); Debug.Assert(targets != null, "GetSearchTarget() 异常"); // 正式检索 string strError; if (bOutputKeyID == true) this.m_bFirstColumnIsKey = true; else this.m_bFirstColumnIsKey = false; this.ClearListViewPropertyCache(); this.ClearListViewItems(); stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在检索 ..."); stop.BeginLoop(); EnableControlsInSearching(true); // 2010/5/18 string strBrowseStyle = "id,cols"; string strOutputStyle = ""; if (bOutputKeyID == true) { strOutputStyle = "keyid"; strBrowseStyle = "keyid,id,key,cols"; } long lTotalCount = 0; // 命中记录总数 for(int i=0;i<targets.Count;i++) { if (stop.State >= 1) break; TargetItem item = (TargetItem)targets[i]; channel = Channels.GetChannel(item.Url); Debug.Assert(channel != null, "Channels.GetChannel 异常"); // MessageBox.Show(this, item.Xml); long nRet = channel.DoSearch(textBox_xmlQueryString.Text, "default", strOutputStyle, out strError); if (nRet == -1) { textBox_xmlQuery_comment.Text += "出错: " + strError + "\r\n"; MessageBox.Show(this, strError); continue; } lTotalCount += nRet; textBox_xmlQuery_comment.Text += "命中记录数: " + Convert.ToString(nRet) + "\r\n"; if (nRet == 0) continue; // 获取结果集 nRet = channel.DoBrowse(listView_browse, listView_browse.Lang, stop, "default", strBrowseStyle, out strError); if (nRet == -1) { textBox_xmlQuery_comment.Text += "装载浏览信息时出错: " + strError + "\r\n"; MessageBox.Show(this, strError); continue; } } if (targets.Count > 1) { textBox_xmlQuery_comment.Text += "命中总条数: " + Convert.ToString(lTotalCount) + "\r\n"; } stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); if (lTotalCount == 0) { MessageBox.Show(this, "未命中"); } EnableControlsInSearching(false); channel = null; }
// 复杂检索 public void DoComplexSearch(bool bOutputKeyID) { textBox_complexQuery_comment.Text = ""; ArrayList aServer = null; ArrayList aQueryXml = null; string strError = ""; long nRet = BuildQueryXml( out aServer, out aQueryXml, out strError); if (nRet == -1) { MessageBox.Show(strError); return; } if (aServer.Count == 0) { MessageBox.Show("因没有选定任何服务器地址,无法进行检索"); return; } // 正式检索 // string strError; if (bOutputKeyID == true) this.m_bFirstColumnIsKey = true; else this.m_bFirstColumnIsKey = false; this.ClearListViewPropertyCache(); this.ClearListViewItems(); stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在检索 ..."); stop.BeginLoop(); EnableControlsInSearching(true); // 2010/5/18 string strBrowseStyle = "id,cols"; string strOutputStyle = ""; if (bOutputKeyID == true) { strOutputStyle = "keyid"; strBrowseStyle = "keyid,id,key,cols"; } long lTotalCount = 0; // 命中记录总数 int i=0; for(i=0;i<aServer.Count;i++) { if (stop.State >= 1) break; string strServer = (string)aServer[i]; string strQueryXml = (string)aQueryXml[i]; channel = Channels.GetChannel(strServer); Debug.Assert(channel != null, "Channels.GetChannel 异常"); textBox_complexQuery_comment.Text += "目标服务器:\t" + strServer + "\r\n"; textBox_complexQuery_comment.Text += "检索式XML:\r\n" + DomUtil.GetIndentXml(strQueryXml) + "\r\n"; // MessageBox.Show(this, item.Xml); nRet = channel.DoSearch(strQueryXml, "default", strOutputStyle, out strError); if (nRet == -1) { textBox_complexQuery_comment.Text += "出错: " + strError + "\r\n"; MessageBox.Show(this, strError); continue; } lTotalCount += nRet; textBox_complexQuery_comment.Text += "命中记录数: " + Convert.ToString(nRet) + "\r\n"; if (nRet == 0) continue; // 获取结果集 nRet = channel.DoBrowse(listView_browse, listView_browse.Lang, stop, "default", strBrowseStyle, out strError); if (nRet == -1) { textBox_complexQuery_comment.Text += "装载浏览信息时出错: " + strError + "\r\n"; MessageBox.Show(this, strError); continue; } } if (aServer.Count > 1) { textBox_complexQuery_comment.Text += "命中总条数: " + Convert.ToString(lTotalCount) + "\r\n"; } stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); if (lTotalCount == 0) { MessageBox.Show(this, "未命中"); } EnableControlsInSearching(false); channel = null; }
public void DoSimpleSearch(bool bOutputKeyID) { textBox_simpleQuery_comment.Text = ""; // 第一阶段 TargetItemCollection targets = treeView_simpleQueryResTree. GetSearchTarget(); Debug.Assert(targets != null, "GetSearchTarget() 异常"); int i; // 第二阶段 for(i=0;i<targets.Count;i++) { TargetItem item = (TargetItem)targets[i]; item.Words = textBox_simpleQueryWord.Text; } targets.MakeWordPhrases( Convert.ToBoolean(MainForm.AppInfo.GetInt("simple_query_property", "auto_split_words", 1)), Convert.ToBoolean( MainForm.AppInfo.GetInt("simple_query_property", "auto_detect_range", 0) ), Convert.ToBoolean( MainForm.AppInfo.GetInt("simple_query_property", "auto_detect_relation", 0) ) ); // 参数 for(i=0;i<targets.Count;i++) { TargetItem item = (TargetItem)targets[i]; item.MaxCount = MainForm.AppInfo.GetInt("simple_query_property", "maxcount", -1); } // 第三阶段 targets.MakeXml(); // 正式检索 string strError; if (bOutputKeyID == true) this.m_bFirstColumnIsKey = true; else this.m_bFirstColumnIsKey = false; this.ClearListViewPropertyCache(); this.ClearListViewItems(); stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在检索 ..."); stop.BeginLoop(); EnableControlsInSearching(true); long lTotalCount = 0; // 命中记录总数 for(i=0;i<targets.Count;i++) { if (stop.State >= 1) break; TargetItem item = (TargetItem)targets[i]; channel = Channels.GetChannel(item.Url); Debug.Assert(channel != null, "Channels.GetChannel 异常"); textBox_simpleQuery_comment.Text += "检索式XML:\r\n" + DomUtil.GetIndentXml(item.Xml) + "\r\n"; // 2010/5/18 string strBrowseStyle = "id,cols"; string strOutputStyle = ""; if (bOutputKeyID == true) { strOutputStyle = "keyid"; strBrowseStyle = "keyid,id,key,cols"; } // MessageBox.Show(this, item.Xml); long nRet = channel.DoSearch(item.Xml, "default", strOutputStyle, out strError); if (nRet == -1) { textBox_simpleQuery_comment.Text += "出错: " + strError + "\r\n"; MessageBox.Show(this, strError); continue; } lTotalCount += nRet; textBox_simpleQuery_comment.Text += "命中记录数: " + Convert.ToString(nRet) + "\r\n"; if (nRet == 0) continue; // 获取结果集 nRet = channel.DoBrowse(listView_browse, listView_browse.Lang, stop, "default", strBrowseStyle, out strError); if (nRet == -1) { textBox_simpleQuery_comment.Text += "装载浏览信息时出错: " + strError + "\r\n"; MessageBox.Show(this, strError); continue; } } if (targets.Count > 1) { textBox_simpleQuery_comment.Text += "命中总条数: " + Convert.ToString(lTotalCount) + "\r\n"; } stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); if (lTotalCount == 0) { MessageBox.Show(this, "未命中"); } EnableControlsInSearching(false); channel = null; }