// 获得批次号表 // parameters: // strPubType 出版物类型。为 图书/连续出版物/(空) 之一 internal static void GetBatchNoTable(GetKeyCountListEventArgs e, IWin32Window owner, string strPubType, // 出版物类型 string strType, Stop stop, LibraryChannel Channel) { string strError = ""; long lRet = 0; if (e.KeyCounts == null) e.KeyCounts = new List<KeyCount>(); string strName = ""; if (strType == "order") strName = "订购"; else if (strType == "item") strName = "册"; else if (strType == "biblio") strName = "编目"; else throw new Exception("未知的strType '" + strType + "' 值"); // EnableControls(false); stop.OnStop += new StopEventHandler(Channel.DoStop); stop.Initial("正在列出全部" + strName + "批次号 ..."); stop.BeginLoop(); try { int nPerMax = 2000; // 一次检索命中的最大条数限制 string strLang = "zh"; string strDbName = "<all>"; if (strPubType == "图书") strDbName = "<all book>"; else if (strPubType == "连续出版物") strDbName = "<all series>"; else strDbName = "<all>"; if (strType == "order") { lRet = Channel.SearchOrder( stop, strDbName, // "<all>", "", // strBatchNo nPerMax, // -1, "批次号", "left", strLang, "batchno", // strResultSetName "desc", "keycount", // strOutputStyle out strError); } else if (strType == "biblio") { string strQueryXml = ""; lRet = Channel.SearchBiblio( stop, strDbName, // "<all>", // 尽管可以用 this.comboBox_inputBiblioDbName.Text, 以便获得和少数书目库相关的批次号实例,但是容易造成误会:因为数据库名列表刷新后,这里却不会刷新? "", // strBatchNo, nPerMax, // -1, // nPerMax "batchno", "left", strLang, "batchno", // strResultSetName "desc", "keycount", // strOutputStyle "", out strQueryXml, out strError); } else if (strType == "item") { lRet = Channel.SearchItem( stop, strDbName, // "<all>", "", // strBatchNo nPerMax, // -1, "批次号", "left", strLang, "batchno", // strResultSetName "desc", "keycount", // strOutputStyle out strError); } else { Debug.Assert(false, ""); } if (lRet == -1) goto ERROR1; if (lRet == 0) { strError = "没有找到任何" + strName + "批次号检索点"; return; } long lHitCount = lRet; long lStart = 0; long lCount = lHitCount; DigitalPlatform.LibraryClient.localhost.Record[] searchresults = null; // 装入浏览格式 for (; ; ) { Application.DoEvents(); // 出让界面控制权 if (stop != null) { if (stop.State != 0) { strError = "用户中断"; goto ERROR1; } } lRet = Channel.GetSearchResult( stop, "batchno", // strResultSetName lStart, lCount, "keycount", strLang, out searchresults, out strError); if (lRet == -1) { strError = "GetSearchResult() error: " + strError; goto ERROR1; } if (lRet == 0) { // MessageBox.Show(this, "未命中"); return; } // 处理浏览结果 for (int i = 0; i < searchresults.Length; i++) { if (searchresults[i].Cols == null) { strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出" + strName + "批次号的功能"; goto ERROR1; } KeyCount keycount = new KeyCount(); keycount.Key = searchresults[i].Path; keycount.Count = Convert.ToInt32(searchresults[i].Cols[0]); e.KeyCounts.Add(keycount); } 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; ERROR1: MessageBox.Show(owner, strError); }