Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,9 @@ private async Task ShowConnectionDialogAsync()
_selectedDatabase = dialog.ResultDatabase;
_connectionString = _serverConnection.GetConnectionString(_credentialService, _selectedDatabase);

ServerLabel.Text = _serverConnection.ServerName;
ServerLabel.Text = _serverConnection.ApplicationIntentReadOnly
? $"{_serverConnection.ServerName} (Secondary)"
: _serverConnection.ServerName;
ServerLabel.Foreground = Brushes.LimeGreen;
ConnectButton.Content = "Reconnect";

Expand Down
25 changes: 17 additions & 8 deletions src/PlanViewer.App/Dialogs/ConnectionDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,23 @@
</StackPanel>

<!-- Connection Options -->
<StackPanel Grid.Row="6" Orientation="Horizontal" Margin="0,0,0,12" Spacing="16">
<CheckBox x:Name="TrustCertBox" Content="Trust server certificate"
Foreground="{DynamicResource ForegroundBrush}" FontSize="12"/>
<ComboBox x:Name="EncryptBox" Height="28" FontSize="11" Width="140">
<ComboBoxItem Content="Encrypt: Mandatory" Tag="Mandatory" IsSelected="True"/>
<ComboBoxItem Content="Encrypt: Optional" Tag="Optional"/>
<ComboBoxItem Content="Encrypt: Strict" Tag="Strict"/>
</ComboBox>
<StackPanel Grid.Row="6" Margin="0,0,0,12" Spacing="8">
<StackPanel Orientation="Horizontal" Spacing="16">
<CheckBox x:Name="TrustCertBox" Content="Trust server certificate"
Foreground="{DynamicResource ForegroundBrush}" FontSize="12"/>
<ComboBox x:Name="EncryptBox" Height="28" FontSize="11" Width="140">
<ComboBoxItem Content="Encrypt: Mandatory" Tag="Mandatory" IsSelected="True"/>
<ComboBoxItem Content="Encrypt: Optional" Tag="Optional"/>
<ComboBoxItem Content="Encrypt: Strict" Tag="Strict"/>
</ComboBox>
</StackPanel>

<!-- Read-Only Intent -->
<CheckBox x:Name="ReadOnlyIntentCheckBox"
Content="Read-only intent (for AG listeners and readable replicas - including Query Store on secondary replicas)"
Foreground="{DynamicResource ForegroundBrush}" Margin="0,0,0,6"
ToolTip.Tip="Sets ApplicationIntent=ReadOnly. Required when connecting via an AG listener or Azure failover group endpoint to route to a readable secondary (including Query Store on secondary replicas)."
FontSize="12"/>
</StackPanel>

<!-- Test Connection + Status -->
Expand Down
9 changes: 7 additions & 2 deletions src/PlanViewer.App/Dialogs/ConnectionDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private void ApplySavedConnection(ServerConnection saved)
}

TrustCertBox.IsChecked = saved.TrustServerCertificate;
ReadOnlyIntentCheckBox.IsChecked = saved.ApplicationIntentReadOnly;

// Load stored credentials
var cred = _credentialService.GetCredential(saved.Id);
Expand Down Expand Up @@ -217,7 +218,8 @@ private ServerConnection BuildServerConnection()
DisplayName = serverName,
AuthenticationType = GetSelectedAuthType(),
TrustServerCertificate = TrustCertBox.IsChecked == true,
EncryptMode = GetSelectedEncryptMode()
EncryptMode = GetSelectedEncryptMode(),
ApplicationIntentReadOnly = ReadOnlyIntentCheckBox.IsChecked == true
};
}

Expand Down Expand Up @@ -249,7 +251,10 @@ private string BuildConnectionString(ServerConnection connection)
"Optional" => SqlConnectionEncryptOption.Optional,
"Strict" => SqlConnectionEncryptOption.Strict,
_ => SqlConnectionEncryptOption.Mandatory
}
},
ApplicationIntent = connection.ApplicationIntentReadOnly
? ApplicationIntent.ReadOnly
: ApplicationIntent.ReadWrite
};

switch (connection.AuthenticationType)
Expand Down
1 change: 1 addition & 0 deletions src/PlanViewer.App/Services/ConnectionStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void AddOrUpdate(ServerConnection connection)
existing.AuthenticationType = connection.AuthenticationType;
existing.EncryptMode = connection.EncryptMode;
existing.TrustServerCertificate = connection.TrustServerCertificate;
existing.ApplicationIntentReadOnly = connection.ApplicationIntentReadOnly;
existing.DisplayName = connection.DisplayName;
existing.LastConnected = DateTime.Now;
}
Expand Down
6 changes: 5 additions & 1 deletion src/PlanViewer.Core/Models/ServerConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ServerConnection
public bool IsFavorite { get; set; }
public string EncryptMode { get; set; } = "Mandatory";
public bool TrustServerCertificate { get; set; } = false;
public bool ApplicationIntentReadOnly { get; set; } = false;

[JsonIgnore]
public string AuthenticationDisplay => AuthenticationType switch
Expand All @@ -39,7 +40,10 @@ public string GetConnectionString(ICredentialService credentialService, string?
"Optional" => SqlConnectionEncryptOption.Optional,
"Strict" => SqlConnectionEncryptOption.Strict,
_ => SqlConnectionEncryptOption.Mandatory
}
},
ApplicationIntent = ApplicationIntentReadOnly
? ApplicationIntent.ReadOnly
: ApplicationIntent.ReadWrite
};

if (!string.IsNullOrEmpty(databaseName))
Expand Down
Loading