Skip to content

Commit a1e243d

Browse files
committed
Fix for Hidden Instances
Application context now filters the list of instance IDs to exclude hidden instances when required. This avoids the need for a `@ShowHidden` parameter to be included in reports and ensures consistency in the app. #1111
1 parent c380e1d commit a1e243d

File tree

5 files changed

+113
-170
lines changed

5 files changed

+113
-170
lines changed

DBADashGUI/AgentJobs/RunningJobs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private void AddColsToDGV()
6161
public void RefreshData()
6262
{
6363
var dt = GetRunningJobs();
64-
dgvRunningJobs.DataSource = new DataView(dt,PersistedFilter,PersistedSort, DataViewRowState.CurrentRows);
64+
dgvRunningJobs.DataSource = new DataView(dt, PersistedFilter, PersistedSort, DataViewRowState.CurrentRows);
6565
PersistedFilter = null;
6666
PersistedSort = null;
6767
}
@@ -179,7 +179,7 @@ private void DgvRunningJobs_CellContentClick(object sender, DataGridViewCellEven
179179

180180
JobHistoryForm?.Close();
181181
JobHistoryForm = new();
182-
var jobContext = new DBADashContext() { InstanceID = instanceId, JobID = jobId, InstanceIDs = new HashSet<int>() { instanceId }, RegularInstanceIDs = new HashSet<int>() { instanceId }, JobStepID = -1 };
182+
var jobContext = new DBADashContext() { InstanceID = instanceId, JobID = jobId, RegularInstanceIDsWithHidden = new HashSet<int>() { instanceId }, JobStepID = -1 };
183183
JobHistoryForm.ShowSteps = true;
184184
JobHistoryForm.SetContext(jobContext);
185185
JobHistoryForm.FormClosed += delegate { JobHistoryForm = null; };

DBADashGUI/Checks/Summary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ private void ShowUptimeThresholdConfig(int instanceId)
558558

559559
private void ShowCorruptionViewer(string instance, int instanceID)
560560
{
561-
DBADashContext ctx = new() { InstanceIDs = new HashSet<int>() { instanceID }, InstanceID = instanceID, InstanceName = instance };
561+
DBADashContext ctx = new() { RegularInstanceIDsWithHidden = new HashSet<int>() { instanceID }, InstanceID = instanceID, InstanceName = instance };
562562
ShowCorruptionViewer(ctx);
563563
}
564564

DBADashGUI/CommonData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Data;
6+
using System.Linq;
67
using System.Runtime.Caching;
78
using DBADash;
89

@@ -17,6 +18,7 @@ internal static class CommonData
1718
public static void UpdateInstancesList(string tagIDs = "", bool? Active = true, bool? azureDB = null, string searchString = "", string groupByTag = "")
1819
{
1920
Instances = GetInstances(tagIDs, Active, azureDB, searchString, groupByTag);
21+
DBADashContext.HiddenInstanceIDs = Instances.Rows.Cast<DataRow>().Where(r => !r.Field<bool>("ShowInSummary")).Select(r => r.Field<int>("InstanceID")).ToHashSet();
2022
}
2123

2224
public static DataTable GetInstances(string tagIDs = "", bool? Active = true, bool? azureDB = null, string searchString = "", string groupByTag = "")

DBADashGUI/DBADashContext.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@ namespace DBADashGUI
99
{
1010
public class DBADashContext : ICloneable
1111
{
12-
public HashSet<int> InstanceIDs;
13-
public HashSet<int> AzureInstanceIDs;
14-
public HashSet<int> RegularInstanceIDs;
12+
public HashSet<int> InstanceIDs => new HashSet<int>(RegularInstanceIDs.Union(AzureInstanceIDs));
13+
public HashSet<int> AzureInstanceIDs => ShowHiddenInstances ? AzureInstanceIDsWithHidden : new HashSet<int>(AzureInstanceIDsWithHidden.Except(HiddenInstanceIDs));
14+
public HashSet<int> RegularInstanceIDs => ShowHiddenInstances ? RegularInstanceIDsWithHidden : new HashSet<int>(RegularInstanceIDsWithHidden.Except(HiddenInstanceIDs));
15+
16+
public bool ShowHiddenInstances => Common.ShowHidden || InstanceID > 0;
17+
18+
public HashSet<int> RegularInstanceIDsWithHidden = new();
19+
public HashSet<int> AzureInstanceIDsWithHidden = new();
20+
21+
public static HashSet<int> HiddenInstanceIDs = new();
22+
1523
public string InstanceName { get; set; }
1624
public string DatabaseName { get; set; }
1725
public int InstanceID { get; set; }
@@ -41,7 +49,7 @@ public Version ProductVersion
4149
{
4250
get
4351
{
44-
if(_productVersion != null) return _productVersion;
52+
if (_productVersion != null) return _productVersion;
4553
GetAdditionalInfo();
4654
return _productVersion;
4755
}
@@ -51,7 +59,7 @@ public int? ImportAgentID
5159
{
5260
get
5361
{
54-
if(_importAgentID != null || InstanceID <=0) return _importAgentID;
62+
if (_importAgentID != null || InstanceID <= 0) return _importAgentID;
5563
GetAdditionalInfo();
5664
return _importAgentID;
5765
}
@@ -61,7 +69,7 @@ public int? CollectAgentID
6169
{
6270
get
6371
{
64-
if(_collectAgentID != null || InstanceID<=0) return _collectAgentID;
72+
if (_collectAgentID != null || InstanceID <= 0) return _collectAgentID;
6573
GetAdditionalInfo();
6674
return _collectAgentID;
6775
}
@@ -71,7 +79,7 @@ public string ConnectionID
7179
{
7280
get
7381
{
74-
if(_connectionID != null) return _connectionID;
82+
if (_connectionID != null) return _connectionID;
7583
GetAdditionalInfo();
7684
return _connectionID;
7785
}
@@ -81,8 +89,8 @@ public string ConnectionID
8189

8290
private void GetAdditionalInfo()
8391
{
84-
if(InstanceID<=0) return;
85-
var row = CommonData.Instances.Select($"InstanceID={InstanceID}").FirstOrDefault();
92+
if (InstanceID <= 0) return;
93+
var row = CommonData.Instances.Select($"InstanceID={InstanceID}").FirstOrDefault();
8694
if (row == null) return;
8795
_collectAgentID = (int)row["CollectAgentID"];
8896
_importAgentID = (int)row["ImportAgentID"];

0 commit comments

Comments
 (0)