Exemple #1
0
        public LibraryServerResult GetZhongcihaoSearchResult(
            SessionInfo sessioninfo,
            string strZhongcihaoGroupName,
            string strResultSetName,
            long lStart,
            long lCount,
            string strBrowseInfoStyle,
            string strLang,
            out ZhongcihaoSearchResult[] searchresults)
        {
            string strError = "";

            searchresults = null;

            LibraryServerResult result = new LibraryServerResult();
            int  nRet = 0;
            long lRet = 0;

            if (String.IsNullOrEmpty(strZhongcihaoGroupName) == true)
            {
                strError = "strZhongcihaoGroupName参数值不能为空";
                goto ERROR1;
            }

            if (strZhongcihaoGroupName[0] == '!')
            {
                string strTemp = GetZhongcihaoGroupName(strZhongcihaoGroupName.Substring(1));

                if (strTemp == null)
                {
                    strError = "书目库名 " + strZhongcihaoGroupName.Substring(1) + " 没有找到对应的种次号组名";
                    goto ERROR1;
                }
                strZhongcihaoGroupName = strTemp;
            }

            RmsChannel channel = sessioninfo.Channels.GetChannel(this.WsUrl);

            if (channel == null)
            {
                result.Value     = -1;
                result.ErrorInfo = "get channel error";
                result.ErrorCode = ErrorCode.SystemError;
                return(result);
            }

            //
            XmlNode nodeNsTable = this.LibraryCfgDom.DocumentElement.SelectSingleNode("//zhongcihao/nstable");

            XmlNamespaceManager mngr = null;

            if (nodeNsTable != null)
            {
                // 准备名字空间环境
                nRet = PrepareNs(
                    nodeNsTable,
                    out mngr,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
            }

            // 构造数据库定义和库名的对照表
            XmlNodeList nodes = this.LibraryCfgDom.DocumentElement.SelectNodes("//zhongcihao/group[@name='" + strZhongcihaoGroupName + "']/database");

            if (nodes.Count == 0)
            {
                strError = "library.xml中尚未配置有关 '" + strZhongcihaoGroupName + "'的<zhongcihao>/<group>/<database>相关参数";
                goto ERROR1;
            }

            Hashtable db_prop_table = new Hashtable();

            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                DbZhongcihaoProperty prop = new DbZhongcihaoProperty();
                prop.DbName      = DomUtil.GetAttr(node, "name");
                prop.NumberXPath = DomUtil.GetAttr(node, "rightxpath");
                prop.TitleXPath  = DomUtil.GetAttr(node, "titlexpath");
                prop.AuthorXPath = DomUtil.GetAttr(node, "authorxpath");

                db_prop_table[prop.DbName] = prop;
            }

            if (String.IsNullOrEmpty(strResultSetName) == true)
            {
                strResultSetName = "default";
            }

            Record[] origin_searchresults = null; //

            lRet = channel.DoGetSearchResult(
                strResultSetName,
                lStart,
                lCount,
                "id",
                strLang,
                null,
                out origin_searchresults,
                out strError);
            if (lRet == -1)
            {
                goto ERROR1;
            }

            long lResultCount = lRet;

            searchresults = new ZhongcihaoSearchResult[origin_searchresults.Length];

            for (int i = 0; i < origin_searchresults.Length; i++)
            {
                ZhongcihaoSearchResult item = new ZhongcihaoSearchResult();

                item.Path        = origin_searchresults[i].Path;
                searchresults[i] = item;

                // 继续填充其余成员
                string strXml        = "";
                string strMetaData   = "";
                byte[] timestamp     = null;
                string strOutputPath = "";

                lRet = channel.GetRes(item.Path,
                                      out strXml,
                                      out strMetaData,
                                      out timestamp,
                                      out strOutputPath,
                                      out strError);
                if (lRet == -1)
                {
                    item.Zhongcihao = "获取记录 '" + item.Path + "' 出错: " + strError;
                    continue;
                }

                string strDbName = ResPath.GetDbName(item.Path);

                DbZhongcihaoProperty prop = (DbZhongcihaoProperty)db_prop_table[strDbName];
                if (prop == null)
                {
                    item.Zhongcihao = "数据库名 '" + strDbName + "' 不在定义的种次号特性(<zhongcihao>/<group>/<database>)中";
                    continue;
                }

                string strNumber = "";
                string strTitle  = "";
                string strAuthor = "";

                nRet = GetRecordProperties(
                    strXml,
                    prop,
                    mngr,
                    out strNumber,
                    out strTitle,
                    out strAuthor,
                    out strError);
                if (nRet == -1)
                {
                    item.Zhongcihao = strError;
                    continue;
                }

                item.Zhongcihao = strNumber;
                item.Cols       = new string[2];
                item.Cols[0]    = strTitle;
                item.Cols[1]    = strAuthor;
            }


            result.Value = lResultCount;
            return(result);

ERROR1:
            result.Value     = -1;
            result.ErrorCode = ErrorCode.SystemError;
            result.ErrorInfo = strError;
            return(result);
        }
