Esempio n. 1
0
        public void DoSearch(bool bOutputKeyCount,
            bool bOutputKeyID,
            ItemQueryParam input_query = null)
        {
            string strError = "";
            int nRet = 0;
            bool bDisplayClickableError = false;

            if (bOutputKeyCount == true
    && bOutputKeyID == true)
            {
                strError = "bOutputKeyCount和bOutputKeyID不能同时为true";
                goto ERROR1;
            }

            bool bQuickLoad = false;    // 是否快速装入
            bool bClear = true; // 是否清除浏览窗中已有的内容

            if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                bQuickLoad = true;

            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                bClear = false;

            // 修改窗口标题
            this.Text = "书目查询 " + this.textBox_queryWord.Text;

            if (input_query != null)
            {
                QueryToPanel(input_query);
            }

            // 记忆下检索式
            this.m_bFirstColumnIsKey = bOutputKeyID;
            this.ClearListViewPropertyCache();

            ItemQueryParam query = PanelToQuery();
            PushQuery(query);

            if (bClear == true)
            {
                if (this.m_nChangedCount > 0)
                {
                    DialogResult result = MessageBox.Show(this,
                        "当前命中记录列表中有 " + this.listView_records.Items.Count.ToString() + " 项修改尚未保存。\r\n\r\n是否继续操作?\r\n\r\n(Yes 清除,然后继续操作;No 放弃操作)",
                        "BiblioSearchForm",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.No)
                        return;
                }
                this.ClearListViewItems();

                /*
                // 2008/11/22
                this.SortColumns.Clear();
                SortColumns.ClearColumnSortDisplay(this.listView_records.Columns);
                 * */
                ListViewUtil.ClearSortColumns(this.listView_records);

                this._browseTitleTable.Clear();
            }

            this.m_lHitCount = 0;
            this.m_lLoaded = 0;
            stop.HideProgress();

            this.label_message.Text = "";

            LibraryChannel channel = this.GetChannel();

            stop.Style = StopStyle.None;
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在检索 '" + this.textBox_queryWord.Text + "' ...");
            stop.BeginLoop();

            this.ShowMessage("正在检索 '" + this.textBox_queryWord.Text + "' ...");

            this.EnableControlsInSearching(false);
            try
            {
                if (this.comboBox_from.Text == "")
                {
                    strError = "尚未选定检索途径";
                    goto ERROR1;
                }

                string strFromStyle = "";

                try
                {
                    strFromStyle = this.MainForm.GetBiblioFromStyle(this.comboBox_from.Text);
                }
                catch (Exception ex)
                {
                    strError = "BiblioSearchForm GetBiblioFromStyle() exception: " + ExceptionUtil.GetAutoText(ex);
                    goto ERROR1;
                }

                if (String.IsNullOrEmpty(strFromStyle) == true)
                {
                    strError = "GetFromStyle()没有找到 '" + this.comboBox_from.Text + "' 对应的style字符串";
                    goto ERROR1;
                }

                // 注:"null"只能在前端短暂存在,而内核是不认这个所谓的matchstyle的
                string strMatchStyle = GetCurrentMatchStyle(this.comboBox_matchStyle.Text);

                if (this.textBox_queryWord.Text == "")
                {
                    if (strMatchStyle == "null")
                    {
                        this.textBox_queryWord.Text = "";

                        // 专门检索空值
                        strMatchStyle = "exact";
                    }
                    else
                    {
                        // 为了在检索词为空的时候,检索出全部的记录
                        strMatchStyle = "left";
                    }
                }
                else
                {
                    // 2009/11/5
                    if (strMatchStyle == "null")
                    {
                        strError = "检索空值的时候,请保持检索词为空";
                        goto ERROR1;
                    }
                }

                // string strBrowseStyle = "id,cols";
                string strOutputStyle = "";
                if (bOutputKeyCount == true)
                {
                    strOutputStyle = "keycount";
                }
                else if (bOutputKeyID == true)
                {
                    strOutputStyle = "keyid";
                    // strBrowseStyle = "keyid,id,key,cols";
                }

                bool bNeedShareSearch = false;
                if (this.SearchShareBiblio == true
    && this.MainForm != null && this.MainForm.MessageHub != null
    && this.MainForm.MessageHub.ShareBiblio == true
                    && bOutputKeyCount == false
                    && bOutputKeyID == false)
                {
                    bNeedShareSearch = true;
                }

                if (bNeedShareSearch == true)
                {
                    // 开始检索共享书目
                    // return:
                    //      -1  出错
                    //      0   没有检索目标
                    //      1   成功启动检索
                    nRet = BeginSearchShareBiblio(
                        this.textBox_queryWord.Text,
                        strFromStyle,
                        strMatchStyle,
                        out strError);
                    if (nRet == -1)
                    {
                        // 显示错误信息
                        this.ShowMessage(strError, "red", true);
                        bDisplayClickableError = true;
                    }
                }

                string strQueryXml = "";
                channel.Timeout = new TimeSpan(0, 5, 0);
                long lRet = channel.SearchBiblio(stop,
                    this.checkedComboBox_biblioDbNames.Text,
                    this.textBox_queryWord.Text,
                    this.MaxSearchResultCount,  // 1000
                    strFromStyle,
                    strMatchStyle,  // "left",
                    this.Lang,
                    null,   // strResultSetName
                    "",    // strSearchStyle
                    strOutputStyle,
                    this.GetLocationFilter(),
                    out strQueryXml,
                    out strError);
                if (lRet == -1)
                    goto ERROR1;

                long lHitCount = lRet;

                this.m_lHitCount = lHitCount;

                this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条书目记录";

                stop.SetProgressRange(0, lHitCount);
                stop.Style = StopStyle.EnableHalfStop;

                long lStart = 0;
                long lPerCount = Math.Min(50, lHitCount);
                DigitalPlatform.LibraryClient.localhost.Record[] searchresults = null;

                bool bPushFillingBrowse = this.PushFillingBrowse;

                // 装入浏览格式
                for (; ; )
                {
                    Application.DoEvents();	// 出让界面控制权

                    if (stop != null && stop.State != 0)
                    {
                        // MessageBox.Show(this, "用户中断");
                        this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条书目记录,已装入 " + lStart.ToString() + " 条,用户中断...";
                        return;
                    }

                    stop.SetMessage("正在装入浏览信息 " + (lStart + 1).ToString() + " - " + (lStart + lPerCount).ToString() + " (命中 " + lHitCount.ToString() + " 条记录) ...");

                    bool bTempQuickLoad = bQuickLoad;

                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                        bTempQuickLoad = true;

                    string strBrowseStyle = "id,cols";
                    if (bOutputKeyCount == true)
                        strBrowseStyle = "keycount";
                    else
                    {
                        if (bTempQuickLoad == true)
                        {
                            if (bOutputKeyID == true)
                                strBrowseStyle = "keyid,id,key";
                            else
                                strBrowseStyle = "id";
                        }
                        else
                        {
                            // 
                            if (bOutputKeyID == true)
                                strBrowseStyle = "keyid,id,key,cols";
                            else
                                strBrowseStyle = "id,cols";
                        }
                    }

                    lRet = channel.GetSearchResult(
                        stop,
                        null,   // strResultSetName
                        lStart,
                        lPerCount,
                        strBrowseStyle,
                        this.Lang,
                        out searchresults,
                        out strError);
                    if (lRet == -1)
                    {
                        this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条书目记录,已装入 " + lStart.ToString() + " 条," + strError;
                        goto ERROR1;
                    }

                    if (lRet == 0)
                        break;

                    if (lRet > 0)
                    {
                        this.listView_records.BeginUpdate();
                        try
                        {
                            // 处理浏览结果
                            for (int i = 0; i < searchresults.Length; i++)
                            {
                                ListViewItem item = null;

                                DigitalPlatform.LibraryClient.localhost.Record searchresult = searchresults[i];

                                string[] cols = null;
                                if (bOutputKeyCount == true)
                                {
                                    // 输出keys
                                    if (searchresult.Cols == null)
                                    {
                                        strError = "要使用获取检索点功能,请将 dp2Library 应用服务器和 dp2Kernel 数据库内核升级到最新版本";
                                        goto ERROR1;
                                    }
                                    cols = new string[(searchresult.Cols == null ? 0 : searchresult.Cols.Length) + 1];
                                    cols[0] = searchresult.Path;
                                    if (cols.Length > 1)
                                        Array.Copy(searchresult.Cols, 0, cols, 1, cols.Length - 1);

                                    if (bPushFillingBrowse == true)
                                        item = Global.InsertNewLine(
                                            this.listView_records,
                                            "",
                                            cols);
                                    else
                                        item = Global.AppendNewLine(
                                            this.listView_records,
                                            "",
                                            cols);
                                    item.Tag = query;
                                    goto CONTINUE;
                                }
                                else if (bOutputKeyID == true)
                                {
                                    // 输出keys
                                    if (searchresult.Cols == null
                                        && bTempQuickLoad == false)
                                    {
                                        strError = "要使用获取检索点功能,请将 dp2Library 应用服务器和 dp2Kernel 数据库内核升级到最新版本";
                                        goto ERROR1;
                                    }

                                    cols = new string[(searchresult.Cols == null ? 0 : searchresult.Cols.Length) + 1];
                                    cols[0] = LibraryChannel.BuildDisplayKeyString(searchresult.Keys);
                                    if (cols.Length > 1)
                                        Array.Copy(searchresult.Cols, 0, cols, 1, cols.Length - 1);
                                }
                                else
                                {
                                    cols = searchresult.Cols;
                                }

                                if (bPushFillingBrowse == true)
                                {
                                    if (bTempQuickLoad == true)
                                        item = Global.InsertNewLine(
                                            (ListView)this.listView_records,
                                            searchresult.Path,
                                            cols);
                                    else
                                        item = Global.InsertNewLine(
                                            this.listView_records,
                                            searchresult.Path,
                                            cols);
                                }
                                else
                                {
                                    if (bTempQuickLoad == true)
                                        item = Global.AppendNewLine(
                                            (ListView)this.listView_records,
                                            searchresult.Path,
                                            cols);
                                    else
                                        item = Global.AppendNewLine(
                                            this.listView_records,
                                            searchresult.Path,
                                            cols);
                                }

                            CONTINUE:
                                query.Items.Add(item);
                            }
                        }
                        finally
                        {
                            this.listView_records.EndUpdate();
                        }

                        lStart += searchresults.Length;
                        // lCount -= searchresults.Length;
                        if (lStart >= lHitCount || lPerCount <= 0)
                            break;

                        this.m_lLoaded = lStart;
                        stop.SetProgressValue(lStart);
                    }
                }

                // MessageBox.Show(this, Convert.ToString(lRet) + " : " + strError);

                if (bNeedShareSearch == true)
                {
                    this.ShowMessage("等待共享检索响应 ...");
                    // 结束检索共享书目
                    // return:
                    //      -1  出错
                    //      >=0 命中记录个数
                    nRet = EndSearchShareBiblio(out strError);
                    if (nRet == -1)
                    {
                        // 显示错误信息
                        this.ShowMessage(strError, "red", true);
                        bDisplayClickableError = true;
                    }
                    else
                    {
                        if (_searchParam._searchCount > 0)
                        {
                            this.ShowMessage("共享书目命中 " + _searchParam._searchCount + " 条", "green");
                            this._floatingMessage.DelayClear(new TimeSpan(0, 0, 3));
#if NO
                            Application.DoEvents();
                            // TODO: 延时一段自动删除
                            Thread.Sleep(1000);
#endif
                        }
                    }

                    lHitCount += _searchParam._searchCount;
                }

                if (lHitCount == 0)
                {
                    this.ShowMessage("未命中", "yellow", true);
                    bDisplayClickableError = true;
                }

                if (lHitCount == 0)
                    this.label_message.Text = "未命中";
                else
                    this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条书目记录,已全部装入";

            }
            finally
            {
                if (bDisplayClickableError == false
                    && this._floatingMessage.InDelay() == false)
                    this.ClearMessage();
                if (this.MainForm.MessageHub != null)
                    this.MainForm.MessageHub.SearchResponseEvent -= MessageHub_SearchResponseEvent;

                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
                stop.HideProgress();
                stop.Style = StopStyle.None;

                this.ReturnChannel(channel);

                this.EnableControlsInSearching(true);
            }

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Esempio n. 2
0
        ItemQueryParam PanelToQuery()
        {
            ItemQueryParam query = new ItemQueryParam();

            query.QueryWord = this.textBox_queryWord.Text;
            query.DbNames = this.checkedComboBox_biblioDbNames.Text;
            query.From = this.comboBox_from.Text;
            query.MatchStyle = this.comboBox_matchStyle.Text;
            query.FirstColumnIsKey = this.m_bFirstColumnIsKey;
            return query;
        }
Esempio n. 3
0
        void PushQuery(ItemQueryParam query)
        {
            if (query == null)
                throw new Exception("query值不能为空");

            // 截断尾部多余的
            if (this.m_nQueryIndex < this.m_queries.Count - 1)
                this.m_queries.RemoveRange(this.m_nQueryIndex + 1, this.m_queries.Count - (this.m_nQueryIndex + 1));

            if (this.m_queries.Count > 100)
            {
                int nDelta = this.m_queries.Count - 100;
                this.m_queries.RemoveRange(0, nDelta);
                if (this.m_nQueryIndex >= 0)
                {
                    this.m_nQueryIndex -= nDelta;
                    Debug.Assert(this.m_nQueryIndex >= 0, "");
                }
            }

            this.m_queries.Add(query);
            this.m_nQueryIndex++;
            SetQueryPrevNextState();
        }
Esempio n. 4
0
        // 在一个新开的书目查询窗内检索key
        void listView_searchKeysAtNewWindow_Click(object sender, EventArgs e)
        {
            if (this.listView_records.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未在列表中选定要操作的事项");
                return;
            }

            BiblioSearchForm form = new BiblioSearchForm();
            form.MdiParent = this.MainForm;
            // form.MainForm = this.MainForm;
            form.Show();

            ItemQueryParam query = (ItemQueryParam)this.listView_records.SelectedItems[0].Tag;
            Debug.Assert(query != null, "");

            ItemQueryParam input_query = new ItemQueryParam();

            input_query.QueryWord = ListViewUtil.GetItemText(this.listView_records.SelectedItems[0], 1);
            input_query.DbNames = query.DbNames;
            input_query.From = query.From;
            input_query.MatchStyle = "精确一致";

            // 检索命中记录(而不是key)
            form.DoSearch(false, false, input_query);
        }
Esempio n. 5
0
        void QueryToPanel(ItemQueryParam query)
        {
            Cursor oldCursor = this.Cursor;
            this.Cursor = Cursors.WaitCursor;
            try
            {
                this.textBox_queryWord.Text = query.QueryWord;
                this.checkedComboBox_biblioDbNames.Text = query.DbNames;
                this.comboBox_from.Text = query.From;
                this.comboBox_matchStyle.Text = query.MatchStyle;

                if (this.m_nChangedCount > 0)
                {
                    DialogResult result = MessageBox.Show(this,
                        "当前命中记录列表中有 " + this.listView_records.Items.Count.ToString() + " 项修改尚未保存。\r\n\r\n是否继续操作?\r\n\r\n(Yes 清除,然后继续操作;No 放弃操作)",
                        "BiblioSearchForm",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.No)
                        return;
                }
                this.ClearListViewItems();

                this.listView_records.BeginUpdate();
                for (int i = 0; i < query.Items.Count; i++)
                {
                    this.listView_records.Items.Add(query.Items[i]);
                }
                this.listView_records.EndUpdate();

                this.m_bFirstColumnIsKey = query.FirstColumnIsKey;
                this.ClearListViewPropertyCache();
            }
            finally
            {
                this.Cursor = oldCursor;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 执行一次检索
        /// </summary>
        /// <param name="bOutputKeyCount">是否要输出为 key+count 形态</param>
        /// <param name="bOutputKeyID">是否为 keyid 形态</param>
        /// <param name="input_query">检索式</param>
        /// <param name="bClearList">是否要在检索开始时清空浏览列表</param>
        /// <returns>-1:出错 0:中断 1:正常结束</returns>
        public int DoSearch(bool bOutputKeyCount,
            bool bOutputKeyID,
            ItemQueryParam input_query,
            bool bClearList = true)
        {
            string strError = "";
            int nRet = 0;

            if (bOutputKeyCount == true
                && bOutputKeyID == true)
            {
                strError = "bOutputKeyCount和bOutputKeyID不能同时为true";
                goto ERROR1;
            }

            /*
            bool bOutputKeyCount = false;
            if (Control.ModifierKeys == Keys.Control)
                bOutputKeyCount = true;
             * */

            if (input_query != null)
            {
                QueryToPanel(input_query, bClearList);
            }

            // 记忆下检索式
            this.m_bFirstColumnIsKey = bOutputKeyID;
            this.ClearListViewPropertyCache();

            ItemQueryParam query = PanelToQuery();
            PushQuery(query);

            if (bClearList == true)
            {
                ClearListViewItems();
                m_tableSummaryColIndex.Clear();
            }

            EnableControls(false);
            this.label_message.Text = "";

            stop.Style = StopStyle.None;
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在检索 ...");
            stop.BeginLoop();

            try
            {
                string strMatchStyle = "";

                strMatchStyle = GetCurrentMatchStyle();

                if (this.textBox_queryWord.Text == "")
                {
                    if (strMatchStyle == "null")
                    {
                        this.textBox_queryWord.Text = "";

                        // 专门检索空值
                        strMatchStyle = "exact";
                    }
                    else
                    {
                        // 为了在检索词为空的时候,检索出全部的记录
                        strMatchStyle = "left";
                    }
                }

                // string strBrowseStyle = "id, cols";
                string strOutputStyle = "";
                if (bOutputKeyCount == true)
                {
                    strOutputStyle = "keycount";
                    //strBrowseStyle = "keycount";
                }
                else if (bOutputKeyID == true)
                {
                    strOutputStyle = "keyid";
                    //strBrowseStyle = "keyid,key,id,cols";
                }

                long lRet = 0;

                if (this.DbType == "item")
                {
                    lRet = Channel.SearchItem(stop,
                        this.comboBox_entityDbName.Text, // "<all>",
                        this.textBox_queryWord.Text,
                        this.MaxSearchResultCount,
                        this.comboBox_from.Text,
                        strMatchStyle, // this.textBox_queryWord.Text == "" ? "left" : "exact",    // 原来为left 2007/10/18 changed
                        this.Lang,
                        null,   // strResultSetName
                        "",    // strSearchStyle
                        strOutputStyle, // (bOutputKeyCount == true ? "keycount" : ""),
                        out strError);
                }
                else if (this.DbType == "comment")
                {
                    lRet = Channel.SearchComment(stop,
                        this.comboBox_entityDbName.Text,
                        this.textBox_queryWord.Text,
                        this.MaxSearchResultCount,
                        this.comboBox_from.Text,
                        strMatchStyle,
                        this.Lang,
                        null,
                        "",
                        strOutputStyle,
                        out strError);
                }
                else if (this.DbType == "order")
                {
                    lRet = Channel.SearchOrder(stop,
                        this.comboBox_entityDbName.Text,
                        this.textBox_queryWord.Text,
                        this.MaxSearchResultCount,
                        this.comboBox_from.Text,
                        strMatchStyle,
                        this.Lang,
                        null,
                        "",
                        strOutputStyle,
                        out strError);
                }
                else if (this.DbType == "issue")
                {
                    lRet = Channel.SearchIssue(stop,
                        this.comboBox_entityDbName.Text,
                        this.textBox_queryWord.Text,
                        this.MaxSearchResultCount,
                        this.comboBox_from.Text,
                        strMatchStyle,
                        this.Lang,
                        null,
                        "",
                        strOutputStyle,
                        out strError);
                }
                else if (this.DbType == "arrive")
                {
#if NO
                    string strArrivedDbName = "";
                    // return:
                    //      -1  出错
                    //      0   没有配置
                    //      1   找到
                    nRet = GetArrivedDbName(false, out strArrivedDbName, out strError);
                    if (nRet == -1 || nRet == 0)
                        goto ERROR1;
#endif
                    if (string.IsNullOrEmpty(this.MainForm.ArrivedDbName) == true)
                    {
                        strError = "当前服务器尚未配置预约到书库名";
                        goto ERROR1;
                    }

                    string strQueryXml = "<target list='" + this.MainForm.ArrivedDbName + ":" + this.comboBox_from.Text + "'><item><word>"
        + StringUtil.GetXmlStringSimple(this.textBox_queryWord.Text)
        + "</word><match>" + strMatchStyle + "</match><relation>=</relation><dataType>string</dataType><maxCount>"
                    + this.MaxSearchResultCount + "</maxCount></item><lang>" + this.Lang + "</lang></target>";
                    // strOutputStyle ?
                    lRet = Channel.Search(stop,
                        strQueryXml,
                        "",
                        strOutputStyle,
                        out strError);
                }
                else
                    throw new Exception("未知的 DbType '" + this.DbType + "'");

                if (lRet == -1)
                    goto ERROR1;

                long lHitCount = lRet;

                // return:
                //      -1  出错
                //      0   用户中断
                //      1   正常完成
                nRet = FillBrowseList(
                    query,
                    lHitCount,
                    bOutputKeyCount,
                    bOutputKeyID,
                    out strError);
                if (nRet == 0)
                    return 0;
                if (nRet == -1)
                    this.ShowMessage("填充浏览列时出错: " + strError, "red", true);

                // MessageBox.Show(this, Convert.ToString(lRet) + " : " + strError);
                this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条,已全部装入";
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
                stop.HideProgress();
                stop.Style = StopStyle.None;

                EnableControls(true);
            }

            return 1;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Esempio n. 7
0
        //long m_lLoaded = 0; // 本次已经装入浏览框的条数
        //long m_lHitCount = 0;   // 检索命中结果条数


        /// <summary>
        /// 执行一次逻辑检索
        /// </summary>
        /// <param name="bOutputKeyCount">是否要输出为 key+count 形态</param>
        /// <param name="bOutputKeyID">是否为 keyid 形态</param>
        /// <param name="input_query">检索式</param>
        public void DoLogicSearch(bool bOutputKeyCount,
            bool bOutputKeyID,
            ItemQueryParam input_query)
        {
            string strError = "";

            if (bOutputKeyCount == true
    && bOutputKeyID == true)
            {
                strError = "bOutputKeyCount和bOutputKeyID不能同时为true";
                goto ERROR1;
            }

            if (input_query != null)
            {
                QueryToPanel(input_query);
            }

            bool bQuickLoad = false;    // 是否快速装入
            bool bClear = true; // 是否清除浏览窗中已有的内容

            if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                bQuickLoad = true;

            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                bClear = false;


            // 修改窗口标题
            // this.Text = "书目查询 逻辑检索";

            this.m_bFirstColumnIsKey = bOutputKeyID;
            this.ClearListViewPropertyCache();

            ItemQueryParam query = PanelToQuery();
            PushQuery(query);

            if (bClear == true)
            {
                if (this.m_nChangedCount > 0)
                {
                    DialogResult result = MessageBox.Show(this,
                        "当前命中记录列表中有 " + this.m_nChangedCount.ToString() + " 项修改尚未保存。\r\n\r\n是否继续操作?\r\n\r\n(Yes 清除,然后继续操作;No 放弃操作)",
                        "ItemSearchForm",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.No)
                        return;
                }
                this.ClearListViewItems();

                ListViewUtil.ClearSortColumns(this.listView_records);
            }

            //this.m_lHitCount = 0;
            //this.m_lLoaded = 0;
            stop.HideProgress();

            this.label_message.Text = "";

            stop.Style = StopStyle.None;
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在检索 ...");
            stop.BeginLoop();

            this.EnableControls(false);
            try
            {
                // string strBrowseStyle = "id,cols";
                string strOutputStyle = "";
                if (bOutputKeyCount == true)
                {
                    strOutputStyle = "keycount";
                    // strBrowseStyle = "keycount";
                }
                else if (bOutputKeyID == true)
                {
                    strOutputStyle = "keyid";
                    // strBrowseStyle = "keyid,id,key,cols";
                }

                string strQueryXml = "";
                int nRet = dp2QueryControl1.BuildQueryXml(
    this.MaxSearchResultCount,
    "zh",
    out strQueryXml,
    out strError);
                if (nRet == -1)
                    goto ERROR1;

                long lRet = Channel.Search(stop,
                    strQueryXml,
                    "default",
                    strOutputStyle,
                    out strError);
                if (lRet == -1)
                    goto ERROR1;

                long lHitCount = lRet;

                // return:
                //      -1  出错
                //      0   用户中断
                //      1   正常完成
                nRet = FillBrowseList(
                    query,
                    lHitCount,
                    bOutputKeyCount,
                    bOutputKeyID,
                    out strError);
                if (nRet == 0)
                    return;

                // MessageBox.Show(this, Convert.ToString(lRet) + " : " + strError);
                this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条,已全部装入";
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
                stop.HideProgress();
                stop.Style = StopStyle.None;

                this.EnableControls(true);
            }

            return;

        ERROR1:
            MessageBox.Show(this, strError);
        }
Esempio n. 8
0
        // 将 ItemQueryParam 中的信息恢复到面板中
        void QueryToPanel(ItemQueryParam query,
            bool bClearList = true)
        {
            Cursor oldCursor = this.Cursor;
            this.Cursor = Cursors.WaitCursor;
            try
            {
                this.textBox_queryWord.Text = query.QueryWord;
                this.comboBox_entityDbName.Text = query.DbNames;
                this.comboBox_from.Text = query.From;
                this.comboBox_matchStyle.Text = query.MatchStyle;

                if (bClearList == true)
                    this.ClearListViewItems();
                this.listView_records.BeginUpdate();
                for (int i = 0; i < query.Items.Count; i++)
                {
                    this.listView_records.Items.Add(query.Items[i]);
                }
                this.listView_records.EndUpdate();

                this.m_bFirstColumnIsKey = query.FirstColumnIsKey;
                this.ClearListViewPropertyCache();
            }
            finally
            {
                this.Cursor = oldCursor;
            }
        }
Esempio n. 9
0
        // 在一个新开的实体查询窗内检索key
        void listView_searchKeysAtNewWindow_Click(object sender, EventArgs e)
        {
            if (this.listView_records.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未在列表中选定要操作的事项");
                return;
            }

            ItemSearchForm form = new ItemSearchForm();
            form.DbType = this.DbType;
            form.MdiParent = this.MainForm;
            // form.MainForm = this.MainForm;
            form.Show();

            int i = 0;
            foreach (ListViewItem item in this.listView_records.SelectedItems)
            {
                ItemQueryParam query = (ItemQueryParam)item.Tag;
                Debug.Assert(query != null, "");

                ItemQueryParam input_query = new ItemQueryParam();

                input_query.QueryWord = ListViewUtil.GetItemText(item, 1);
                input_query.DbNames = query.DbNames;
                input_query.From = query.From;
                input_query.MatchStyle = "精确一致";

                // 2015/1/17
                if (string.IsNullOrEmpty(input_query.QueryWord) == true)
                    input_query.MatchStyle = "空值";
                else
                    input_query.MatchStyle = "精确一致";


                // 检索命中记录(而不是key)
                int nRet = form.DoSearch(false, false, input_query, i == 0 ? true : false);
                if (nRet != 1)
                    break;

                i++;
            }
        }
Esempio n. 10
0
        // return:
        //      -1  出错
        //      0   用户中断或者未命中
        //      1   正常完成
        int FillBrowseList(
            ItemQueryParam query,
            long lHitCount,
            bool bOutputKeyCount,
            bool bOutputKeyID,
            out string strError)
        {
            strError = "";

            bool bAccessBiblioSummaryDenied = false;

            string strBrowseStyle = "id, cols";
            //string strOutputStyle = "";
            if (bOutputKeyCount == true)
            {
                //strOutputStyle = "keycount";
                strBrowseStyle = "keycount";
            }
            else if (bOutputKeyID == true)
            {
                //strOutputStyle = "keyid";
                strBrowseStyle = "keyid,key,id,cols";
            }
            //
            this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条";
            stop.SetProgressRange(0, lHitCount);
            stop.Style = StopStyle.EnableHalfStop;

            bool bSelectFirstLine = false;
            long lStart = 0;
            long lCount = lHitCount;
            DigitalPlatform.LibraryClient.localhost.Record[] searchresults = null;

            bool bPushFillingBrowse = this.PushFillingBrowse;

            // 装入浏览格式
            for (; ; )
            {
                Application.DoEvents();	// 出让界面控制权

                if (stop != null)
                {
                    if (stop.State != 0)
                    {
                        // MessageBox.Show(this, "用户中断");
                        this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条,用户中断...";
                        return 0;
                    }
                }

                long lRet = Channel.GetSearchResult(
                    stop,
                    null,   // strResultSetName
                    lStart,
                    lCount,
                    strBrowseStyle, // bOutputKeyCount == true ? "keycount" : "id,cols",
                    this.Lang,
                    out searchresults,
                    out strError);
                if (lRet == -1)
                {
                    this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条," + strError;
                    goto ERROR1;
                }

                if (lRet == 0)
                {
                    MessageBox.Show(this, "未命中");
                    return 0;
                }

                // 处理浏览结果
                this.listView_records.BeginUpdate();
                try
                {
                    List<ListViewItem> items = new List<ListViewItem>();
                    for (int i = 0; i < searchresults.Length; i++)
                    {
                        ListViewItem item = null;

                        DigitalPlatform.LibraryClient.localhost.Record searchresult = searchresults[i];

                        if (bOutputKeyCount == false
                            && bOutputKeyID == false)
                        {
                            if (bPushFillingBrowse == true)
                                item = Global.InsertNewLine(
                                    this.listView_records,
                                    searchresult.Path,
                                    this.m_bBiblioSummaryColumn == true ? Global.InsertBlankColumn(searchresult.Cols) : searchresult.Cols);
                            else
                                item = Global.AppendNewLine(
                                    this.listView_records,
                                    searchresult.Path,
                                    this.m_bBiblioSummaryColumn == true ? Global.InsertBlankColumn(searchresult.Cols) : searchresult.Cols);
                        }
                        else if (bOutputKeyCount == true)
                        {
                            // 输出keys
                            if (searchresult.Cols == null)
                            {
                                strError = "要使用获取检索点功能,请将 dp2Library 应用服务器和 dp2Kernel 数据库内核升级到最新版本";
                                goto ERROR1;
                            }
                            string[] cols = new string[(searchresult.Cols == null ? 0 : searchresult.Cols.Length) + 1];
                            cols[0] = searchresult.Path;
                            if (cols.Length > 1)
                                Array.Copy(searchresult.Cols, 0, cols, 1, cols.Length - 1);

                            if (bPushFillingBrowse == true)
                                item = Global.InsertNewLine(
                                    this.listView_records,
                                    "",
                                    cols);
                            else
                                item = Global.AppendNewLine(
                                    this.listView_records,
                                    "",
                                    cols);
                            item.Tag = query;
                        }
                        else if (bOutputKeyID == true)
                        {
                            if (searchresult.Cols == null)
                            {
                                strError = "要使用带有检索点的检索功能,请将 dp2Library 应用服务器和 dp2Kernel 数据库内核升级到最新版本";
                                goto ERROR1;
                            }


#if NO
                                string[] cols = new string[(searchresult.Cols == null ? 0 : searchresult.Cols.Length) + 1];
                                cols[0] = LibraryChannel.BuildDisplayKeyString(searchresult.Keys);
                                if (cols.Length > 1)
                                    Array.Copy(searchresult.Cols, 0, cols, 1, cols.Length - 1);
#endif
                            string[] cols = this.m_bBiblioSummaryColumn == true ? Global.InsertBlankColumn(searchresult.Cols, 2) : searchresult.Cols;
                            cols[0] = LibraryChannel.BuildDisplayKeyString(searchresult.Keys);

                            if (bPushFillingBrowse == true)
                                item = Global.InsertNewLine(
                                    this.listView_records,
                                    searchresult.Path,
                                    cols);
                            else
                                item = Global.AppendNewLine(
                                    this.listView_records,
                                    searchresult.Path,
                                    cols);
                            item.Tag = query;
                        }

                        query.Items.Add(item);
                        items.Add(item);
                        stop.SetProgressValue(lStart + i);
                    }

                    if (bOutputKeyCount == false
                        && bAccessBiblioSummaryDenied == false)
                    {
                        // return:
                        //      -2  获得书目摘要的权限不够
                        //      -1  出错
                        //      0   用户中断
                        //      1   完成
                        int nRet = _fillBiblioSummaryColumn(items,
                            0,
                            false,
                            true,   // false,  // bAutoSearch
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;
                        if (nRet == -2)
                            bAccessBiblioSummaryDenied = true;

                        if (nRet == 0)
                        {
                            this.label_message.Text = "检索共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条,用户中断...";
                            return 0;
                        }
                    }
                }
                finally
                {
                    this.listView_records.EndUpdate();
                }

                if (bSelectFirstLine == false && this.listView_records.Items.Count > 0)
                {
                    if (this.listView_records.SelectedItems.Count == 0)
                        this.listView_records.Items[0].Selected = true;
                    bSelectFirstLine = true;
                }

                lStart += searchresults.Length;
                lCount -= searchresults.Length;

                stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条");

                if (lStart >= lHitCount || lCount <= 0)
                    break;
                stop.SetProgressValue(lStart);
            }

            if (bAccessBiblioSummaryDenied == true)
                MessageBox.Show(this, "当前用户不具备获取书目摘要的权限");

            return 1;
        ERROR1:
            return -1;
        }