Skip to content

Commit

Permalink
SQS Configuration in service config tool
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidWiseman committed Jun 16, 2024
1 parent 2394a4b commit 94f95bd
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 29 deletions.
48 changes: 42 additions & 6 deletions DBADashServiceConfig/ServiceConfig.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 22 additions & 23 deletions DBADashServiceConfig/ServiceConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ private void SetFromJson(string json)
txtSummaryRefreshCron.Text = collectionConfig.SummaryRefreshCron;
chkSummaryRefresh.Checked = !string.IsNullOrEmpty(collectionConfig.SummaryRefreshCron);
chkEnableMessaging.Checked = collectionConfig.EnableMessaging;
txtSQS.Text = collectionConfig.ServiceSQSQueueUrl;
UpdateSummaryCron();
UpdateScanInterval();
SetDgv();
Expand Down Expand Up @@ -1539,15 +1540,7 @@ private void ChkEnableMessaging_CheckedChanged(object sender, EventArgs e)
if (IsSetFromJson) return;
collectionConfig.EnableMessaging = chkEnableMessaging.Checked;
SetJson();
if (chkEnableMessaging.Checked)
{
if (!IsMessagingSupported())
{
MessageBox.Show("The destination connection doesn't support messaging. Messaging requires the destination to support service broker.", "Messaging", MessageBoxButtons.OK, MessageBoxIcon.Warning);
chkEnableMessaging.Checked = false;
return;
}
}

if (chkEnableMessaging.Checked && collectionConfig.SourceConnections.Exists(src => string.IsNullOrEmpty(src.ConnectionID)))
{
if (MessageBox.Show(
Expand All @@ -1559,20 +1552,7 @@ private void ChkEnableMessaging_CheckedChanged(object sender, EventArgs e)
}
}

private bool IsMessagingSupported()
{
try
{
return collectionConfig.DestinationConnection.Type == ConnectionType.SQL &&
!collectionConfig.DestinationConnection.ConnectionInfo.IsAzureDB;
}
catch
{
return false;
}
}

private void PopulateConnectionID()
private void PopulateConnectionID()
{
var errors = new StringBuilder(); // Using StringBuilder instead of StringBuilder() for consistency

Expand Down Expand Up @@ -1615,5 +1595,24 @@ public void ApplyTheme(BaseTheme theme)
lblServerNameWarning.ForeColor = theme.WarningForeColor;
lblServerNameWarning.BackColor = theme.WarningBackColor;
}

private void TxtSQS_Validated(object sender, EventArgs e)
{
if (IsSetFromJson) return;
collectionConfig.ServiceSQSQueueUrl = txtSQS.Text;
SetJson();
}

private void TxtSQS_Validating(object sender, CancelEventArgs e)
{
if (!string.IsNullOrEmpty(txtSQS.Text) && !txtSQS.Text.StartsWith("https://sqs.", StringComparison.OrdinalIgnoreCase))
{
errorProvider1.SetError(txtSQS,"Invalid SQS Url");
}
else
{
errorProvider1.SetError(txtSQS, "");
}
}
}
}

0 comments on commit 94f95bd

Please sign in to comment.