Exemple #1
0
        // 根据特性的评注记录路径,获得一定范围的检索命中结果
        // return:
        //      -1  出错
        //      0   没有找到
        //      1   找到
        public static int GetCommentsSearchResult(
            OpacApplication app,
            LibraryChannel channel,
            ItemLoadEventHandler itemLoadProc,
            SetStartEventHandler setStartProc,
            int nPerCount,
            string strCommentRecPath,
            bool bGetRecord,
            string strLang, // 2012/7/9
            out int nStart,
            out string strError)
        {
            strError = "";
            nStart = -1;

            long lHitCount = 0;

            bool bFound = false;
            List<string> aPath = null;
            for (int j = 0; ; j++)
            {
                nStart = j * nPerCount;
                // 只获得路径。确保所要的lStart lCount范围全部获得
                long lRet = // this.Channel.
                    channel.GetSearchResult(
                    null,
                    "default",
                    nStart, // 0,
                    nPerCount, // -1,
                    strLang,
                    out aPath,
                    out strError);
                if (lRet == -1)
                    goto ERROR1;

                lHitCount = lRet;

                if (lHitCount == 0)
                    return 0;

                if (aPath.Count == 0)
                    break;

                for (int i = 0; i < aPath.Count; i++)
                {
                    if (aPath[i] == strCommentRecPath)
                    {
                        bFound = true;
                        break;
                    }
                }

                if (bFound == true)
                    break;

                if (nStart >= lHitCount)
                    break;
            }

            if (bFound == true)
            {
                if (// this.SetStart != null
                    setStartProc != null)
                {
                    SetStartEventArgs e = new SetStartEventArgs();
                    e.StartIndex = nStart;

                    // this.SetStart(this, e);
                    setStartProc(null, e);
                }

                for (int i = 0; i < aPath.Count; i++)
                {
                    if (bGetRecord == true)
                    {
                        string strXml = "";
                        string strMetaData = "";
                        byte[] timestamp = null;
                        string strOutputPath = "";
                        string strStyle = LibraryChannel.GETRES_ALL_STYLE;

                        long lRet = // this.Channel.
                            channel.GetRes(
                            null,
                            aPath[i],
                            strStyle,
                            out strXml,
                            out strMetaData,
                            out timestamp,
                            out strOutputPath,
                            out strError);
                        if (lRet == -1)
                            goto ERROR1;

                        if (//this.ItemLoad != null
                            itemLoadProc != null)
                        {
                            ItemLoadEventArgs e = new ItemLoadEventArgs();
                            e.Path = aPath[i];
                            e.Index = i;
                            e.Count = aPath.Count;
                            e.Xml = strXml;
                            e.Timestamp = timestamp;
                            e.TotalCount = (int)lHitCount;

                            // this.ItemLoad(this, e);
                            e.Channel = channel;
                            itemLoadProc(null, e);
                        }
                    }
                    else
                    {
                        if (//this.ItemLoad != null
                            itemLoadProc != null)
                        {
                            ItemLoadEventArgs e = new ItemLoadEventArgs();
                            e.Path = aPath[i];
                            e.Index = i;
                            e.Count = aPath.Count;
                            e.Xml = "";
                            e.Timestamp = null;
                            e.TotalCount = (int)lHitCount;

                            // this.ItemLoad(this, e);
                            e.Channel = channel;
                            itemLoadProc(null, e);
                        }
                    }
                }

                return 1;   // 找到
            }

            nStart = -1;
            strError = "路径为 '" + strCommentRecPath + "' 的记录在结果集中没有找到";
            return 0;   // 没有找到
        ERROR1:
            return -1;
        }
Exemple #2
0
 void sessioninfo_SetStart(object sender, SetStartEventArgs e)
 {
     Debug.Assert(e.StartIndex != -1, "");
     this.StartIndex = e.StartIndex;
 }
Exemple #3
0
        // 根据特性的评注记录路径,获得一定范围的检索命中结果
        // return:
        //      -1  出错
        //      0   没有找到
        //      1   找到
        public int GetCommentsSearchResult(
            OpacApplication app,
            int nPerCount,
            string strCommentRecPath,
            bool bGetRecord,
            string strLang, // 2012/7/9
            out int nStart,
            out string strError)
        {
            strError = "";
            nStart   = -1;

            long lHitCount = 0;

            bool          bFound = false;
            List <string> aPath  = null;

            for (int j = 0; ; j++)
            {
                nStart = j * nPerCount;
                // 只获得路径。确保所要的lStart lCount范围全部获得
                long lRet = this.Channel.GetSearchResult(
                    null,
                    "default",
                    nStart,    // 0,
                    nPerCount, // -1,
                    strLang,
                    out aPath,
                    out strError);
                if (lRet == -1)
                {
                    goto ERROR1;
                }

                lHitCount = lRet;

                if (lHitCount == 0)
                {
                    return(0);
                }

                if (aPath.Count == 0)
                {
                    break;
                }

                for (int i = 0; i < aPath.Count; i++)
                {
                    if (aPath[i] == strCommentRecPath)
                    {
                        bFound = true;
                        break;
                    }
                }

                if (bFound == true)
                {
                    break;
                }

                if (nStart >= lHitCount)
                {
                    break;
                }
            }

            if (bFound == true)
            {
                if (this.SetStart != null)
                {
                    SetStartEventArgs e = new SetStartEventArgs();
                    e.StartIndex = nStart;

                    this.SetStart(this, e);
                }

                for (int i = 0; i < aPath.Count; i++)
                {
                    if (bGetRecord == true)
                    {
                        string strXml        = "";
                        string strMetaData   = "";
                        byte[] timestamp     = null;
                        string strOutputPath = "";
                        string strStyle      = LibraryChannel.GETRES_ALL_STYLE;

                        long lRet = this.Channel.GetRes(
                            null,
                            aPath[i],
                            strStyle,
                            out strXml,
                            out strMetaData,
                            out timestamp,
                            out strOutputPath,
                            out strError);
                        if (lRet == -1)
                        {
                            goto ERROR1;
                        }

                        if (this.ItemLoad != null)
                        {
                            ItemLoadEventArgs e = new ItemLoadEventArgs();
                            e.Path       = aPath[i];
                            e.Index      = i;
                            e.Count      = aPath.Count;
                            e.Xml        = strXml;
                            e.Timestamp  = timestamp;
                            e.TotalCount = (int)lHitCount;

                            this.ItemLoad(this, e);
                        }
                    }
                    else
                    {
                        if (this.ItemLoad != null)
                        {
                            ItemLoadEventArgs e = new ItemLoadEventArgs();
                            e.Path       = aPath[i];
                            e.Index      = i;
                            e.Count      = aPath.Count;
                            e.Xml        = "";
                            e.Timestamp  = null;
                            e.TotalCount = (int)lHitCount;

                            this.ItemLoad(this, e);
                        }
                    }
                }

                return(1);   // 找到
            }

            nStart   = -1;
            strError = "路径为 '" + strCommentRecPath + "' 的记录在结果集中没有找到";
            return(0);   // 没有找到

ERROR1:
            return(-1);
        }