Exemplo n.º 1
0
        public void BeginGcatLoop(string strMessage)
        {
            bMarcEditorFocued = this.DetailForm.MarcEditor.Focused;
            this.DetailForm.EnableControls(false);

            Stop stop = this.DetailForm.stop;

            stop.OnStop += new StopEventHandler(this.DoGcatStop);
            stop.Initial(strMessage);
            stop.BeginLoop();

            this.DetailForm.Update();
            this.DetailForm.MainForm.Update();
        }
Exemplo n.º 2
0
        // 检索出盘点库内全部批次号名称
        int SearchAllBatchNo(
            LibraryChannel channel,
            Stop stop,
            string strInventoryDbName,
            out string strError)
        {
            strError = "";

            this.listView_records.Items.Clear();

            // EnableControls(false);
            stop.OnStop += new StopEventHandler(channel.DoStop);
            stop.Initial("正在列出全部批次号 ...");
            stop.BeginLoop();

            try
            {
                // 构造检索式
                StringBuilder text = new StringBuilder();

                text.Append("<target list='"
                            + StringUtil.GetXmlStringSimple(strInventoryDbName + ":" + "批次号")
                            + "'>");
                // 当前是否为全局用户
                bool bGlobalUser = this._libraryCodeList.Count == 0 || this._libraryCodeList.IndexOf("") != -1;
                // 全局用户只认列表中 "" 一个值。这样可以检索出全部批次号,包括各个分馆的
                if (bGlobalUser == true && this._libraryCodeList.Count != 1)
                {
                    this._libraryCodeList.Clear();
                    this._libraryCodeList.Add("");
                }
                int i = 0;
                foreach (string librarycode in this.LibraryCodeList)
                {
                    if (i > 0)
                    {
                        text.Append("<operator value='OR' />");
                    }

                    text.Append("<item><word>"
                                + StringUtil.GetXmlStringSimple(bGlobalUser ? "" : librarycode + "-")
                                + "</word><match>left</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang>");
                    i++;
                }

                if (bGlobalUser == true)
                {
                    if (i > 0)
                    {
                        text.Append("<operator value='OR' />");
                    }

                    // 针对空批次号的检索。空只能被全局用户可见
                    text.Append("<item><word>"
                                + StringUtil.GetXmlStringSimple("")
                                + "</word><match>exact</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang>");
                    i++;
                }

                text.Append("</target>");

#if NO
                // 构造检索式
                string strQueryXml = "<target list='"
                                     + StringUtil.GetXmlStringSimple(strInventoryDbName + ":" + "批次号")
                                     + "'><item><word>"
                                     + StringUtil.GetXmlStringSimple("")
                                     + "</word><match>left</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang>";
                strQueryXml += "<operator value='OR' />";
                strQueryXml += "<item><word>"
                               + StringUtil.GetXmlStringSimple("")
                               + "</word><match>exact</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang></target>";
#endif

                long lRet = channel.Search(
                    stop,
                    text.ToString(),
                    "batchno",
                    "keycount", // strOutputStyle
                    out strError);
                if (lRet == 0)
                {
                    strError = "not found";
                    return(0);   // not found
                }
                if (lRet == -1)
                {
                    return(-1);
                }

                long lHitCount = lRet;

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

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

                    if (stop != null && stop.State != 0)
                    {
                        strError = "用户中断";
                        return(-1);
                    }

                    lRet = channel.GetSearchResult(
                        stop,
                        "batchno",   // strResultSetName
                        lStart,
                        lCount,
                        "keycount",
                        "zh",
                        out searchresults,
                        out strError);
                    if (lRet == -1)
                    {
                        strError = "GetSearchResult() error: " + strError;
                        return(-1);
                    }

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

                    // 处理浏览结果
                    foreach (Record record in searchresults)
                    {
                        if (record.Cols == null)
                        {
                            strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出批次号的功能";
                            return(-1);
                        }

                        // 跳过数字为 0 的事项
                        if (record.Cols.Length > 0 && record.Cols[0] == "0")
                        {
                            continue;
                        }

                        ListViewItem item = new ListViewItem();
                        item.Text = string.IsNullOrEmpty(record.Path) == false ? record.Path : "[空]";
                        ListViewUtil.ChangeItemText(item, 1, record.Cols[0]);

                        this.listView_records.Items.Add(item);
                    }

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

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

                    if (lStart >= lHitCount || lCount <= 0)
                    {
                        break;
                    }
                }
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(channel.DoStop);
                stop.Initial("");

                // EnableControls(true);
            }
            return(1);
        }
