示例#1
0
        static List <KeyFromItem> BuildKeyFromList(List <string> results)
        {
            List <KeyFromItem> items = new List <KeyFromItem>();

            for (int i = 0; i < results.Count / 2; i++)
            {
                KeyFromItem item = new KeyFromItem();
                item.Key  = results[i * 2];
                item.From = results[i * 2 + 1].Replace((char)31, '$');
                items.Add(item);
            }

            return(items);
        }
示例#2
0
        static List<KeyFromItem> BuildKeyFromList(List<string> results)
        {
            List<KeyFromItem> items = new List<KeyFromItem>();
            for (int i = 0; i < results.Count / 2; i++)
            {
                KeyFromItem item = new KeyFromItem();
                item.Key = results[i * 2];
                item.From = results[i * 2 + 1].Replace((char)31, '$');
                items.Add(item);
            }

            return items;
        }
示例#3
0
        // 做一个数据库内的检索
        // parameters:
        //      strServerName   目标服务器名。这个和<database>元素name属性中的服务器名部分可不一定一样
        //      strDatabaseName 数据库路径
        int DoOneDatabase(
            XmlNode nodeDatabase,
            out string strError)
        {
            strError = "";

            string strDatabasePath = DomUtil.GetAttr(nodeDatabase, "name");
            string strThreshold    = DomUtil.GetAttr(nodeDatabase, "threshold");

            int nThreshold = 0;

            try
            {
                nThreshold = Convert.ToInt32(strThreshold);
            }
            catch
            {
                strError = "threshold值 '" + strThreshold + "' 格式不正确,应当为纯数字";
                return(-1);
            }

            // string strServerName = GetServerName(strDatabasePath);

            List <string> results = null;

            // 获得一条记录的关于这个数据库的检索点
            int nRet = this.DtlpChannel.GetAccessPoint(strDatabasePath + "/ctlno/?", // 全路径
                                                       this.MarcRecord,
                                                       out results,
                                                       out strError);

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

            // 将results加工为合用的数组
            List <KeyFromItem> items = BuildKeyFromList(results);

            // 遍历数据中实际存在的每个key+from
            for (int i = 0; i < items.Count; i++)
            {
                KeyFromItem item = items[i];

                string strWeight      = "";
                string strSearchStyle = "";

                // 获得这个from有关的weight/searchstyle
                // 获得关于一个检索点的定义信息 weight / searchstyle
                // parameters:
                //      strFromName from名。注意里面的31字符应当替换为'$'
                // return:
                //      -1  error
                //      0   not found
                //      1   found
                nRet = GetAccessPointDef(nodeDatabase,
                                         item.From,
                                         out strWeight,
                                         out strSearchStyle,
                                         out strError);
                if (nRet == -1)
                {
                    return(-1);
                }
                if (nRet == 0)
                {
                    continue;
                }

                Debug.Assert(strWeight != "", "");

                // 进行检索
                nRet = DoOneSearch(
                    strDatabasePath,
                    item.From,
                    item.Key,
                    strWeight,
                    strSearchStyle,
                    nThreshold,
                    out strError);
                if (nRet == -1)
                {
                    return(-1);
                }
            }

            // TODO: 将所有<accessPoint>节点存储到一个hashtable中,以便提高运行速度?便于查检,而不用xpath来选择?


            return(0);
        }