Beispiel #1
0
        private void button_test_Click(object sender, EventArgs e)
        {
#if NO
            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.applicationInfo.GetInt("simple_query_property", "auto_split_words", 1)),
                Convert.ToBoolean(MainForm.applicationInfo.GetInt("simple_query_property", "auto_detect_range", 0)),
                Convert.ToBoolean(MainForm.applicationInfo.GetInt("simple_query_property", "auto_detect_relation", 0))
                );


            // 参数
            for (i = 0; i < targets.Count; i++)
            {
                TargetItem item = (TargetItem)targets[i];
                item.MaxCount = MainForm.applicationInfo.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("正在Test ...");
            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" + item.Xml + "\r\n";

                // MessageBox.Show(this, item.Xml);
                long nRet = channel.DoTest(item.Xml);
                if (nRet == -1)
                {
                    textBox_simpleQuery_comment.Text += "Test出错: \r\n";
                    MessageBox.Show(this, textBox_simpleQuery_comment.Text);
                    continue;
                }
                lTotalCount += nRet;
                textBox_simpleQuery_comment.Text += "命中记录数: " + Convert.ToString(nRet) + "\r\n";

            }

            if (targets.Count > 1)
            {
                textBox_simpleQuery_comment.Text += "命中总条数: " + Convert.ToString(lTotalCount) + "\r\n";
            }

            stop.EndLoop();
            stop.OnStop -= new StopEventHandler(this.DoStop);
            stop.Initial("");

            EnableControlsInSearching(false);

            channel = null;
#endif
        }