protected void Page_Load(object sender, EventArgs e)
    {
        vwarDAL.ISearchProxy _SearchProxy = new DataAccessFactory().CreateSearchProxy(Context.User.Identity.Name);
        _ResultsPerPage = System.Convert.ToInt32(ResultsPerPageDropdown.SelectedValue);

        //Search
        if (!IsPostBack)
        {
            SetInitialSortValue();

            IEnumerable <ContentObject> co = GetSearchResults();

            if (co != null && co.Count() > 0)
            {
                //If it's presorted, we cannot rely on the number of items in the returned collection
                //to get the true number of objects matching the specified search query
                int totalResults = (_Presorted) ? _SearchProxy.GetContentObjectCount() : co.Count();
                BindPageNumbers(totalResults);

                ApplySearchResults(co);
            }
            else
            {
                NoneFoundLabel.Visible = true;
                NoneFoundLabel.Text    = "No models found. <br />";
                SearchList.Visible     = false;
            }
        }
        _SearchProxy.Dispose();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        vwarDAL.ISearchProxy _SearchProxy = new DataAccessFactory().CreateSearchProxy(Context.User.Identity.Name);
        _ResultsPerPage = System.Convert.ToInt32(ResultsPerPageDropdown.SelectedValue);

        string tempUrl = "";

        string[] acceptableArray = { "Search", "Keywords", "DeveloperName", "ArtistName", "SponsorName" };

        for (int i = 0; i < acceptableArray.Length; i++)
        {
            if (Context.Request.QueryString[acceptableArray[i]] != null)
            {
                tempUrl = (acceptableArray[i] == "Keywords") ? "Keywords;" + Context.Request.QueryString[acceptableArray[i]] : Context.Request.QueryString[acceptableArray[i]];
                break;
            }
        }

        APILink.NavigateUrl = "https://" + ConfigurationManager.AppSettings["LR_Integration_APIBaseURL"] + "/Search/" + Server.UrlEncode(tempUrl) + "/json?id=00-00-00";

        //Search
        if (!IsPostBack)
        {
            SetInitialSortValue();

            IEnumerable <ContentObject> co = GetSearchResults();

            if (co != null && co.Count() > 0)
            {
                //If it's presorted, we cannot rely on the number of items in the returned collection
                //to get the true number of objects matching the specified search query
                int totalResults = (_Presorted) ? _SearchProxy.GetContentObjectCount() : co.Count();
                BindPageNumbers(totalResults);

                ApplySearchResults(co);
            }
            else
            {
                NoneFoundLabel.Visible = true;
                if (Membership.GetUser() == null)
                {
                    NoneFoundLabel.Text = "No models found. It's possible that some models are hidden by their owners. Try logging in for more results. <br />";
                }
                else
                {
                    NoneFoundLabel.Text = "No models found. It's possible that some models are hidden by their owners. <br />";
                }
                SearchList.Visible = false;
            }
        }
        _SearchProxy.Dispose();
    }
    protected void NumResultsPerPageChanged(object sender, EventArgs e)
    {
        vwarDAL.ISearchProxy _SearchProxy = new DataAccessFactory().CreateSearchProxy(Context.User.Identity.Name);
        _ResultsPerPage = System.Convert.ToInt32(ResultsPerPageDropdown.SelectedValue);

        IEnumerable <ContentObject> co = GetSearchResults();

        if (co != null)
        {
            BindPageNumbers(_Presorted
                            ? _SearchProxy.GetContentObjectCount()
                            : co.Count());
        }

        ApplySearchResults(co);
        _SearchProxy.Dispose();
    }
    protected void PageNumberChanged(object sender, EventArgs e)
    {
        vwarDAL.ISearchProxy _SearchProxy = new DataAccessFactory().CreateSearchProxy(Context.User.Identity.Name);
        //Get the page number from the value displayed to the user
        LinkButton btn = (LinkButton)sender;

        _PageNumber = System.Convert.ToInt32(btn.CommandArgument);

        IEnumerable <ContentObject> co = GetSearchResults();

        ApplySearchResults(co);

        BindPageNumbers(_Presorted
                        ? _SearchProxy.GetContentObjectCount()
                        : co.Count());
        _SearchProxy.Dispose();
    }
