void form_BorrowComplete(object sender, BorrowCompleteEventArgs e) { if (string.IsNullOrEmpty(e.ItemBarcode) == true) return; ListViewItem item = ListViewUtil.FindItem(this.listView_in, e.ItemBarcode, COLUMN_BARCODE); if (item == null) return; List<ListViewItem> items = new List<ListViewItem>(); items.Add(item); RefreshLines(COLUMN_RECPATH, items, false, new string[] { "summary", "@isbnissn", "targetrecpath" }); }
// 还书 void Return(ChargingTask task) { DateTime start_time = DateTime.Now; List<DateTime> times = new List<DateTime>(); times.Add(start_time); task.State = "begin"; task.Color = "purple"; // "light"; this.Container.DisplayTask("refresh", task); this.Container.SetColorList(); string strOperText = ""; if (task.Action == "inventory") strOperText = task.ReaderBarcode + " 盘点 " + task.ItemBarcode; else strOperText = task.ReaderBarcode + " 还 " + task.ItemBarcode; #if NO stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial(strOperText + " ..."); stop.BeginLoop(); try { #endif stop.SetMessage(strOperText + " ..."); string strError = ""; string strReaderRecord = ""; string strConfirmItemRecPath = null; string strAction = task.Action; string strReaderBarcode = task.ReaderBarcode; if (task.Action == "verify_return") { if (string.IsNullOrEmpty(strReaderBarcode) == true) { strError = "尚未输入读者证条码号"; task.ErrorInfo = strError; goto ERROR1; } strAction = "return"; } else if (task.Action == "verify_lost") { if (string.IsNullOrEmpty(strReaderBarcode) == true) { strError = "尚未输入读者证条码号"; task.ErrorInfo = strError; goto ERROR1; } strAction = "lost"; } else if (task.Action == "inventory") { if (string.IsNullOrEmpty(strReaderBarcode) == true) { strError = "尚未设定批次号"; task.ErrorInfo = strError; goto ERROR1; } strAction = "inventory"; } else { strReaderBarcode = ""; } REDO: string[] aDupPath = null; string[] item_records = null; string[] reader_records = null; string[] biblio_records = null; string strOutputReaderBarcode = ""; ReturnInfo return_info = null; // item返回的格式 string strItemReturnFormats = ""; if (this.Container.MainForm.ChargingNeedReturnItemXml == true) { if (String.IsNullOrEmpty(strItemReturnFormats) == false) strItemReturnFormats += ","; strItemReturnFormats += "xml" + GetPostFix(); } // biblio返回的格式 string strBiblioReturnFormats = ""; // 读者返回格式 string strReaderFormatList = ""; bool bName = false; // 是否直接取得读者姓名,而不要获得读者 XML if (this.Container.MainForm.ServerVersion >= 2.24) { strReaderFormatList = this.Container.PatronRenderFormat + ",summary"; bName = true; } else strReaderFormatList = this.Container.PatronRenderFormat + ",xml" + GetPostFix(); string strStyle = "reader"; if (this.Container.MainForm.ChargingNeedReturnItemXml) strStyle += ",item"; #if NO if (strAction == "inventory") { strItemReturnFormats = "xml"; strStyle += ",item"; } #endif //if (this.Container.MainForm.TestMode == true) // strStyle += ",testmode"; times.Add(DateTime.Now); long lRet = Channel.Return( stop, strAction, strReaderBarcode, task.ItemBarcode, strConfirmItemRecPath, false, strStyle, // this.NoBiblioAndItemInfo == false ? "reader,item,biblio" : "reader", strItemReturnFormats, out item_records, strReaderFormatList, // this.Container.PatronRenderFormat + ",xml" + GetPostFix(), // "html", out reader_records, strBiblioReturnFormats, out biblio_records, out aDupPath, out strOutputReaderBarcode, out return_info, out strError); if (lRet != 0) task.ErrorInfo = strError; #if NO if (return_info != null) { strLocation = StringUtil.GetPureLocation(return_info.Location); } #endif times.Add(DateTime.Now); if (reader_records != null && reader_records.Length > 0) strReaderRecord = reader_records[0]; // 刷新读者信息 if (this.Container.IsCardMode == true) { if (String.IsNullOrEmpty(strReaderRecord) == false) this.Container.SetReaderCardString(strReaderRecord); } else { if (String.IsNullOrEmpty(strReaderRecord) == false) this.Container.SetReaderHtmlString(ReplaceMacro(strReaderRecord)); } string strItemXml = ""; if ((this.Container.MainForm.ChargingNeedReturnItemXml == true || strAction == "inventory") && item_records != null) { Debug.Assert(item_records != null, ""); if (item_records.Length > 0) { // xml总是在最后一个 strItemXml = item_records[item_records.Length - 1]; } } // 对 return_info.Location 进行观察,看看是否超过要求的范围 if (lRet != -1 && strAction == "inventory" && Container.FilterLocations != null && Container.FilterLocations.Count > 0) { #if NO XmlDocument item_dom = new XmlDocument(); try { item_dom.LoadXml(strItemXml); } catch(Exception ex) { strError = "strItemXml 装入 XMLDOM 时出错: " + ex.Message; goto ERROR1; } string strLocation = DomUtil.GetElementText(item_dom.DocumentElement, "location"); #endif string strLocation = return_info.Location; strLocation = StringUtil.GetPureLocation(strLocation); if (Container.FilterLocations.IndexOf(strLocation) == -1) { lRet = 1; if (string.IsNullOrEmpty(task.ErrorInfo) == false) task.ErrorInfo += "; "; task.ErrorInfo += "册记录中的馆藏地 '" + strLocation + "' 不在当前盘点要求的范围 '" + StringUtil.MakePathList(Container.FilterLocations) + "'。请及时处理"; } } if (lRet == -1) goto ERROR1; string strReaderSummary = ""; if (reader_records != null && reader_records.Length > 1) { if (bName == false) strReaderSummary = Global.GetReaderSummary(reader_records[1]); else strReaderSummary = reader_records[1]; } #if NO string strBiblioSummary = ""; if (biblio_records != null && biblio_records.Length > 1) strBiblioSummary = biblio_records[1]; #endif task.ReaderName = strReaderSummary; // task.ItemSummary = strBiblioSummary; this.Container.AsynFillItemSummary(task.ItemBarcode, strConfirmItemRecPath, task); if (string.IsNullOrEmpty(task.ReaderBarcode) == true) task.ReaderBarcode = strOutputReaderBarcode; DateTime end_time = DateTime.Now; this.Container.MainForm.OperHistory.ReturnAsync( this.Container, strAction, // task.Action == "lost" || task.Action == "verify_lost", strOutputReaderBarcode, // this.textBox_readerBarcode.Text, task.ItemBarcode, strConfirmItemRecPath, strReaderSummary, strItemXml, return_info, start_time, end_time); if (lRet == 1) { // 黄色状态 task.Color = "yellow"; } else { // 绿色状态 task.Color = "green"; } // this.m_strCurrentBarcode = strBarcode; task.State = "finish"; // 兑现显示 this.Container.DisplayTask("refresh_and_visible", task); this.Container.SetColorList(); #if NO if (stop != null && stop.State != 0) return true; return false; #endif { BorrowCompleteEventArgs e1 = new BorrowCompleteEventArgs(); e1.Action = task.Action; e1.ItemBarcode = task.ItemBarcode; e1.ReaderBarcode = strOutputReaderBarcode; this.Container.TriggerBorrowComplete(e1); } times.Add(DateTime.Now); LogOperTime("return", times, strOperText); return; ERROR1: task.State = "error"; task.Color = "red"; // this.Container.SetReaderRenderString(strError); // 兑现显示 this.Container.DisplayTask("refresh_and_visible", task); this.Container.SetColorList(); #if NO if (stop != null && stop.State != 0) return true; return false; #endif return; #if NO } finally { stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); } #endif }
internal void TriggerBorrowComplete(BorrowCompleteEventArgs e) { if (this.BorrowComplete != null) this.BorrowComplete(this, e); }
// 借书 void Borrow(ChargingTask task) { DateTime start_time = DateTime.Now; List<DateTime> times = new List<DateTime>(); times.Add(start_time); task.State = "begin"; task.Color = "purple"; // "light"; this.Container.DisplayTask("refresh", task); this.Container.SetColorList(); string strOperText = task.ReaderBarcode + " 借 " + task.ItemBarcode; #if NO stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial(strOperText + " ..."); stop.BeginLoop(); try { #endif stop.SetMessage(strOperText + " ..."); string strError = ""; string strReaderRecord = ""; string strConfirmItemRecPath = null; bool bRenew = false; if (task.Action == "renew" || task.Action == "verify_renew") bRenew = true; if (task.Action == "renew") task.ReaderBarcode = ""; else { if (string.IsNullOrEmpty(task.ReaderBarcode) == true) { strError = "证条码号为空,无法进行借书操作"; task.ErrorInfo = strError; goto ERROR1; } } REDO: string[] aDupPath = null; string[] item_records = null; string[] reader_records = null; string[] biblio_records = null; string strOutputReaderBarcode = ""; BorrowInfo borrow_info = null; // item返回的格式 string strItemReturnFormats = ""; if (this.Container.MainForm.ChargingNeedReturnItemXml == true) { if (String.IsNullOrEmpty(strItemReturnFormats) == false) strItemReturnFormats += ","; strItemReturnFormats += "xml" + GetPostFix(); } // biblio返回的格式 string strBiblioReturnFormats = ""; // 读者返回格式 string strReaderFormatList = ""; bool bName = false; // 是否直接取得读者姓名,而不要获得读者 XML if (this.Container.MainForm.ServerVersion >= 2.24) { strReaderFormatList = this.Container.PatronRenderFormat + ",summary"; bName = true; } else strReaderFormatList = this.Container.PatronRenderFormat + ",xml" + GetPostFix(); string strStyle = "reader"; if (this.Container.MainForm.ChargingNeedReturnItemXml) strStyle += ",item"; //if (this.Container.MainForm.TestMode == true) // strStyle += ",testmode"; times.Add(DateTime.Now); long lRet = Channel.Borrow( stop, bRenew, task.ReaderBarcode, task.ItemBarcode, strConfirmItemRecPath, false, null, // this.OneReaderItemBarcodes, strStyle, strItemReturnFormats, out item_records, strReaderFormatList, // this.Container.PatronRenderFormat + ",xml" + GetPostFix(), out reader_records, strBiblioReturnFormats, out biblio_records, out aDupPath, out strOutputReaderBarcode, out borrow_info, out strError); task.ErrorInfo = strError; times.Add(DateTime.Now); if (reader_records != null && reader_records.Length > 0) strReaderRecord = reader_records[0]; // 刷新读者信息 if (this.Container.IsCardMode == true) { if (String.IsNullOrEmpty(strReaderRecord) == false) this.Container.SetReaderCardString(strReaderRecord); } else { if (String.IsNullOrEmpty(strReaderRecord) == false) this.Container.SetReaderHtmlString(ReplaceMacro(strReaderRecord)); } string strItemXml = ""; if (this.Container.MainForm.ChargingNeedReturnItemXml == true && item_records != null) { Debug.Assert(item_records != null, ""); if (item_records.Length > 0) { // xml总是在最后一个 strItemXml = item_records[item_records.Length - 1]; } } if (lRet == -1) goto ERROR1; DateTime end_time = DateTime.Now; string strReaderSummary = ""; if (reader_records != null && reader_records.Length > 1) { if (bName == false) strReaderSummary = Global.GetReaderSummary(reader_records[1]); else strReaderSummary = reader_records[1]; } #if NO string strBiblioSummary = ""; if (biblio_records != null && biblio_records.Length > 1) strBiblioSummary = biblio_records[1]; #endif task.ReaderName = strReaderSummary; // task.ItemSummary = strBiblioSummary; this.Container.AsynFillItemSummary(task.ItemBarcode, strConfirmItemRecPath, task); this.Container.MainForm.OperHistory.BorrowAsync( this.Container, bRenew, strOutputReaderBarcode, task.ItemBarcode, strConfirmItemRecPath, strReaderSummary, strItemXml, borrow_info, start_time, end_time); /* lRet = 1; task.ErrorInfo = "asdf a asdf asdf as df asdf as f a df asdf a sdf a sdf asd f asdf a sdf as df"; */ if (lRet == 1) { // 黄色状态 task.Color = "yellow"; } else { // 绿色状态 task.Color = "green"; } // this.m_strCurrentBarcode = strBarcode; task.State = "finish"; // 兑现显示 this.Container.DisplayTask("refresh_and_visible", task); this.Container.SetColorList(); #if NO if (stop != null && stop.State != 0) return true; return false; #endif { BorrowCompleteEventArgs e1 = new BorrowCompleteEventArgs(); e1.Action = task.Action; e1.ItemBarcode = task.ItemBarcode; e1.ReaderBarcode = strOutputReaderBarcode; this.Container.TriggerBorrowComplete(e1); } times.Add(DateTime.Now); LogOperTime("borrow", times, strOperText); return; ERROR1: task.State = "error"; task.Color = "red"; // this.Container.SetReaderRenderString(strError); // 兑现显示 this.Container.DisplayTask("refresh_and_visible", task); this.Container.SetColorList(); #if NO if (stop != null && stop.State != 0) return true; return false; #endif return; #if NO } finally { stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); } #endif }