Beispiel #1
0
        protected void btnSumbitSearch_Click(object sender, EventArgs e)
        {
            string url = "~/catalog/searchresults.aspx";

            if (tbSearchTerms.Text != "enter search terms")
            {
                url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "search", tbSearchTerms.Text, false);
            }
            if (ddlGrades.SelectedIndex != 0)
            {
                url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "Grade", ddlGrades.SelectedValue, false);
            }
            if (ddlPublisher.SelectedIndex != 0)
            {
                url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "Publisher", ddlPublisher.SelectedValue, false);
            }
            if (ddlYear.SelectedIndex != 0)
            {
                url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "Year", ddlYear.SelectedValue, false);
            }
            if (ddlSubject.SelectedIndex != 0)
            {
                url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "Subject", ddlSubject.SelectedValue, false);
            }
            if (ddlType.SelectedIndex != 0)
            {
                url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "Type", ddlType.SelectedValue, false);
            }



            Response.Redirect(url);
        }
Beispiel #2
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="unitOfWork"></param>
        /// <param name="queryModel"></param>
        /// <param name="sqlQuery"></param>
        /// <returns></returns>
        public static async Task <PageData <T> > PageQuery <T>(IUnitOfWork unitOfWork, QueryModel queryModel,
                                                               SqlQuery sqlQuery = null) where T : class
        {
            var db = unitOfWork.DbConnection;

            if (sqlQuery == null)
            {
                sqlQuery = SqlQuery <T> .Builder(unitOfWork);
            }
            queryModel.Items = queryModel.Items.Where(p => p.Value.ToString() != "").ToList();
            var where        = "";
            if (queryModel.Items.Count() > 0)
            {
                where += SearchFilterHelper.ConvertFilters(queryModel.Items);
            }
            sqlQuery._Sql = new StringBuilder(where);
            sqlQuery      = sqlQuery.Page(queryModel.PageIndex, queryModel.PageSize);
            var para = sqlQuery.Param;
            var cr   = await db.QueryFirstOrDefaultAsync <dynamic>(sqlQuery.CountSql, para);

            var result = await db.QueryAsync <T>(sqlQuery.PageSql, para);

            return(new PageData <T>()
            {
                DataList = result.ToList(),
                Total = cr.DataCount,
                EXESql = sqlQuery.PageSql
            });
        }
Beispiel #3
0
 /// <summary>
 /// Handles the SelectedIndexChanged event of the SortBy control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void SortBy_SelectedIndexChanged(object sender, EventArgs e)
 {
     // redirect only if postback was caused by changing sort value
     if (Request.Form["__EVENTTARGET"] == ((DropDownList)sender).UniqueID)
     {
         string val = ((DropDownList)sender).SelectedValue;
         Response.Redirect(SearchFilterHelper.GetQueryStringNavigateUrl("s", val));
     }
 }
Beispiel #4
0
        public virtual StringCollection GetOutlinesForNode(string code)
        {
            var nodes = SearchFilterHelper.GetOutlinesForNode(code);

            if (nodes.Count == 0)
            {
                return(nodes);
            }
            nodes[nodes.Count - 1] = nodes[nodes.Count - 1].Replace("*", "");
            return(nodes);
        }
Beispiel #5
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            SearchFilterHelper helper = SearchFilterHelper.Current;
            var query = helper.QueryString["search"];

            if (!IsPostBack)
            {
                search.Text = query;

                ClassType.SelectedValue = helper.QueryString["type"];
            }

            var searchText = search.Text.Trim();

            if (!String.IsNullOrEmpty(searchText))
            {
                var classType = (ClassType.SelectedValue != _allValue) ? ClassType.SelectedValue : null;

                var currentMarketService = ServiceLocator.Current.GetInstance <ICurrentMarket>();
                var marketId             = currentMarketService.GetCurrentMarket().MarketId;

                var language = SiteContext.Current.LanguageName;

                var qs = Request.QueryString;

                var pageSize = (qs[PagingMenu.DefaultShowAllKey] != null) ? 1000 : pagerTop.PageSize;

                var page = qs[PagingMenu.DefaultPageKey] != null
                                         ? Math.Max(Int32.Parse(qs[PagingMenu.DefaultPageKey]), 1)
                                         : 1;

                var startIndex = (page - 1) * pageSize;

                pagerTop.SetPageProperties(startIndex, pageSize, false);
                pagerBottom.SetPageProperties(startIndex, pageSize, false);

                int count   = 0;
                var entries = GetEntries(searchText, classType, marketId, language, startIndex, pageSize, out count);

                SearchResultSummaryPlaceHolder.Visible = true;

                NumberOfHits.Text = count == 0
                            ? "no"
                            : count.ToString(CultureInfo.InvariantCulture);

                searchResults.DataSource = CreateDataSource(entries, count);
                searchResults.DataBind();
            }
        }