Exemple #5
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="c"></param>
    protected void BindViewData(Control c)
    {
        //  return;
        PermissionsManager permManager = new PermissionsManager();
        string             username    = HttpContext.Current.User.Identity.Name;

        //You gotta love how FindControl isn't recursive...
        DataList list = (DataList)c.FindControl("RotatorLayoutTable")
                        .FindControl("RotatorListViewRow")
                        .FindControl("RotatorListViewColumn")
                        .FindControl("RotatorListView");

        ISearchProxy permissionsHonoringProxy = new DataAccessFactory().CreateSearchProxy(HttpContext.Current.User.Identity.Name);

        switch (c.ID)
        {
        case "HighestRatedRotator":
            list.DataSource = permissionsHonoringProxy.GetByRating(4);
            break;

        case "MostPopularRotator":
            list.DataSource = permissionsHonoringProxy.GetByViews(4);
            break;

        case "RecentlyUpdatedRotator":
            list.DataSource = permissionsHonoringProxy.GetByLastUpdated(4);
            break;

        case "RandomRotator":
            list.DataSource = permissionsHonoringProxy.GetByRandom(4);
            break;

        default:
            throw new Exception("No control '" + c.ID + "' could be found to bind data to.");
        }
        list.DataBind();
        permissionsHonoringProxy.Dispose();
        permManager.Dispose();
    }
