示例#1
0
        // 根据日志 XML 记录填充数据
        public override int SetData(XmlDocument dom,
                                    string strDate,
                                    long lIndex,
                                    out List <OperBase> lines,
                                    out string strError)
        {
            strError = "";

            int nRet = base.SetData(dom, strDate, lIndex, out lines, out strError);

            if (nRet == -1)
            {
                return(-1);
            }

            XmlElement record = dom.DocumentElement.SelectSingleNode("record") as XmlElement;

            if (record == null)
            {
                record = dom.DocumentElement.SelectSingleNode("oldRecord") as XmlElement;
            }

            if (record != null)
            {
                this.ItemRecPath = DomUtil.GetAttr(record,
                                                   "recPath");
                string strParentID = record.GetAttribute("parent_id");
                if (string.IsNullOrEmpty(strParentID) == true)
                {
                    string strRecord = record.InnerText.Trim();
                    if (string.IsNullOrEmpty(strRecord) == false)
                    {
                        XmlDocument reader_dom = new XmlDocument();
                        try
                        {
                            reader_dom.LoadXml(strRecord);
                            strParentID = DomUtil.GetElementText(reader_dom.DocumentElement,
                                                                 "parent");
                        }
                        catch (Exception ex)
                        {
                            // 2016/12/6 返回 -1
                            strError = "ItemOperLogLine.SetData() 内部出现异常: " + ExceptionUtil.GetExceptionText(ex);
                            // MainForm.TryWriteErrorLog(strError + "\r\nXML记录: " + dom.OuterXml);
                            return(-1);
                        }
                    }
                }

                if (string.IsNullOrEmpty(strParentID) == false)
                {
                    Debug.Assert(string.IsNullOrEmpty(strParentID) == false, "");

                    Debug.Assert(this.Operation.IndexOf("set") == 0, "");
                    string strDbType = this.Operation.Substring("set".Length).ToLower();

                    // 根据实体库名得到书目库名
                    this.BiblioRecPath = Replication.BuildBiblioRecPath(strDbType, // "item",
                                                                        this.ItemRecPath,
                                                                        strParentID);
                }
            }

            return(0);
        }