예제 #1
0
        // 写入操作日志
        int WriteAdjustOverflowOperLog(
            SessionInfo sessioninfo,
            ItemModifyInfo info,
            out string strError)
        {
            strError = "";

            XmlDocument domOperLog = new XmlDocument();

            domOperLog.LoadXml("<root />");
            DomUtil.SetElementText(domOperLog.DocumentElement,
                                   "libraryCode",
                                   info.LibraryCode); // 读者所在的馆代码
            DomUtil.SetElementText(domOperLog.DocumentElement, "operation", "adjustOverflow");
            // DomUtil.SetElementText(domOperLog.DocumentElement, "action", strAction);

            DomUtil.SetElementText(domOperLog.DocumentElement, "borrowID", info.BorrowID);
            DomUtil.SetElementText(domOperLog.DocumentElement, "patronBarcode", info.PatronBarcode);
            DomUtil.SetElementText(domOperLog.DocumentElement, "itemBarcode", info.ItemBarcode);
            DomUtil.SetElementText(domOperLog.DocumentElement, "confirmItemRecPath", info.ConfirmItemRecPath);
            DomUtil.SetElementText(domOperLog.DocumentElement, "borrowDate", info.BorrowDate);

            DomUtil.SetElementText(domOperLog.DocumentElement, "borrowPeriod", info.BorrowPeriod);
            DomUtil.SetElementText(domOperLog.DocumentElement, "returningDate", info.ReturningDate);
            if (string.IsNullOrEmpty(info.DenyPeriod) == false)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement, "denyPeriod", info.DenyPeriod);
            }

            // 修改前的 borrow 元素
            var borrow = domOperLog.DocumentElement.AppendChild(domOperLog.CreateElement("borrow")) as XmlElement;

            DomUtil.SetElementOuterXml(borrow, info.OldBorrowInfo);

            DomUtil.SetElementText(domOperLog.DocumentElement, "operator",
                                   sessioninfo.UserID);

            string strOperTime = this.Clock.GetClock();

            DomUtil.SetElementText(domOperLog.DocumentElement, "operTime",
                                   strOperTime);

            int nRet = this.OperLog.WriteOperLog(domOperLog,
                                                 sessioninfo.ClientAddress,
                                                 out strError);

            if (nRet == -1)
            {
                strError = "写入 AdjustOverflow 操作日志时发生错误: " + strError;
                return(-1);
            }

            return(0);
        }
예제 #2
0
        // 修改册记录中的借期,并去掉 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);
        }