/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { //load my models - by User.Id.Name if (!Page.IsPostBack) { vwarDAL.ISearchProxy srch = new vwarDAL.DataAccessFactory().CreateSearchProxy(Context.User.Identity.Name); MyModelsDataList.DataSource = srch.GetContentObjectsBySubmitterEmail(Context.User.Identity.Name.Trim()); MyModelsDataList.DataBind(); srch.Dispose(); } }
/// <summary> /// /// </summary> /// <param name="c"></param> protected void BindViewData(Control c) { 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(); }
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(); }
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; }
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 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(); }
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(); }