Ejemplo n.º 1
0
        // 根据书目库名(或者别名)获得检索途径名
        // parameters:
        //      strOutputDbName 输出的数据库名。不是Z39.50服务器定义的别名,而是正规数据库名。
        public string GetFromName(string strDbNameOrAlias,
                                  long lAttributeValue,
                                  out string strOutputDbName,
                                  out string strError)
        {
            strError        = "";
            strOutputDbName = "";

            // 因为XMLDOM中无法进行大小写不敏感的搜索,所以把搜索别名的这个任务交给properties
            Debug.Assert(this.CfgDom != null, "");
            BiblioDbProperty prop = this.GetDbProperty(strDbNameOrAlias, true);

            if (prop == null)
            {
                strError = "名字或者别名为 '" + strDbNameOrAlias + "' 的数据库不存在";
                return(null);
            }

            strOutputDbName = prop.DbName;


            XmlNode nodeDatabase = this.CfgDom.DocumentElement.SelectSingleNode("//databases/database[@name='" + strOutputDbName + "']");

            if (nodeDatabase == null)
            {
                strError = "名字为 '" + strOutputDbName + "' 的数据库不存在";
            }

            XmlNode nodeUse = nodeDatabase.SelectSingleNode("use[@value='" + lAttributeValue.ToString() + "']");

            if (nodeUse == null)
            {
                strError = "数据库 '" + strDbNameOrAlias + "' 中没有找到关于 '" + lAttributeValue.ToString() + "' 的检索途径定义";
                return(null);
            }

            string strFrom = DomUtil.GetAttr(nodeUse, "from");

            if (String.IsNullOrEmpty(strFrom) == true)
            {
                strError = "数据库 '" + strDbNameOrAlias + "' <database>元素中关于 '" + lAttributeValue.ToString() + "' 的<use>配置缺乏from属性值";
                return(null);
            }

            return(strFrom);
        }
Ejemplo n.º 2
0
        // 为数据库属性集合中增补需要从xml文件中获得的其他属性
        int AppendDbProperties(out string strError)
        {
            strError = "";

            // 增补MaxResultCount
            if (this.CfgDom == null)
            {
                strError = "调用 GetBiblioDbProperties()以前,需要先初始化和装载CfgDom";
                return(-1);
            }

            Debug.Assert(this.CfgDom != null, "");

            for (int i = 0; i < this.BiblioDbProperties.Count; i++)
            {
                BiblioDbProperty prop = this.BiblioDbProperties[i];

                string strDbName = prop.DbName;

                XmlNode nodeDatabase = this.CfgDom.DocumentElement.SelectSingleNode("//databases/database[@name='" + strDbName + "']");
                if (nodeDatabase == null)
                {
                    continue;
                }

                // maxResultCount

                // 获得整数型的属性参数值
                // return:
                //      -1  出错。但是nValue中已经有了nDefaultValue值,可以不加警告而直接使用
                //      0   正常获得明确定义的参数值
                //      1   参数没有定义,因此代替以缺省参数值返回
                int nRet = DomUtil.GetIntegerParam(nodeDatabase,
                                                   "maxResultCount",
                                                   -1,
                                                   out prop.MaxResultCount,
                                                   out strError);
                if (nRet == -1)
                {
                    strError = "为数据库 '" + strDbName + "' 配置的<databases/database>元素的" + strError;
                    return(-1);
                }

                // alias
                prop.DbNameAlias = DomUtil.GetAttr(nodeDatabase, "alias");


                // addField901
                // 2007/12/16
                nRet = DomUtil.GetBooleanParam(nodeDatabase,
                                               "addField901",
                                               false,
                                               out prop.AddField901,
                                               out strError);
                if (nRet == -1)
                {
                    strError = "为数据库 '" + strDbName + "' 配置的<databases/database>元素的" + strError;
                    return(-1);
                }
            }

            return(0);
        }
