diff --git a/DBADashGUI/CustomReports/CustomReportView.Designer.cs b/DBADashGUI/CustomReports/CustomReportView.Designer.cs index 1f00d303..0912809f 100644 --- a/DBADashGUI/CustomReports/CustomReportView.Designer.cs +++ b/DBADashGUI/CustomReports/CustomReportView.Designer.cs @@ -80,7 +80,7 @@ private void InitializeComponent() toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { tsExecute, tsRefresh, tsCancel, tsCopy, tsExcel, tsCols, tsConfigure, cboResults, lblSelectResults, tsParams, tsClearFilter, tsTrigger, tsNewWindow }); toolStrip1.Location = new System.Drawing.Point(0, 0); toolStrip1.Name = "toolStrip1"; - toolStrip1.Size = new System.Drawing.Size(1242, 27); + toolStrip1.Size = new System.Drawing.Size(1242, 28); toolStrip1.TabIndex = 1; toolStrip1.Text = "toolStrip1"; // @@ -277,7 +277,7 @@ private void InitializeComponent() tsNewWindow.Image = Properties.Resources.NewWindow_16x; tsNewWindow.ImageTransparentColor = System.Drawing.Color.Magenta; tsNewWindow.Name = "tsNewWindow"; - tsNewWindow.Size = new System.Drawing.Size(29, 24); + tsNewWindow.Size = new System.Drawing.Size(29, 25); tsNewWindow.Text = "Open in new window"; tsNewWindow.Click += TsNewWindow_Click; // @@ -287,7 +287,7 @@ private void InitializeComponent() lnkParams.Font = new System.Drawing.Font("Segoe UI", 16F); lnkParams.Location = new System.Drawing.Point(0, 0); lnkParams.Name = "lnkParams"; - lnkParams.Size = new System.Drawing.Size(824, 258); + lnkParams.Size = new System.Drawing.Size(824, 257); lnkParams.TabIndex = 2; lnkParams.TabStop = true; lnkParams.Text = "Set Parameters"; @@ -300,7 +300,7 @@ private void InitializeComponent() pnlParams.Dock = System.Windows.Forms.DockStyle.Fill; pnlParams.Location = new System.Drawing.Point(0, 0); pnlParams.Name = "pnlParams"; - pnlParams.Size = new System.Drawing.Size(824, 559); + pnlParams.Size = new System.Drawing.Size(824, 558); pnlParams.TabIndex = 3; // // splitContainer2 @@ -320,8 +320,8 @@ private void InitializeComponent() // splitContainer2.Panel2.Controls.Add(lblParamsRequired); splitContainer2.Panel2.RightToLeft = System.Windows.Forms.RightToLeft.No; - splitContainer2.Size = new System.Drawing.Size(824, 559); - splitContainer2.SplitterDistance = 258; + splitContainer2.Size = new System.Drawing.Size(824, 558); + splitContainer2.SplitterDistance = 257; splitContainer2.TabIndex = 4; // // lblParamsRequired @@ -338,7 +338,7 @@ private void InitializeComponent() // splitContainer1 // splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - splitContainer1.Location = new System.Drawing.Point(0, 27); + splitContainer1.Location = new System.Drawing.Point(0, 28); splitContainer1.Name = "splitContainer1"; // // splitContainer1.Panel1 @@ -348,7 +348,7 @@ private void InitializeComponent() // splitContainer1.Panel2 // splitContainer1.Panel2.Controls.Add(pnlParams); - splitContainer1.Size = new System.Drawing.Size(1242, 559); + splitContainer1.Size = new System.Drawing.Size(1242, 558); splitContainer1.SplitterDistance = 414; splitContainer1.TabIndex = 4; // diff --git a/DBADashGUI/CustomReports/CustomReportView.cs b/DBADashGUI/CustomReports/CustomReportView.cs index eee857eb..efd3434c 100644 --- a/DBADashGUI/CustomReports/CustomReportView.cs +++ b/DBADashGUI/CustomReports/CustomReportView.cs @@ -53,7 +53,8 @@ private void SetCellHighlightingRules(DBADashDataGridView dgv) { var customReportResult = Report.CustomReportResults[dgv.ResultSetID]; var columnName = dgv.Columns[dgv.ClickedColumnIndex].DataPropertyName; - customReportResult.CellHighlightingRules.TryGetValue(dgv.Columns[dgv.ClickedColumnIndex].DataPropertyName, + customReportResult.CellHighlightingRules.TryGetValue( + dgv.Columns[dgv.ClickedColumnIndex].DataPropertyName, out var ruleSet); var frm = new CellHighlightingRulesConfig() @@ -61,9 +62,12 @@ private void SetCellHighlightingRules(DBADashDataGridView dgv) ColumnList = dgv.Columns, CellHighlightingRules = new KeyValuePair(columnName, ruleSet.DeepCopy() ?? new CellHighlightingRuleSet() { TargetColumn = columnName }), - CellValue = dgv.ClickedRowIndex >= 0 ? dgv.Rows[dgv.ClickedRowIndex].Cells[dgv.ClickedColumnIndex].Value : null, + CellValue = dgv.ClickedRowIndex >= 0 + ? dgv.Rows[dgv.ClickedRowIndex].Cells[dgv.ClickedColumnIndex].Value + : null, CellValueIsNull = dgv.ClickedRowIndex >= 0 && - dgv.Rows[dgv.ClickedRowIndex].Cells[dgv.ClickedColumnIndex].Value.DBNullToNull() == null + dgv.Rows[dgv.ClickedRowIndex].Cells[dgv.ClickedColumnIndex].Value + .DBNullToNull() == null }; frm.ShowDialog(); @@ -81,7 +85,7 @@ private void SetCellHighlightingRules(DBADashDataGridView dgv) catch (Exception ex) { MessageBox.Show("Error setting highlighting rules: " + ex.Message, "Error", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBoxIcon.Error); } } @@ -122,7 +126,7 @@ private void AddLink_Click(DBADashDataGridView dgv) catch (Exception ex) { MessageBox.Show("Error adding link: " + ex.Message, "Error", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBoxIcon.Error); } } @@ -151,12 +155,14 @@ private void ConvertLocalMenuItem_Click(object sender, DBADashDataGridView dgv) switch (convertLocalMenuItem.Checked) { case true when Report.CustomReportResults[dgv.ResultSetID].DoNotConvertToLocalTimeZone.Contains(name): - if (MessageBox.Show("Convert column from UTC to local time?", "Convert?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; + if (MessageBox.Show("Convert column from UTC to local time?", "Convert?", MessageBoxButtons.YesNo, + MessageBoxIcon.Question) == DialogResult.No) return; Report.CustomReportResults[dgv.ResultSetID].DoNotConvertToLocalTimeZone.Remove(name); break; case false when !Report.CustomReportResults[dgv.ResultSetID].DoNotConvertToLocalTimeZone.Contains(name): - if (MessageBox.Show("Remove UTC to local time zone conversion for this column?", "Convert?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; + if (MessageBox.Show("Remove UTC to local time zone conversion for this column?", "Convert?", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; Report.CustomReportResults[dgv.ResultSetID].DoNotConvertToLocalTimeZone.Add(name); break; } @@ -184,12 +190,13 @@ private void RenameColumnMenuItem_Click(DBADashDataGridView dgv) { newName = dgv.Columns[dgv.ClickedColumnIndex].DataPropertyName; } + dgv.Columns[dgv.ClickedColumnIndex].HeaderText = newName; try { var alias = dgv.Columns.Cast() - .Where(column => column.DataPropertyName != column.HeaderText) - .ToDictionary(column => column.DataPropertyName, column => column.HeaderText); + .Where(column => column.DataPropertyName != column.HeaderText) + .ToDictionary(column => column.DataPropertyName, column => column.HeaderText); Report.CustomReportResults[dgv.ResultSetID].ColumnAlias = alias; Report.Update(); } @@ -221,7 +228,9 @@ private void ConvertDateTimeColsToLocalTimeZone(DataSet ds) if (!Report.CustomReportResults.TryGetValue(i, out var result)) continue; var dt = ds.Tables[i]; var convertCols = dt.Columns.Cast() - .Where(column => column.DataType == typeof(DateTime) && !result.DoNotConvertToLocalTimeZone.Contains(column.ColumnName)) + .Where(column => + column.DataType == typeof(DateTime) && + !result.DoNotConvertToLocalTimeZone.Contains(column.ColumnName)) .Select(column => column.ColumnName).ToList(); if (convertCols.Count > 0) { @@ -274,6 +283,7 @@ public void RefreshData() MessageBoxIcon.Warning); return; } + if (Report is DirectExecutionReport) { RefreshDataMessage(); @@ -283,10 +293,7 @@ public void RefreshData() StartTimer(); cancellationTokenSource = new CancellationTokenSource(); IsMessageInProgress = true; - Task.Run(() => - { - _ = RefreshDataRepository(cancellationTokenSource.Token); - }); + Task.Run(() => { _ = RefreshDataRepository(cancellationTokenSource.Token); }); } } @@ -347,6 +354,13 @@ public async Task RefreshDataRepository(CancellationToken token) } } + public void ShowData(DataSet ds) + { + reportDS = ds; + ShowTable(); + LoadResultsCombo(); + } + private bool IsMessageInProgress { get => tsCancel.Enabled; @@ -1377,9 +1391,12 @@ await MessagingHelper.SendMessageAndProcessReply(msg, context, SetStatus, Proces private void TsNewWindow_Click(object sender, EventArgs e) { var frm = new CustomReportViewer(); + var ctx = context.DeepCopy(); ctx.Report = Report; frm.Context = ctx; + frm.DataSet = reportDS; + frm.CustomParams = customParams; frm.Show(); } } diff --git a/DBADashGUI/CustomReports/CustomReportViewer.cs b/DBADashGUI/CustomReports/CustomReportViewer.cs index 13ecdd5e..ca91fd6b 100644 --- a/DBADashGUI/CustomReports/CustomReportViewer.cs +++ b/DBADashGUI/CustomReports/CustomReportViewer.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Windows.Forms; using DBADash; @@ -16,10 +17,16 @@ public CustomReportViewer() public List CustomParams { get; set; } + public DataSet DataSet; + private async void CustomReportViewer_Load(object sender, EventArgs e) { Text = Context.Report.ReportName; await customReportView1.SetContext(Context, CustomParams); + if(DataSet != null) + { + customReportView1.ShowData(DataSet); + } } } } \ No newline at end of file