Exemple #2
0
        public LibraryServerResult GetZhongcihaoSearchResult(
            SessionInfo sessioninfo,
            string strZhongcihaoGroupName,
            string strResultSetName,
            long lStart,
            long lCount,
            string strBrowseInfoStyle,
            string strLang,
            out ZhongcihaoSearchResult[] searchresults)
        {
            string strError = "";
            searchresults = null;

            LibraryServerResult result = new LibraryServerResult();
            int nRet = 0;
            long lRet = 0;

            if (String.IsNullOrEmpty(strZhongcihaoGroupName) == true)
            {
                strError = "strZhongcihaoGroupName参数值不能为空";
                goto ERROR1;
            }

            if (strZhongcihaoGroupName[0] == '!')
            {
                string strTemp = GetZhongcihaoGroupName(strZhongcihaoGroupName.Substring(1));

                if (strTemp == null)
                {
                    strError = "书目库名 " + strZhongcihaoGroupName.Substring(1) + " 没有找到对应的种次号组名";
                    goto ERROR1;
                }
                strZhongcihaoGroupName = strTemp;
            }

            RmsChannel channel = sessioninfo.Channels.GetChannel(this.WsUrl);
            if (channel == null)
            {
                result.Value = -1;
                result.ErrorInfo = "get channel error";
                result.ErrorCode = ErrorCode.SystemError;
                return result;
            }

            // 
            XmlNode nodeNsTable = this.LibraryCfgDom.DocumentElement.SelectSingleNode("//zhongcihao/nstable");

            XmlNamespaceManager mngr = null;

            if (nodeNsTable != null)
            {
                // 准备名字空间环境
                nRet = PrepareNs(
                    nodeNsTable,
                    out mngr,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;
            }

            // 构造数据库定义和库名的对照表
            XmlNodeList nodes = this.LibraryCfgDom.DocumentElement.SelectNodes("//zhongcihao/group[@name='" + strZhongcihaoGroupName + "']/database");
            if (nodes.Count == 0)
            {
                strError = "library.xml中尚未配置有关 '" + strZhongcihaoGroupName + "'的<zhongcihao>/<group>/<database>相关参数";
                goto ERROR1;
            }

            Hashtable db_prop_table = new Hashtable();

            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                DbZhongcihaoProperty prop = new DbZhongcihaoProperty();
                prop.DbName = DomUtil.GetAttr(node, "name");
                prop.NumberXPath = DomUtil.GetAttr(node, "rightxpath");
                prop.TitleXPath = DomUtil.GetAttr(node, "titlexpath");
                prop.AuthorXPath = DomUtil.GetAttr(node, "authorxpath");

                db_prop_table[prop.DbName] = prop;
            }

            if (String.IsNullOrEmpty(strResultSetName) == true)
                strResultSetName = "default";

            Record[] origin_searchresults = null; // 

            lRet = channel.DoGetSearchResult(
                strResultSetName,
                lStart,
                lCount,
                "id",
                strLang,
                null,
                out origin_searchresults,
                out strError);
            if (lRet == -1)
                goto ERROR1;

            long lResultCount = lRet;

            searchresults = new ZhongcihaoSearchResult[origin_searchresults.Length];

            for (int i = 0; i < origin_searchresults.Length; i++)
            {
                ZhongcihaoSearchResult item = new ZhongcihaoSearchResult();

                item.Path = origin_searchresults[i].Path;
                searchresults[i] = item;

                // 继续填充其余成员
                string strXml = "";
                string strMetaData = "";
                byte[] timestamp = null;
                string strOutputPath = "";

                lRet = channel.GetRes(item.Path,
                    out strXml,
                    out strMetaData,
                    out timestamp,
                    out strOutputPath,
                    out strError);
                if (lRet == -1)
                {
                    item.Zhongcihao = "获取记录 '" + item.Path + "' 出错: " + strError;
                    continue;
                }

                string strDbName = ResPath.GetDbName(item.Path);

                DbZhongcihaoProperty prop = (DbZhongcihaoProperty)db_prop_table[strDbName];
                if (prop == null)
                {
                    item.Zhongcihao = "数据库名 '" + strDbName + "' 不在定义的种次号特性(<zhongcihao>/<group>/<database>)中";
                    continue;
                }

                string strNumber = "";
                string strTitle = "";
                string strAuthor = "";

                nRet = GetRecordProperties(
                    strXml,
                    prop,
                    mngr,
                    out strNumber,
                    out strTitle,
                    out strAuthor,
                    out strError);
                if (nRet == -1)
                {
                    item.Zhongcihao = strError;
                    continue;
                }

                item.Zhongcihao = strNumber;
                item.Cols = new string[2];
                item.Cols[0] = strTitle;
                item.Cols[1] = strAuthor;
            }


            result.Value = lResultCount;
            return result;
        ERROR1:
            result.Value = -1;
            result.ErrorCode = ErrorCode.SystemError;
            result.ErrorInfo = strError;
            return result;
        }
