Exemplo n.º 1
0
        SearchResult QueryAdvance()
        {
            SearchResult   result = null;
            SiteConfigInfo si     = SiteConfigs.GetConfig();
            string         url    = "tcp://localhost:11001";

            if (!string.IsNullOrEmpty(si.FullTextSearchUrl))
            {
                url = si.FullTextSearchUrl;
            }

            ISearchService searcher = Activator.GetObject(typeof(ISearchService), url + "/SearchService") as ISearchService;

            if (searcher != null)
            {
                Query query = new Query();
                bool  onlyArticleType;
                int   days;
                byte  keywordsRange;

                if (bool.TryParse(Request["ArticleTypeFlags"], out onlyArticleType) &&
                    !string.IsNullOrEmpty(Request["ArticleType"]))
                {
                    query.ArticleType = Request["ArticleType"];
                }

                if (int.TryParse(Request["ArticleCreateTime"], out days) && days > 0)
                {
                    query.ArticleCreateTime = DateTime.Now.AddDays(days * -1).ToString("yyyyMMddHHmmss");
                }

                if (OnlyThisSite)
                {
                    query.Url = si.RootUrl;
                }
                byte.TryParse(Request["KeywordsRange"], out keywordsRange);

                query.Keywords        = Keyword;
                query.OnlyArticleType = onlyArticleType;
                query.KeywordsRange   = (KeywordsRange)keywordsRange;
                query.OnlyUrl         = OnlyThisSite;
                query.PageCount       = Pager.PageSize;
                query.PageIndex       = Pager.PageIndex;

                result = searcher.AdvanceSearch(query);
            }
            return(result);
        }