7.7 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||
|---|---|---|---|---|---|---|---|---|
|
2026-04-17T15:53:09.999426+00:00 | zai-org/GLM-5-FP8 | 1 | 759c4bea5bfc5343 |
DBConfiguration Module Documentation
1. Purpose
The DBConfiguration module is a Windows Forms application that serves as a custom action for the DataPRO installer. It provides database configuration and migration capabilities, allowing users to choose between Local, Centralized, or Both database configurations. The module handles SQL Server Express LocalDB instance management (create, start, stop, delete), database attach/detach operations for DataPRO and ISO databases, and supports initializing databases to preset configurations (TSR AIR, Aero, Crash) or migrating data from previous installations.
2. Public Interface
MigrationStatus Class
public class MigrationStatus
A data class representing migration status information.
Properties:
StatusTypes StatusType { get; set; }- The type of status being reportedstring StatusText { get; set; }- The status message text
Nested Enum:
public enum StatusTypes
{
Status,
MigrationStatus,
SourceDb
}
DBConfig Class (Static)
static class DBConfig
The application entry point class.
Methods:
static void Main(string[] args)- Entry point that parses command-line arguments and launches either the configuration UI or TSR AIR initialization. Accepts arguments in order:targetDir,productVersion,noUI,tsrAirGo(boolean). Supports standalone mode with 0 or 2 arguments.
CommonUtilities Class
public class CommonUtilities
Core utility class for database operations.
Constructor:
CommonUtilities()- Initializes the event log with source "DataPRODbMigratorInstaller"
Public Methods:
-
void InitializeDbToTSRAIR(string targetDir)- Initializes the database to TSR AIR settings. Attaches databases, initializes viaDbOperations.Connection.Initialize(), then detaches. -
string Attach(string targetDbDir, string scriptsDir)- Attaches the previous LocalDB database. Logs and sets migration status before callingInstallDatabase(). -
string InstallDatabase(string dBdir, string dbName, string scriptsDir)- Creates, starts a new LocalDB instance, and attaches both DataPRO and ISO databases. SetsDbOperations._usingCentralizedDB = false,DbOperations._usingMSSQL = true, andDbOperations._usingNTLMAuthentication = true. -
string Detach(string sourceDbName, string targetDbDir, string scriptsDir)- Detaches both the specified source database and ISO database. -
MigrationStatus SetMigrationStatus(string migrationStatus, bool output = false)- Sets the current migration status text and returns aMigrationStatusinstance withStatusTypes.MigrationStatus. -
string ProcessSqlLocalDbCommand(string command)- Executes a SQL LocalDB command using the highest version of SQL Server Express LocalDB installed. -
static string AttachOrDetachDatabase(string scriptsDir, string dbName, string sqlDbFileName, string sqlLogFileName, string attachOrDetach)- Executes a batch file to attach or detach a database using sqlcmd.exe. -
static void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)- Event handler for process output, appends to staticsbStringBuilder. -
static string SqlCommandProcessor(string sqlLocalDbExeFileName, string command)- Executes a SQL LocalDB command and returns output/errors. -
static string BatchCommandProcessor(string batchFileName, string dbName, string sqlDbFileName, string sqlLogFileName, string fullSqlcmdPath)- Executes a batch file with database parameters and returns output/errors.
Public Fields:
public static StringBuilder sb- Static StringBuilder shared across process output handling
DBTypeChoice Class (Windows Form)
partial class DBTypeChoice
Configuration UI form for selecting database type and initialization options.
Key UI Controls:
rbLocal,rbCentralized,rbBoth- Radio buttons for database type selectionrbMigrateLocal,rbAero,rbCrash,rbTSRAIR,rbNoneOfTheAbove- Radio buttons for initialization modetbDBHostname,tbDBName,tbDBUser,tbDBPassword- Text fields for centralized database connectioncbUseNTLMAuthentication,cbShowPassword,cbCopyConfig- Checkbox optionstbSourceDB,tbDestinationDB- Text fields for migration paths (conditionally visible)btnOK,btnCancel- Action buttons
3. Invariants
- SQL Server Express LocalDB 2014 is a prerequisite and must be installed unless subsequently uninstalled
- Database name is hardcoded to
"DataPRO"during TSR AIR Go installation and cannot be changed Settings.Default.LocalDbFolder,Settings.Default.ScriptsFolder, and other Settings values must be properly configured- The registry path
SOFTWARE\Microsoft\Microsoft SQL Server\LocalDB\InstalledVersionsmust exist for LocalDB detection - Process output handling uses a shared static
StringBuilderthat is cleared before each operation - The form is displayed as topmost (
TopMost = true) with no control box (ControlBox = false)
4. Dependencies
External Dependencies (from imports):
DTS.Common.Storage- ProvidesConfigInitializationHelperDTS.Common.Enums- ProvidesInitializationTypesDTS.Common.Utilities- Referenced in namespaceDTS.Common.Utils.Database- ProvidesGetODBCToolsPath()Microsoft.Win32- Registry accessSystem.Windows.Forms- UI frameworkSystem.Diagnostics-EventLog,ProcessclassesSystem.Runtime.InteropServices- P/Invoke support
Internal Dependencies:
DbOperations.Connection- Used for database connection settings (DBName,Server,Initialize())DbOperations- Static fields:_usingCentralizedDB,_usingMSSQL,_usingNTLMAuthenticationSettings.Default- Application settings for paths, instance names, messages
Native Dependencies:
kernel32.dll-GetConsoleWindow()functionuser32.dll-ShowWindow()function
5. Gotchas
-
DEBUG mode hardcodes: When compiled with DEBUG defined, the application uses hardcoded test paths (
D:\DTS\DTS.Suite\4.4.309\DataPRO) and version strings. The comment instructs developers to enable this via project properties. -
Console window visibility: The application hides/shows the console window via P/Invoke. In standalone mode (0 args), the window briefly flashes; with 2 args, it remains visible; when called from installer (4 args), it's hidden.
-
Shared static StringBuilder: The
sbfield is static and shared acrossSqlCommandProcessorandBatchCommandProcessor. It's cleared at the start of each call, which could cause issues if multiple operations run concurrently. -
Argument parsing fragility: The
Mainmethod parses arguments by position (index 0-3) rather than named parameters, making the calling convention brittle. -
Registry dependency:
GetSqlServerLocalDBPath()returnsstring.Emptyif the LocalDB registry keys are not found, which causesProcessSqlLocalDbCommandto return an error message but not throw an exception. -
UI element visibility: Several controls (
lblSourceDB,tbSourceDB,btnBrowseSourceDB,lblDestinationDB,tbDestinationDB,btnBrowseDestinationDB) are initialized withVisible = falseand their visibility logic is not shown in the designer file (likely controlled in the code-behind fileDBTypeChoice.cswhich was not provided).