Exemple #3
0
        public LibraryServerResult GetZhongcihaoSearchResult(
            SessionInfo sessioninfo,
            string strZhongcihaoGroupName,
            string strResultSetName,
            long lStart,
            long lCount,
            string strBrowseInfoStyle,
            string strLang,
            out ZhongcihaoSearchResult[] searchresults)
        {
            string strError = "";

            searchresults = null;

            LibraryServerResult result = new LibraryServerResult();
            // int nRet = 0;
            long lRet = 0;

            if (String.IsNullOrEmpty(strZhongcihaoGroupName) == true)
            {
                strError = "strZhongcihaoGroupName参数值不能为空";
                goto ERROR1;
            }

            if (strZhongcihaoGroupName[0] == '!')
            {
                string strTemp = GetZhongcihaoGroupName(strZhongcihaoGroupName.Substring(1));

                if (strTemp == null)
                {
                    strError = "书目库名 " + strZhongcihaoGroupName.Substring(1) + " 没有找到对应的种次号组名";
                    goto ERROR1;
                }
                strZhongcihaoGroupName = strTemp;
            }

            RmsChannel channel = sessioninfo.Channels.GetChannel(this.WsUrl);

            if (channel == null)
            {
                result.Value     = -1;
                result.ErrorInfo = "get channel error";
                result.ErrorCode = ErrorCode.SystemError;
                return(result);
            }

            /*
             *
             * //
             * XmlNode nodeNsTable = this.LibraryCfgDom.DocumentElement.SelectSingleNode("//zhongcihao/nstable");
             *
             * XmlNamespaceManager mngr = null;
             *
             * if (nodeNsTable != null)
             * {
             * // 准备名字空间环境
             * nRet = PrepareNs(
             * nodeNsTable,
             * out mngr,
             * out strError);
             * if (nRet == -1)
             * goto ERROR1;
             * }
             *
             * // 构造数据库定义和库名的对照表
             * XmlNodeList nodes = this.LibraryCfgDom.DocumentElement.SelectNodes("//zhongcihao/group[@name='" + strZhongcihaoGroupName + "']/database");
             * if (nodes.Count == 0)
             * {
             * strError = "library.xml中尚未配置有关 '" + strZhongcihaoGroupName + "'的<zhongcihao>/<group>/<database>相关参数";
             * goto ERROR1;
             * }
             *
             * Hashtable db_prop_table = new Hashtable();
             *
             * for (int i = 0; i < nodes.Count; i++)
             * {
             * XmlNode node = nodes[i];
             *
             * DbZhongcihaoProperty prop = new DbZhongcihaoProperty();
             * prop.DbName = DomUtil.GetAttr(node, "name");
             * prop.NumberXPath = DomUtil.GetAttr(node, "rightxpath");
             * prop.TitleXPath = DomUtil.GetAttr(node, "titlexpath");
             * prop.AuthorXPath = DomUtil.GetAttr(node, "authorxpath");
             *
             * db_prop_table[prop.DbName] = prop;
             * }
             * */
            bool   bCols          = (StringUtil.IsInList("cols", strBrowseInfoStyle) == true);
            string strBrowseStyle = "keyid,key,id";

            if (bCols == true)
            {
                strBrowseStyle += ",cols";
            }

            if (String.IsNullOrEmpty(strResultSetName) == true)
            {
                strResultSetName = "default";
            }

            Record[] origin_searchresults = null; //

            lRet = channel.DoGetSearchResult(
                strResultSetName,
                lStart,
                lCount,
                strBrowseStyle, // "id",
                strLang,
                null,
                out origin_searchresults,
                out strError);
            if (lRet == -1)
            {
                goto ERROR1;
            }

            long lResultCount = lRet;

            searchresults = new ZhongcihaoSearchResult[origin_searchresults.Length];

            for (int i = 0; i < origin_searchresults.Length; i++)
            {
                ZhongcihaoSearchResult item = new ZhongcihaoSearchResult();

                Record origin_item = origin_searchresults[i];

                item.Path        = origin_item.Path;
                searchresults[i] = item;
                item.Zhongcihao  = BuildZhongcihaoString(origin_item.Keys);
                item.Cols        = origin_item.Cols;
            }


#if NO
            List <string> pathlist = new List <string>();

            searchresults = new ZhongcihaoSearchResult[origin_searchresults.Length];

            for (int i = 0; i < origin_searchresults.Length; i++)
            {
                ZhongcihaoSearchResult item = new ZhongcihaoSearchResult();

                item.Path        = origin_searchresults[i].Path;
                searchresults[i] = item;
                item.Zhongcihao  = BuildZhongcihaoString(origin_searchresults[i].Keys);

                if (bCols == true)
                {
                    pathlist.Add(item.Path);
                }
            }

            if (pathlist.Count > 0)
            {
                // string[] paths = new string[pathlist.Count];
                string[] paths = StringUtil.FromListString(pathlist);

                ArrayList aRecord = null;

                nRet = channel.GetBrowseRecords(paths,
                                                "cols",
                                                out aRecord,
                                                out strError);
                if (nRet == -1)
                {
                    strError = "GetBrowseRecords() error: " + strError;
                    goto ERROR1;
                }

                int j = 0;
                for (int i = 0; i < searchresults.Length; i++)
                {
                    ZhongcihaoSearchResult result_item = searchresults[i];
                    if (result_item.Path != pathlist[j])
                    {
                        continue;
                    }

                    string[] cols = (string[])aRecord[j];

                    result_item.Cols = cols;   // style中不包含id
                    j++;
                    if (j >= pathlist.Count)
                    {
                        break;
                    }
                }
            }
#endif

            result.Value = lResultCount;
            return(result);

ERROR1:
            result.Value     = -1;
            result.ErrorCode = ErrorCode.SystemError;
            result.ErrorInfo = strError;
            return(result);
        }