Beispiel #6
0
        public List <Entry> BookSearch(BookFilter BookFilter)
        {
            int  count        = 0;
            bool cacheResults = true;

            TimeSpan cacheTimeout = new TimeSpan(0, 0, 30);

            if (String.IsNullOrEmpty(BookFilter.search))
            {
                cacheTimeout = new TimeSpan(0, 1, 0);
            }

            SearchFilterHelper filter = SearchFilterHelper.Current;

            CatalogEntrySearchCriteria criteria = filter.CreateSearchCriteria(BookFilter.search, new SearchSort(BookFilter.sort));


            if (criteria.CatalogNames.Count == 0)
            {
                CatalogDto catalogs = CatalogContext.Current.GetCatalogDto(CMSContext.Current.SiteId);
                if (catalogs.Catalog.Count > 0)
                {
                    foreach (CatalogDto.CatalogRow row in catalogs.Catalog)
                    {
                        if (row.IsActive && row.StartDate <= FrameworkContext.Current.CurrentDateTime && row.EndDate >= FrameworkContext.Current.CurrentDateTime)
                        {
                            criteria.CatalogNames.Add(row.Name);
                        }
                    }
                }
            }


            Entries entries = filter.SearchEntries(criteria, BookFilter.startIndex, BookFilter.itemsPerPage, out count, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo), cacheResults, cacheTimeout);

            int resultsCount = entries.Entry != null?entries.Entry.Count() : 0;

            if (entries.Entry != null && entries.Entry.Count() > BookFilter.itemsPerPage)               //ECF's search helper pads the results by 5
            {
                Entry[] entryset = entries.Entry;
                Array.Resize <Entry>(ref entryset, BookFilter.itemsPerPage);
                entries.Entry = entryset;
            }

            return(new List <Entry> (entries.Entry));
        }
        /// <summary>
        /// When someone clicks the search button,
        /// build a url that includes all the relevant search criteria in the query string:
        /// <list type="bullet">
        ///	<item>Keyword</item>
        ///	<item>Publisher</item>
        /// </list>
        /// The URL is built using ECF's  SearchFilterHelper.GetQueryStringNavigateUrl method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmitSearch_Click(object sender, EventArgs e)
        {
            //get the url of the search results page
            string searchPageUrl = NavigationManager.GetUrl("Search");

            //base the new search on the current url and start passing it along
            string url = CMSContext.Current.CurrentUrl;

            //if we're not already on the search results page, get the correct url
            if (!url.Contains(this.ResolveUrl(searchPageUrl)))
            {
                url = searchPageUrl;
            }

            //first, deal with the keyword.
            if ((!this.AllowSearchForDefaultText && tbKeyWord.Text != this.DefaultSearchText)) //if there is a keyword, add it to the query string
            {
                url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "Search", tbKeyWord.Text, false);
            }
            else
            {
                url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "Search", string.Empty, true); //this method has an overload that allows you to omit the value, but it doesn't seem to work, so we're passing an empty string and false to remove the value from the url
            }
            //next deal with the selected publisher
            if (ddlPublisher.Visible)
            {
                if (ddlPublisher.SelectedIndex != 0 && ddlPublisher.SelectedValue != this.Publisher)                  //if there is a selected publisher, and its not the current one, chang it
                {
                    url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "Publisher", ddlPublisher.SelectedValue, false);
                }
                //if no publisher is selected, remove publisher from the query string altogether
                else
                {
                    url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "Publisher", string.Empty, true);                  //this method has an overload that allows you to omit the value, but it doesn't seem to work, so we're passing an empty string and false to remove the value from the url
                }
            }
            //remove the page number
            url = SearchFilterHelper.GetQueryStringNavigateUrl(url, "page", string.Empty, true);
            Response.Redirect(url);
        }
