Example #1
0
        public BaseCommand GetCommand(string cmdName)
        {
            if (CmdDict.ContainsKey(cmdName))
            {
                return(CmdDict[cmdName]);
            }

            // 不存在自动创建
            BaseCommand command = null;

            if (cmdName == dp2CommandUtility.C_Command_Search)
            {
                command = new SearchCommand();
            }
            //else if (cmdName == dp2CommandUtility.C_Command_Set)
            //{
            //    command = new SetCommand();
            //}
            else
            {
                command = new BaseCommand();
            }
            command.CommandName = cmdName;
            CmdDict[cmdName]    = command;
            return(command);
        }
Example #2
0
        /// <summary>
        /// 检索书目
        /// </summary>
        /// <param name="strWord"></param>
        /// <returns></returns>
        public virtual long SearchBiblio(string remoteUserName,
                                         string strWord,
                                         SearchCommand searchCmd,
                                         out string strFirstPage,
                                         out string strError)
        {
            strFirstPage = "";
            strError     = "未实现";

            return(-1);
        }
Example #3
0
        public virtual int GetDetailBiblioInfo(string remoteUserName,
                                               SearchCommand searchCmd,
                                               int nIndex,
                                               out string strBiblioInfo,
                                               out string strError)
        {
            strBiblioInfo = "";
            strError      = "未实现";
            Debug.Assert(searchCmd != null);

            return(-1);
        }
Example #4
0
        /// <summary>
        /// 根据书目序号得到详细的参考信息
        /// </summary>
        /// <param name="nIndex">书目序号,从1排序</param>
        /// <param name="strInfo"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public override int GetDetailBiblioInfo(string remoteUserName,
                                                SearchCommand searchCmd,
                                                int nIndex,
                                                out string strBiblioInfo,
                                                out string strError)
        {
            strBiblioInfo = "";
            strError      = "";
            Debug.Assert(searchCmd != null);

            //检查有无超过数组界面
            if (nIndex <= 0 || searchCmd.BiblioResultPathList.Count < nIndex)
            {
                strError = "您输入的书目序号[" + nIndex.ToString() + "]越出范围。";
                return(-1);
            }

            // 获取路径,注意要截取
            string strPath = searchCmd.BiblioResultPathList[nIndex - 1];
            int    index   = strPath.IndexOf("*");

            if (index > 0)
            {
                strPath = strPath.Substring(0, index);
            }

            LibraryChannel channel = this.ChannelPool.GetChannel(this.dp2Url, this.dp2UserName);

            channel.Password = this.dp2Password;
            try
            {
                long lRet1 = channel.GetBiblioDetail(strPath,
                                                     out strBiblioInfo,
                                                     out strError);
                if (lRet1 == -1)
                {
                    strError = "获取详细信息失败:" + strError;
                    return(-1);
                }
            }
            finally
            {
                this.ChannelPool.ReturnChannel(channel);
            }
            return(0);
        }
Example #5
0
        /// <summary>
        /// 根据操作时间检索
        /// </summary>
        /// <param name="strWord"></param>
        /// <param name="searchCmd"></param>
        /// <param name="strFirstPage"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public long SearchBiblioByPublishtime(string strWord,
                                              SearchCommand searchCmd,
                                              out string strFirstPage,
                                              out string strError)
        {
            strFirstPage = "";
            strError     = "";

            // 判断检索词
            strWord = strWord.Trim();
            if (String.IsNullOrEmpty(strWord))
            {
                strError = "检索词不能为空。";
                return(-1);
            }

            long lTotoalCount = 0;
            // 从池中征用通道
            LibraryChannel channel = this.ChannelPool.GetChannel(this.dp2Url, this.dp2UserName);

            channel.Password = this.dp2Password;
            try
            {
                /*
                 * public long SearchBiblio(
                 * string strBiblioDbNames,
                 * string strQueryWord,
                 * int nPerMax,
                 * string strFromStyle,
                 * string strMatchStyle,
                 * string strResultSetName,
                 * string strOutputStyle,
                 * out string strError)
                 */
                // -1失败
                // 0 未命令
                string strQueryXml = "";
                long   lRet        = channel.SearchBiblio("",//全部途径
                                                          strWord,
                                                          C_Search_MaxCount,
                                                          "publishtime,_time,_freetime",
                                                          "left",
                                                          "",
                                                          "id,cols",
                                                          out strQueryXml,
                                                          out strError);
                if (lRet == -1 || lRet == 0)
                {
                    return(lRet);
                }

                // 取出命中记录列表
                lTotoalCount = lRet;

                List <string> totalResultList = new List <string>();
                long          lStart          = 0;
                // 当前总共取的多少记录
                long lCurTotalCount = 0;

REDO:
                List <string> resultPathList = null;
                long lCount = -1;
                lRet = channel.GetBiblioSearchResult(lStart,
                                                     lCount,
                                                     out resultPathList,
                                                     out strError);
                if (lRet == -1)
                {
                    return(-1);
                }

                // 加到结果集中
                totalResultList.AddRange(resultPathList);

                // 检查记录是否获取完成,没取完继续取
                lCurTotalCount += lRet;
                if (lCurTotalCount < lTotoalCount)
                {
                    lStart = lCurTotalCount;
                    goto REDO;
                }


                // 检查一下,取出来的记录数,是否与返回的命中数量一致
                if (lTotoalCount != totalResultList.Count)
                {
                    strError = "内部错误,不可能结果集数量不一致";
                    return(-1);
                }

                // 将检索结果信息保存到检索命令中
                searchCmd.BiblioResultPathList = totalResultList;
                searchCmd.ResultNextStart      = 0;
                searchCmd.IsCanNextPage        = true;

                // 获得第一页检索结果
                bool bRet = searchCmd.GetNextPage(out strFirstPage, out strError);
                if (bRet == false)
                {
                    return(-1);
                }
            }
            finally
            {
                // 归还通道到池
                this.ChannelPool.ReturnChannel(channel);
            }

            return(lTotoalCount);
        }