// 从 XML 元素设置到 XML 属性 public static void SetAttribute(ref XmlDocument dom, string strElementName, XmlElement nodeBorrow, string strAttrName, bool bDeleteElement) { string strValue = DomUtil.GetElementText(dom.DocumentElement, strElementName); if (string.IsNullOrEmpty(strValue) == false) { nodeBorrow.SetAttribute(strAttrName, strValue); } if (bDeleteElement == true) { DomUtil.DeleteElement(dom.DocumentElement, strElementName); } }
public static void SetXml(ItemEditControlBase control, string strXml, string strPublicationType) { string strError = ""; // 去掉记录里面的 issueCount 和 range 元素 if (string.IsNullOrEmpty(strXml) == false && strPublicationType == "book") { XmlDocument dom = new XmlDocument(); DomUtil.SafeLoadXml(dom, strXml); DomUtil.DeleteElement(dom.DocumentElement, "range"); DomUtil.DeleteElement(dom.DocumentElement, "issueCount"); strXml = dom.DocumentElement.OuterXml; } int nRet = control.SetData(strXml, "", null, out strError); if (nRet == -1) { throw new Exception(strError); } }
// parameters: // strItemBarcodeParam 册条码号。可以使用 @refID: 前缀 public static int ReturnChangeReaderAndItemRecord( string strAction, string strItemBarcodeParam, string strReaderBarcode, XmlDocument domLog, string strRecoverComment, ref XmlDocument readerdom, ref XmlDocument itemdom, out string strError) { strError = ""; if (strAction != "return" && strAction != "lost") { strError = "ReturnChangeReaderAndItemRecord() 只能处理 strAction 为 'return' 和 'lost' 的情况,不能处理 '" + strAction + "'"; return(-1); } string strReturnOperator = DomUtil.GetElementText(domLog.DocumentElement, "operator"); string strOperTime = DomUtil.GetElementText(domLog.DocumentElement, "operTime"); // *** 修改读者记录 string strDeletedBorrowFrag = ""; XmlNode dup_reader_history = null; // 既然日志记录中记载的是 @refID: 的形态,那读者记录中 borrows 里面势必记载的也是这个形态 XmlNode nodeBorrow = readerdom.DocumentElement.SelectSingleNode( "borrows/borrow[@barcode='" + strItemBarcodeParam + "']"); if (nodeBorrow != null) { if (String.IsNullOrEmpty(strRecoverComment) == false) { string strText = strRecoverComment; string strOldRecoverComment = DomUtil.GetAttr(nodeBorrow, "recoverComment"); if (String.IsNullOrEmpty(strOldRecoverComment) == false) { strText = "(借阅时原注: " + strOldRecoverComment + ") " + strRecoverComment; } DomUtil.SetAttr(nodeBorrow, "recoverComment", strText); } strDeletedBorrowFrag = nodeBorrow.OuterXml; nodeBorrow.ParentNode.RemoveChild(nodeBorrow); // 获得几个查重需要的参数 XmlDocument temp = new XmlDocument(); temp.LoadXml(strDeletedBorrowFrag); string strItemBarcode = temp.DocumentElement.GetAttribute("barcode"); string strBorrowDate = temp.DocumentElement.GetAttribute("borrowDate"); string strBorrowPeriod = temp.DocumentElement.GetAttribute("borrowPeriod"); dup_reader_history = readerdom.DocumentElement.SelectSingleNode("borrowHistory/borrow[@barcode='" + strItemBarcode + "' and @borrowDate='" + strBorrowDate + "' and @borrowPeriod='" + strBorrowPeriod + "']"); } // 加入到读者记录借阅历史字段中 if (string.IsNullOrEmpty(strDeletedBorrowFrag) == false && dup_reader_history == null) { // 看看根下面是否有 borrowHistory 元素 XmlNode root = readerdom.DocumentElement.SelectSingleNode("borrowHistory"); if (root == null) { root = readerdom.CreateElement("borrowHistory"); readerdom.DocumentElement.AppendChild(root); } XmlDocumentFragment fragment = readerdom.CreateDocumentFragment(); fragment.InnerXml = strDeletedBorrowFrag; // 插入到最前面 XmlNode temp = DomUtil.InsertFirstChild(root, fragment); // 2007/6/19 if (temp != null) { // returnDate 加入还书时间 DomUtil.SetAttr(temp, "returnDate", strOperTime); // borrowOperator string strBorrowOperator = DomUtil.GetAttr(temp, "operator"); // 把原来的operator属性值复制到borrowOperator属性中 DomUtil.SetAttr(temp, "borrowOperator", strBorrowOperator); // operator 此时需要表示还书操作者了 DomUtil.SetAttr(temp, "operator", strReturnOperator); } // 如果超过100个,则删除多余的 while (root.ChildNodes.Count > 100) { root.RemoveChild(root.ChildNodes[root.ChildNodes.Count - 1]); } // 2007/6/19 // 增量借阅量属性值 string strBorrowCount = DomUtil.GetAttr(root, "count"); if (String.IsNullOrEmpty(strBorrowCount) == true) { strBorrowCount = "1"; } else { long lCount = 1; try { lCount = Convert.ToInt64(strBorrowCount); } catch { } lCount++; strBorrowCount = lCount.ToString(); } DomUtil.SetAttr(root, "count", strBorrowCount); } // 增添超期信息 string strOverdueString = DomUtil.GetElementText(domLog.DocumentElement, "overdues"); if (String.IsNullOrEmpty(strOverdueString) == false) { XmlDocumentFragment fragment = readerdom.CreateDocumentFragment(); fragment.InnerXml = strOverdueString; List <string> existing_ids = new List <string>(); // 看看根下面是否有overdues元素 XmlNode root = readerdom.DocumentElement.SelectSingleNode("overdues"); if (root == null) { root = readerdom.CreateElement("overdues"); readerdom.DocumentElement.AppendChild(root); } else { // 记载以前已经存在的 id XmlNodeList nodes = root.SelectNodes("overdue"); foreach (XmlElement node in nodes) { string strID = node.GetAttribute("id"); if (string.IsNullOrEmpty(strID) == false) { existing_ids.Add(strID); } } } // root.AppendChild(fragment); { // 一个一个加入,丢掉重复 id 属性值得 overdue 元素 XmlNodeList nodes = fragment.SelectNodes("overdue"); foreach (XmlElement node in nodes) { string strID = node.GetAttribute("id"); if (existing_ids.IndexOf(strID) != -1) { continue; } root.AppendChild(node); } } } if (itemdom != null) { // *** 检查册记录操作前在借的读者,是否指向另外一个读者。如果是这样,则需要事先消除相关的另一个读者记录的痕迹,也就是说相当于把相关的册给进行还书操作 string strBorrower0 = DomUtil.GetElementInnerText(itemdom.DocumentElement, "borrower"); if (string.IsNullOrEmpty(strBorrower0) == false && strBorrower0 != strReaderBarcode) { #if NO string strRemovedInfo = ""; // 去除读者记录侧的借阅信息链条 // return: // -1 出错 // 0 没有必要修复 // 1 修复成功 nRet = RemoveReaderSideLink( // Channels, channel, strBorrower0, strItemBarcodeParam, out strRemovedInfo, out strError); if (nRet == -1) { this.WriteErrorLog("册条码号为 '" + strItemBarcodeParam + "' 的册记录,在进行还书操作(拟被读者 '" + strReaderBarcode + "' 借阅)以前,发现它被另一读者 '" + strBorrower0 + "' 持有,软件尝试自动修正(删除)此读者记录的半侧借阅信息链。不过,在去除读者记录册借阅链时发生错误: " + strError); } else { this.WriteErrorLog("册条码号为 '" + strItemBarcodeParam + "' 的册记录,在进行还书操作(拟被读者 '" + strReaderBarcode + "' 借阅)以前,发现它被另一读者 '" + strBorrower0 + "' 持有,软件已经自动修正(删除)了此读者记录的半侧借阅信息链。被移走的片断 XML 信息为 '" + strRemovedInfo + "'"); } #endif } // *** 修改册记录 XmlElement nodeHistoryBorrower = null; string strBorrower = DomUtil.GetElementText(itemdom.DocumentElement, "borrower"); XmlNode dup_item_history = null; // 看看相同借者、借阅日期、换回日期的 BorrowHistory/borrower 元素是否已经存在 { string strBorrowDate = DomUtil.GetElementText(itemdom.DocumentElement, "borrowDate"); dup_item_history = itemdom.DocumentElement.SelectSingleNode("borrowHistory/borrower[@barcode='" + strBorrower + "' and @borrowDate='" + strBorrowDate + "' and @returnDate='" + strOperTime + "']"); } if (dup_item_history != null) { // 历史信息节点已经存在,就不必加入了 // 清空相关元素 DomUtil.DeleteElement(itemdom.DocumentElement, "borrower"); DomUtil.DeleteElement(itemdom.DocumentElement, "borrowDate"); DomUtil.DeleteElement(itemdom.DocumentElement, "returningDate"); DomUtil.DeleteElement(itemdom.DocumentElement, "borrowPeriod"); DomUtil.DeleteElement(itemdom.DocumentElement, "operator"); DomUtil.DeleteElement(itemdom.DocumentElement, "no"); DomUtil.DeleteElement(itemdom.DocumentElement, "renewComment"); } else { // 加入历史信息节点 // TODO: 也可从 domLog 中取得信息,创建 borrowHistory 下级事项。但要防范重复加入的情况 // 这里判断册记录中 borrower 元素是否为空的做法,具有可以避免重复加入 borrowHistory 下级事项的优点 if (string.IsNullOrEmpty(strBorrower) == false) { // 加入到借阅历史字段中 { // 看看根下面是否有borrowHistory元素 XmlNode root = itemdom.DocumentElement.SelectSingleNode("borrowHistory"); if (root == null) { root = itemdom.CreateElement("borrowHistory"); itemdom.DocumentElement.AppendChild(root); } nodeHistoryBorrower = itemdom.CreateElement("borrower"); // 插入到最前面 nodeHistoryBorrower = DomUtil.InsertFirstChild(root, nodeHistoryBorrower) as XmlElement; // 2015/1/12 增加等号左边的部分 // 如果超过100个,则删除多余的 while (root.ChildNodes.Count > 100) { root.RemoveChild(root.ChildNodes[root.ChildNodes.Count - 1]); } } #if NO DomUtil.SetAttr(nodeOldBorrower, "barcode", DomUtil.GetElementText(itemdom.DocumentElement, "borrower")); DomUtil.SetElementText(itemdom.DocumentElement, "borrower", ""); #endif SetAttribute(ref itemdom, "borrower", nodeHistoryBorrower, "barcode", true); #if NO DomUtil.SetAttr(nodeOldBorrower, "borrowDate", DomUtil.GetElementText(itemdom.DocumentElement, "borrowDate")); DomUtil.SetElementText(itemdom.DocumentElement, "borrowDate", ""); #endif SetAttribute(ref itemdom, "borrowDate", nodeHistoryBorrower, "borrowDate", true); #if NO DomUtil.SetAttr(nodeOldBorrower, "returningDate", DomUtil.GetElementText(itemdom.DocumentElement, "returningDate")); DomUtil.SetElementText(itemdom.DocumentElement, "returningDate", ""); #endif SetAttribute(ref itemdom, "returningDate", nodeHistoryBorrower, "returningDate", true); SetAttribute(ref itemdom, "borrowPeriod", nodeHistoryBorrower, "borrowPeriod", true); // borrowOperator SetAttribute(ref itemdom, "operator", nodeHistoryBorrower, "borrowOperator", true); // operator 本次还书的操作者 DomUtil.SetAttr(nodeHistoryBorrower, "operator", strReturnOperator); DomUtil.SetAttr(nodeHistoryBorrower, "returnDate", strOperTime); // TODO: 0 需要省略 SetAttribute(ref itemdom, "no", nodeHistoryBorrower, "no", true); // renewComment SetAttribute(ref itemdom, "renewComment", nodeHistoryBorrower, "renewComment", true); { string strText = strRecoverComment; string strOldRecoverComment = DomUtil.GetElementText(itemdom.DocumentElement, "recoverComment"); if (String.IsNullOrEmpty(strOldRecoverComment) == false) { strText = "(借阅时原注: " + strOldRecoverComment + ") " + strRecoverComment; } if (String.IsNullOrEmpty(strText) == false) { DomUtil.SetAttr(nodeHistoryBorrower, "recoverComment", strText); } } } if (strAction == "lost") { // 修改册记录的<state> string strState = DomUtil.GetElementText(itemdom.DocumentElement, "state"); if (nodeHistoryBorrower != null) { DomUtil.SetAttr(nodeHistoryBorrower, "state", strState); } if (String.IsNullOrEmpty(strState) == false) { strState += ","; } strState += "丢失"; DomUtil.SetElementText(itemdom.DocumentElement, "state", strState); // 将日志记录中的<lostComment>内容追加写入册记录的<comment>中 string strLostComment = DomUtil.GetElementText(domLog.DocumentElement, "lostComment"); if (strLostComment != "") { string strComment = DomUtil.GetElementText(itemdom.DocumentElement, "comment"); if (nodeHistoryBorrower != null) { DomUtil.SetAttr(nodeHistoryBorrower, "comment", strComment); } if (String.IsNullOrEmpty(strComment) == false) { strComment += "\r\n"; } strComment += strLostComment; DomUtil.SetElementText(itemdom.DocumentElement, "comment", strComment); } } } } return(0); }
// 注:move 时候可能涉及到读者所从属的 libraryCode 发生变化,需要研究一下如何表达 // 一个方法是可以多发送一条 delete 动作的通知 void BuildReaderChangedRecord(XmlDocument domOperLog, out string strBodyXml, out string strReaderBarcode, out string strReaderRefID) { strBodyXml = ""; strReaderBarcode = ""; strReaderRefID = ""; #if NO string strOperation = DomUtil.GetElementText(domOperLog.DocumentElement, "operation"); string strAction = DomUtil.GetElementText(domOperLog.DocumentElement, "action"); #endif string strLibraryCode = DomUtil.GetElementText(domOperLog.DocumentElement, "libraryCode"); string strReaderRecord = DomUtil.GetElementText(domOperLog.DocumentElement, "record"); XmlDocument readerdom = new XmlDocument(); if (string.IsNullOrEmpty(strReaderRecord) == false) { readerdom.LoadXml(strReaderRecord); } else { readerdom = null; } #if NO string strOldReaderRecord = DomUtil.GetElementText(domOperLog.DocumentElement, "oldRecord"); XmlDocument old_readerdom = new XmlDocument(); if (string.IsNullOrEmpty(strOldReaderRecord) == false) { old_readerdom.LoadXml(strOldReaderRecord); } else { old_readerdom = null; } #endif #if NO string strReaderRecPath = ""; XmlElement reader_record = domOperLog.DocumentElement.SelectSingleNode("record") as XmlElement; if (reader_record != null) { strReaderRecPath = reader_record.GetAttribute("recPath"); } #endif if (readerdom != null) { strReaderRefID = DomUtil.GetElementText(readerdom.DocumentElement, "refID"); strReaderBarcode = DomUtil.GetElementText(readerdom.DocumentElement, "barcode"); } // 构造内容 XmlDocument bodydom = new XmlDocument(); bodydom.LoadXml("<root />"); DomUtil.SetElementText(bodydom.DocumentElement, "type", "读者记录变动"); // 复制日志记录中的一级元素 XmlNodeList nodes = domOperLog.DocumentElement.SelectNodes("*"); foreach (XmlNode node in nodes) { if (node.Name == "record" || node.Name == "oldRecord" || node.Name == "changedEntityRecord") { continue; } DomUtil.SetElementText(bodydom.DocumentElement, node.Name, node.InnerText); } if (readerdom != null) { XmlElement record = bodydom.CreateElement("patronRecord"); bodydom.DocumentElement.AppendChild(record); record.InnerXml = readerdom.DocumentElement.InnerXml; DomUtil.DeleteElement(record, "borrowHistory"); DomUtil.DeleteElement(record, "password"); DomUtil.DeleteElement(record, "fingerprint"); DomUtil.DeleteElement(record, "face"); XmlElement library_code = record.SelectSingleNode("libraryCode") as XmlElement; if (library_code == null) { DomUtil.SetElementText(record, "libraryCode", strLibraryCode); } } #if NO if (old_readerdom != null) { XmlElement record = bodydom.CreateElement("oldPatronRecord"); bodydom.DocumentElement.AppendChild(record); record.InnerXml = old_readerdom.DocumentElement.InnerXml; DomUtil.DeleteElement(record, "borrowHistory"); DomUtil.DeleteElement(record, "password"); DomUtil.DeleteElement(record, "fingerprint"); DomUtil.DeleteElement(record, "face"); } #endif strBodyXml = bodydom.DocumentElement.OuterXml; }
void BuildAmerceRecord(XmlDocument domOperLog, out string strBodyXml, out string strReaderBarcode, out string strReaderRefID) { strBodyXml = ""; strReaderBarcode = ""; strReaderRefID = ""; string strError = ""; // string strOperation = DomUtil.GetElementText(domOperLog.DocumentElement, "operation"); string strAction = DomUtil.GetElementText(domOperLog.DocumentElement, "action"); string strLibraryCode = DomUtil.GetElementText(domOperLog.DocumentElement, "libraryCode"); string strReaderRecord = DomUtil.GetElementText(domOperLog.DocumentElement, "readerRecord"); XmlDocument readerdom = new XmlDocument(); readerdom.LoadXml(strReaderRecord); strReaderRefID = DomUtil.GetElementText(readerdom.DocumentElement, "refID"); strReaderBarcode = DomUtil.GetElementText(readerdom.DocumentElement, "barcode"); // 构造内容 XmlDocument bodydom = new XmlDocument(); bodydom.LoadXml("<root />"); if (strAction == "amerce") { DomUtil.SetElementText(bodydom.DocumentElement, "type", "交费"); } else if (strAction == "undo") { DomUtil.SetElementText(bodydom.DocumentElement, "type", "撤销交费"); } else if (strAction == "modifyprice") { // DomUtil.SetElementText(bodydom.DocumentElement, "type", "变更交费金额"); strBodyXml = ""; return; } else if (strAction == "expire") { DomUtil.SetElementText(bodydom.DocumentElement, "type", "以停代金到期"); } else if (strAction == "modifycomment") { // DomUtil.SetElementText(bodydom.DocumentElement, "type", "修改交费注释"); strBodyXml = ""; return; } else { #if NO strError = "无法识别的 strAction '" + strAction + "'"; throw new Exception(strError); #endif strBodyXml = ""; return; } // 复制日志记录中的一级元素 XmlNodeList nodes = domOperLog.DocumentElement.SelectNodes("*"); foreach (XmlNode node in nodes) { if (node.Name == "readerRecord" || node.Name == "oldReaderRecord" || node.Name == "expireOverdues" || node.Name == "amerceItems" || node.Name == "amerceRecord") { continue; } DomUtil.SetElementText(bodydom.DocumentElement, node.Name, node.InnerText); } { XmlElement record = bodydom.CreateElement("patronRecord"); bodydom.DocumentElement.AppendChild(record); record.InnerXml = readerdom.DocumentElement.InnerXml; DomUtil.DeleteElement(record, "borrowHistory"); DomUtil.DeleteElement(record, "password"); DomUtil.DeleteElement(record, "fingerprint"); DomUtil.DeleteElement(record, "face"); DomUtil.SetElementText(record, "libraryCode", strLibraryCode); } // items XmlElement amerce_items = bodydom.DocumentElement.SelectSingleNode("items") as XmlElement; if (amerce_items == null) { amerce_items = bodydom.CreateElement("items"); bodydom.DocumentElement.AppendChild(amerce_items); } XmlNodeList amerce_records = domOperLog.DocumentElement.SelectNodes("amerceRecord"); foreach (XmlElement amerce_record in amerce_records) { string strAmercedXml = amerce_record.InnerText; if (string.IsNullOrEmpty(strAmercedXml)) { continue; } string strOverdueString = ""; string strTemp = ""; int nRet = LibraryApplication.ConvertAmerceRecordToOverdueString(strAmercedXml, out strTemp, out strOverdueString, out strError); if (nRet == -1) { throw new Exception(strError); } XmlDocumentFragment fragment = bodydom.CreateDocumentFragment(); fragment.InnerXml = strOverdueString; amerce_items.AppendChild(fragment); } // expire 情况要把 expireOverdues/overdue 翻译为 items/overdue 元素 if (strAction == "expire") { XmlElement expireOverdues = domOperLog.DocumentElement.SelectSingleNode("expiredOverdues") as XmlElement; if (expireOverdues != null) { amerce_items.InnerXml = expireOverdues.InnerXml; } } else { // 留着 amerceItem 元素做测试对照 } RmsChannel channel = this.RmsChannels.GetChannel(this.App.WsUrl); if (channel == null) { strError = "channel == null"; throw new Exception(strError); } // 为 overdue 元素添加 summary 属性 XmlNodeList overdues = bodydom.DocumentElement.SelectNodes("items/overdue"); foreach (XmlElement overdue in overdues) { string strItemBarcode = overdue.GetAttribute("barcode"); if (string.IsNullOrEmpty(strItemBarcode)) { continue; } // 加入书目摘要 string strSummary = ""; string strBiblioRecPath = ""; LibraryServerResult result = this.App.GetBiblioSummary( null, channel, strItemBarcode, "", // strItemRecPath, null, out strBiblioRecPath, out strSummary); if (result.Value == -1) { // strSummary = result.ErrorInfo; } else { overdue.SetAttribute("summary", strSummary); } } strBodyXml = bodydom.DocumentElement.OuterXml; }
void BuildBorrowReturnRecord(XmlDocument domOperLog, out string strBodyXml, out string strReaderBarcode, out string strReaderRefID) { strBodyXml = ""; strReaderBarcode = ""; strReaderRefID = ""; string strError = ""; string strOperation = DomUtil.GetElementText(domOperLog.DocumentElement, "operation"); string strLibraryCode = DomUtil.GetElementText(domOperLog.DocumentElement, "libraryCode"); string strReaderRecord = DomUtil.GetElementText(domOperLog.DocumentElement, "readerRecord"); XmlDocument readerdom = new XmlDocument(); readerdom.LoadXml(strReaderRecord); string strItemRecord = DomUtil.GetElementText(domOperLog.DocumentElement, "itemRecord"); XmlDocument itemdom = new XmlDocument(); itemdom.LoadXml(strItemRecord); string strItemRecPath = ""; XmlElement item_record = domOperLog.DocumentElement.SelectSingleNode("itemRecord") as XmlElement; if (item_record != null) { strItemRecPath = item_record.GetAttribute("recPath"); } strReaderRefID = DomUtil.GetElementText(readerdom.DocumentElement, "refID"); strReaderBarcode = DomUtil.GetElementText(readerdom.DocumentElement, "barcode"); // 构造内容 XmlDocument bodydom = new XmlDocument(); bodydom.LoadXml("<root />"); if (strOperation == "borrow") { DomUtil.SetElementText(bodydom.DocumentElement, "type", "借书成功"); } else if (strOperation == "return") { DomUtil.SetElementText(bodydom.DocumentElement, "type", "还书成功"); } else { #if NO strError = "无法识别的 strOperation '" + strOperation + "'"; throw new Exception(strError); #endif DomUtil.SetElementText(bodydom.DocumentElement, "type", "修改交费注释"); strBodyXml = ""; return; } // 复制日志记录中的一级元素 XmlNodeList nodes = domOperLog.DocumentElement.SelectNodes("*"); foreach (XmlNode node in nodes) { if (node.Name == "readerRecord" || node.Name == "itemRecord") { continue; } if (node.Name == "type") { DomUtil.SetElementText(bodydom.DocumentElement, "bookType", node.InnerText); } else { DomUtil.SetElementText(bodydom.DocumentElement, node.Name, node.InnerText); } } { XmlElement record = bodydom.CreateElement("patronRecord"); bodydom.DocumentElement.AppendChild(record); record.InnerXml = readerdom.DocumentElement.InnerXml; DomUtil.DeleteElement(record, "borrowHistory"); DomUtil.DeleteElement(record, "password"); DomUtil.DeleteElement(record, "fingerprint"); DomUtil.DeleteElement(record, "face"); DomUtil.SetElementText(record, "libraryCode", strLibraryCode); } { XmlElement record = bodydom.CreateElement("itemRecord"); bodydom.DocumentElement.AppendChild(record); record.InnerXml = itemdom.DocumentElement.InnerXml; string strItemBarcode = DomUtil.GetElementText(itemdom.DocumentElement, "barcode"); DomUtil.DeleteElement(record, "borrowHistory"); // 加入书目摘要 string strSummary = ""; string strBiblioRecPath = ""; RmsChannel channel = this.RmsChannels.GetChannel(this.App.WsUrl); if (channel == null) { strError = "channel == null"; throw new Exception(strError); } LibraryServerResult result = this.App.GetBiblioSummary( null, channel, strItemBarcode, strItemRecPath, null, out strBiblioRecPath, out strSummary); if (result.Value == -1) { // strSummary = result.ErrorInfo; } else { } DomUtil.SetElementText(record, "summary", strSummary); } strBodyXml = bodydom.DocumentElement.OuterXml; }
// 修改册记录中的借期,并去掉 overflow 元素 int ModifyItemRecord( SessionInfo sessioninfo, ItemModifyInfo info, out string strError) { strError = ""; int nRet = 0; string strFrom = "册条码号"; // 获得册记录 var result = GetItemRecord(sessioninfo, info.ItemBarcode, null, // strOwnerInstitution, ref strFrom, info.ConfirmItemRecPath, // ref strLibraryCode, out List <string> aPath, out string strItemXml, out string strOutputItemRecPath, out byte[] item_timestamp); if (aPath.Count > 1) { strError = $"册条码号为 {info.ItemBarcode} 的册记录有 {aPath.Count} 条,无法进行借阅操作"; return(-1); } if (result.Value == -1) { strError = result.ErrorInfo; return(-1); } XmlDocument itemdom = null; nRet = LibraryApplication.LoadToDom(strItemXml, out itemdom, out strError); if (nRet == -1) { strError = "装载册记录进入XML DOM时发生错误: " + strError; return(-1); } // 修改 DomUtil.SetElementText(itemdom.DocumentElement, "borrowPeriod", info.BorrowPeriod); if (string.IsNullOrEmpty(info.DenyPeriod) == false) { DomUtil.SetElementText(itemdom.DocumentElement, "denyPeriod", info.DenyPeriod); } else { DomUtil.DeleteElement(itemdom.DocumentElement, "denyPeriod"); } DomUtil.SetElementText(itemdom.DocumentElement, "returningDate", info.ReturningDate); DomUtil.DeleteElement(itemdom.DocumentElement, "overflow"); RmsChannel channel = sessioninfo.Channels.GetChannel(this.WsUrl); if (channel == null) { strError = "get channel error"; return(-1); } // 写回册记录 long lRet = channel.DoSaveTextRes(strOutputItemRecPath, itemdom.OuterXml, false, "content", item_timestamp, out byte[] output_timestamp, out string strOutputPath, out strError); if (lRet == -1) { return(-1); } return(0); }