Exemplo n.º 1
0
        public ActionResult Index(string province = "quanguo", int city = 0,
            int mediacode = 0,
            int childmediacode = 0,
            int formatcode = 0,
            int ownercode = 0,
            int periodcode = 0,
            int price = 0,
            int order = 0,
            int descending = 0,
            int page = 1,
            string query = null)
        {
            if (!province.Equals(ProvinceName.quanguo.ToString(), StringComparison.CurrentCultureIgnoreCase))
            {
                CookieHelper.SetProvinceCookie(province);
            }

            var provinceValue = EnumHelper.GetProvinceValue(province);

            var isQuanGuo = provinceValue == (int)ProvinceName.quanguo;

            var LeftMenu = GetLeftMenu(provinceValue);

            //搜索条件
            ListSearchItemViewModel searchTrem = new ListSearchItemViewModel()
            {
                Province = province,
                City = city,
                MediaCode = mediacode,
                ChildMediaCode = childmediacode,
                FormatCode = formatcode,
                OwnerCode = ownercode,
                PeriodCode = periodcode,
                Page = page,
                Price = price,
                Order = order,
                Descending = descending,
                Query = query
            };

            ViewBag.LeftMenu = SetLeftMenu(LeftMenu, searchTrem);

            ViewBag.Bread = GetBread(LeftMenu, searchTrem);

            //ViewBag.SuggestList = sourceService.GetSuggestMedia(provinceValue, 5, searchTrem.City, searchTrem.MediaCode, searchTrem.ChildMediaCode);

            //ViewBag.HotList = sourceService.GetGoodMedia(provinceValue, 5, searchTrem.City, searchTrem.MediaCode, searchTrem.ChildMediaCode);

            //ViewBag.SuggestCompanyList = sourceService.GetSuggestCompany(provinceValue, 5, searchTrem.City, searchTrem.MediaCode, searchTrem.ChildMediaCode);

            //ViewBag.RelateCompany = sourceService.GetRelateCompany(provinceValue, 5, searchTrem.City);

            ViewBag.Search = GetSearch(searchTrem);

            ViewBag.PriceListFilter = GetPriceListFilter(searchTrem);

            ViewBag.DefaultOrderUrl = Url.Action("index", new
            {
                province = searchTrem.Province,
                city = searchTrem.City,
                mediacode = searchTrem.MediaCode,
                childmediacode = searchTrem.ChildMediaCode,
                formatcode = searchTrem.FormatCode,
                ownercode = searchTrem.OwnerCode,
                periodcode = searchTrem.PeriodCode,
                price = searchTrem.Price,
                order = 0,
                descending = 0,
                page = searchTrem.Page,

            });

            ViewBag.PriceOrderAscUrl = Url.Action("index", new
            {
                province = searchTrem.Province,
                city = searchTrem.City,
                mediacode = searchTrem.MediaCode,
                childmediacode = searchTrem.ChildMediaCode,
                formatcode = searchTrem.FormatCode,
                ownercode = searchTrem.OwnerCode,
                periodcode = searchTrem.PeriodCode,
                price = searchTrem.Price,
                order = (int)SortProperty.Price,
                descending = (int)SortDirection.Ascending,
                page = searchTrem.Page
            });

            ViewBag.PriceOrderDescUrl = Url.Action("index", new
            {
                province = searchTrem.Province,
                city = searchTrem.City,
                mediacode = searchTrem.MediaCode,
                childmediacode = searchTrem.ChildMediaCode,
                formatcode = searchTrem.FormatCode,
                ownercode = searchTrem.OwnerCode,
                periodcode = searchTrem.PeriodCode,
                price = searchTrem.Price,
                order = (int)SortProperty.Price,
                descending = (int)SortDirection.Descending,
                page = searchTrem.Page
            });

            ViewBag.Result = GetResult(searchTrem);

            ViewBag.Sort = GetSort(searchTrem);

            ViewBag.Query = searchTrem;

            return View();
        }
