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
13 changes: 13 additions & 0 deletions Installer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static async Task<int> Main(string[] args)
*/
bool automatedMode = args.Length > 0;
bool reinstallMode = args.Any(a => a.Equals("--reinstall", StringComparison.OrdinalIgnoreCase));
bool resetSchedule = args.Any(a => a.Equals("--reset-schedule", StringComparison.OrdinalIgnoreCase));
bool trustCert = args.Any(a => a.Equals("--trust-cert", StringComparison.OrdinalIgnoreCase));

/*Parse encryption option (default: Mandatory)*/
Expand All @@ -103,6 +104,7 @@ static async Task<int> Main(string[] args)
/*Filter out option flags to get positional arguments*/
var filteredArgs = args
.Where(a => !a.Equals("--reinstall", StringComparison.OrdinalIgnoreCase))
.Where(a => !a.Equals("--reset-schedule", StringComparison.OrdinalIgnoreCase))
.Where(a => !a.Equals("--trust-cert", StringComparison.OrdinalIgnoreCase))
.Where(a => !a.StartsWith("--encrypt=", StringComparison.OrdinalIgnoreCase))
.ToArray();
Expand Down Expand Up @@ -167,6 +169,7 @@ Automated mode with command-line arguments
Console.WriteLine();
Console.WriteLine("Options:");
Console.WriteLine(" --reinstall Drop existing database and perform clean install");
Console.WriteLine(" --reset-schedule Reset collection schedule to recommended defaults");
Console.WriteLine(" --encrypt=<level> Connection encryption: optional (default), mandatory, strict");
Console.WriteLine(" --trust-cert Trust server certificate without validation (default: require valid cert)");
return ExitCodes.InvalidArguments;
Expand Down Expand Up @@ -610,6 +613,16 @@ Connection pooling handles the underlying socket reuse
{
string sqlContent = await File.ReadAllTextAsync(sqlFile);

/*
Reset schedule to defaults if requested — truncate before the
INSERT...WHERE NOT EXISTS re-populates with current recommended values
*/
if (resetSchedule && fileName.StartsWith("04_", StringComparison.Ordinal))
{
sqlContent = "TRUNCATE TABLE config.collection_schedule;\nGO\n" + sqlContent;
Console.Write("(resetting schedule) ");
}

/*
Remove SQLCMD directives (:r includes) as we're executing files directly
*/
Expand Down
6 changes: 6 additions & 0 deletions InstallerGui/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@
Margin="0,0,0,10"
Foreground="{DynamicResource ForegroundBrush}"/>

<!-- Reset Schedule Checkbox -->
<CheckBox x:Name="ResetScheduleCheckBox"
Content="Reset collection schedule to recommended defaults"
Margin="0,0,0,10"
Foreground="{DynamicResource ForegroundBrush}"/>

<!-- Validation Checkbox -->
<CheckBox x:Name="ValidationCheckBox"
Content="Run validation after install (recommended)"
Expand Down
2 changes: 2 additions & 0 deletions InstallerGui/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,12 @@ private async void Install_Click(object sender, RoutedEventArgs e)
Execute installation
Community dependencies install automatically before validation (98_validate)
*/
bool resetSchedule = ResetScheduleCheckBox.IsChecked == true;
_installationResult = await InstallationService.ExecuteInstallationAsync(
_connectionString,
_sqlFiles,
isCleanInstall,
resetSchedule,
progress,
preValidationAction: async () =>
{
Expand Down
12 changes: 12 additions & 0 deletions InstallerGui/Services/InstallationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ public static async Task<InstallationResult> ExecuteInstallationAsync(
string connectionString,
List<string> sqlFiles,
bool cleanInstall,
bool resetSchedule = false,
IProgress<InstallationProgress>? progress = null,
Func<Task>? preValidationAction = null,
CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -410,6 +411,17 @@ Execute SQL files
{
string sqlContent = await File.ReadAllTextAsync(sqlFile, cancellationToken).ConfigureAwait(false);

/*Reset schedule to defaults if requested*/
if (resetSchedule && fileName.StartsWith("04_", StringComparison.Ordinal))
{
sqlContent = "TRUNCATE TABLE config.collection_schedule;\nGO\n" + sqlContent;
progress?.Report(new InstallationProgress
{
Message = "Resetting schedule to recommended defaults...",
Status = "Info"
});
}

/*Remove SQLCMD directives*/
sqlContent = SqlCmdDirectivePattern.Replace(sqlContent, "");

Expand Down
Loading