Exemple #4
0
        public LibraryServerResult GetZhongcihaoSearchResult(
    SessionInfo sessioninfo,
    string strZhongcihaoGroupName,
    string strResultSetName,
    long lStart,
    long lCount,
    string strBrowseInfoStyle,
    string strLang,
    out ZhongcihaoSearchResult[] searchresults)
        {
            string strError = "";
            searchresults = null;

            LibraryServerResult result = new LibraryServerResult();
            // int nRet = 0;
            long lRet = 0;

            if (String.IsNullOrEmpty(strZhongcihaoGroupName) == true)
            {
                strError = "strZhongcihaoGroupName参数值不能为空";
                goto ERROR1;
            }

            if (strZhongcihaoGroupName[0] == '!')
            {
                string strTemp = GetZhongcihaoGroupName(strZhongcihaoGroupName.Substring(1));

                if (strTemp == null)
                {
                    strError = "书目库名 " + strZhongcihaoGroupName.Substring(1) + " 没有找到对应的种次号组名";
                    goto ERROR1;
                }
                strZhongcihaoGroupName = strTemp;
            }

            RmsChannel channel = sessioninfo.Channels.GetChannel(this.WsUrl);
            if (channel == null)
            {
                result.Value = -1;
                result.ErrorInfo = "get channel error";
                result.ErrorCode = ErrorCode.SystemError;
                return result;
            }

            /*

// 
XmlNode nodeNsTable = this.LibraryCfgDom.DocumentElement.SelectSingleNode("//zhongcihao/nstable");

XmlNamespaceManager mngr = null;

if (nodeNsTable != null)
{
    // 准备名字空间环境
    nRet = PrepareNs(
        nodeNsTable,
        out mngr,
        out strError);
    if (nRet == -1)
        goto ERROR1;
}

// 构造数据库定义和库名的对照表
XmlNodeList nodes = this.LibraryCfgDom.DocumentElement.SelectNodes("//zhongcihao/group[@name='" + strZhongcihaoGroupName + "']/database");
if (nodes.Count == 0)
{
    strError = "library.xml中尚未配置有关 '" + strZhongcihaoGroupName + "'的<zhongcihao>/<group>/<database>相关参数";
    goto ERROR1;
}

Hashtable db_prop_table = new Hashtable();

for (int i = 0; i < nodes.Count; i++)
{
    XmlNode node = nodes[i];

    DbZhongcihaoProperty prop = new DbZhongcihaoProperty();
    prop.DbName = DomUtil.GetAttr(node, "name");
    prop.NumberXPath = DomUtil.GetAttr(node, "rightxpath");
    prop.TitleXPath = DomUtil.GetAttr(node, "titlexpath");
    prop.AuthorXPath = DomUtil.GetAttr(node, "authorxpath");

    db_prop_table[prop.DbName] = prop;
}
 * */
            bool bCols = (StringUtil.IsInList("cols", strBrowseInfoStyle) == true);
            string strBrowseStyle = "keyid,key,id";
            if (bCols == true)
                strBrowseStyle += ",cols";

            if (String.IsNullOrEmpty(strResultSetName) == true)
                strResultSetName = "default";

            Record[] origin_searchresults = null; // 

            lRet = channel.DoGetSearchResult(
                strResultSetName,
                lStart,
                lCount,
                strBrowseStyle, // "id",
                strLang,
                null,
                out origin_searchresults,
                out strError);
            if (lRet == -1)
                goto ERROR1;

            long lResultCount = lRet;

            searchresults = new ZhongcihaoSearchResult[origin_searchresults.Length];

            for (int i = 0; i < origin_searchresults.Length; i++)
            {
                ZhongcihaoSearchResult item = new ZhongcihaoSearchResult();

                Record origin_item =  origin_searchresults[i];

                item.Path = origin_item.Path;
                searchresults[i] = item;
                item.Zhongcihao = BuildZhongcihaoString(origin_item.Keys);
                item.Cols = origin_item.Cols;
            }


#if NO
            List<string> pathlist = new List<string>();

            searchresults = new ZhongcihaoSearchResult[origin_searchresults.Length];

            for (int i = 0; i < origin_searchresults.Length; i++)
            {
                ZhongcihaoSearchResult item = new ZhongcihaoSearchResult();

                item.Path = origin_searchresults[i].Path;
                searchresults[i] = item;
                item.Zhongcihao = BuildZhongcihaoString(origin_searchresults[i].Keys);

                if (bCols == true)
                    pathlist.Add(item.Path);
            }

            if (pathlist.Count > 0)
            {
                // string[] paths = new string[pathlist.Count];
                string[] paths = StringUtil.FromListString(pathlist);

                ArrayList aRecord = null;

                nRet = channel.GetBrowseRecords(paths,
                    "cols",
                    out aRecord,
                    out strError);
                if (nRet == -1)
                {
                    strError = "GetBrowseRecords() error: " + strError;
                    goto ERROR1;
                }

                int j = 0;
                for (int i = 0; i < searchresults.Length; i++)
                {
                    ZhongcihaoSearchResult result_item = searchresults[i];
                    if (result_item.Path != pathlist[j])
                        continue;

                    string[] cols = (string[])aRecord[j];

                    result_item.Cols = cols;   // style中不包含id
                    j++;
                    if (j >= pathlist.Count)
                        break;
                }
            }

#endif

            result.Value = lResultCount;
            return result;
        ERROR1:
            result.Value = -1;
            result.ErrorCode = ErrorCode.SystemError;
            result.ErrorInfo = strError;
            return result;
        }