Beispiel #8
0
        protected void BindSearch()
        {
            int        count        = 0;
            bool       cacheResults = false;
            TimeSpan   cacheTimeout = new TimeSpan(0, 0, 1);
            SearchSort sort         = new SearchSort("TypeSort");

            SearchFilterHelper filter = SearchFilterHelper.Current;

            CatalogEntrySearchCriteria criteria = filter.CreateSearchCriteria(null, sort);

            criteria.CatalogNames.Add("NWTD");

            Entries entries = filter.SearchEntries(criteria, 0, 5, //ECF's API pads the results
                                                   out count,
                                                   new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo),
                                                   cacheResults, cacheTimeout
                                                   );

            this.gvSearchResults.DataSource = entries.Entry;
            this.gvSearchResults.DataBind();
        }
        public ActionResult Search(string keyWord)
        {
            // ToDo: SearchHelper and Criteria
            SearchFilterHelper searchHelper = SearchFilterHelper.Current; // the easy way

            CatalogEntrySearchCriteria criteria = searchHelper.CreateSearchCriteria(keyWord
                                                                                    , CatalogEntrySearchCriteria.DefaultSortOrder);

            criteria.RecordsToRetrieve = 25;
            criteria.StartingRecord    = 0;
            //criteria.Locale = "en"; // needed
            criteria.Locale = ContentLanguage.PreferredCulture.Name;

            int      count       = 0; // "Out"
            bool     cacheResult = true;
            TimeSpan timeSpan    = new TimeSpan(0, 10, 0);

            // ToDo: Search
            // One way of "doing it" ... retrieve it like ISearchResults (preferred, most certainly)
            ISearchResults  searchResult = searchHelper.SearchEntries(criteria);
            ISearchDocument aDoc         = searchResult.Documents.FirstOrDefault();

            int[] ints = searchResult.GetKeyFieldValues <int>();

            /* == ways of loading, keeping some old stuff for enjoying squiggles == */
            // ECF style Entries, old-school & legacy, not recommended at all...
            // ...work with DTOs if not using the ContentModel
            Entries entries = CatalogContext.Current.GetCatalogEntries(ints // Note "ints"
                                                                       , new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));

            // still interesting
            CatalogContext.Current.GetCatalogEntriesDto(ints
                                                        , new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));

            // Same thing... ECF-old-style, not recommended... if not absolutely needed...
            // Use the helper and get the entries direct
            // If entries are needed ... like for calculating discounts with legacy StoreHelper()
            Entries entriesDirect = searchHelper.SearchEntries(criteria, out count // Note the different return-types ... akward!
                                                               , new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo)
                                                               , cacheResult, new TimeSpan());

            // CMS style (better)... using ReferenceConverter and ContentLoader
            List <ContentReference> refs = new List <ContentReference>();

            ints.ToList().ForEach(i => refs.Add(_referenceConverter.GetContentLink(i, CatalogContentType.CatalogEntry, 0)));

            // LoaderOptions() is new in CMS 8
            // ILanguageSelector selector = ServiceLocator.Current.GetInstance<ILanguageSelector>(); // obsolete
            _localContent = _contentLoader.GetItems(refs, new LoaderOptions()); // use this in CMS 8+

            // ToDo: Facets
            List <string> facetList = new List <string>();

            int facetGroups = searchResult.FacetGroups.Count();

            foreach (ISearchFacetGroup item in searchResult.FacetGroups)
            {
                foreach (var item2 in item.Facets)
                {
                    facetList.Add(String.Format("{0} {1} ({2})", item.Name, item2.Name, item2.Count));
                }
            }

            // Fill up the ViewModel
            var searchResultViewModel = new SearchResultViewModel();

            searchResultViewModel.totalHits = new List <string> {
                ""
            };                                                         // change
            searchResultViewModel.nodes      = _localContent.OfType <FashionNode>();
            searchResultViewModel.products   = _localContent.OfType <ShirtProduct>();
            searchResultViewModel.variants   = _localContent.OfType <ShirtVariation>();
            searchResultViewModel.allContent = _localContent;
            searchResultViewModel.facets     = facetList;

            return(View(searchResultViewModel));
        }
