private void OpenReportPreviewWithRecords() { WorkAsync(new WorkAsyncInfo("Loading entities...", (eventargs) => { var qe = new QueryExpression(EntityName); qe.ColumnSet = new ColumnSet(EntitySelectedField, EntityPrimaryField); eventargs.Result = Service.RetrieveMultiple(qe).Entities.ToList(); }) { PostWorkCallBack = (completedargs) => { if (completedargs.Error != null) { MessageBox.Show(completedargs.Error.Message); } else { if (!(completedargs.Result is List <Entity>)) { return; } var records = ((List <Entity>)completedargs.Result); _previewForm = new ReportPreviewForm(this, records); _previewForm.ShowDialog(); } } }); }
private void tsbPreview_Click(object sender, EventArgs e) { if (!Guid.TryParse(tbReportId.Text, out var parsedGuid) || Guid.Empty == new Guid(tbReportId.Text)) { MessageBox.Show( "You must enter a valid Report ID before opening the preview.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var loadWithRecords = cbxPbiFilter.Checked && !string.IsNullOrWhiteSpace(tbPbiTable.Text) && !string.IsNullOrWhiteSpace(tbPbiColumn.Text) && cmbEntityField.SelectedIndex != -1; if (loadWithRecords) { OpenReportPreviewWithRecords(); } else { _previewForm = new ReportPreviewForm(this, null); _previewForm.ShowDialog(); } }