Exemplo n.º 3
0
        // 为一行装载数据
        int LoadItemData(ListViewItem item,
                         out string strError)
        {
            Debug.Assert(item.Tag == null, "");

            strError = "";

            string strRecPath = item.Text;

            string strItemXml    = "";
            string strBiblioHtml = "";

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在获取路径为 '" + strRecPath + "' 的册信息和书目信息 ...");
            stop.BeginLoop();

            Cursor oldCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;

            try
            {
                long lRet = Channel.GetItemInfo(
                    stop,
                    "@path:" + strRecPath,
                    "xml",
                    out strItemXml,
                    "html",
                    out strBiblioHtml,
                    out strError);
                if (lRet == -1)
                {
                    goto ERROR1;  // error
                }
                if (lRet == 0)
                {
                    strError = "路径为 '" + strRecPath + "' 的册记录没有找到";
                    goto ERROR1;   // not found
                }
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");

                this.Cursor = oldCursor;
            }

            ItemInfo info = new ItemInfo();

            info.BiblioHtml = strBiblioHtml;
            info.ItemXml    = strItemXml;
            info.RecPath    = strRecPath;

            item.Tag = info;    // 储存起来

            return(0);

ERROR1:
            return(-1);
        }
Exemplo n.º 4
0
        // 检索出实体库全部可用的馆藏地名称
        int SearchAllLocation(
            LibraryChannel channel,
            Stop stop,
            out string strError)
        {
            strError = "";

            long lTotalCount = 0;

            this.listView_records.Items.Clear();

            // EnableControls(false);
            stop.OnStop += new StopEventHandler(channel.DoStop);
            stop.Initial("正在列出全部馆藏地 ...");
            stop.BeginLoop();

            try
            {
                for (int i = 0; i < 2; i++)
                {
                    long lRet = Channel.SearchItem(
                        stop,
                        "<all>",
                        "", // strBatchNo
                        -1,
                        "馆藏地点",
                        i == 0 ? "left" : "exact", // 第二次为检索空值
                        "zh",
                        "batchno",                 // strResultSetName
                        "",                        // "desc",
                        "keycount",                // strOutputStyle
                        out strError);
                    if (lRet == 0)
                    {
#if NO
                        strError = "not found";
                        return(0);   // not found
#endif
                        continue;
                    }
                    if (lRet == -1)
                    {
                        return(-1);
                    }

                    long lHitCount = lRet;

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

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

                        if (stop != null && stop.State != 0)
                        {
                            strError = "用户中断";
                            return(-1);
                        }

                        lRet = channel.GetSearchResult(
                            stop,
                            "batchno",   // strResultSetName
                            lStart,
                            lCount,
                            "keycount",
                            "zh",
                            out searchresults,
                            out strError);
                        if (lRet == -1)
                        {
                            strError = "GetSearchResult() error: " + strError;
                            return(-1);
                        }

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

                        // 处理浏览结果
                        foreach (Record record in searchresults)
                        {
                            if (record.Cols == null)
                            {
                                strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出馆藏地的功能";
                                return(-1);
                            }

                            if (this._libraryCodeList.Count > 0 &&
                                MatchLibraryCode(this._libraryCodeList, record.Path) == false)
                            {
                                continue;
                            }

                            // 跳过数字为 0 的事项
                            if (record.Cols.Length > 0 && record.Cols[0] == "0")
                            {
                                continue;
                            }

                            ListViewItem item = new ListViewItem();
                            item.Text = string.IsNullOrEmpty(record.Path) == false ? record.Path : "[空]";
                            ListViewUtil.ChangeItemText(item, 1, record.Cols[0]);

                            this.listView_records.Items.Add(item);
                        }

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

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

                        if (lStart >= lHitCount || lCount <= 0)
                        {
                            break;
                        }
                    }

                    lTotalCount += lHitCount;
                }

                if (lTotalCount == 0)
                {
                    strError = "not found";
                    return(0);
                }
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(channel.DoStop);
                stop.Initial("");

                // EnableControls(true);
            }
            return(1);
        }