Beispiel #10
0
        /// <summary>
        /// Binds the fields.
        /// </summary>
        private void BindFields()
        {
            int recordsToRetrieve = DataPager2.PageSize;

            // Perform search
            string   keywords     = Request.QueryString["search"];
            int      count        = 0;
            bool     cacheResults = true;
            TimeSpan cacheTimeout = new TimeSpan(0, 0, 30);

            if (String.IsNullOrEmpty(keywords))
            {
                cacheTimeout = new TimeSpan(0, 1, 0);
            }

            SearchFilterHelper filter = SearchFilterHelper.Current;

            string sort = Request.QueryString["s"];

            SearchSort sortObject = null;

            if (!String.IsNullOrEmpty(sort))
            {
                if (sort.Equals("name", StringComparison.OrdinalIgnoreCase))
                {
                    sortObject = new SearchSort("DisplayName");
                }
                else if (sort.Equals("plh", StringComparison.OrdinalIgnoreCase))
                {
                    sortObject = new SearchSort(String.Format("SalePrice{0}", CMSContext.Current.CurrencyCode));
                }
                else if (sort.Equals("phl", StringComparison.OrdinalIgnoreCase))
                {
                    sortObject = new SearchSort(String.Format("SalePrice{0}", CMSContext.Current.CurrencyCode), true);
                }
            }

            // Put default sort order if none is set
            if (sortObject == null)
            {
                sortObject = CatalogEntrySearchCriteria.DefaultSortOrder;
            }

            CatalogEntrySearchCriteria criteria = filter.CreateSearchCriteria(keywords, sortObject);

            if (_Parameters.Contains("Catalogs"))
            {
                foreach (string catalog in _Parameters["Catalogs"].ToString().Split(new char[',']))
                {
                    if (!String.IsNullOrEmpty(catalog))
                    {
                        criteria.CatalogNames.Add(catalog);
                    }
                }
            }

            if (_Parameters.Contains("NodeCode"))
            {
                foreach (string node in _Parameters["NodeCode"].ToString().Split(new char[',']))
                {
                    if (!String.IsNullOrEmpty(node))
                    {
                        criteria.CatalogNodes.Add(node);
                    }
                }
            }

            if (_Parameters.Contains("EntryClasses"))
            {
                foreach (string node in _Parameters["EntryClasses"].ToString().Split(new char[',']))
                {
                    if (!String.IsNullOrEmpty(node))
                    {
                        criteria.SearchIndex.Add(node);
                    }
                }
            }

            if (_Parameters.Contains("EntryTypes"))
            {
                foreach (string entry in _Parameters["EntryTypes"].ToString().Split(new char[',']))
                {
                    if (!String.IsNullOrEmpty(entry))
                    {
                        criteria.ClassTypes.Add(entry);
                    }
                }
            }

            if (_Parameters.Contains("RecordsPerPage"))
            {
                recordsToRetrieve = Int32.Parse(_Parameters["RecordsPerPage"].ToString());
            }

            // Bind default catalogs if none found
            if (criteria.CatalogNames.Count == 0)
            {
                CatalogDto catalogs = CatalogContext.Current.GetCatalogDto(CMSContext.Current.SiteId);
                if (catalogs.Catalog.Count > 0)
                {
                    foreach (CatalogDto.CatalogRow row in catalogs.Catalog)
                    {
                        if (row.IsActive && row.StartDate <= FrameworkContext.Current.CurrentDateTime && row.EndDate >= FrameworkContext.Current.CurrentDateTime)
                        {
                            criteria.CatalogNames.Add(row.Name);
                        }
                    }
                }
            }

            // No need to perform search if no catalogs specified
            if (criteria.CatalogNames.Count != 0)
            {
                Entries entries = filter.SearchEntries(criteria, _StartRowIndex, recordsToRetrieve, out count, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo), cacheResults, cacheTimeout);
                CatalogSearchDataSource.TotalResults   = count;
                CatalogSearchDataSource.CatalogEntries = entries;
            }
            _Results = filter.Results;

            if (count == 0)
            {
                PagingHeader.Visible = false;
                PagingFooter.Visible = false;
                DataPager2.Visible   = false;
                DataPager3.Visible   = false;
                MyMenu.Visible       = false;
            }
            else
            {
                MyMenu.Filters = filter.SelectedFilters;
                MyMenu.Facets  = filter.GetFacets(cacheResults, cacheTimeout);
                MyMenu.Visible = true;
                //MyMenu.DataBind();
                PagingHeader.Visible = true;
                PagingFooter.Visible = true;
                DataPager2.Visible   = true;
                DataPager3.Visible   = true;
            }
        }