Exemplo n.º 2
0
 private ListSort GetSort(ListSearchItemViewModel search)
 {
     ListSort result = new ListSort();
     if (search.Order == 0)
     {
         result.SortDefault = true;
     }
     else if (search.Order == (int)SortProperty.Price)
     {
         if (search.Descending == (int)SortDirection.Descending)
         {
             result.SortPriceDesc = true;
         }
         else
         {
             result.SortPriceAsc = true;
         }
     }
     return result;
 }
Exemplo n.º 3
0
        private List<HttpLinkGroup> SetLeftMenu(List<HttpLinkGroup> list, ListSearchItemViewModel search)
        {
            foreach (var item in list)
            {
                item.Group.Selected = item.Group.ID == search.MediaCode;

                foreach (var childItem in item.Items)
                {
                    childItem.Selected = childItem.ID == search.ChildMediaCode;
                }
            }
            return list;
        }
Exemplo n.º 4
0
        private ListSource GetResult(ListSearchItemViewModel search)
        {
            const int PageSize = 15;
            var model = new ListSource();
            var query = new List<HttpLinkItem>();
            int totalHits;
            Dictionary<string, string> cacheDic = CreateSearchDic("ResultList", search);
            Dictionary<string, string> countDic = CreateSearchDic("ResultCount", search);
            if (string.IsNullOrWhiteSpace(search.Query)
                && CacheService.Exists(cacheDic)
                && CacheService.Exists(countDic))
            {
                query = CacheService.Get<List<HttpLinkItem>>(cacheDic);
                totalHits = CacheService.GetInt32Value(countDic);
            }
            else
            {
                var searchFilter = GetSearchFilter(search.Query, search.Order, search.Descending, search.Page, PageSize);

                using (MiniProfiler.Current.Step("LuceneSearch"))
                {
                    query = searchService.Search(search, searchFilter, out totalHits);
                }
                if (string.IsNullOrWhiteSpace(search.Query))
                {
                    CacheService.Add<List<HttpLinkItem>>(query, cacheDic, 10);
                    CacheService.AddInt32Value(totalHits, countDic, 10);
                }
            }
            model.Items = query;
            model.TotalCount = totalHits;
            model.CurrentPage = search.Page;
            model.PageSize = PageSize;
            model.Querywords = string.IsNullOrEmpty(search.Query) ? "" : search.Query;
            return model;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取搜索条件列表
        /// </summary>
        /// <param name="searchTrem"></param>
        /// <returns></returns>
        private List<HttpLinkGroup> GetSearch(ListSearchItemViewModel search)
        {
            List<HttpLinkGroup> result = new List<HttpLinkGroup>();

            Dictionary<string, string> cacheDic = new Dictionary<string, string>();

            cacheDic.Add(CacheService.ServiceName, "ListController");
            cacheDic.Add(CacheService.ServiceMethod, "GetSearch");
            cacheDic.Add("Province", search.Province);
            cacheDic.Add("City", search.City.ToString());
            cacheDic.Add("MediaCode", search.MediaCode.ToString());
            cacheDic.Add("ChildMediaCode", search.ChildMediaCode.ToString());
            cacheDic.Add("FormatCode", search.FormatCode.ToString());
            cacheDic.Add("OwnerCode", search.OwnerCode.ToString());
            cacheDic.Add("PeriodCode", search.PeriodCode.ToString());

            if (CacheService.Exists(cacheDic))
            {
                result = CacheService.Get<List<HttpLinkGroup>>(cacheDic);
            }
            else
            {
                var provinceValue = EnumHelper.GetProvinceValue(search.Province);

                #region CityGroup

                if (provinceValue != (int)ProvinceName.quanguo)
                {
                    HttpLinkGroup cityGroup = new HttpLinkGroup()
                    {
                        Group = new HttpLinkItem()
                        {
                            Name = "城市",
                            Url = Url.Action("index", new
                              {
                                  province = search.Province,
                                  city = 0,
                                  mediacode = search.MediaCode,
                                  childmediacode = search.ChildMediaCode,
                                  formatcode = search.FormatCode,
                                  ownercode = search.OwnerCode,
                                  periodcode = search.PeriodCode
                              })

                        }
                    };
                    cityGroup.Items = areaService.GetALL().Where(x => x.PID == provinceValue).ToList().Select(x => new HttpLinkItem()
                    {
                        ID = x.ID,
                        Name = x.CateName,
                        Url = Url.Action("index", new
                        {
                            province = search.Province,
                            city = x.ID,
                            mediacode = search.MediaCode,
                            childmediacode = search.ChildMediaCode,
                            formatcode = search.FormatCode,
                            ownercode = search.OwnerCode,
                            periodcode = search.PeriodCode

                        }),
                        Selected = x.ID == search.City
                    }).ToList();

                    result.Add(cityGroup);
                }

                #endregion

                #region MediaCode

                HttpLinkGroup categoryGroup = new HttpLinkGroup()
                {
                    Group = new HttpLinkItem()
                    {
                        Name = "媒体类别",
                        Url = Url.Action("index", new
                        {
                            province = search.Province,
                            city = search.City,
                            mediacode = 0,
                            childmediacode = 0,
                            formatcode = search.FormatCode,
                            ownercode = search.OwnerCode,
                            periodcode = search.PeriodCode
                        })
                    }
                };
                categoryGroup.Items = outDoorMediaCateService.GetALL().Where(x => x.PID.Equals(null)).ToList().Select(x => new HttpLinkItem()
                {
                    ID = x.ID,
                    Name = x.CateName,
                    Url = Url.Action("index", new
                    {
                        province = search.Province,
                        city = search.City,
                        mediacode = x.ID,
                        childmediacode = 0,
                        formatcode = search.FormatCode,
                        ownercode = search.OwnerCode,
                        periodcode = search.PeriodCode

                    }),
                    Selected = search.MediaCode == x.ID

                }).ToList();

                result.Add(categoryGroup);

                #endregion

                #region ChildMediaCode
                if (search.MediaCode != 0)
                {
                    HttpLinkGroup childCategoryGroup = new HttpLinkGroup()
                    {
                        Group = new HttpLinkItem()
                        {
                            Name = "媒体子类别",
                            Url = Url.Action("index", new
                            {
                                province = search.Province,
                                city = search.City,
                                mediacode = search.MediaCode,
                                childmediacode = 0,
                                formatcode = search.FormatCode,
                                ownercode = search.OwnerCode,
                                periodcode = search.PeriodCode
                            })
                        }
                    };

                    childCategoryGroup.Items = outDoorMediaCateService.GetALL().Where(x => x.PID == search.MediaCode).ToList().Select(x => new HttpLinkItem()
                    {
                        ID = x.ID,
                        Name = x.CateName,
                        Url = Url.Action("index", new
                        {
                            province = search.Province,
                            city = search.City,
                            mediacode = search.MediaCode,
                            childmediacode = x.ID,
                            formatcode = search.FormatCode,
                            ownercode = search.OwnerCode,
                            periodcode = search.PeriodCode

                        }),
                        Selected = search.ChildMediaCode == x.ID

                    }).ToList();

                    result.Add(childCategoryGroup);
                }
                #endregion

                #region FormatCode
                HttpLinkGroup formatGroup = new HttpLinkGroup()
                {
                    Group = new HttpLinkItem()
                    {
                        Name = "表现形式",
                        Url = Url.Action("index", new
                         {
                             province = search.Province,
                             city = search.City,
                             mediacode = search.MediaCode,
                             childmediacode = search.ChildMediaCode,
                             formatcode = 0,
                             ownercode = search.OwnerCode,
                             periodcode = search.PeriodCode
                         })
                    }
                };
                formatGroup.Items = formatCateService.GetALL().Where(x => x.PID.Equals(null)).ToList().Select(x => new HttpLinkItem()
                {
                    ID = x.ID,
                    Name = x.CateName,
                    Url = Url.Action("index", new
                    {
                        province = search.Province,
                        city = search.City,
                        mediacode = search.MediaCode,
                        childmediacode = search.ChildMediaCode,
                        formatcode = x.ID,
                        ownercode = search.OwnerCode,
                        periodcode = search.PeriodCode

                    }),
                    Selected = search.FormatCode == x.ID

                }).ToList();

                result.Add(formatGroup);

                #endregion

                #region OwnerCode
                HttpLinkGroup ownerGroup = new HttpLinkGroup()
                {
                    Group = new HttpLinkItem()
                    {
                        Name = "代理类型",
                        Url = Url.Action("index", new
                        {
                            province = search.Province,
                            city = search.City,
                            mediacode = search.MediaCode,
                            childmediacode = search.ChildMediaCode,
                            formatcode = search.FormatCode,
                            ownercode = 0,
                            periodcode = search.PeriodCode
                        })
                    }
                };
                ownerGroup.Items = ownerCateService.GetALL().Where(x => x.PID.Equals(null)).ToList().Select(x => new HttpLinkItem()
                {
                    ID = x.ID,
                    Name = x.CateName,
                    Url = Url.Action("index", new
                    {
                        province = search.Province,
                        city = search.City,
                        mediacode = search.MediaCode,
                        childmediacode = search.ChildMediaCode,
                        formatcode = search.FormatCode,
                        ownercode = x.ID,
                        periodcode = search.PeriodCode

                    }),
                    Selected = search.OwnerCode == x.ID

                }).ToList();

                result.Add(ownerGroup);

                #endregion

                #region PeriodCode
                HttpLinkGroup periodGroup = new HttpLinkGroup()
                {
                    Group = new HttpLinkItem()
                    {
                        Name = "投放周期",
                        Url = Url.Action("index", new
                        {
                            province = search.Province,
                            city = search.City,
                            mediacode = search.MediaCode,
                            childmediacode = search.ChildMediaCode,
                            formatcode = search.FormatCode,
                            ownercode = search.OwnerCode
                        })
                    }
                };
                periodGroup.Items = periodCateService.GetALL().Where(x => x.PID.Equals(null)).ToList().Select(x => new HttpLinkItem()
                {
                    ID = x.ID,
                    Name = x.CateName,
                    Url = Url.Action("index", new
                    {
                        province = search.Province,
                        city = search.City,
                        mediacode = search.MediaCode,
                        childmediacode = search.ChildMediaCode,
                        formatcode = search.FormatCode,
                        ownercode = search.OwnerCode,
                        periodcode = x.ID

                    }),
                    Selected = search.PeriodCode == x.ID

                }).ToList();

                result.Add(periodGroup);

                #endregion

                CacheService.Add<List<HttpLinkGroup>>(result, cacheDic, 180);
            }

            return result;
        }
Exemplo n.º 6
0
        private List<HttpLinkItem> GetBread(List<HttpLinkGroup> menu, ListSearchItemViewModel search)
        {
            List<HttpLinkItem> model = new List<HttpLinkItem>();

            HttpLinkItem home = new HttpLinkItem()
            {
                Url = Url.Action("index", "home", new
                {
                    province = search.Province
                })
            };
            model.Add(home);

            foreach (var item in menu)
            {
                if (item.Group.Selected)
                {
                    model.Add(new HttpLinkItem()
                    {
                        Name = item.Group.Name,
                        Url = Url.Action("index", "list", new
                        {
                            province = search.Province,
                            city = search.City,
                            mediacode = item.Group.ID
                        })
                    });

                    foreach (var childitem in item.Items)
                    {
                        if (childitem.Selected)
                        {
                            model.Add(new HttpLinkItem()
                            {
                                Name = childitem.Name,
                                Url = Url.Action("index", "list", new
                                {
                                    province = search.Province,
                                    city = search.City,
                                    mediacode = item.Group.ID,
                                    childmediacode = childitem.ID
                                })
                            });
                        }
                    }
                }
            }
            return model;
        }
Exemplo n.º 7
0
        private List<HttpLinkItem> GetPriceListFilter(ListSearchItemViewModel search)
        {
            List<HttpLinkItem> result = new List<HttpLinkItem>();

            result = UIHelper.PriceList.Select(x => new HttpLinkItem()
            {
                Name = x.Text,
                Selected = x.Value == search.Price.ToString(),
                Url = Url.Action("index", new
                {
                    province = search.Province,
                    city = search.City,
                    mediacode = search.MediaCode,
                    childmediacode = search.ChildMediaCode,
                    formatcode = search.FormatCode,
                    ownercode = search.OwnerCode,
                    periodcode = search.PeriodCode,
                    price = Convert.ToInt32(x.Value),
                    order = 0,
                    descending = 0,
                    page = 1,
                })

            }).ToList();

            return result;
        }
Exemplo n.º 8
0
 private Dictionary<string, string> CreateSearchDic(string MethodName, ListSearchItemViewModel search)
 {
     Dictionary<string, string> cacheDic = new Dictionary<string, string>();
     cacheDic.Add(CacheService.ServiceName, "ListController");
     cacheDic.Add(CacheService.ServiceMethod, MethodName);
     cacheDic.Add("Province", search.Province);
     cacheDic.Add("City", search.City.ToString());
     cacheDic.Add("MediaCode", search.MediaCode.ToString());
     cacheDic.Add("ChildMediaCode", search.ChildMediaCode.ToString());
     cacheDic.Add("FormatCode", search.FormatCode.ToString());
     cacheDic.Add("OwnerCode", search.OwnerCode.ToString());
     cacheDic.Add("PeriodCode", search.PeriodCode.ToString());
     cacheDic.Add("Order", search.Order.ToString());
     cacheDic.Add("Descending", search.Descending.ToString());
     cacheDic.Add("AuthStatus", search.AuthStatus.ToString());
     cacheDic.Add("Price", search.Price.ToString());
     cacheDic.Add("Page", search.Page.ToString());
     return cacheDic;
 }
Exemplo n.º 9
0
        public ActionResult GetSearchArea(float minX, float minY, float maxX, float maxY, int page = 1, int category = 0, int childcategory = 0, int price = 0)
        {
            var model = new ListSource();

            var result = new List<HttpLinkItem>();

            ListSearchItemViewModel query = new ListSearchItemViewModel();

            query.MinX = minX;
            query.MinY = minY;
            query.MaxX = maxX;
            query.MaxY = maxY;
            if (category != 0)
            {
                query.MediaCode = category;
                if (childcategory != 0)
                {
                    query.ChildMediaCode = childcategory;
                }
            }
            if (price != 0)
            {
                query.Price = price;
            }

            var pageSize = 10;

            int totalHits = 0;

            SearchFilter sf = new SearchFilter();

            sf.PageSize = pageSize;

            sf.Skip = (page - 1) * pageSize;

            sf.Take = pageSize;

            sf.SortProperty = SortProperty.Published;

            sf.SortDirection = SortDirection.Descending;

            result = searchService.Search(query, sf, out totalHits);

            model.Items = result;

            model.TotalCount = totalHits;

            model.CurrentPage = page;

            model.PageSize = pageSize;

            return Json(model, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 10
0
        private static List<HttpLinkItem> SearchCore(ListSearchItemViewModel queryParams, SearchFilter searchFilter, out int totalHits)
        {
            if (!Directory.Exists(LuceneCommon.IndexDirectory))
            {
                totalHits = 0;
                return new List<HttpLinkItem>();
            }

            SortField sortField = GetSortField(searchFilter);

            int numRecords = searchFilter.Skip + searchFilter.Take;

            using (var directory = new LuceneFileSystem(LuceneCommon.IndexDirectory))
            {
                var searcher = new IndexSearcher(directory, readOnly: true);

                var query = ParseQuery(queryParams, searchFilter);

                var results = searcher.Search(query, filter: null, n: numRecords, sort: new Sort(sortField));

                var keys = results.ScoreDocs.Skip(searchFilter.Skip)
                    .Select(c => GetMediaItem(searcher.Doc(c.Doc)))
                    .ToList();

                totalHits = results.TotalHits;

                searcher.Close();

                return keys;
            }
        }
Exemplo n.º 11
0
        private static Query ParseQuery(ListSearchItemViewModel queryParams, SearchFilter searchFilter)
        {
            var combineQuery = new BooleanQuery();

            #region 关键字查询构建
            if (!String.IsNullOrWhiteSpace(searchFilter.SearchTerm))
            {
                var fields = new[] {
                    OutDoorIndexFields.Title,
                    OutDoorIndexFields.Description,
                    OutDoorIndexFields.AreaAtt,
                    OutDoorIndexFields.MediaCateName,
                    OutDoorIndexFields.CityName,
                    OutDoorIndexFields.ProvinceName,
                    OutDoorIndexFields.PMediaCateName,
                    OutDoorIndexFields.FormatName,
                    OutDoorIndexFields.PeriodName,
                    OutDoorIndexFields.OwnerCateName
                };
                var analyzer = new PanGuAnalyzer();
                //var analyzer = new StandardAnalyzer(LuceneCommon.LuceneVersion);
                var queryParser = new MultiFieldQueryParser(LuceneCommon.LuceneVersion, fields, analyzer);

                var query = queryParser.Parse(searchFilter.SearchTerm);

                var conjuctionQuery = new BooleanQuery();
                conjuctionQuery.Boost = 2.0f;

                var disjunctionQuery = new BooleanQuery();
                disjunctionQuery.Boost = 0.1f;

                var wildCardQuery = new BooleanQuery();
                wildCardQuery.Boost = 0.5f;

                var escapedSearchTerm = Escape(searchFilter.SearchTerm);

                var exactIdQuery = new TermQuery(new Term(OutDoorIndexFields.Title, escapedSearchTerm));

                exactIdQuery.Boost = 2.5f;

                var wildCardIdQuery = new WildcardQuery(new Term(OutDoorIndexFields.Title, "*" + escapedSearchTerm + "*"));

                foreach (var term in GetSearchTerms(searchFilter.SearchTerm))
                {
                    var termQuery = queryParser.Parse(term);
                    conjuctionQuery.Add(termQuery, Occur.MUST);
                    disjunctionQuery.Add(termQuery, Occur.SHOULD);

                    foreach (var field in fields)
                    {
                        var wildCardTermQuery = new WildcardQuery(new Term(field, term + "*"));
                        wildCardTermQuery.Boost = 0.7f;
                        wildCardQuery.Add(wildCardTermQuery, Occur.SHOULD);
                    }
                }
                //关键查询
                var keywordsQuery =
                    conjuctionQuery.Combine(new Query[] { exactIdQuery, wildCardIdQuery, conjuctionQuery, disjunctionQuery, wildCardQuery });

                combineQuery.Add(keywordsQuery, Occur.MUST);
            }
            #endregion

            #region 审核状态查询构建
            var verifyStatus = NumericRangeQuery.NewIntRange(OutDoorIndexFields.Status, (int)OutDoorStatus.ShowOnline, 99, true, true);
            combineQuery.Add(verifyStatus, Occur.MUST);
            #endregion

            #region 省份查询
            if (!String.IsNullOrEmpty(queryParams.Province) && queryParams.Province != "quanguo")
            {
                int ProvinceValue = EnumHelper.GetProvinceValue(queryParams.Province);
                var provinceQuery = NumericRangeQuery.NewIntRange(OutDoorIndexFields.Province, ProvinceValue, ProvinceValue, true, true);
                combineQuery.Add(provinceQuery, Occur.MUST);
            }
            #endregion

            #region 城市查询
            if (queryParams.City != 0)
            {
                var cityQuery = NumericRangeQuery.NewIntRange(OutDoorIndexFields.City, queryParams.City, queryParams.City, true, true);
                combineQuery.Add(cityQuery, Occur.MUST);
            }
            #endregion

            #region 认证状态
            if (queryParams.AuthStatus != 0)
            {
                var authStatusQuery = NumericRangeQuery.NewIntRange(OutDoorIndexFields.AuthStatus, queryParams.AuthStatus, queryParams.AuthStatus, true, true);
                combineQuery.Add(authStatusQuery, Occur.MUST);
            }
            #endregion

            #region 经纬度搜索
            if (queryParams.MinX != 0)
            {
                var latQuery = NumericRangeQuery.NewDoubleRange(OutDoorIndexFields.Lat, queryParams.MinX, queryParams.MaxX, true, true);
                var lngQuery = NumericRangeQuery.NewDoubleRange(OutDoorIndexFields.Lng, queryParams.MinY, queryParams.MaxY, true, true);
                combineQuery.Add(latQuery, Occur.MUST);
                combineQuery.Add(lngQuery, Occur.MUST);
            }
            #endregion

            #region 媒体类别查询
            if (queryParams.MediaCode != 0)
            {
                var mediaCodeQuery = NumericRangeQuery.NewIntRange(OutDoorIndexFields.PMediaCode,
                    queryParams.MediaCode, queryParams.MediaCode, true, true);
                combineQuery.Add(mediaCodeQuery, Occur.MUST);
            }
            #endregion

            #region 媒体子类别查询
            if (queryParams.ChildMediaCode != 0)
            {
                var ChildMediaCodeQuery = NumericRangeQuery.NewIntRange(OutDoorIndexFields.MediaCode,
                    queryParams.ChildMediaCode, queryParams.ChildMediaCode, true, true);
                combineQuery.Add(ChildMediaCodeQuery, Occur.MUST);
            }
            #endregion

            #region 媒体表现形式查询
            if (queryParams.FormatCode != 0)
            {
                var FormatCodeCodeQuery = NumericRangeQuery.NewIntRange(OutDoorIndexFields.FormatCode,
                    queryParams.FormatCode, queryParams.FormatCode, true, true);
                combineQuery.Add(FormatCodeCodeQuery, Occur.MUST);
            }
            #endregion

            #region 媒体所有权查询
            if (queryParams.OwnerCode != 0)
            {
                var OwnerCodeCodeQuery = NumericRangeQuery.NewIntRange(OutDoorIndexFields.OwnerCode,
                    queryParams.OwnerCode, queryParams.OwnerCode, true, true);
                combineQuery.Add(OwnerCodeCodeQuery, Occur.MUST);
            }
            #endregion

            #region 媒体购买周期查询
            if (queryParams.PeriodCode != 0)
            {
                var PeriodCodeCodeQuery = NumericRangeQuery.NewIntRange(OutDoorIndexFields.PeriodCode,
                    queryParams.PeriodCode, queryParams.PeriodCode, true, true);
                combineQuery.Add(PeriodCodeCodeQuery, Occur.MUST);
            }
            #endregion

            #region 媒体价格区间查询
            if (queryParams.Price != 0)
            {
                var rangeValue = EnumHelper.GetPriceValue(queryParams.Price);
                var PriceQuery = NumericRangeQuery.NewDoubleRange(OutDoorIndexFields.Price,
                    Convert.ToDouble(rangeValue.Min), Convert.ToDouble(rangeValue.Max), true, true);
                combineQuery.Add(PriceQuery, Occur.MUST);
            }
            #endregion

            return combineQuery;
        }
Exemplo n.º 12
0
        public List<HttpLinkItem> Search(ListSearchItemViewModel queryParams, SearchFilter searchFilter, out int totalHits)
        {
            if (searchFilter == null)
            {
                throw new ArgumentNullException("searchFilter");
            }

            if (searchFilter.Skip < 0)
            {
                throw new ArgumentOutOfRangeException("searchFilter");
            }

            if (searchFilter.Take < 0)
            {
                throw new ArgumentOutOfRangeException("searchFilter");
            }
            var searchResults = SearchCore(queryParams, searchFilter, out totalHits);

            return searchResults;
        }