/// <summary> /// Gets the data source. /// </summary> protected override void GetDataSource() { if (!this.Page.IsPostBack) { using (ResourceDataAccess resourceAccess = new ResourceDataAccess(base.CreateContext())) { switch (BrowseBy) { case BrowseByCriteria.BrowseByYear: if (!IsSecurityAwareControl) { this._yearRange = resourceAccess.GetYear(null); } else if (this.AuthenticatedToken != null) { this._yearRange = resourceAccess.GetYear(this.AuthenticatedToken); } break; case BrowseByCriteria.BrowseByAuthors: if (!IsSecurityAwareControl) { this._authorList = resourceAccess.GetAuthors(null).ToList(); } else if (this.AuthenticatedToken != null) { this._authorList = resourceAccess.GetAuthors(this.AuthenticatedToken).ToList(); } break; case BrowseByCriteria.BrowseByResourceType: this._resTypeList = resourceAccess.GetResourceTypes().ToList(); _resTypeList = CoreHelper.FilterSecurityResourceTypes(_resTypeList).ToList(); break; case BrowseByCriteria.BrowseByCategoryHierarchy: PopulateRootNodeDropDown(); if (!string.IsNullOrEmpty(RootNodeDropDown.SelectedValue)) { this._rootCategoryNode = resourceAccess.GetCategoryNodeWithHierarchy( new Guid(RootNodeDropDown.SelectedValue)); if (IsSecurityAwareControl && _rootCategoryNode != null) { _authorizedCategoryNodeIds = GetAuthorizedCategoryNodes(AuthenticatedToken, _rootCategoryNode, resourceAccess); } } break; } } } }
private void Refresh() { IList <Contact> authors = null; string range = string.Empty; AuthorsListBox.Items.Clear(); //Find selected bucket if (AtoELink.Font.Bold) { range = Constants.A_EAuthors; } else if (FtoJLink.Font.Bold) { range = Constants.F_JAuthors; } else if (KtoOLink.Font.Bold) { range = Constants.K_OAuthors; } else if (PtoTLink.Font.Bold) { range = Constants.P_TAuthors; } else if (UtoZLink.Font.Bold) { range = Constants.U_ZAuthors; } else if (OtherLink.Font.Bold) { range = Constants.OtherAuthors; } int fetchRecordCount = 0; int totalRecords = 0; //Calculate fetched record count if (PageIndex > 0) { fetchRecordCount = PageSize * this.PageIndex; } //Fetch authors using (ResourceDataAccess dataAccess = new ResourceDataAccess(this.CreateContext())) { if (IsSecurityAwareControl) { if (AuthenticatedToken != null) { authors = (IList <Contact>)dataAccess.GetAuthors(this.AuthenticatedToken, range, FilterTextBox.Text.Trim(), PageSize, fetchRecordCount, out totalRecords); } } else { authors = (IList <Contact>)dataAccess.GetAuthors(null, range, FilterTextBox.Text.Trim(), PageSize, fetchRecordCount, out totalRecords); } } //Set Page count. if (totalRecords > 0 && totalRecords > PageSize) { PageCount = Convert.ToInt32(Math.Ceiling((double)totalRecords / PageSize)); } else { PageCount = 0; } //Set status of Next and Previous navigation buttons NextButton.Enabled = PrevButton.Enabled = false; NextButton.Enabled = PageCount == 1 | PageCount <= (PageIndex + 1) ? false : true; PrevButton.Enabled = PageIndex == 0 ? false : true; if (authors != null) { foreach (Contact contact in authors) { string title = contact.Title; contact.Title = HttpUtility.HtmlEncode(CoreHelper.FitString(CoreHelper.GetTitleByResourceType(contact), 30)); Person person = contact as Person; if (person != null) { if (!string.IsNullOrEmpty(person.FirstName) || !string.IsNullOrEmpty(person.LastName)) { contact.Title += "(" + title + ")"; } } } } AuthorsListBox.DataSource = authors; AuthorsListBox.DataBind(); }