// 根据批次号检索装载 private void button_load_loadFromBatchNo_Click(object sender, EventArgs e) { SearchByBatchnoForm dlg = new SearchByBatchnoForm(); MainForm.SetControlFont(dlg, this.Font, false); // 2008/11/30 dlg.BatchNo = this.BatchNo; dlg.ItemLocation = this.LocationString; dlg.CfgSectionName = "AccountBookForm_SearchByBatchnoForm"; dlg.GetLocationValueTable -= new GetValueTableEventHandler(dlg_GetLocationValueTable); dlg.GetLocationValueTable += new GetValueTableEventHandler(dlg_GetLocationValueTable); dlg.GetBatchNoTable -= new GetKeyCountListEventHandler(dlg_GetBatchNoTable); dlg.GetBatchNoTable += new GetKeyCountListEventHandler(dlg_GetBatchNoTable); dlg.RefDbName = ""; /* dlg.RefDbName = EntityForm.GetDbName(this.entityEditControl1.RecPath); * */ dlg.MainForm = this.MainForm; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) return; this.SourceStyle = "batchno"; // 2008/11/22 this.BatchNo = dlg.BatchNo; this.LocationString = dlg.ItemLocation; string strMatchLocation = dlg.ItemLocation; if (strMatchLocation == "<不指定>") strMatchLocation = null; // null和""的区别很大 string strBatchNo = dlg.BatchNo; if (strBatchNo == "<不指定>") strBatchNo = null; // null和""的区别很大 string strError = ""; bool bClearBefore = true; if (System.Windows.Forms.Control.ModifierKeys == Keys.Control) bClearBefore = false; if (bClearBefore == true) ClearBefore(); string strRecPathFilename = Path.GetTempFileName(); try { // 检索 批次号 和 馆藏地点 将命中的记录路径写入文件 int nRet = SearchBatchNoAndLocation( this.comboBox_load_type.Text, strBatchNo, strMatchLocation, strRecPathFilename, out strError); if (nRet == -1) goto ERROR1; nRet = LoadFromRecPathFile(strRecPathFilename, this.comboBox_load_type.Text, this.checkBox_load_fillBiblioSummary.Checked, new string[] { "summary", "@isbnissn" }, false, out strError); if (nRet == -1) goto ERROR1; } finally { if (string.IsNullOrEmpty(strRecPathFilename) == false) { File.Delete(strRecPathFilename); strRecPathFilename = ""; } } return; ERROR1: MessageBox.Show(this, strError); }
// 根据批次号检索装载 private void button_load_loadFromBatchNo_Click(object sender, EventArgs e) { SearchByBatchnoForm dlg = new SearchByBatchnoForm(); MainForm.SetControlFont(dlg, this.Font, false); // 2008/11/30 dlg.BatchNo = this.BatchNo; dlg.ItemLocation = this.LocationString; dlg.CfgSectionName = "AccountBookForm_SearchByBatchnoForm"; dlg.GetLocationValueTable -= new GetValueTableEventHandler(dlg_GetLocationValueTable); dlg.GetLocationValueTable += new GetValueTableEventHandler(dlg_GetLocationValueTable); dlg.GetBatchNoTable -= new GetKeyCountListEventHandler(dlg_GetBatchNoTable); dlg.GetBatchNoTable += new GetKeyCountListEventHandler(dlg_GetBatchNoTable); dlg.RefDbName = ""; /* dlg.RefDbName = EntityForm.GetDbName(this.entityEditControl1.RecPath); * */ dlg.MainForm = this.MainForm; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) return; this.SourceStyle = "batchno"; // 2008/11/22 this.BatchNo = dlg.BatchNo; this.LocationString = dlg.ItemLocation; string strMatchLocation = dlg.ItemLocation; if (strMatchLocation == "<不指定>") strMatchLocation = null; // null和""的区别很大 string strError = ""; if (Control.ModifierKeys == Keys.Control) { } else { this.listView_in.Items.Clear(); this.SortColumns_in.Clear(); SortColumns.ClearColumnSortDisplay(this.listView_in.Columns); this.refid_table.Clear(); this.orderxml_table.Clear(); } EnableControls(false); //MainForm.ShowProgress(true); stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在检索 ..."); stop.BeginLoop(); try { stop.SetProgressRange(0, 100); // stop.SetProgressValue(0); long lRet = Channel.SearchItem( stop, // 2010/2/25 changed this.comboBox_load_type.Text == "图书" ? "<all book>" : "<all series>", dlg.BatchNo, -1, "批次号", string.IsNullOrEmpty(dlg.BatchNo) == false ? "exact" : "left", // 这样允许配次号为空检索 this.Lang, "batchno", // strResultSetName "", // strSearchStyle "", // strOutputStyle out strError); if (lRet == -1) goto ERROR1; if (lRet == 0) { strError = "批次号 '"+dlg.BatchNo+"' 没有命中记录。"; goto ERROR1; } int nDupCount = 0; long lHitCount = lRet; stop.SetProgressRange(0, lHitCount); stop.SetProgressValue(0); long lStart = 0; long lCount = lHitCount; DigitalPlatform.CirculationClient.localhost.Record[] searchresults = null; // 装入浏览格式 for (; ; ) { Application.DoEvents(); // 出让界面控制权 if (stop != null) { if (stop.State != 0) { MessageBox.Show(this, "用户中断"); return; } } lRet = Channel.GetSearchResult( stop, "batchno", // strResultSetName lStart, lCount, "id,cols", this.Lang, out searchresults, out strError); if (lRet == -1) { strError = "GetSearchResult() error: " + strError; // Debug.Assert(false, ""); goto ERROR1; } if (lRet == 0) { MessageBox.Show(this, "未命中"); return; } // 处理浏览结果 for (int i = 0; i < searchresults.Length; i++) { Application.DoEvents(); // 出让界面控制权 if (stop != null) { if (stop.State != 0) { MessageBox.Show(this, "用户中断"); return; } } DigitalPlatform.CirculationClient.localhost.Record result_item = searchresults[i]; string strBarcode = result_item.Cols[0]; string strRecPath = result_item.Path; /* // 如果册条码号为空,则改用路径装载 // 2009/8/6 if (String.IsNullOrEmpty(strBarcode) == true) { strBarcode = "@path:" + strRecPath; } * */ // 加速 strBarcode = "@path:" + strRecPath; string strOutputItemRecPath = ""; ListViewItem item = null; // 根据册条码号或者记录路径,装入册记录 // return: // -2 册条码号已经在list中存在了 // -1 出错 // 0 因为馆藏地点不匹配,没有加入list中 // 1 成功 int nRet = LoadOneItem( this.comboBox_load_type.Text, strBarcode, null, this.listView_in, strMatchLocation, out strOutputItemRecPath, out item, out strError); if (nRet == -2) nDupCount++; /* ReaderSearchForm.NewLine( this.listView_records, searchresults[i].Path, searchresults[i].Cols); * */ stop.SetProgressValue(lStart + i + 1); // TODO: 是否要检查记录路径从属的图书或者期刊库是否正确? } lStart += searchresults.Length; lCount -= searchresults.Length; stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条"); if (lStart >= lHitCount || lCount <= 0) break; } if (this.listView_in.Items.Count == 0 && strMatchLocation != null) { strError = "虽然批次号 '" + dlg.BatchNo + "' 命中了记录 " + lHitCount.ToString() + " 条, 但它们均未能匹配馆藏地点 '" + strMatchLocation + "' 。"; goto ERROR1; } // MessageBox.Show(this, Convert.ToString(lRet) + " : " + strError); } finally { stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); stop.HideProgress(); EnableControls(true); // MainForm.ShowProgress(false); } return; ERROR1: MessageBox.Show(this, strError); }
private void button_load_loadFromBatchNo_Click(object sender, EventArgs e) { SearchByBatchnoForm dlg = new SearchByBatchnoForm(); MainForm.SetControlFont(dlg, this.Font, false); this.ClearErrorInfoForm(); dlg.BatchNo = this.BatchNo; dlg.ItemLocation = this.LocationString; dlg.CfgSectionName = "PrintBindingForm_SearchByBatchnoForm"; dlg.GetLocationValueTable -= new GetValueTableEventHandler(dlg_GetLocationValueTable); dlg.GetLocationValueTable += new GetValueTableEventHandler(dlg_GetLocationValueTable); dlg.GetBatchNoTable -= new GetKeyCountListEventHandler(dlg_GetBatchNoTable); dlg.GetBatchNoTable += new GetKeyCountListEventHandler(dlg_GetBatchNoTable); dlg.RefDbName = ""; dlg.MainForm = this.MainForm; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) return; this.SourceStyle = "batchno"; // 记忆 this.BatchNo = dlg.BatchNo; this.LocationString = dlg.ItemLocation; string strMatchLocation = dlg.ItemLocation; if (strMatchLocation == "<不指定>") strMatchLocation = null; // null和""的区别很大 string strError = ""; int nRet = 0; if (Control.ModifierKeys == Keys.Control) { } else { /* if (this.Changed == true) { // 警告尚未保存 DialogResult result = MessageBox.Show(this, "当前窗口内有册信息被修改后尚未保存。若此时为装载新内容而清除原有信息,则未保存信息将丢失。\r\n\r\n确实要装载新内容? ", "ItemHandoverForm", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result != DialogResult.Yes) { return; // 放弃 } } * */ this.listView_parent.Items.Clear(); this.SortColumns_parent.Clear(); SortColumns.ClearColumnSortDisplay(this.listView_parent.Columns); this.listView_member.Items.Clear(); this.SortColumns_member.Clear(); SortColumns.ClearColumnSortDisplay(this.listView_member.Columns); } EnableControls(false); stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在检索 ..."); stop.BeginLoop(); try { stop.SetProgressRange(0, 100); // stop.SetProgressValue(0); long lRet = 0; if (this.BatchNo == "<不指定>") { // 2013/3/25 lRet = Channel.SearchItem( stop, // 2010/2/25 changed "<all series>", "", // -1, "__id", "left", this.Lang, "batchno", // strResultSetName "", // strSearchStyle "", // strOutputStyle out strError); if (lRet == 0) { // TODO: 优化提示 strError = "检索全部 '连续出版物' 类型的册记录没有命中记录。"; goto ERROR1; } } else lRet = Channel.SearchItem( stop, // 2010/2/25 changed "<all series>", dlg.BatchNo, -1, "批次号", "exact", this.Lang, "batchno", // strResultSetName "", // strSearchStyle "", // strOutputStyle out strError); if (lRet == -1) goto ERROR1; if (lRet == 0) { strError = "批次号 '" + dlg.BatchNo + "' 没有命中记录。"; goto ERROR1; } int nDupCount = 0; long lHitCount = lRet; stop.SetProgressRange(0, lHitCount); stop.SetProgressValue(0); long lStart = 0; long lCount = lHitCount; DigitalPlatform.CirculationClient.localhost.Record[] searchresults = null; // 装入浏览格式 for (; ; ) { Application.DoEvents(); // 出让界面控制权 if (stop != null) { if (stop.State != 0) { MessageBox.Show(this, "用户中断"); return; } } lRet = Channel.GetSearchResult( stop, "batchno", // strResultSetName lStart, lCount, "id,cols", this.Lang, out searchresults, out strError); if (lRet == -1) { strError = "GetSearchResult() error: " + strError; // Debug.Assert(false, ""); goto ERROR1; } if (lRet == 0) { MessageBox.Show(this, "未命中"); return; } // 处理浏览结果 for (int i = 0; i < searchresults.Length; i++) { DigitalPlatform.CirculationClient.localhost.Record result_item = searchresults[i]; string strBarcode = result_item.Cols[0]; string strRecPath = result_item.Path; // 检查路径所从属书目库是否为图书/期刊库? // return: // -1 error // 0 不符合要求。提示信息在strError中 // 1 符合要求 nRet = CheckItemRecPath("连续出版物", strRecPath, out strError); if (nRet == -1) goto ERROR1; if (nRet == 0) { GetErrorInfoForm().WriteHtml("路径为 " + strRecPath + " 的册记录 " + strError + "\r\n"); } /* // 如果册条码号为空,则改用路径装载 // 2009/8/6 if (String.IsNullOrEmpty(strBarcode) == true) { strBarcode = "@path:" + strRecPath; }*/ // 加速 strBarcode = "@path:" + strRecPath; string strOutputItemRecPath = ""; // 根据册条码号或者记录路径,装入册记录 // return: // -2 册条码号已经在list中存在了 // -1 出错 // 0 因为馆藏地点不匹配,没有加入list中 // 1 成功 nRet = LoadOneItem(strBarcode, this.listView_parent, strMatchLocation, out strOutputItemRecPath, out strError); if (nRet == -2) nDupCount++; /* ReaderSearchForm.NewLine( this.listView_records, searchresults[i].Path, searchresults[i].Cols); * */ stop.SetProgressValue(lStart + i + 1); } lStart += searchresults.Length; lCount -= searchresults.Length; stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条"); if (lStart >= lHitCount || lCount <= 0) break; } if (this.listView_parent.Items.Count == 0 && strMatchLocation != null) { strError = "虽然批次号 '" + dlg.BatchNo + "' 命中了记录 " + lHitCount.ToString() + " 条, 但它们均未能匹配馆藏地点 '" + strMatchLocation + "' 。"; goto ERROR1; } // MessageBox.Show(this, Convert.ToString(lRet) + " : " + strError); } finally { stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); stop.HideProgress(); EnableControls(true); // MainForm.ShowProgress(false); } this.Text = "打印装订单 -- " + this.SourceDescription; // 汇报数据装载情况。 // return: // 0 尚未装载任何数据 // 1 装载已经完成 // 2 虽然装载了数据,但是其中有错误事项 int nState = ReportLoadState(out strError); if (nState != 1) goto ERROR1; return; ERROR1: this.Text = "打印装订单"; MessageBox.Show(this, strError); }