private void reportToolStripButton_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; List <CPUser> users = new List <CPUser>(); foreach (ListViewItem item in this.ResultsListView.CheckedItems) { users.Add(item.Tag as CPUser); } UserAccountsReport viewer = new UserAccountsReport() { CampaignSelectionEnabled = false, BeginGetReportData = (BackgroundWorker worker) => { var candidates = CPProviders.DataProvider.GetCandidates(); return(from u in users select ReportableUser.CreateReportableUser(u, candidates.ContainsKey(u.Cid)?candidates[u.Cid].GetFullName(true) : string.Empty)); }, Title = "C-Access User Account Search Results" }; viewer.LocalReport.DataSources.Add(new ReportDataSource("Cfb_CandidatePortal_Security", this.ReportableUserBindingSource)); viewer.LocalReport.ReportEmbeddedResource = "Cfb.Camp.Security.Reports.GenericAccountsReport.rdlc"; viewer.ShowAsMdiSiblingOf(this); this.Cursor = Cursors.Default; }
/// <summary> /// Retrieves a collection of C-Access users. /// </summary> /// <param name="worker">The <see cref="BackgroundWorker"/> that will asynchronously execute the method.</param> /// <returns>A collection of C-Access users in reportable format.</returns> private IEnumerable <ReportableUser> GetCampaignUsers(BackgroundWorker worker) { string cycle = this.Election == null ? null : this.Election.Cycle; // thread-safely get "Show Disabled" selection value bool includeDisabled = (bool)this.Invoke(new Func <bool>(() => { return(this.showDisabledButton.Checked); })); // create collection of users based on campaign selection List <ReportableUser> users = new List <ReportableUser>(); var candidates = this.AllCandidates ? CPProviders.DataProvider.GetCandidates() : new[] { this.Candidate }.ToDictionary(c => c.ID, c => c); foreach (var cid in candidates.Keys) { if (worker != null && worker.CancellationPending) { break; } users.AddRange( from u in CPSecurity.Provider.GetCampaignUsers(cid, cycle, includeDisabled) select ReportableUser.CreateReportableUser(u, candidates[cid].GetFullName(true))); } return(users); }