Beispiel #11
0
        /// <summary>
        /// This event handler existed for some sort dropdown lists that were once part of the UI
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlSortBy_SelectedIndexChanged(object sender, EventArgs e)
        {
            string val = ((DropDownList)sender).SelectedValue;

            Response.Redirect(SearchFilterHelper.GetQueryStringNavigateUrl("sort", val));
        }
Beispiel #12
0
        /// <summary>
        /// When the page loads, we'll perform the search based on the criteria defined in the query string.
        /// Some of this is automatically done by ECF, for better or for worse, other things are done by us in our
        /// public properties such as KeyWords
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //before we conduct the search, we'd better make sure the prices are set for the user
            global::NWTD.Profile.SetSaleInformation();

            //Hide the "Add Selected items to cart" button on the top of the results
            this.srBookSearch.AddToCartTop.Visible = false;


            //The criteria for this search is going to be based on the query string.

            //first get some variables ready
            int      count        = 0;
            bool     cacheResults = true;
            TimeSpan cacheTimeout = new TimeSpan(0, 0, 30);             //by default we'll have our cache timeout after 30 seconds

            if (String.IsNullOrEmpty(this.KeyWords))
            {
                cacheTimeout = new TimeSpan(0, 1, 0);                 //if there's no keyword search, we'll up the timeout to a minute
            }
            //get the current filter
            //(ECF will automatically pull filters from the query string)
            SearchFilterHelper filter = SearchFilterHelper.Current;


            string keyWords = this.KeyWords;
            ////check to see if the KeyWords matches an ISBN Pattern
            //if(System.Text.RegularExpressions.Regex.IsMatch(keyWords, @"^[0-9-]+[a-z-0-9]?$")){ //any string of all hyphens or numbers and possibly an alpha character at the end
            //    keyWords = keyWords.Replace("-",string.Empty);
            //}


            //build the criteria based on sort and keywords
            CatalogEntrySearchCriteria criteria = filter.CreateSearchCriteria(keyWords, this.SortBy);


            // the current catalog if that's not been added yet (which it shouldn't be)
            if (criteria.CatalogNames.Count == 0)
            {
                CatalogDto catalogs = CatalogContext.Current.GetCatalogDto(CMSContext.Current.SiteId);
                if (catalogs.Catalog.Count > 0)
                {
                    foreach (CatalogDto.CatalogRow row in catalogs.Catalog)
                    {
                        if (row.IsActive && row.StartDate <= FrameworkContext.Current.CurrentDateTime && row.EndDate >= FrameworkContext.Current.CurrentDateTime)
                        {
                            criteria.CatalogNames.Add(row.Name);
                        }
                    }
                }
            }

            //Incorporate the state availablity flag
            criteria.Add(
                global::NWTD.Catalog.UserStateAvailablityField,
                new SimpleValue()
            {
                key          = string.Empty,
                value        = "y",
                locale       = "en-us",
                Descriptions = new Descriptions()
                {
                    defaultLocale = "en-us"
                }
            });

            //setting this in the helper class now
            //Lucene.Net.Search.BooleanQuery.SetMaxClauseCount(Int32.MaxValue);
            //exectute the search
            Entries entries = filter.SearchEntries(
                criteria,
                this.StartIndex,
                this.ItemsPerPage,
                out count,
                new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo),
                cacheResults,
                cacheTimeout
                );

            //Lucene.Net.Search.BooleanQuery.SetMaxClauseCount(1024);
            //the number of results that were returned
            int resultsCount = entries.Entry != null?entries.Entry.Count() : 0;

            if (entries.Entry != null && entries.Entry.Count() > this.ItemsPerPage)               //ECF's search helper pads the results by 5
            {
                Entry[] entryset = entries.Entry;
                Array.Resize <Entry>(ref entryset, this.ItemsPerPage);

                entries.Entry = entryset;
            }

            int fromResult = (this.StartIndex + 1);
            int toResult   = this.StartIndex + (this.ItemsPerPage > resultsCount ? resultsCount : this.ItemsPerPage);

            //indicate to the user what page we're on
            if (resultsCount > 0)
            {
                this.litPageNumber.Text = string.Format("({0}-{1} of {2})", fromResult.ToString(), toResult.ToString(), count.ToString());
            }
            else
            {
                //this.ddlSortBy.Visible = false;
            }

            decimal numberOfPages = 1 + Convert.ToDecimal(Math.Floor(Convert.ToDouble((count / this.ItemsPerPage))));

            //if we're not on page 1, add a prev button to the pager
            if (this.PageNumber != 1)
            {
                this.blPager.Items.Add(new ListItem("Prev", SearchFilterHelper.GetQueryStringNavigateUrl("page", (PageNumber - 1).ToString())));
                this.blBottomPager.Items.Add(new ListItem("Prev", SearchFilterHelper.GetQueryStringNavigateUrl("page", (PageNumber - 1).ToString())));
            }
            //if we're not on the last page, add a next button to the pager
            if (this.PageNumber != numberOfPages)
            {
                this.blPager.Items.Add(new ListItem("Next", SearchFilterHelper.GetQueryStringNavigateUrl("page", (PageNumber + 1).ToString())));
                this.blBottomPager.Items.Add(new ListItem("Next", SearchFilterHelper.GetQueryStringNavigateUrl("page", (PageNumber + 1).ToString())));
            }

            //this.srBookSearch.ResultsGrid.ShowFooter = true;
            this.srBookSearch.ResultsGrid.Parent.Controls.AddAt(this.srBookSearch.ResultsGrid.Parent.Controls.IndexOf(this.srBookSearch.ResultsGrid) + 1, this.pnlBottomPager);

            //I can't figure out why this needs to be cast. For some reason VS is calling it a UserControl, not a SideMenu
            FiltersSideMenu.Filters = filter.SelectedFilters;

            //Only show facet if results are more than 1 - Heath Gardner 01/22/16 ////////////////////////////////////////
            FacetGroup[] facets = null;


            if (resultsCount > 1)
            {
                facets = filter.GetFacets(cacheResults, cacheTimeout);
            }

            FiltersSideMenu.Facets = facets;
            //End modify//////////////////////////////////////////////////////////////////////////////////////////////////

            //Original facet logic that was replaced with the above - Heath Gardner 01/22/16
            //FacetGroup[]  facets = filter.GetFacets(cacheResults, cacheTimeout);
            //FiltersSideMenu.Facets = facets;

            //Bind the results to our search results control
            this.srBookSearch.Entries      = entries;
            this.srBookSearch.TotalResults = count;

            //We don't want them to be able to just view everything with no search (for reasons unbeknownst to me)
            if (Request.QueryString.Count == 0)
            {
                this.srBookSearch.Visible     = false;
                this.blPager.Visible          = false;
                this.blBottomPager.Visible    = false;
                this.litPageNumber.Visible    = false;
                this.pnlBrowseCatalog.Visible = true;
                this.pnlSearchHead.Visible    = false;
                //return;
            }
            //if there are no results, we need to hide certain things
            else if (count == 0)
            {
                this.srBookSearch.Visible  = false;
                this.blPager.Visible       = false;
                this.blBottomPager.Visible = false;
                this.litPageNumber.Visible = false;
                this.pnlNoResults.Visible  = true;
                this.pnlSearchHead.Visible = false;
                //return;
            }

            if (!string.IsNullOrEmpty(this.KeyWords))
            {
                this.litSearchString.Text = string.Format("<span class=\"nwtd-searchString\">for \"{0}\"</span>", this.KeyWords);
            }

            DataBind();
        }
