Esempio n. 1
0
        /// <summary>
        /// Update data source of ZentityGridView base of current page index.
        /// </summary>
        private void Refresh()
        {
            RefreshResourceData();

            //Enable feed for this control
            CreateSearchCriteria();
            ResourceListView.EnableFeed(SearchCriteria);
        }
Esempio n. 2
0
    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();
        }
    }