Exemplo n.º 1
0
        /// <summary>
        /// 照片全局搜索
        /// </summary>
        /// <param name="query">搜索条件</param>
        /// <param name="topNumber">显示数目</param>
        /// <returns></returns>
        public ActionResult _GlobalSearch(PhotoFullTextQuery query, int topNumber)
        {
            query.TenantTypeId = TenantTypeIds.Instance().User();
            query.PageIndex    = 1;
            query.PageSize     = 20;
            PhotoSearcher         photoSearcher = (PhotoSearcher)SearcherFactory.GetSearcher(PhotoSearcher.CODE);
            PagingDataSet <Photo> photos        = photos = photoSearcher.Search(query);

            List <Photo> list = new List <Photo>();

            foreach (var item in photos)
            {
                if (authorizer.Photo_Search(item.Album))
                {
                    list.Add(item);
                }
            }
            ViewData["photoSearcherUrl"] = photoSearcher.PageSearchActionUrl(query.Keyword);
            ViewData["total"]            = photos.TotalRecords;
            ViewData["queryDuration"]    = photos.QueryDuration;
            return(View(list.Take(topNumber)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 快捷搜索
        /// </summary>
        /// <param name="query"></param>
        /// <param name="topNumber"></param>
        /// <returns></returns>
        public ActionResult _QuickSearch(PhotoFullTextQuery query, int topNumber)
        {
            query.TenantTypeId = TenantTypeIds.Instance().User();
            query.PageSize     = 20;
            query.Keyword      = WebUtility.HtmlDecode(query.Keyword);
            query.Filter       = PhotoSearchRange.DESCRIPTION;

            PhotoSearcher         photoSearcher = (PhotoSearcher)SearcherFactory.GetSearcher(PhotoSearcher.CODE);
            PagingDataSet <Photo> photos        = photoSearcher.Search(query);

            List <Photo> list = new List <Photo>();

            foreach (var item in photos)
            {
                if (authorizer.Photo_Search(item.Album))
                {
                    list.Add(item);
                }
            }
            ViewData["total"]            = photos.TotalRecords;
            ViewData["photoSearcherUrl"] = photoSearcher.PageSearchActionUrl(query.Keyword);

            return(View(list.Take(topNumber)));
        }