Ejemplo n.º 3
0
        // 获得编目库属性列表
        int GetBiblioDbProperties(out string strError)
        {
            strError = "";
            try
            {
                this.BiblioDbProperties = new List <BiblioDbProperty>();

                string strValue = "";
                long   lRet     = Channel.GetSystemParameter(null,
                                                             "biblio",
                                                             "dbnames",
                                                             out strValue,
                                                             out strError);
                if (lRet == -1)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得编目库名列表过程发生错误:" + strError;
                    goto ERROR1;
                }

                string[] biblioDbNames = strValue.Split(new char[] { ',' });

                for (int i = 0; i < biblioDbNames.Length; i++)
                {
                    BiblioDbProperty property = new BiblioDbProperty();
                    property.DbName = biblioDbNames[i];
                    this.BiblioDbProperties.Add(property);
                }

                // 获得语法格式
                lRet = Channel.GetSystemParameter(null,
                                                  "biblio",
                                                  "syntaxs",
                                                  out strValue,
                                                  out strError);
                if (lRet == -1)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得编目库数据格式列表过程发生错误:" + strError;
                    goto ERROR1;
                }

                string[] syntaxs = strValue.Split(new char[] { ',' });

                if (syntaxs.Length != this.BiblioDbProperties.Count)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得编目库名为 " + this.BiblioDbProperties.Count.ToString() + " 个,而数据格式为 " + syntaxs.Length.ToString() + " 个,数量不一致";
                    goto ERROR1;
                }

                // 增补数据格式
                for (int i = 0; i < this.BiblioDbProperties.Count; i++)
                {
                    this.BiblioDbProperties[i].Syntax = syntaxs[i];
                }


                ///

                // 获得对应的实体库名
                lRet = Channel.GetSystemParameter(null,
                                                  "item",
                                                  "dbnames",
                                                  out strValue,
                                                  out strError);
                if (lRet == -1)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得实体库名列表过程发生错误:" + strError;
                    goto ERROR1;
                }

                string[] itemdbnames = strValue.Split(new char[] { ',' });

                if (itemdbnames.Length != this.BiblioDbProperties.Count)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得编目库名为 " + this.BiblioDbProperties.Count.ToString() + " 个,而实体库名为 " + itemdbnames.Length.ToString() + " 个,数量不一致";
                    goto ERROR1;
                }

                // 增补数据格式
                for (int i = 0; i < this.BiblioDbProperties.Count; i++)
                {
                    this.BiblioDbProperties[i].ItemDbName = itemdbnames[i];
                }

                // 获得虚拟数据库名
                lRet = Channel.GetSystemParameter(null,
                                                  "virtual",
                                                  "dbnames",
                                                  out strValue,
                                                  out strError);
                if (lRet == -1)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得虚拟库名列表过程发生错误:" + strError;
                    goto ERROR1;
                }
                string[] virtualDbNames = strValue.Split(new char[] { ',' });

                for (int i = 0; i < virtualDbNames.Length; i++)
                {
                    BiblioDbProperty property = new BiblioDbProperty();
                    property.DbName    = virtualDbNames[i];
                    property.IsVirtual = true;
                    this.BiblioDbProperties.Add(property);
                }
            }
            finally
            {
            }

            return(0);

ERROR1:
            this.BiblioDbProperties = null;
            return(-1);
        }
Ejemplo n.º 4
0
        // 获得编目库属性列表
        int GetBiblioDbProperties(out string strError)
        {
            strError = "";
            try
            {
                this.BiblioDbProperties = new List<BiblioDbProperty>();

                string strValue = "";
                long lRet = Channel.GetSystemParameter(null,
                    "biblio",
                    "dbnames",
                    out strValue,
                    out strError);
                if (lRet == -1)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得编目库名列表过程发生错误:" + strError;
                    goto ERROR1;
                }

                string[] biblioDbNames = strValue.Split(new char[] { ',' });

                for (int i = 0; i < biblioDbNames.Length; i++)
                {
                    BiblioDbProperty property = new BiblioDbProperty();
                    property.DbName = biblioDbNames[i];
                    this.BiblioDbProperties.Add(property);
                }

                // 获得语法格式
                lRet = Channel.GetSystemParameter(null,
                    "biblio",
                    "syntaxs",
                    out strValue,
                    out strError);
                if (lRet == -1)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得编目库数据格式列表过程发生错误:" + strError;
                    goto ERROR1;
                }

                string[] syntaxs = strValue.Split(new char[] { ',' });

                if (syntaxs.Length != this.BiblioDbProperties.Count)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得编目库名为 " + this.BiblioDbProperties.Count.ToString() + " 个,而数据格式为 " + syntaxs.Length.ToString() + " 个,数量不一致";
                    goto ERROR1;
                }

                // 增补数据格式
                for (int i = 0; i < this.BiblioDbProperties.Count; i++)
                {
                    this.BiblioDbProperties[i].Syntax = syntaxs[i];
                }


                ///

                // 获得对应的实体库名
                lRet = Channel.GetSystemParameter(null,
                    "item",
                    "dbnames",
                    out strValue,
                    out strError);
                if (lRet == -1)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得实体库名列表过程发生错误:" + strError;
                    goto ERROR1;
                }

                string[] itemdbnames = strValue.Split(new char[] { ',' });

                if (itemdbnames.Length != this.BiblioDbProperties.Count)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得编目库名为 " + this.BiblioDbProperties.Count.ToString() + " 个,而实体库名为 " + itemdbnames.Length.ToString() + " 个,数量不一致";
                    goto ERROR1;
                }

                // 增补数据格式
                for (int i = 0; i < this.BiblioDbProperties.Count; i++)
                {
                    this.BiblioDbProperties[i].ItemDbName = itemdbnames[i];
                }

                // 获得虚拟数据库名
                lRet = Channel.GetSystemParameter(null,
                    "virtual",
                    "dbnames",
                    out strValue,
                    out strError);
                if (lRet == -1)
                {
                    strError = "针对服务器 " + Channel.Url + " 获得虚拟库名列表过程发生错误:" + strError;
                    goto ERROR1;
                }
                string[] virtualDbNames = strValue.Split(new char[] { ',' });

                for (int i = 0; i < virtualDbNames.Length; i++)
                {
                    BiblioDbProperty property = new BiblioDbProperty();
                    property.DbName = virtualDbNames[i];
                    property.IsVirtual = true;
                    this.BiblioDbProperties.Add(property);
                }
            }
            finally
            {
            }

            return 0;
        ERROR1:
            this.BiblioDbProperties = null;
            return -1;
        }