/// <summary> /// Fetches list of entities based on set EntityType /// </summary> /// <param name="fetchedRecords">Records fetched</param> /// <param name="pageSize">Page size</param> /// <param name="totalRecords">Total record count</param> /// <returns>List of Entities</returns> private IList <Resource> GetEntityList(int fetchedRecords, int pageSize, out int totalRecords) { using (ResourceDataAccess dataAccess = new ResourceDataAccess(base.CreateContext())) { if (SortDirection == System.Web.UI.WebControls.SortDirection.Ascending) { return(dataAccess.SearchResources(SearchCriteria, fetchedRecords, pageSize, out totalRecords, Zentity.Platform.SortDirection.Ascending, SortExpression, AuthenticatedToken, IsSecurityAwareControl).ToList()); } else { return(dataAccess.SearchResources(SearchCriteria, fetchedRecords, pageSize, out totalRecords, Zentity.Platform.SortDirection.Descending, SortExpression, AuthenticatedToken, IsSecurityAwareControl).ToList()); } } }
private void RefreshDataSource(int pageIndex, string searchText) { int totalPages = 0; ResourceListView.PageIndex = 0; ResourceListView.TotalRecords = 0; ResourceListView.DataSource.Clear(); if (!string.IsNullOrEmpty(searchText)) { int totalRecords = 0; ResourceListView.PageSize = _pageSize; int totalParsedRecords = totalParsedRecords = _pageSize * pageIndex; List <Resource> foundRestResource = null; Dictionary <Guid, IEnumerable <string> > userPermissions = null; SortProperty sortProp = null; if (ResourceListView.SortDirection == System.Web.UI.WebControls.SortDirection.Ascending) { sortProp = new SortProperty(ResourceListView.SortExpression, Zentity.Platform.SortDirection.Ascending); } else { sortProp = new SortProperty(ResourceListView.SortExpression, Zentity.Platform.SortDirection.Descending); } //search resources and user permissions on the searched resources. using (ResourceDataAccess dataAccess = new ResourceDataAccess()) { AuthenticatedToken token = this.Session[Constants.AuthenticationTokenKey] as AuthenticatedToken; if (token != null) { foundRestResource = dataAccess.SearchResources(token, searchText, _pageSize, sortProp, totalParsedRecords, false, out totalRecords).ToList(); userPermissions = GetPermissions(token, foundRestResource); } } //Calculate total pages if (totalRecords > 0) { totalPages = Convert.ToInt32(Math.Ceiling((double)totalRecords / _pageSize)); } // Update empty resource's title with default value. if (foundRestResource != null && foundRestResource.Count() > 0) { Utility.UpdateResourcesEmptyTitle(foundRestResource); } //Bind data to GridView ResourceListView.TotalRecords = totalRecords; ResourceListView.PageIndex = pageIndex; foreach (Resource resource in foundRestResource) { ResourceListView.DataSource.Add(resource); } ResourceListView.UserPermissions = userPermissions; //Enable feed for this page. string searchString = GetSearchString(); if (!string.IsNullOrEmpty(searchString)) { ResourceListView.EnableFeed(searchString); } ResourceListView.DataBind(); } }
private void RefreshDataSource(int pageIndex) { int totalPages = 0; string searchText = SearchText.Text; if (!string.IsNullOrEmpty(searchText)) { LabelErrorMessage.Text = string.Empty; try { searchText = SearchText.Text.Trim(); SearchText.Text = searchText; int totalRecords = 0; int pageSize = SearchResourceListView.PageSize; int totalParsedRecords = totalParsedRecords = pageSize * pageIndex; List <Resource> foundRestResource = null; Dictionary <Guid, IEnumerable <string> > userPermissions = null; SortProperty sortProp = null; if (SearchResourceListView.SortDirection == System.Web.UI.WebControls.SortDirection.Ascending) { sortProp = new SortProperty(SearchResourceListView.SortExpression, Zentity.Platform.SortDirection.Ascending); } else { sortProp = new SortProperty(SearchResourceListView.SortExpression, Zentity.Platform.SortDirection.Descending); } //search resources and user permissions on the searched resources. using (ResourceDataAccess dataAccess = new ResourceDataAccess()) { AuthenticatedToken token = this.Session[Constants.AuthenticationTokenKey] as AuthenticatedToken; if (token != null) { foundRestResource = dataAccess.SearchResources(token, searchText, pageSize, sortProp, totalParsedRecords, ContentSearchCheckBox.Checked, out totalRecords).ToList(); userPermissions = GetPermissions(token, foundRestResource); } } //Calculate total pages if (totalRecords > 0) { //this.DisplayMatchedResourcesCount(totalRecords); totalPages = Convert.ToInt32(Math.Ceiling((double)totalRecords / pageSize)); } // Update empty resource's title with default value. if (foundRestResource != null && foundRestResource.Count() > 0) { Utility.UpdateResourcesEmptyTitle(foundRestResource); } //Bind data to GridView SearchResourceListView.TotalRecords = totalRecords; SearchResourceListView.DataSource.Clear(); foreach (Resource resource in foundRestResource) { SearchResourceListView.DataSource.Add(resource); } SearchResourceListView.UserPermissions = userPermissions; SearchResourceListView.DataBind(); if (!this.ContentSearchCheckBox.Checked) { SearchResourceListView.EnableFeed(searchText); } } catch (SearchException ex) { LabelErrorMessage.Text = ex.Message; } } SearchText.Focus(); }