Exemple #6
0
    /// <summary>
    ///
    /// </summary>
    //private vwarDAL.IDataRepository vd;
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string[] tempPopularTags;

            ((HyperLink)RandomRotator.FindControl("ViewMoreHyperLink")).Text        = "More...";
            ((HyperLink)RandomRotator.FindControl("ViewMoreHyperLink")).NavigateUrl = "/Default.aspx?refresh=true";

            if (Session["MostPopular"] == null || Context.Request.QueryString["refresh"] != null)
            {
                BindViewData(HighestRatedRotator);
                BindViewData(MostPopularRotator);
                BindViewData(RecentlyUpdatedRotator);
                BindViewData(RandomRotator);



                ISearchProxy permissionsHonoringProxy = new DataAccessFactory().CreateSearchProxy(HttpContext.Current.User.Identity.Name);

                tempPopularTags = permissionsHonoringProxy.GetMostPopularTags();

                PopularDevelopersList.DataSource = permissionsHonoringProxy.GetMostPopularDevelopers();
                PopularDevelopersList.DataBind();

                permissionsHonoringProxy.Dispose();

                Session["HighestRated"]      = ((DataList)HighestRatedRotator.FindControl("RotatorLayoutTable").FindControl("RotatorListViewRow").FindControl("RotatorListViewColumn").FindControl("RotatorListView")).DataSource;
                Session["MostPopular"]       = ((DataList)MostPopularRotator.FindControl("RotatorLayoutTable").FindControl("RotatorListViewRow").FindControl("RotatorListViewColumn").FindControl("RotatorListView")).DataSource;
                Session["RecentlyUpdated"]   = ((DataList)RecentlyUpdatedRotator.FindControl("RotatorLayoutTable").FindControl("RotatorListViewRow").FindControl("RotatorListViewColumn").FindControl("RotatorListView")).DataSource;
                Session["Random"]            = ((DataList)RandomRotator.FindControl("RotatorLayoutTable").FindControl("RotatorListViewRow").FindControl("RotatorListViewColumn").FindControl("RotatorListView")).DataSource;
                Session["PopularTags"]       = tempPopularTags;
                Session["PopularDevelopers"] = PopularDevelopersList.DataSource;
            }
            else
            {
                DataList list = (DataList)HighestRatedRotator.FindControl("RotatorLayoutTable")
                                .FindControl("RotatorListViewRow")
                                .FindControl("RotatorListViewColumn")
                                .FindControl("RotatorListView");
                list.DataSource = (IEnumerable <ContentObject>)Session["HighestRated"];
                list.DataBind();

                list = (DataList)MostPopularRotator.FindControl("RotatorLayoutTable")
                       .FindControl("RotatorListViewRow")
                       .FindControl("RotatorListViewColumn")
                       .FindControl("RotatorListView");
                list.DataSource = (IEnumerable <ContentObject>)Session["MostPopular"];
                list.DataBind();

                list = (DataList)RecentlyUpdatedRotator.FindControl("RotatorLayoutTable")
                       .FindControl("RotatorListViewRow")
                       .FindControl("RotatorListViewColumn")
                       .FindControl("RotatorListView");
                list.DataSource = (IEnumerable <ContentObject>)Session["RecentlyUpdated"];
                list.DataBind();

                list = (DataList)RandomRotator.FindControl("RotatorLayoutTable")
                       .FindControl("RotatorListViewRow")
                       .FindControl("RotatorListViewColumn")
                       .FindControl("RotatorListView");
                list.DataSource = (IEnumerable <ContentObject>)Session["Random"];
                list.DataBind();

                tempPopularTags = (string[])Session["PopularTags"];

                PopularDevelopersList.DataSource = (string[])Session["PopularDevelopers"];
                PopularDevelopersList.DataBind();
            }

            PopularTagsView.ClientIDMode = ClientIDMode.Static;

            StylizeTags((string [])tempPopularTags.Clone());
        }
    }
    private IEnumerable <ContentObject> GetSearchResults()
    {
        IEnumerable <ContentObject> co = null;

        vwarDAL.ISearchProxy _SearchProxy = new DataAccessFactory().CreateSearchProxy(Context.User.Identity.Name);
        SearchMethod         method;
        string methodParam = Request.QueryString["Method"];

        if (!String.IsNullOrEmpty(methodParam) && methodParam.ToLowerInvariant() == "and")
        {
            method = SearchMethod.AND;
        }
        else
        {
            method = SearchMethod.OR;
        }

        if (!String.IsNullOrEmpty(Request.QueryString["Search"]))
        {
            string searchTerm = Request.QueryString["Search"];
            if (!String.IsNullOrEmpty(searchTerm))
            {
                SearchTextBox.Text = Server.UrlDecode(searchTerm);
                if (SearchTextBox.Text.Contains(','))
                {
                    var terms = SearchTextBox.Text.Split(',');
                    co = _SearchProxy.QuickSearch(terms, method);
                }
                else
                {
                    co = _SearchProxy.QuickSearch(SearchTextBox.Text);
                }
            }
        }
        else if (!String.IsNullOrEmpty(Request.QueryString["Group"]))
        {
            /* Here, we are getting "everything" (limit NumResultsPerPage) by a grouping.
             *
             * By doing a little processing ahead of time, we can
             * avoid having to use ApplySort when unnecessary, as well
             * as reduce the size of the data returned from MySQL.
             */

            string[] sortParams = SortInfo.Split('-');
            if (sortParams.Length == 2) //Make sure it's in the right format!
            {
                SortOrder order = (sortParams[1].ToLowerInvariant() == "low")
                  ? SortOrder.Ascending
                  : SortOrder.Descending;

                int start = (_PageNumber - 1) * _ResultsPerPage;

                switch (sortParams[0].ToLowerInvariant())
                {
                case "views":
                    co = _SearchProxy.GetByViews(_ResultsPerPage, start, order);
                    break;

                case "updated":
                    co = _SearchProxy.GetByLastUpdated(_ResultsPerPage, start, order);
                    break;

                case "viewed":
                    co = _SearchProxy.GetByLastViewed(_ResultsPerPage, start, order);
                    break;

                case "rating":
                default:
                    co = _SearchProxy.GetByRating(_ResultsPerPage, start, order);
                    break;
                }
                _Presorted = true;
            }
        }
        else //We're searching by field
        {
            System.Collections.Specialized.NameValueCollection fieldsToSearch = new System.Collections.Specialized.NameValueCollection();

            string[] searchableFields = { "Title", "Description", "ArtistName", "SponsorName", "DeveloperName", "Keywords" };

            foreach (string field in searchableFields)
            {
                if (!String.IsNullOrEmpty(Request.QueryString[field]))
                {
                    fieldsToSearch[field] = Server.UrlDecode(Request.QueryString[field]);
                }
            }

            co = _SearchProxy.SearchByFields(fieldsToSearch, method);
        }

        _SearchProxy.Dispose();
        return(co);
    }