Beispiel #1
0
        // 将一条 borrow 或 return 操作日志信息加入 mongodb 日志库
        // mongodb 日志库的意义在于提供借阅历史检索功能
        public static int AppendOperationBorrowReturn(
            LibraryApplication app,
            XmlDocument domOperLog,
            string strOperation,
            out string strError)
        {
            strError = "";

            string strAction = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                      "action");

            ChargingOperItem item = new ChargingOperItem();

            item.Operation   = strOperation;
            item.Action      = strAction;
            item.LibraryCode = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                      "libraryCode");
            item.ItemBarcode = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                      "itemBarcode");
            item.PatronBarcode = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                        "readerBarcode");

            {
                string strBiblioRecPath = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                                 "biblioRecPath");
                if (string.IsNullOrEmpty(strBiblioRecPath) == false)
                {
                    item.BiblioRecPath = strBiblioRecPath;
                }
            }

            if (strOperation == "borrow")
            {
                item.Period = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                     "borrowPeriod");
                item.No = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                 "no");
            }

            // 2017/5/22
            string strVolume = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                      "volume");

            if (string.IsNullOrEmpty(strVolume) == false)
            {
                item.Volume = strVolume;
            }

#if NO
            if (strOperation == "return" && strAction == "read")
            {
                // no 用作卷册信息 ???
                item.No = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                 "no");
            }
#endif

            item.ClientAddress = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                        "clientAddress");
            item.Operator = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                   "operator");
            string strOperTime = DomUtil.GetElementText(domOperLog.DocumentElement,
                                                        "operTime");
            try
            {
                item.OperTime = DateTimeUtil.FromRfc1123DateTimeString(strOperTime).ToLocalTime();
            }
            catch (Exception ex)
            {
                strError = "operTime 元素内容 '" + strOperTime + "' 格式错误:" + ex.Message;
                return(-1);
            }

            app.ChargingOperDatabase.Add(item);
            return(0);
        }
        // 将一条 borrow 或 return 操作日志信息加入 mongodb 日志库
        // mongodb 日志库的意义在于提供借阅历史检索功能
        public static int AppendOperationBorrowReturn(
            LibraryApplication app,
            XmlDocument domOperLog,
            string strOperation,
            out string strError)
        {
            strError = "";

            string strAction = DomUtil.GetElementText(domOperLog.DocumentElement,
                "action");

            ChargingOperItem item = new ChargingOperItem();
            item.Operation = strOperation;
            item.Action = strAction;
            item.LibraryCode = DomUtil.GetElementText(domOperLog.DocumentElement,
                "libraryCode");
            item.ItemBarcode = DomUtil.GetElementText(domOperLog.DocumentElement,
                "itemBarcode");
            item.PatronBarcode = DomUtil.GetElementText(domOperLog.DocumentElement,
                "readerBarcode");

            {
                string strBiblioRecPath = DomUtil.GetElementText(domOperLog.DocumentElement,
                    "biblioRecPath");
                if (string.IsNullOrEmpty(strBiblioRecPath) == false)
                    item.BiblioRecPath = strBiblioRecPath;
            }

            if (strOperation == "borrow")
            {
                item.Period = DomUtil.GetElementText(domOperLog.DocumentElement,
                    "borrowPeriod");
                item.No = DomUtil.GetElementText(domOperLog.DocumentElement,
                    "no");
            }

            if (strOperation == "return" && strAction == "read")
            {
                // no 用作卷册信息
                item.No = DomUtil.GetElementText(domOperLog.DocumentElement,
    "no");
            }

            item.ClientAddress = DomUtil.GetElementText(domOperLog.DocumentElement,
                "clientAddress");
            item.Operator = DomUtil.GetElementText(domOperLog.DocumentElement,
                    "operator");
            string strOperTime = DomUtil.GetElementText(domOperLog.DocumentElement,
                    "operTime");
            try
            {
                item.OperTime = DateTimeUtil.FromRfc1123DateTimeString(strOperTime).ToLocalTime();
            }
            catch (Exception ex)
            {
                strError = "operTime 元素内容 '" + strOperTime + "' 格式错误:" + ex.Message;
                return -1;
            }

            app.ChargingOperDatabase.Add(item);
            return 0;
        }