/// <summary> /// 续借 /// </summary> /// <param name="strItemBarcode">册条码号</param> /// <returns></returns> public int Renew(string strReaderBarcode, string strItemBarcode, out BorrowInfo borrowInfo, out string strError) { borrowInfo = null; strError = ""; if (strItemBarcode == null) { strItemBarcode = ""; } strItemBarcode = strItemBarcode.Trim(); if (strItemBarcode == "") { strError = "续借失败:您输入的续借图书编号或者册条码号为空。"; return(-1); } if (String.IsNullOrEmpty(strReaderBarcode) == true) { strError = "续借失败:内部错误,读者证条码号为空。"; return(-1); } /* * // 优先从序号字典中找下 * if (this.CurrentMessageContext.BorrowDict.ContainsKey(strItemBarcode)) * { * string temp = this.CurrentMessageContext.BorrowDict[strItemBarcode]; * if (temp != null && temp != "") * strItemBarcode = temp; * } */ LibraryChannel channel = this.ChannelPool.GetChannel(this.dp2Url, this.dp2UserName); channel.Password = this.dp2Password; try { string strOutputReaderBarcode = ""; string strReaderXml = ""; long lRet = channel.Borrow(true, strReaderBarcode, strItemBarcode, out strOutputReaderBarcode, out strReaderXml, out borrowInfo, out strError); if (lRet == -1) { return(-1); } return(1); } finally { this.ChannelPool.ReturnChannel(channel); } }
public Command AddCmd(Command item) { Debug.Assert(item != null, "AddCmd传进的item不能为空。"); Debug.Assert(String.IsNullOrEmpty(item.type) == false, "命令类型不能为空。"); string strError = ""; // 补充命令信息 item.id = this.cmdList.Count + 1; item.description = item.readerBarcode + "-" + item.type + "-" + item.itemBarcode; item.operTime = DateTimeToString(DateTime.Now); item.typeString = Command.getTypeString(item.type); if (item.type == Command.C_Command_Borrow || item.type == Command.C_Command_VerifyRenew || item.type == Command.C_Command_VerifyReturn) { if (String.IsNullOrEmpty(item.readerBarcode) == true) { item.state = -1; item.resultInfo = "读者证条码号不能为空。"; } } if (String.IsNullOrEmpty(item.itemBarcode) == true) { item.state = -1; item.resultInfo = "册条码号不能为空。"; } // 执行这个命令 LibraryChannel channel = ilovelibraryServer.Instance.ChannelPool.GetChannel(ilovelibraryServer.Instance.dp2LibraryUrl, this.UserName); channel.Password = this.Password; channel.Parameters = this.Parameters; try { long lRet = -1; string strOutputReaderBarcode = ""; string strReaderXml = ""; // 借书或续借 if (item.type == Command.C_Command_Borrow || item.type == Command.C_Command_Renew || item.type == Command.C_Command_VerifyRenew) { bool bRenew = false; if (item.type == Command.C_Command_Renew || item.type == Command.C_Command_VerifyRenew) { bRenew = true; } DigitalPlatform.LibraryRestClient.BorrowInfo borrowInfo = null; lRet = channel.Borrow(bRenew, item.readerBarcode, item.itemBarcode, out strOutputReaderBarcode, out strReaderXml, out borrowInfo, out strError); } else if (item.type == Command.C_Command_Return || item.type == Command.C_Command_VerifyReturn || item.type == Command.C_Command_Read) { string strAction = ""; if (item.type == Command.C_Command_Return || item.type == Command.C_Command_VerifyReturn) { strAction = "return"; } else { strAction = "read"; } ReturnInfo returnInfo = null; lRet = channel.Return(strAction, item.readerBarcode, item.itemBarcode, out strOutputReaderBarcode, out strReaderXml, out returnInfo, out strError); } // 设上实际的读者证条码 item.readerBarcode = strOutputReaderBarcode; // 读者重复 if (lRet == 2) { item.state = (int)lRet; item.resultInfo = item.typeString + "书操作失败:" + strError; //直接返回了,因为不会加到操作历史里 return(item); } // 册重复 if (lRet == 3) { item.state = (int)lRet; item.resultInfo = strError;//item.typeString + "书操作失败:" + strError; //直接返回了,因为不会加到操作历史里 return(item); } if (lRet == -1) { item.state = -1; item.resultInfo = item.typeString + "书操作失败:" + strError; } else if (lRet == 0) { item.state = 0; item.resultInfo = item.typeString + "书操作成功。"; } else { item.state = 1; item.resultInfo = strError; } // 检索是否与前面同一个读者,不加要加线 if (this.cmdList.Count > 0) { Command firstCmd = this.cmdList[0]; if (firstCmd.readerBarcode != item.readerBarcode && String.IsNullOrEmpty(item.readerBarcode) == false && String.IsNullOrEmpty(firstCmd.readerBarcode) == false) { item.isAddLine = 1; } } // 设链接地址 if (item.itemBarcode.Contains("@biblioRecPath") == false && string.IsNullOrEmpty(ilovelibraryServer.Instance.dp2OpacUrl) == false) { item.itemBarcodeUrl = ilovelibraryServer.Instance.dp2OpacUrl + "/book.aspx?barcode=" + HttpUtility.UrlEncode(item.itemBarcode) + "&borrower=" + item.readerBarcode; item.itemBarcodeUrl = "<a href='" + item.itemBarcodeUrl + "' target='_blank'>" + item.itemBarcode + "</a>"; } else { item.itemBarcodeUrl = item.itemBarcode; } // 解析读者信息 //PatronResult patronResult = ilovelibraryServer.Instance.GetPatronInfo(this, item.readerBarcode); //item.patronResult = patronResult; PatronResult patronResult = new PatronResult(); patronResult.patron = null; patronResult.apiResult = new ApiResult(); if (String.IsNullOrEmpty(strReaderXml) == true) { patronResult.apiResult.errorCode = -1; patronResult.apiResult.errorInfo = "dp2服务端操作api返回的读者xml为空。"; } else { //解析返回的读者xml ilovelibraryServer.Instance.ParseReaderXml(strReaderXml, patronResult); } item.patronResult = patronResult; // 加到集合里 this.cmdList.Insert(0, item); return(item); } finally { ilovelibraryServer.Instance.ChannelPool.ReturnChannel(channel); } }
void renewButton_Click(object sender, EventArgs e) { List <string> barcodes = this.GetCheckedBorrowBarcodes(); if (barcodes.Count == 0) { // text-level: 用户提示 this.SetDebugInfo("errorinfo", this.GetString("尚未选择要续借的事项")); // "操作失败。尚未选择要续借的事项。" return; } OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; LibraryChannel channel = sessioninfo.GetChannel(true); try { for (int i = 0; i < barcodes.Count; i++) { string strItemBarcode = barcodes[i]; //string strItemRecord = ""; //string strReaderRecord = ""; string strReaderBarcode = ""; if (String.IsNullOrEmpty(this.ReaderBarcode) == false) { strReaderBarcode = this.ReaderBarcode; } else { strReaderBarcode = sessioninfo.ReaderInfo.Barcode; } if (String.IsNullOrEmpty(strReaderBarcode) == true) { // text-level: 用户提示 this.SetDebugInfo("errorinfo", this.GetString("尚未指定读者证条码号")); // "尚未指定读者证条码号。操作失败。" return; } string[] aDupPath = null; string[] item_records = null; string[] reader_records = null; string[] biblio_records = null; BorrowInfo borrow_info = null; string strError = ""; string strOutputReaderBarcode = ""; long lRet = // sessioninfo.Channel. channel.Borrow( null, true, strReaderBarcode, strItemBarcode, null, false, null, "", // style "", out item_records, "", out reader_records, "", out biblio_records, out aDupPath, out strOutputReaderBarcode, out borrow_info, out strError); if (lRet == -1) { this.SetDebugInfo("errorinfo", strError); return; } // 清除读者记录缓存,以便借阅信息得到刷新 sessioninfo.ClearLoginReaderDomCache(); } } finally { sessioninfo.ReturnChannel(channel); } // text-level: 用户提示 this.SetDebugInfo(this.GetString("续借成功")); // "续借成功。" }
// 借书 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 (StringUtil.CompareVersion(this.Container.MainForm.ServerVersion, "2.24") >= 0) { 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; #if NO this.Container.AsynFillItemSummary(task.ItemBarcode, strConfirmItemRecPath, task); #endif this.Container.AddItemSummaryTask(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 }