49 lines
2.1 KiB
Markdown
49 lines
2.1 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DataPRO/Modules/InstallerCustomActions/LocalSQLDB/LocalDBPreparation.cs
|
||
|
|
- DataPRO/Modules/InstallerCustomActions/LocalSQLDB/LocalDBPrepare.cs
|
||
|
|
generated_at: "2026-04-17T16:45:09.055203+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "23d0d5081a0df6ea"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Documentation: LocalSQLDB Module
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module provides installer custom actions for preparing LocalDB database files during DataPRO installation. It determines whether the application will use a local or centralized database configuration, and if local, copies database files (`.mdf` and `.ldf`) from a previous installation to the new installation directory. This enables database migration during upgrades while preserving existing data.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### `LocalDBPreparation` (Class)
|
||
|
|
Entry point class invoked by the installer.
|
||
|
|
|
||
|
|
**Method: `Main(string[] args)`**
|
||
|
|
- **Signature:** `static void Main(string[] args)`
|
||
|
|
- **Behavior:** Parses command-line arguments, creates a `LocalDBPrepare` instance, and invokes `PrepareDB()`. On exception, displays a message box with the error message and rethrows an empty `Exception`.
|
||
|
|
|
||
|
|
**Arguments:**
|
||
|
|
- `args[0]` — Target installation directory path (`targetDir`)
|
||
|
|
- `args[1]` — Product version string (parsed into `Version`)
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### `LocalDBPrepare` (Class)
|
||
|
|
Core logic class for database preparation.
|
||
|
|
|
||
|
|
**Constructor: `LocalDBPrepare(string targetDir, Version productVersion)`**
|
||
|
|
- Initializes the instance with the target directory and installing version.
|
||
|
|
|
||
|
|
**Method: `PrepareDB()`**
|
||
|
|
- **Signature:** `public bool PrepareDB()`
|
||
|
|
- **Behavior:**
|
||
|
|
1. Loads configuration from the newly installed executable via `GetNewConfig()`
|
||
|
|
2. Determines `DbType` from configuration (defaults to `DbType.Local` on parse failure)
|
||
|
|
3. Returns `false` if `DbType.Centralized`
|
||
|
|
4. Retrieves `dbName` from configuration (defaults to `Settings.Default.DataPRO`)
|
||
|
|
5. Returns `true` if `dbName` matches `Settings.Default.DataPRO` (case-insensitive)
|
||
|
|
6. Otherwise, copies `.mdf` and `.ldf` files from the most recent previous installation to the new location
|
||
|
|
|