Esempio n. 1
0
        /// <summary>
        /// 检索
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        public bool DoSearch(string strParam)
        {
            // 设置当前命令
            this.CurrentCmdName = dp2CommandUtility.C_Command_Search;

            long          lRet      = 0;
            string        strError  = "";
            SearchCommand searchCmd = (SearchCommand)this.CmdContiner.GetCommand(dp2CommandUtility.C_Command_Search);

            if (strParam == "")
            {
                Console.WriteLine("请输入检索词");
                return(false);
            }

            // 如果没有结果集,优先认查询
            if (searchCmd.BiblioResultPathList != null &&
                searchCmd.BiblioResultPathList.Count > 0)
            {
                // 下一页
                if (strParam == "n")
                {
                    string strNextPage = "";
                    bool   bRet        = searchCmd.GetNextPage(out strNextPage, out strError);
                    if (bRet == true)
                    {
                        Console.WriteLine(strNextPage);
                    }
                    else
                    {
                        Console.WriteLine(strError);
                    }
                    return(false);
                }

                // 试着转换为书目序号
                int nBiblioIndex = 0;
                try
                {
                    nBiblioIndex = int.Parse(strParam);
                }
                catch
                { }
                // 获取详细信息
                if (nBiblioIndex >= 1)
                {
                    string strBiblioInfo = "";
                    lRet = dp2CommandService.Instance.GetDetailBiblioInfo("",
                                                                          searchCmd, nBiblioIndex,
                                                                          out strBiblioInfo,
                                                                          out strError);
                    if (lRet == -1)
                    {
                        Console.WriteLine(strError);
                        return(false);
                    }

                    // 输入详细信息
                    Console.WriteLine(strBiblioInfo);
                    return(false);
                }
            }

            // 检索
            string strFirstPage = "";

            lRet = dp2CommandService.Instance.SearchBiblio("",
                                                           strParam, searchCmd,
                                                           out strFirstPage,
                                                           out strError);
            if (lRet == -1)
            {
                Console.WriteLine("检索出错:" + strError);
            }
            else if (lRet == 0)
            {
                Console.WriteLine("未命中");
            }
            else
            {
                Console.WriteLine(strFirstPage);
            }
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// 检索
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        private IResponseMessageBase DoSearch(string strParam)
        {
            // 设置当前命令
            this.CurrentMessageContext.CurrentCmdName = dp2CommandUtility.C_Command_Search;

            long          lRet      = 0;
            string        strError  = "";
            SearchCommand searchCmd = (SearchCommand)this.CurrentMessageContext.CmdContiner.GetCommand(dp2CommandUtility.C_Command_Search);

            if (strParam == "")
            {
                if (searchCmd.BiblioResultPathList != null && searchCmd.BiblioResultPathList.Count > 0)
                {
                    return(this.CreateTextResponseMessage("请输入检索词重新检索,或者输入V查看上次检索结果。"));
                }
                else
                {
                    return(this.CreateTextResponseMessage("请输入检索词"));
                }
            }

            // 如果没有结果集,优先认查询
            if (searchCmd.BiblioResultPathList != null &&
                searchCmd.BiblioResultPathList.Count > 0)
            {
                // 查看,从第一页开始
                if (strParam.ToLower() == "v")
                {
                    // 从头显示
                    searchCmd.ResultNextStart = 0;
                    searchCmd.IsCanNextPage   = true;
                    string strNextPage = "";
                    bool   bRet        = searchCmd.GetNextPage(out strNextPage, out strError);
                    if (bRet == true)
                    {
                        return(this.CreateTextResponseMessage(strNextPage));
                    }
                    else
                    {
                        return(this.CreateTextResponseMessage(strError));
                    }
                }

                // 下一页
                if (strParam.ToLower() == "n")
                {
                    string strNextPage = "";
                    bool   bRet        = searchCmd.GetNextPage(out strNextPage, out strError);
                    if (bRet == true)
                    {
                        return(this.CreateTextResponseMessage(strNextPage));
                    }
                    else
                    {
                        return(this.CreateTextResponseMessage(strError));
                    }
                }

                // 试着转换为书目序号
                int nBiblioIndex = 0;
                try
                {
                    nBiblioIndex = int.Parse(strParam);
                }
                catch
                { }
                // 获取详细信息
                if (nBiblioIndex >= 1)
                {
                    string strBiblioInfo = "";
                    lRet = this.CmdService.GetDetailBiblioInfo(searchCmd, nBiblioIndex,
                                                               out strBiblioInfo,
                                                               out strError);
                    if (lRet == -1)
                    {
                        return(this.CreateTextResponseMessage(strError));
                    }

                    // 输入详细信息
                    return(this.CreateTextResponseMessage(strBiblioInfo));
                }
            }

            // 检索
            string strFirstPage = "";

            lRet = this.CmdService.SearchBiblio(strParam, searchCmd,
                                                out strFirstPage,
                                                out strError);
            if (lRet == -1)
            {
                return(this.CreateTextResponseMessage("检索出错:" + strError));
            }
            else if (lRet == 0)
            {
                return(this.CreateTextResponseMessage("未命中"));
            }
            else
            {
                return(this.CreateTextResponseMessage(strFirstPage));
            }
        }