Ejemplo n.º 1
0
        /// <summary>
        /// Method to get best bets
        /// </summary>
        /// <param name="searchTerm"></param>
        /// <returns></returns>
        private BestBetUIResult[] GetBestBetsResults(string searchTerm)
        {
            BestBetUIResult[] results = new BestBetUIResult[0];

            try
            {
                results = BestBetsPresentationManager.GetBestBets(searchTerm, PageDisplayInformation.Language);
            }
            catch (Exception ex)
            {
                //Search results should be retrieved even if Best Bets fail
                //log the error  but don't throw an exception
                log.ErrorFormat("Error in GetBestBetsResults - {0}", ex, Request.Url.AbsoluteUri);
            }

            return(results);
        }
Ejemplo n.º 2
0
        protected string BestBetResultsHyperlinkOnclick(RepeaterItem result)
        {
            string resultData = "";

            if (WebAnalyticsOptions.IsEnabled)
            {
                try
                {
                    BestBetUIResult bbResultItem = (BestBetUIResult)result.DataItem;
                    resultData = bbResultItem.CategoryDisplay;

                    // Did not use html parser here, seemed like a overkill just to inject a simple string.
                    int hrefIndex = resultData.IndexOf("<a");

                    if (hrefIndex != -1)
                    {
                        // The analytics rank was previously set to '1' for all listed items in best bets;
                        // added some String methods to increment the value.
                        // First, split the results string into an array based on the number of <a> tags found.
                        int      i          = 1;
                        string[] separators = new string[] { "<a" };
                        string[] temp       = resultData.Split(separators, StringSplitOptions.None);

                        foreach (string t in temp)
                        {
                            // Add the BestBets arguments with the rank incrementing with each pass through
                            // the links in the results. Then smoosh the whole thing back together with the new opening
                            // <a onClick="..."
                            temp[i]    = String.Concat("(this,true,'" + i.ToString() + "');\"", temp[i]);
                            resultData = String.Join("<a onClick=\"NCIAnalytics.SiteWideSearchResults", temp);
                            i++;

                            // Return the re-assembled string once the rank and total number of links match.
                            if (i == temp.Length)
                            {
                                return(resultData);
                            }
                        } // End foreach
                    }     // End href index 'if' statement
                }
                catch { }
            }

            return("");
        }