Ejemplo n.º 1
0
        public void SetVersion(LibEntity libEntity, string version)
        {
            string strError = "";

            // 设置版本
            this._version = version;

            // 更新状态
            this.UpdateState();


            // 获取数据库信息
            if (this.State != LibraryManager.C_State_Hangup ||
                (this.State == LibraryManager.C_State_Hangup && this.Version != "-1"))
            {
                // 得到期库
                //用点对点的 getSystemParameter 功能。category 为 "system", name 为 "biblioDbGroup",
                //可以获得一段 XML 字符串,格式和 library.xml 中的 itemdbgroup 元素相仿,
                //但每个 database 元素的 name 属性名字变为 itemDbName。
                // item.IssueDbName = DomUtil.GetAttr(node, "issueDbName");
                List <string> dataList = new List <string>();
                //(较早的dp2Capo在上述功能被调用时会返回ErrorInfo=未知的 category '_clock' 和 name '',ErrorCode=NotFound)
                int nRet = dp2WeiXinService.Instance.GetSystemParameter(libEntity,
                                                                        "system",
                                                                        "biblioDbGroup",
                                                                        out dataList,
                                                                        out strError);
                if (nRet == -1 || nRet == 0)
                {
                    goto ERROR1;
                }

                // 取出数据库配置xml
                this.BiblioDbGroup = "<root>" + dataList[0] + "</root>";

                XmlDocument dom = new XmlDocument();
                dom.LoadXml(this.BiblioDbGroup);
                XmlNodeList databaseList = dom.DocumentElement.SelectNodes("database");
                foreach (XmlNode node in databaseList)
                {
                    DbCfg db = new DbCfg();

                    db.DbName         = DomUtil.GetAttr(node, "itemDbName");
                    db.BiblioDbName   = DomUtil.GetAttr(node, "biblioDbName");
                    db.BiblioDbSyntax = DomUtil.GetAttr(node, "syntax");
                    db.IssueDbName    = DomUtil.GetAttr(node, "issueDbName");

                    db.OrderDbName       = DomUtil.GetAttr(node, "orderDbName");
                    db.CommentDbName     = DomUtil.GetAttr(node, "commentDbName");
                    db.UnionCatalogStyle = DomUtil.GetAttr(node, "unionCatalogStyle");

                    // 2008/6/4
                    bool bValue = true;
                    nRet = DomUtil.GetBooleanParam(node,
                                                   "inCirculation",
                                                   true,
                                                   out bValue,
                                                   out strError);
                    if (nRet == -1)
                    {
                        throw new Exception("元素<//biblioDbGroup/database>属性inCirculation读入时发生错误: " + strError);
                    }
                    db.InCirculation = bValue;

                    db.Role = DomUtil.GetAttr(node, "role");

                    this.DbList.Add(db);
                }
            }

            return;

ERROR1:
            dp2WeiXinService.Instance.WriteErrorLog1("获取库信息出错:" + strError);
        }
Ejemplo n.º 2
0
        public void GetDbs(Library library)
        {
            int    nRet     = 0;
            string strError = "";
            // 获取数据库
            //用点对点的 getSystemParameter 功能。category 为 "system", name 为 "biblioDbGroup",
            //可以获得一段 XML 字符串,格式和 library.xml 中的 itemdbgroup 元素相仿,
            //但每个 database 元素的 name 属性名字变为 itemDbName。
            // item.IssueDbName = DomUtil.GetAttr(node, "issueDbName");
            List <string> dataList = new List <string>();

            //(较早的dp2Capo在上述功能被调用时会返回ErrorInfo=未知的 category '_clock' 和 name '',ErrorCode=NotFound)
            nRet = dp2WeiXinService.Instance.GetSystemParameter(library.Entity,
                                                                "system",
                                                                "biblioDbGroup",
                                                                out dataList,
                                                                out strError);
            // -1 记录错误日志,不影响其它馆使用
            if (nRet == -1 || nRet == 0)  //0是什么情况?
            {
                dp2WeiXinService.Instance.WriteErrorLog("获取[" + library.Entity.libName + "]的数据库信息出错:" + strError);
                return;
            }

            // 取出数据库配置xml
            library.BiblioDbGroup = "<root>" + dataList[0] + "</root>";

            XmlDocument dom = new XmlDocument();

            dom.LoadXml(library.BiblioDbGroup);
            XmlNodeList databaseList = dom.DocumentElement.SelectNodes("database");

            foreach (XmlNode node in databaseList)
            {
                DbCfg db = new DbCfg();

                db.DbName         = DomUtil.GetAttr(node, "itemDbName");
                db.BiblioDbName   = DomUtil.GetAttr(node, "biblioDbName");
                db.BiblioDbSyntax = DomUtil.GetAttr(node, "syntax");
                db.IssueDbName    = DomUtil.GetAttr(node, "issueDbName");

                db.OrderDbName       = DomUtil.GetAttr(node, "orderDbName");
                db.CommentDbName     = DomUtil.GetAttr(node, "commentDbName");
                db.UnionCatalogStyle = DomUtil.GetAttr(node, "unionCatalogStyle");

                // 2008/6/4
                bool bValue = true;
                nRet = DomUtil.GetBooleanParam(node,
                                               "inCirculation",
                                               true,
                                               out bValue,
                                               out strError);
                if (nRet == -1)
                {
                    throw new Exception("元素<//biblioDbGroup/database>属性inCirculation读入时发生错误: " + strError);
                }
                db.InCirculation = bValue;

                db.Role = DomUtil.GetAttr(node, "role");

                library.DbList.Add(db);
            }
        }