Beispiel #13
0
 public virtual StringCollection GetOutlinesForNode(string code)
 {
     return(SearchFilterHelper.GetOutlinesForNode(code));
 }
Beispiel #14
0
 /// <summary>
 /// Gets the facet URL.
 /// </summary>
 /// <param name="facet">The facet.</param>
 /// <returns></returns>
 protected string GetFacetUrl(ISearchFacet facet)
 {
     return(SearchFilterHelper.GetQueryStringNavigateUrl(facet.Group.FieldName, facet.Key));
 }
Beispiel #15
0
        /// <summary>
        /// Binds the results.
        /// </summary>
        private void BindResults(bool list)
        {
            SearchSort sortObject = CatalogEntrySearchCriteria.DefaultSortOrder;
            //string sort = SortBy.SelectedValue;
            //if (!String.IsNullOrEmpty(sort))
            //{
            //    if (sort.Equals("name", StringComparison.OrdinalIgnoreCase))
            //        sortObject = new SearchSort("displayname");
            //    else if (sort.Equals("plh", StringComparison.OrdinalIgnoreCase))
            //        sortObject =
            //            new SearchSort(String.Format("saleprice{0}", SiteContext.Current.CurrencyCode).ToLower());
            //    else if (sort.Equals("phl", StringComparison.OrdinalIgnoreCase))
            //        sortObject =
            //            new SearchSort(String.Format("saleprice{0}", SiteContext.Current.CurrencyCode).ToLower(), true);
            //}

            var group = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
            SearchFilterHelper         helper   = SearchFilterHelper.Current;
            CatalogEntrySearchCriteria criteria = helper.CreateSearchCriteria("", sortObject);

            //AddNodesToCriteria(criteria);
            criteria.RecordsToRetrieve = 25;
            criteria.StartingRecord    = _startRowIndex;
            criteria.ClassTypes.Add("Product");

            var searchManager = new SearchManager(AppContext.Current.ApplicationName);

            try
            {
                var results = searchManager.Search(criteria);
                if (results == null)
                {
                    return;
                }

                var resultIndexes = results.GetKeyFieldValues <int>();
                var entries       = CatalogContext.Current.GetCatalogEntries(resultIndexes, group);
                if (entries.Entry != null)
                {
                    var ds = CreateDataSource(entries, results.TotalCount);
                    if (!list)
                    {
                        EntriesList.DataSource = ds;
                        EntriesList.DataBind();
                        EntriesList.Visible = true;
                        listView.Visible    = false;
                    }
                    else
                    {
                        listView.DataSource = ds;
                        listView.DataBind();
                        EntriesList.Visible = false;
                        listView.Visible    = true;
                    }

                    if (results.TotalCount < 25)
                    {
                        DataPager3.Visible = false;
                    }
                }

                _filters = helper.SelectedFilters;
                _facets  = results.FacetGroups;

                if (_filters != null && _filters.Length > 0)
                {
                    ActiveFilterList.DataSource = _filters;
                    ActiveFilterList.DataBind();
                    ActiveFilterList.Visible = true;
                }
                else
                {
                    ActiveFilterList.Visible = false;
                }

                if (_facets != null && _facets.Length > 0)
                {
                    FilterList.Visible    = true;
                    FilterList.DataSource = _facets;
                    FilterList.DataBind();
                }
                else
                {
                    FilterList.Visible = false;
                }
            }
            catch (Exception ex)
            {
                LogManager.GetLogger(GetType()).Error(ex.Message, ex);
            }
        }