init
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseInitializationScripts/EmbeddedResource.cs
|
||||
generated_at: "2026-04-17T16:46:25.600912+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "95b12383e1ed5dba"
|
||||
---
|
||||
|
||||
# Documentation: EmbeddedResource
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
`EmbeddedResource` is a static utility class that provides methods for loading embedded resources from .NET assemblies. It exists to abstract the complexity of locating and extracting manifest resources by name, supporting partial name matching. This class is part of the `DatabaseInitializationScripts` namespace, indicating its primary role is loading embedded database scripts (likely SQL files) that are packaged within the assembly at compile time.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `public static StreamReader GetStream(System.Reflection.Assembly assembly, string name)`
|
||||
|
||||
**Signature:** `(Assembly, string) -> StreamReader`
|
||||
|
||||
Locates an embedded resource within the specified assembly by performing a partial name match (using `EndsWith`). Returns a `StreamReader` wrapping the resource stream if found, or `null` if no matching resource name exists.
|
||||
|
||||
### `public static string GetString(System.Reflection.Assembly assembly, string name)`
|
||||
|
||||
**Signature:** `(Assembly, string) -> string`
|
||||
|
||||
Retrieves the full text content of an embedded resource from the specified assembly. Internally calls `GetStream`, reads the entire content via `ReadToEnd()`, closes the stream, and returns the string.
|
||||
|
||||
### `public static string GetString(string name)`
|
||||
|
||||
**Signature:** `string -> string`
|
||||
|
||||
Convenience overload that retrieves an embedded resource from the assembly containing the `EmbeddedResource` class itself (via `typeof(EmbeddedResource).Assembly`). Delegates to `GetString(Assembly, string)`.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- The class cannot be instantiated; the private constructor enforces static-only usage.
|
||||
- Resource name matching is always a suffix match (`EndsWith`), not an exact match.
|
||||
- The `GetString` methods assume the resource exists; behavior is undefined (likely `NullReferenceException`) if the resource is not found.
|
||||
- The `GetString(Assembly, string)` method always closes the `StreamReader` before returning.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
**This module depends on:**
|
||||
- `System.IO` — for `StreamReader`
|
||||
- `System.Reflection` — for `Assembly` and manifest resource APIs
|
||||
|
||||
**What depends on this module:**
|
||||
- Not determinable from source alone. However, given the namespace `DatabaseInitializationScripts`, consumers are likely database initialization logic that needs to load SQL scripts or configuration files embedded in the assembly.
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Null return not handled in `GetString`:** `GetStream` returns `null` when no resource matches, but `GetString(Assembly, string)` immediately calls `sr.ReadToEnd()` without null-checking `sr`. This will throw a `NullReferenceException` if the resource name is not found.
|
||||
|
||||
2. **Partial name matching ambiguity:** The use of `EndsWith(name)` means requesting `"schema.sql"` could match multiple resources (e.g., `"folderA.schema.sql"` and `"folderB.schema.sql"`). The method returns the first match found, which depends on `GetManifestResourceNames()` ordering—this ordering is not guaranteed to be deterministic.
|
||||
|
||||
3. **No `using`/dispose pattern:** `GetString(Assembly, string)` uses `sr.Close()` rather than a `using` statement. If `ReadToEnd()` throws an exception, the stream will not be closed.
|
||||
|
||||
4. **Assembly coupling
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseInitializationScripts/Properties/Settings.Designer.cs
|
||||
- DataPRO/Modules/Database/DatabaseInitializationScripts/Properties/AssemblyInfo.cs
|
||||
- DataPRO/Modules/Database/DatabaseInitializationScripts/Properties/Resources.Designer.cs
|
||||
generated_at: "2026-04-17T16:44:43.081982+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "772a1dcffd01e6da"
|
||||
---
|
||||
|
||||
# Documentation: DatabaseInitializationScripts Properties
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module contains the auto-generated Properties layer for the `DatabaseInitializationScripts` assembly within the DataPRO system. The files provided are standard Visual Studio tooling outputs that manage application settings and localized resources. **Note: The actual database initialization logic is not present in these files**—only the infrastructure for settings and resource management is visible. The assembly appears to be a WPF-aware component (indicated by `ThemeInfo` attribute) targeting .NET Framework 4.0+.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `Settings` (class) — `Settings.Designer.cs`
|
||||
```csharp
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
```
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `Default` | `public static Settings Default { get; }` | Returns the synchronized singleton instance of the settings class. Internally casts the result of `ApplicationSettingsBase.Synchronized(new Settings())`. |
|
||||
|
||||
**Visibility:** `internal` — only accessible within the `DatabaseInitializationScripts` assembly.
|
||||
|
||||
---
|
||||
|
||||
### `Resources` (class) — `Resources.Designer.cs`
|
||||
```csharp
|
||||
internal class Resources
|
||||
```
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `ResourceManager` | `internal static global::System.Resources.ResourceManager ResourceManager { get; }` | Lazily initializes and returns a cached `ResourceManager` for the resource bundle `"DatabaseInitializationScripts.Properties.Resources"`. |
|
||||
| `Culture` | `internal static global::System.Globalization.CultureInfo Culture { get; set; }` | Gets or sets the current thread's UI culture for resource lookups. Defaults to `null` if not explicitly set. |
|
||||
|
||||
**Visibility:** `internal` — only accessible within the `DatabaseInitializationScripts` assembly.
|
||||
|
||||
**Constructor:** `internal Resources()` — marked with `SuppressMessageAttribute` for `CA1811:AvoidUncalledPrivateCode`.
|
||||
|
||||
---
|
||||
|
||||
### Assembly Metadata — `AssemblyInfo.cs`
|
||||
|
||||
The following assembly-level attributes are defined:
|
||||
|
||||
| Attribute | Value |
|
||||
|-----------|-------|
|
||||
| `AssemblyTitle` | `"DatabaseInitializationScripts"` |
|
||||
| `AssemblyDescription` | `""` (empty) |
|
||||
| `AssemblyCompany` | `""` (empty) |
|
||||
| `AssemblyProduct` | `"DatabaseInitializationScripts"` |
|
||||
| `AssemblyCopyright` | `"Copyright © 2021"` |
|
||||
| `ComVisible` | `false` |
|
||||
| `AssemblyVersion` | `"1.0.0.0"` |
|
||||
| `AssemblyFileVersion` | `"1.0.0.0"` |
|
||||
| `ThemeInfo` | `ResourceDictionaryLocation.None` (theme-specific), `ResourceDictionaryLocation.SourceAssembly` (generic) |
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **Singleton Pattern for Settings:** The `Settings.Default` property always returns the same synchronized instance created at class initialization time via `ApplicationSettingsBase.Synchronized()`.
|
||||
|
||||
2. **Thread Safety for Settings:** The settings instance is explicitly synchronized via `ApplicationSettingsBase.Synchronized()`, indicating thread-safe access guarantees.
|
||||
|
||||
3. **Lazy Initialization for Resources:** The `ResourceManager` property uses lazy initialization with a null-check pattern; the `ResourceManager` is only instantiated on first access.
|
||||
|
||||
4. **
|
||||
20
docs/ai/DataPRO/Modules/Database/DatabaseMigrationScripts.md
Normal file
20
docs/ai/DataPRO/Modules/Database/DatabaseMigrationScripts.md
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseMigrationScripts/EmbeddedResource.cs
|
||||
generated_at: "2026-04-17T16:29:51.550416+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "5e7d1318be4e002b"
|
||||
---
|
||||
|
||||
# DatabaseMigrationScripts
|
||||
|
||||
### Purpose
|
||||
This module provides a static utility class for extracting embedded resources from .NET assemblies. It is designed to retrieve migration scripts that have been embedded within the assembly as resources, returning them as either `StreamReader` objects or raw strings for consumption by database migration logic.
|
||||
|
||||
### Public Interface
|
||||
|
||||
**Class:** `EmbeddedResource` (static utility class, enforced via private constructor)
|
||||
|
||||
| Method | Signature | Description |
|
||||
|--------|-----------
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseMigrationScripts/Properties/AssemblyInfo.cs
|
||||
generated_at: "2026-04-17T16:29:51.552199+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "cdc10acf4ecfbe8e"
|
||||
---
|
||||
|
||||
# Properties
|
||||
|
||||
### Purpose
|
||||
This module contains the assembly metadata configuration for the `RegionOfInterestChannels` assembly. It is a standard .NET Properties folder that defines assembly identity, versioning information, and COM visibility settings through assembly-level attributes. This module exists to provide build-time configuration and does not contain executable logic.
|
||||
|
||||
### Public Interface
|
||||
No public types or functions are exposed. This module consists entirely of assembly-level attributes:
|
||||
|
||||
- `AssemblyTitle` - Set to "RegionOfInterestChannels"
|
||||
- `AssemblyDescription` - Empty
|
||||
- `AssemblyConfiguration` - Empty
|
||||
- `AssemblyCompany` - Empty
|
||||
- `AssemblyProduct` - Set to "RegionOfInterestChannels"
|
||||
- `AssemblyCopyright` - Set to "Copyright © 2018"
|
||||
- `AssemblyTrademark` - Empty
|
||||
- `AssemblyCulture` - Empty
|
||||
- `ComVisible` - Set to `false`
|
||||
- `Guid` - "bdb25406-3e28-4e62-ae2a-622120f933da"
|
||||
- `AssemblyVersion` - "1.0.0.0"
|
||||
- `AssemblyFileVersion` - "1.0.0.0"
|
||||
|
||||
### Invariants
|
||||
- The assembly version and file version are synchronized at "1.0.0.0".
|
||||
- COM visibility is disabled for all types in this assembly by default.
|
||||
- The GUID "bdb25406-3e28-4e62-ae2a-622120f933da" uniquely identifies this assembly's type library.
|
||||
|
||||
### Dependencies
|
||||
**Imports:**
|
||||
- `System.Reflection`
|
||||
- `System.Runtime.CompilerServices`
|
||||
- `System.Runtime.InteropServices`
|
||||
|
||||
**Dependents:** Unclear from source alone - this is a properties module that would be referenced by any project consuming the RegionOfInterestChannels assembly.
|
||||
|
||||
### Gotchas
|
||||
None identified from source alone. This is standard boilerplate assembly metadata.
|
||||
|
||||
---
|
||||
115
docs/ai/DataPRO/Modules/Database/DatabaseMigrator.md
Normal file
115
docs/ai/DataPRO/Modules/Database/DatabaseMigrator.md
Normal file
@@ -0,0 +1,115 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseMigrator/MigrateDatabase.cs
|
||||
- DataPRO/Modules/Database/DatabaseMigrator/MigrationForm.Designer.cs
|
||||
- DataPRO/Modules/Database/DatabaseMigrator/MigrationForm.cs
|
||||
generated_at: "2026-04-17T15:55:24.798276+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "0f84be859c5d0bf5"
|
||||
---
|
||||
|
||||
# DatabaseMigrator Module Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
The `DatabaseMigrator` module is a Windows Forms application that provides a GUI utility for migrating DataPRO databases between versions. It handles SQL Server Express LocalDB instance management, database backup creation, and version upgrades by orchestrating calls to `DbOperations.Connection.UpgradeVersionsIfNeeded`. The module exists to allow developers or administrators to upgrade database schemas from older versions (minimum version 61) to the current database version.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### MigrateDatabase (static class)
|
||||
|
||||
**`static void Main(string[] args)`**
|
||||
- Entry point for the application. Marked with `[STAThread]`.
|
||||
- Currently ignores command-line arguments (parsing logic is commented out).
|
||||
- Sets `targetDir` to `Environment.CurrentDirectory`.
|
||||
- Initializes visual styles and launches `MigrationForm`.
|
||||
|
||||
### MigrationForm (class, inherits from `Form`)
|
||||
|
||||
**`public MigrationForm(string targetDir)`**
|
||||
- Constructor accepting the target directory path where database files reside.
|
||||
- Initializes the form components and stores `targetDir` in a private readonly field.
|
||||
|
||||
**Event Handlers (private, wired to UI controls):**
|
||||
|
||||
- **`void buttonOK_Click(object sender, EventArgs e)`** - Initiates the migration process. Queries current database version, validates against desired version, creates a backup via `CopyLocalDB()`, and calls `DbOperations.Connection.UpgradeVersionsIfNeeded()`. Displays appropriate warnings if versions match or current version exceeds desired.
|
||||
|
||||
- **`void buttonCancel_Click(object sender, EventArgs e)`** - Closes the form without performing migration.
|
||||
|
||||
- **`void MigrationForm_Load(object sender, EventArgs e)`** - Initializes `numericUpDownDesiredVersion` with minimum 61, maximum `DbOperations.CURRENT_DB_VERSION`, and default value of current version. Checks for existing local database and populates `TbDatabasePath`.
|
||||
|
||||
- **`void numericUpDownDesiredVersion_ValueChanged(object sender, EventArgs e)`** - Updates `_desiredDatabaseVersion` field from the numeric control.
|
||||
|
||||
**Helper Methods (private):**
|
||||
|
||||
- **`int GetDatabaseVersion(bool usingLocalDatabase)`** - Retrieves current database version by calling stored procedure `sp_DbVersionGet`. Returns 0 on failure.
|
||||
|
||||
- **`bool CopyLocalDB()`** - Creates timestamped backup copies of `.mdf` and `_log.ldf` files.
|
||||
|
||||
- **`string InstallDatabase()`** - Configures SQL LocalDB instance by stopping, deleting, creating, and starting `DataPROInstance`, then attaches both DataPRO and ISO databases.
|
||||
|
||||
- **`static string ProcessSqlLocalDbCommand(string command)`** - Executes SQL LocalDB utility commands.
|
||||
|
||||
- **`static string AttachDatabase(string targetDir, string dbName, string sqlDbFileName, string sqlLogFileName)`** - Attaches a database using `sqlcmd.exe` via batch file.
|
||||
|
||||
- **`static string GetSqlServerLocalDBPath()`** - Queries Windows Registry to find the highest installed SQL Server LocalDB version path.
|
||||
|
||||
- **`static string SqlCommandProcessor(string sqlLocalDbExeFileName, string command)`** - Executes a SQL command-line utility and captures output.
|
||||
|
||||
- **`static string BatchCommandProcessor(string batchFileName, string dbName, string sqlDbFileName, string sqlLogFileName, string fullSqlcmdPath)`** - Executes a batch file for database operations.
|
||||
|
||||
- **`bool LocalDataExists()`** - Checks for existence of `DataPRO.mdf` (SQL LocalDB) or `datapro.db` (SQLite) files.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **Version bounds**: `numericUpDownDesiredVersion.Minimum` is always 61; `numericUpDownDesiredVersion.Maximum` is always `DbOperations.CURRENT_DB_VERSION`.
|
||||
- **Database name**: The database name is hardcoded as `"DataPRO"` throughout the module.
|
||||
- **Form behavior**: The form is always `TopMost = true` and centered on screen (`StartPosition = CenterScreen`).
|
||||
- **Backup naming**: Backup files are named with timestamp format `YYYY_MM_DD HH_MM` appended before the file extension.
|
||||
- **SQL LocalDB instance name**: The instance name is `DataPROInstance` (from `Settings.Default.LocalDbDataPROInstance`).
|
||||
- **Migration direction**: Migration only proceeds if `currentDatabaseVersion < _desiredDatabaseVersion`. Equal or greater versions result in user warnings and no migration.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This module depends on:
|
||||
- `System.Windows.Forms` - Windows Forms UI framework
|
||||
- `System.Data.SqlClient` - SQL Server database connectivity
|
||||
- `Microsoft.Win32` - Registry access for SQL LocalDB path detection
|
||||
- `DTS.Common.Storage` - Contains `DbOperations` and `DbOperationsEnum`
|
||||
- `DTS.Common.Enums` - Contains `MigrationResult` enum
|
||||
- `DTS.Common.Utils.Database` - Contains `GetODBCToolsPath()` method
|
||||
- `DatabaseMigrator.Properties.Settings` - Application settings for paths, instance names, and message strings
|
||||
|
||||
### External dependencies (inferred from usage):
|
||||
- `DbOperations.Connection` - Must provide `UpgradeVersionsIfNeeded()`, `Server`, `DBName`, `DbVersion` properties
|
||||
- `DbOperations.CURRENT_DB_VERSION` - Constant defining maximum supported version
|
||||
- `DbOperations.GetSQLCommand()` - Factory method for SQL commands
|
||||
- `MigrationResult` enum with values: `OK`, `ExceptionThrown`, `WarningAllowStreamingModesWasNotMigrated`
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Dead code**: Command-line argument parsing in `Main()` is fully commented out. The application always uses `Environment.CurrentDirectory` regardless of arguments passed.
|
||||
|
||||
2. **Hardcoded values with "fix this" comments**: Multiple locations contain hardcoded values that were intended to be configurable:
|
||||
- `GetDatabaseVersion(true)` - parameter is ignored; `true` is hardcoded
|
||||
- Database name `"DataPRO"` is hardcoded instead of using `tbDBName.Text` (commented out)
|
||||
- `UpgradeVersionsIfNeeded` receives hardcoded strings `"previousdir"`, `"targetdir"`, `"applicationSettings"` with a "fix this" comment
|
||||
|
||||
3. **SQLite support is incomplete**: The code contains commented-out SQLite handling in `GetDatabaseVersion()` and `LocalDataExists()`. The `localSQLiteDataExists` flag is set but never acted upon.
|
||||
|
||||
4. **Silent failures**: `GetDatabaseVersion()` catches all exceptions and returns 0 without logging or rethrowing. This could mask connectivity or schema issues.
|
||||
|
||||
5. **Static mutable state**: The `StringBuilder sb` field is static and reused across `SqlCommandProcessor` and `BatchCommandProcessor`. While it's cleared before each use, this could cause issues if methods are called concurrently.
|
||||
|
||||
6. **Commented-out exit codes**: Multiple `Environment.Exit()` calls are commented out after error conditions, meaning errors display a message box but allow the application to continue.
|
||||
|
||||
7. **Process output handling asymmetry**: `SqlCommandProcessor` and `BatchCommandProcessor` redirect both stdout and stderr, but only stderr is read asynchronously via `OutputHandler`, while stdout is read synchronously with `ReadToEnd()`.
|
||||
@@ -0,0 +1,52 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseMigrator/Properties/AssemblyInfo.cs
|
||||
- DataPRO/Modules/Database/DatabaseMigrator/Properties/Settings.Designer.cs
|
||||
generated_at: "2026-04-17T15:57:31.462614+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "006745ce9f0b7f0a"
|
||||
---
|
||||
|
||||
# DatabaseMigrator Properties Module Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides assembly metadata and strongly-typed configuration settings for the `DatabaseMigrator` component within the DataPRO system. It exists to centralize configuration values related to SQL Server LocalDB instance management, database file paths, migration status messages, and registry locations. The settings defined here support the creation, deletion, starting, and stopping of a LocalDB instance named `DataPROInstance`, as well as handling database version migrations and user-facing status messages.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### AssemblyInfo.cs
|
||||
|
||||
This file contains only assembly-level attributes; it exposes no public types or methods.
|
||||
|
||||
**Assembly Attributes:**
|
||||
- `AssemblyTitle`: `"DatabaseMigrator"`
|
||||
- `AssemblyDescription`: Empty
|
||||
- `AssemblyVersion`: `"1.0.0.0"`
|
||||
- `AssemblyFileVersion`: `"1.0.0.0"`
|
||||
- `Guid`: `"14d2b644-ac7a-4d21-a826-198ee1bc25f7"`
|
||||
- `ComVisible`: `false`
|
||||
|
||||
---
|
||||
|
||||
### Settings.Designer.cs
|
||||
|
||||
**Namespace:** `DatabaseMigrator.Properties`
|
||||
|
||||
**Class:** `Settings` (internal sealed partial, inherits from `System.Configuration.ApplicationSettingsBase`)
|
||||
|
||||
#### Static Property
|
||||
|
||||
| Signature | Description |
|
||||
|-----------|-------------|
|
||||
| `public static Settings Default { get; }` | Returns a synchronized singleton instance of the `Settings` class. |
|
||||
|
||||
#### Application-Scoped Settings (Read-Only)
|
||||
|
||||
| Property Name | Type | Default Value | Purpose |
|
||||
|---------------|------|---------------|---------|
|
||||
| `LocalDbDataPROInstance` | `string` | `"(localdb)\\DataPROInstance"` | Connection string fragment for the LocalDB instance. |
|
||||
| `StopDataProInstance` | `string` | `"stop DataPROInstance"` | Command argument to stop the LocalDB instance. |
|
||||
| `Warning` | `string` | `"Warning"` | Generic warning label. |
|
||||
| `DeleteDataProInstance` | `string` | `"delete DataPROInstance"` | Command argument to delete the LocalDB instance
|
||||
39
docs/ai/DataPRO/Modules/Database/DatabaseServices.md
Normal file
39
docs/ai/DataPRO/Modules/Database/DatabaseServices.md
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseServices/DatabaseServicesModule.cs
|
||||
generated_at: "2026-04-17T16:43:59.359198+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "8adb3f6fd91327f3"
|
||||
---
|
||||
|
||||
# DatabaseServicesModule Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
The `DatabaseServicesModule` is a Prism module that registers database-related views and view models with the Unity dependency injection container. It serves as the composition root for database services UI components within the larger DTS application, specifically belonging to the "Prepare" assembly group. The module also provides assembly-level metadata (name, image, group, region) via custom attributes for use by the main application shell.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `DatabaseServicesModule` Class
|
||||
|
||||
Implements `Prism.Modularity.IModule`.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| Constructor | `DatabaseServicesModule(IUnityContainer unityContainer)` | Accepts an injected Unity container instance and stores it in `_unityContainer`. |
|
||||
| `Initialize` | `void Initialize()` | Registers six type mappings: `IDatabaseCopyView`→`DatabaseCopyView`, `IDatabaseCopyViewModel`→`DatabaseCopyViewModel`, `IDatabaseStatusBarView`→`DatabaseStatusBarView`, `IDatabaseStatusBarViewModel`→`DatabaseStatusBarViewModel`, `IDatabaseSwitchView`→`DatabaseSwitchView`, `IDatabaseSwitchViewModel`→`DatabaseSwitchViewModel`. |
|
||||
| `OnInitialized` | `void OnInitialized(IContainerProvider containerProvider)` | Empty implementation. |
|
||||
| `RegisterTypes` | `void RegisterTypes(IContainerRegistry containerRegistry)` | Calls `Initialize()`. |
|
||||
|
||||
### `DatabaseServicesModuleNameAttribute` Class
|
||||
|
||||
Extends `TextAttribute`. Assembly-level attribute for providing the module name.
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| Constructor | `DatabaseServicesModuleNameAttribute()` | Default constructor. |
|
||||
| Constructor | `DatabaseServicesModuleNameAttribute(string s)` | Overloaded constructor; parameter `s` is unused. |
|
||||
| `AssemblyName` | `override string AssemblyName { get; }` | Returns `AssemblyNames.DatabaseServices.ToString()`. |
|
||||
| `GetAttributeType` | `override Type GetAttributeType()` | Returns `typeof(TextAttribute)`. |
|
||||
| `GetAssemblyName`
|
||||
@@ -0,0 +1,45 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseServices/Converters/DbTypeToVisibilityConverter.cs
|
||||
generated_at: "2026-04-17T16:44:02.991131+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "f33cb579dbf56959"
|
||||
---
|
||||
|
||||
# Documentation: DbTypeToVisibilityConverter
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
`DbTypeToVisibilityConverter` is a WPF `IMultiValueConverter` that determines the visibility of UI elements based on database connection type state. It bridges the view layer (`DatabaseStatusBarView`) and view model layer (`DatabaseStatusBarViewModel`) to conditionally show or hide elements depending on the current `DbType` configuration and connection status. This converter is specifically designed for the database status bar component in the application.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `DbTypeToVisibilityConverter` (class)
|
||||
|
||||
Implements: `IMultiValueConverter`
|
||||
|
||||
#### `Convert(object[] values, Type targetType, object parameter, CultureInfo culture)`
|
||||
|
||||
**Signature:**
|
||||
```csharp
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
```
|
||||
|
||||
**Behavior:** Converts database type information to a `Visibility` value.
|
||||
|
||||
- **`values[0]`**: Expected to be an integer value castable to `DbType` enum (the target database type being evaluated for visibility).
|
||||
- **`values[1]`**: Expected to be a `DatabaseStatusBarView` instance.
|
||||
- **Returns:** `Visibility.Visible` or `Visibility.Collapsed` based on the following logic:
|
||||
- If `view.DataContext` is `null`, returns `Visibility.Collapsed`.
|
||||
- If `vm.DatabaseType` is `DbType.RemoteOnly`: Visible only when `dbType == DbType.RemoteOnly`.
|
||||
- If `vm.DatabaseType` is `DbType.LocalOnly`: Visible only when `dbType == DbType.LocalOnly`.
|
||||
- If `vm.DatabaseType` is `DbType.RemoteLocalHybrid`:
|
||||
- When `vm.RemoteConnected` is `true`: Visible only when `dbType == DbType.RemoteOnly`.
|
||||
- When `vm.RemoteConnected` is `false`: Visible only when `dbType == DbType.RemoteLocalHybrid`.
|
||||
- All other cases: Returns `Visibility.Collapsed`.
|
||||
|
||||
#### `ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)`
|
||||
|
||||
**Signature:**
|
||||
```csharp
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseServices/Properties/Settings.Designer.cs
|
||||
- DataPRO/Modules/Database/DatabaseServices/Properties/AssemblyInfo.cs
|
||||
generated_at: "2026-04-17T16:25:38.816580+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "9c93cde3415ea476"
|
||||
---
|
||||
|
||||
# Properties
|
||||
|
||||
### Purpose
|
||||
This module provides assembly metadata and application settings infrastructure for the `DatabaseServices` assembly. It is a standard .NET properties folder containing auto-generated settings and assembly-level attributes. The settings class is currently minimal, suggesting either a placeholder or that configuration is managed elsewhere in the solution.
|
||||
|
||||
### Public Interface
|
||||
|
||||
**`DatabaseServices.Properties.Settings`** (internal sealed partial class)
|
||||
- Inherits from `global::System.Configuration.ApplicationSettingsBase`
|
||||
- `public static Settings Default { get; }` - Returns a synchronized singleton instance of the settings class. This is the entry point for accessing any application-scoped or user-scoped settings defined for this assembly.
|
||||
|
||||
### Invariants
|
||||
- The `Settings` class is marked `internal sealed`, meaning it cannot be inherited and is only accessible within the `DatabaseServices` assembly.
|
||||
- The `defaultInstance` field is synchronized via `ApplicationSettingsBase.Synchronized()`, ensuring thread-safe access to the singleton.
|
||||
- The settings class is auto-generated (via `SettingsSingleFileGenerator`); manual changes will be overwritten on regeneration.
|
||||
|
||||
### Dependencies
|
||||
- **Depends on**: `System.Configuration.ApplicationSettingsBase` (from `System.Configuration` assembly)
|
||||
- **Depended on by**: Cannot be determined from source alone (internal class, likely used by other classes within DatabaseServices assembly)
|
||||
|
||||
### Gotchas
|
||||
- The `Settings` class contains no actual setting properties beyond the `Default` accessor. This is unusual for a settings file—either settings are defined in an external `.config` file not shown here, or this assembly does not require persistent configuration.
|
||||
- The file is auto-generated by Visual Studio tooling (version 17.10.0.0); do not edit manually.
|
||||
|
||||
---
|
||||
@@ -0,0 +1,48 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseServices/Resources/TranslateExtension.cs
|
||||
- DataPRO/Modules/Database/DatabaseServices/Resources/StringResources.Designer.cs
|
||||
generated_at: "2026-04-17T16:07:59.007705+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "63cd62f694267ff8"
|
||||
---
|
||||
|
||||
# Resources
|
||||
|
||||
### Purpose
|
||||
This module provides localization resources and a XAML markup extension for the `DatabaseServices` assembly. It enables the resolution of user-facing strings (such as status messages regarding database operations) within the UI layer, supporting both direct code access via a resource manager and declarative access within XAML files.
|
||||
|
||||
### Public Interface
|
||||
**Class: `TranslateExtension`**
|
||||
* **Signature:** `public class TranslateExtension : MarkupExtension`
|
||||
* **Constructor:** `TranslateExtension(string key)` - Initializes the extension with the resource key to be looked up.
|
||||
* **Method:** `public override object ProvideValue(IServiceProvider serviceProvider)` - Resolves the `_key` to a localized string. Returns `#stringnotfound#` if the key is null/empty, or `#stringnotfound# <key>` if the lookup fails.
|
||||
|
||||
**Class: `StringResources` (Internal)**
|
||||
* **Signature:** `internal class StringResources`
|
||||
* **Property:** `static ResourceManager ResourceManager` - Provides access to the resource cache.
|
||||
* **Property:** `static CultureInfo Culture` - Gets or sets the current UI culture for resource lookups.
|
||||
* **Static Properties (Localized Strings):**
|
||||
* `string ClearingLocalDb` ("Clearing local db")
|
||||
* `string ConnectedTo` ("Connected to: ")
|
||||
* `string CopyFromRemoteServer` ("Copy from remote server to local")
|
||||
* `string CopyingTable` ("Copying")
|
||||
* `string EnablingConstraints` ("Finishing up")
|
||||
* `string Local` ("Local")
|
||||
* `string Remote` ("Remote")
|
||||
* `string SwitchFileNotFound` ("Could not switch to local - File not found:")
|
||||
* `string SwitchToLocal` ("Switch to local")
|
||||
* `string SwitchToRemote` ("Switch to remote")
|
||||
|
||||
### Invariants
|
||||
* `TranslateExtension` never returns `null`. It guarantees a string return, falling back to error indicators (`#stringnotfound#`) if the resource key is missing.
|
||||
* `StringResources` is an auto-generated class; manual modifications will be overwritten by tooling (Visual Studio/ResGen).
|
||||
|
||||
### Dependencies
|
||||
* **Depends on:** `System`, `System.Windows.Markup`, `System.Resources`, `System.Globalization`.
|
||||
* **Dependents:** Any XAML UI components within the `DatabaseServices` scope that require localized text.
|
||||
|
||||
### Gotchas
|
||||
* The `StringResources` class is marked `internal`, making it inaccessible outside the `DatabaseServices` assembly.
|
||||
* The `Translate
|
||||
72
docs/ai/DataPRO/Modules/Database/DatabaseServices/View.md
Normal file
72
docs/ai/DataPRO/Modules/Database/DatabaseServices/View.md
Normal file
@@ -0,0 +1,72 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseServices/View/DatabaseStatusBarView.xaml.cs
|
||||
- DataPRO/Modules/Database/DatabaseServices/View/DatabaseCopyView.xaml.cs
|
||||
- DataPRO/Modules/Database/DatabaseServices/View/DatabaseSwitchView.xaml.cs
|
||||
generated_at: "2026-04-17T16:36:18.725754+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "9b3e32201b851fc1"
|
||||
---
|
||||
|
||||
# Documentation: Database View Components
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides WPF view components for database-related UI operations within the DatabaseServices namespace. It contains three code-behind classes—`DatabaseStatusBarView`, `DatabaseCopyView`, and `DatabaseSwitchView`—that serve as the visual layer for displaying database status, copying databases, and switching between local/remote database connections respectively. These views implement interfaces from `DTS.Common.Interface.Database` and delegate business logic to associated ViewModels via WPF data binding.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `DatabaseStatusBarView`
|
||||
**Namespace:** `DatabaseServices`
|
||||
**Implements:** `IDatabaseStatusBarView`
|
||||
|
||||
```csharp
|
||||
public DatabaseStatusBarView()
|
||||
```
|
||||
Default constructor. Calls `InitializeComponent()` to load the associated XAML layout. No additional public members are exposed beyond the interface implementation.
|
||||
|
||||
---
|
||||
|
||||
### `DatabaseCopyView`
|
||||
**Namespace:** `DatabaseServices`
|
||||
**Implements:** `IDatabaseCopyView`
|
||||
|
||||
```csharp
|
||||
public DatabaseCopyView()
|
||||
```
|
||||
Default constructor. Calls `InitializeComponent()` to load the associated XAML layout.
|
||||
|
||||
```csharp
|
||||
private void Copy_Click(object sender, RoutedEventArgs e)
|
||||
```
|
||||
Event handler for the copy button click. Casts `sender` to `Control`, retrieves the `DataContext` as `IDatabaseCopyViewModel`, and invokes `vm.CopyDatabase()`.
|
||||
|
||||
---
|
||||
|
||||
### `DatabaseSwitchView`
|
||||
**Namespace:** `DatabaseServices`
|
||||
**Implements:** `IDatabaseSwitchView`
|
||||
|
||||
```csharp
|
||||
public DatabaseSwitchView()
|
||||
```
|
||||
Default constructor. Calls `InitializeComponent()` to load the associated XAML layout.
|
||||
|
||||
```csharp
|
||||
private void SwitchToLocal_Click(object sender, RoutedEventArgs e)
|
||||
```
|
||||
Event handler for switching to local database. Casts `sender` to `Control`, retrieves the `DataContext` as `IDatabaseSwitchViewModel`, and invokes `vm.SwitchLocal()`.
|
||||
|
||||
```csharp
|
||||
private void SwitchToRemote_Click(object sender, RoutedEventArgs e)
|
||||
```
|
||||
Event handler for switching to remote database. Casts `sender` to `Control`, retrieves the `DataContext` as `IDatabaseSwitchViewModel`, and invokes `vm.SwitchRemote()`.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **DataContext Contract:** `DatabaseCopyView` requires its `DataContext` to be an instance of `IDatabaseCopyViewModel`. `DatabaseSwitchView` requires its `DataContext` to be an instance of `IDatabaseSwitchViewModel`. Event handlers will fail with invalid
|
||||
193
docs/ai/DataPRO/Modules/Database/DatabaseServices/ViewModel.md
Normal file
193
docs/ai/DataPRO/Modules/Database/DatabaseServices/ViewModel.md
Normal file
@@ -0,0 +1,193 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Database/DatabaseServices/ViewModel/DatabaseStatusBarViewModel.cs
|
||||
- DataPRO/Modules/Database/DatabaseServices/ViewModel/DatabaseSwitchViewModel.cs
|
||||
- DataPRO/Modules/Database/DatabaseServices/ViewModel/DatabaseCopyViewModel.cs
|
||||
generated_at: "2026-04-17T15:41:29.202299+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "f011aeacca70c45c"
|
||||
---
|
||||
|
||||
# Database ViewModels Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module provides three MVVM ViewModels for database management within the `DatabaseServices` namespace:
|
||||
|
||||
- **DatabaseStatusBarViewModel**: Manages the database status bar UI, displaying the active database connection (Local vs Remote) and providing visual feedback (red background when disconnected from remote in hybrid mode).
|
||||
- **DatabaseSwitchViewModel**: Handles switching between local and remote database connections, including connection testing, authentication setup, and forcing user re-login after database switches.
|
||||
- **DatabaseCopyViewModel**: Implements database copy functionality to synchronize a remote database to a local database, including table-by-table copying with identity column handling and constraint management.
|
||||
|
||||
All three ViewModels follow the Prism MVVM pattern, use MEF for dependency injection with shared creation policy, and integrate with the application's event aggregation system.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### DatabaseStatusBarViewModel
|
||||
|
||||
**Implements:** `IDatabaseStatusBarViewModel`
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `View` | `public IDatabaseStatusBarView View { get; set; }` | The associated view instance; DataContext is set to `this` in constructor. |
|
||||
| `DatabaseType` | `public DbType DatabaseType { get; private set; }` | The configured database type (LocalOnly, RemoteOnly, RemoteLocalHybrid). |
|
||||
| `ServerName` | `public string ServerName { get; private set; }` | Name of the database server; "Local" when not remote connected. |
|
||||
| `RemoteConnected` | `public bool RemoteConnected => DbOperations._usingCentralizedDB;` | Indicates if currently connected to centralized/remote database. |
|
||||
| `ActiveDbName` | `public string ActiveDbName { get; }` | Computed display name based on DatabaseType and connection state. Returns localized "Local" string or server name. |
|
||||
| `BackgroundBrush` | `public Brush BackgroundBrush { get; }` | Returns `Brushes.Red` when hybrid mode is disconnected from remote; otherwise `Brushes.Transparent`. |
|
||||
| `InitializeValues` | `public void InitializeValues(DbType dbType, string serverName, bool remoteConnected)` | Initializes the ViewModel's state and triggers PropertyChanged for `ActiveDbName` and `BackgroundBrush`. |
|
||||
| `OnPropertyChanged` | `public void OnPropertyChanged(string propertyName)` | Raises the `PropertyChanged` event. |
|
||||
| `NotificationRequest` | `public InteractionRequest<Notification> NotificationRequest { get; }` | Prism interaction request for notifications. |
|
||||
| `ConfirmationRequest` | `public InteractionRequest<Confirmation> ConfirmationRequest { get; }` | Prism interaction request for confirmations. |
|
||||
| `IsBusy` | `public bool IsBusy { get; set; }` | Bound to busy indicator state. |
|
||||
| `IsMenuIncluded` | `public bool IsMenuIncluded { get; set; }` | Controls menu visibility. |
|
||||
| `IsNavigationIncluded` | `public bool IsNavigationIncluded { get; set; }` | Controls navigation visibility. |
|
||||
| `IsDirty` | `public bool IsDirty { get; private set; }` | Tracks unsaved changes state. |
|
||||
| `Cleanup` / `CleanupAsync` | `public void Cleanup()` / `public Task CleanupAsync()` | No-op cleanup methods. |
|
||||
| `Initialize` overloads | `void Initialize()`, `void Initialize(object)`, `void Initialize(object, object)` | No-op initialization methods. |
|
||||
| `InitializeAsync` overloads | `Task InitializeAsync()`, `Task InitializeAsync(object)` | Return `Task.CompletedTask`. |
|
||||
| `Activated` | `public void Activated()` | No-op activation method. |
|
||||
| `Unset` | `public void Unset()` | No-op unset method. |
|
||||
|
||||
**Constructor:**
|
||||
```csharp
|
||||
public DatabaseStatusBarViewModel(
|
||||
IDatabaseStatusBarView view,
|
||||
IRegionManager regionManager,
|
||||
IEventAggregator eventAggregator,
|
||||
IUnityContainer unityContainer)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### DatabaseSwitchViewModel
|
||||
|
||||
**Implements:** `IDatabaseSwitchViewModel`
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `View` | `public IDatabaseSwitchView View { get; set; }` | The associated view instance. |
|
||||
| `DefaultDbName` | `public string DefaultDbName { get; private set; }` | Default database name for connections. |
|
||||
| `DbHost` | `public string DbHost { get; private set; }` | Remote database host address. |
|
||||
| `NTLMAuthentication` | `public bool NTLMAuthentication { get; private set; }` | Whether NTLM authentication is enabled. |
|
||||
| `DbUser` | `public string DbUser { get; private set; }` | Database username for SQL authentication. |
|
||||
| `DbPassword` | `public string DbPassword { get; private set; }` | Database password for SQL authentication. |
|
||||
| `RemoteIsActive` | `public bool RemoteIsActive => DbOperations._usingCentralizedDB;` | Indicates if remote database is currently active. |
|
||||
| `SwitchRemote` | `public void SwitchRemote()` | Switches to remote database connection. Tests connection, falls back to local on failure, publishes `DbStatusEvent` and `LogoutUserEvent`. |
|
||||
| `SwitchLocal` | `public void SwitchLocal()` | Switches to local database. Validates local files exist, publishes status events and forces logout. |
|
||||
| `InitializeDbSettings` | `public void InitializeDbSettings(string defaultDbName, string dbHost, bool ntlmAuthentication, string dbUser, string dbPassword)` | Stores database connection settings for use by switch methods. |
|
||||
| `IsBusy`, `IsMenuIncluded`, `IsNavigationIncluded`, `IsDirty` | Same as DatabaseStatusBarViewModel | Standard ViewModel properties. |
|
||||
| `NotificationRequest`, `ConfirmationRequest` | Same as DatabaseStatusBarViewModel | Prism interaction requests. |
|
||||
| Lifecycle methods | Same pattern as DatabaseStatusBarViewModel | `Cleanup`, `CleanupAsync`, `Initialize*`, `Activated`, `Unset` are no-ops or return completed tasks. |
|
||||
|
||||
**Constructor:**
|
||||
```csharp
|
||||
public DatabaseSwitchViewModel(
|
||||
IDatabaseSwitchView view,
|
||||
IRegionManager regionManager,
|
||||
IEventAggregator eventAggregator,
|
||||
IUnityContainer unityContainer)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### DatabaseCopyViewModel
|
||||
|
||||
**Implements:** `IDatabaseCopyViewModel`
|
||||
|
||||
| Member | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `View` | `public IDatabaseCopyView View { get; set; }` | The associated view instance. |
|
||||
| `DatabaseType` | `public DTS.Common.Enums.Database.DbType DatabaseType { get; private set; }` | Current database type configuration. |
|
||||
| `DbName` | `public string DbName { get; private set; }` | Name of the database being copied. |
|
||||
| `CopyEnabled` | `public bool CopyEnabled => DatabaseType == DbType.RemoteLocalHybrid && DbOperations._usingCentralizedDB;` | Copy is only enabled in hybrid mode when connected to remote. |
|
||||
| `IsCopyVisible` | `public bool IsCopyVisible { get; set; }` | Controls visibility of copy UI; defaults to `true`. |
|
||||
| `OverallProgressBarView` | `public IStatusAndProgressBarView OverallProgressBarView { get; private set; }` | Progress bar view for overall copy progress. |
|
||||
| `CurrentTaskProgressBarView` | `public IStatusAndProgressBarView CurrentTaskProgressBarView { get; private set; }` | Progress bar view for current table copy progress. |
|
||||
| `CopyDatabase` | `public void CopyDatabase()` | Initiates async database copy via `Task.Run(() => CopyFunc())`. Publishes `AppStatusEvent.Busy`. |
|
||||
| `InitializeState` | `public void InitializeState(DTS.Common.Enums.Database.DbType dbType, string dbName)` | Sets up initial state, resets progress bars, triggers `OnPropertyChanged("CopyEnabled")`. |
|
||||
| `InitializeAsync` | `public Task InitializeAsync()` | Resolves and initializes progress bar views via Unity container. |
|
||||
| `_allDBTables` | `private static readonly List<string>` | Hardcoded list of 73 database table names to copy. |
|
||||
| `_tablesWithIdentities` | `private static readonly HashSet<string>` | Hardcoded set of 48 table names that have identity columns. |
|
||||
| `MAX_BATCH_SIZE` | `private const int MAX_BATCH_SIZE = 20;` | Maximum rows per batch insert to avoid SQL Server's 2100 parameter limit. |
|
||||
| `CurrentTaskBar` | `private const string CurrentTaskBar = "CurrentTaskStatus";` | Identifier for current task progress bar. |
|
||||
| `OverallTaskBar` | `private const string OverallTaskBar = "OverallStatus";` | Identifier for overall progress bar. |
|
||||
| Lifecycle methods | Same pattern as other ViewModels | Standard no-op implementations except `InitializeAsync`. |
|
||||
|
||||
**Constructor:**
|
||||
```csharp
|
||||
public DatabaseCopyViewModel(
|
||||
IDatabaseCopyView view,
|
||||
IRegionManager regionManager,
|
||||
IEventAggregator eventAggregator,
|
||||
IUnityContainer unityContainer)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
### DatabaseStatusBarViewModel
|
||||
- `ActiveDbName` returns empty string for unhandled `DbType` values (not LocalOnly, RemoteOnly, or RemoteLocalHybrid).
|
||||
- `BackgroundBrush` only returns `Brushes.Red` for `DbType.RemoteLocalHybrid` when `RemoteConnected` is false; all other cases return `Brushes.Transparent`.
|
||||
- `RemoteConnected` is directly coupled to `DbOperations._usingCentralizedDB` static field.
|
||||
|
||||
### DatabaseSwitchViewModel
|
||||
- `SwitchRemote` always publishes `LogoutUserEvent` with reason `DatabaseSwitch` on success.
|
||||
- `SwitchRemote` calls `SwitchLocal()` as fallback if connection test fails.
|
||||
- `SwitchLocal` checks for local database file existence before proceeding; returns early with error if files not found.
|
||||
- `SwitchLocal` always publishes `LogoutUserEvent` with reason `DatabaseSwitch` on success.
|
||||
|
||||
### DatabaseCopyViewModel
|
||||
- `CopyEnabled` is only true when `DatabaseType == DbType.RemoteLocalHybrid` AND `DbOperations._usingCentralizedDB` is true.
|
||||
- Copy operation disables constraints before copying and re-enables them after.
|
||||
- If copy fails, attempts to restore from backup via `DTS.Common.Storage.DatabaseServices.RestoreLocalDatabase(DbName)`.
|
||||
- Batch inserts are limited to `MAX_BATCH_SIZE` (20 rows) or when parameter count would exceed 2100.
|
||||
- Identity insert is enabled/disabled per batch for tables in `_tablesWithIdentities`.
|
||||
- `DASId` columns with value 0 are explicitly set to NULL in the Channels table after copy.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### External Dependencies (from imports)
|
||||
- **Prism Framework:** `Prism.Events`, `Prism.Regions`, `Prism.Commands` - Event aggregation, region management, commanding
|
||||
- **Unity Container:** `Unity` - Dependency injection container
|
||||
- **MEF:** `System.ComponentModel.Composition` - Part creation policy
|
||||
- **WPF:** `System.Windows.Media`, `System.ComponentModel` - UI types, INotifyPropertyChanged
|
||||
- **DTS.Common.Enums.Database:** `DbType` enum
|
||||
- **DTS.Common.Events:** `RaiseNotification`, `BusyIndicatorChangeNotification`, `AppStatusEvent`, `AppStatusArg`, `ProgressBarEvent`, `ProgressBarEventArg`, `PageErrorEvent`, `PageErrorArg`
|
||||
- **DTS.Common.Events.Database:** `DbStatusEvent`, `DbStatusArg`, `LogoutUserEvent`, `LogoutUserArg`
|
||||
- **DTS.Common.Interactivity:** `InteractionRequest<T>`, `Notification`, `Confirmation`, `NotificationContentEventArgs`
|
||||
- **DTS.Common.Interface.Database:** `IDatabaseStatusBarView`, `IDatabaseSwitchView`, `IDatabaseCopyView`, `IDatabaseStatusBarViewModel`, `IDatabaseSwitchViewModel`, `IDatabaseCopyViewModel`
|
||||
- **DTS.Common.Interface:** `IStatusAndProgressBarView`, `IStatusAndProgressBarViewModel`
|
||||
- **DTS.Common.Storage:** `DbOperations`, `LocalOnlyOperations`, `DatabaseServices` (static class)
|
||||
- **DTS.Common.Utilities.Logging:** `APILogger`
|
||||
- **DTS.Common.Utils.Database:** `CheckLocalDatabaseFilesExist`
|
||||
- **Resources.StringResources:** Localized strings
|
||||
|
||||
### Static Couplings
|
||||
- `DbOperations._usingCentralizedDB` - Static field accessed directly by all three ViewModels
|
||||
- `DbOperations.Connection.Server` - Server name accessed directly
|
||||
- `DbOperations.GetSQLCommand()` - SQL command creation for remote DB
|
||||
- `LocalOnlyOperations.GetSQLCommand()` - SQL command creation for local DB
|
||||
- `LocalOnlyOperations.BeginStatement`, `LocalOnlyOperations.CommitStatement` - Transaction statements
|
||||
- `LocalOnlyOperations.CreateParam()` - Parameter creation helper
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
### XML Documentation Mismatch
|
||||
- `DatabaseStatusBarViewModel` and `DatabaseSwitchViewModel` XML summary comments state "this class handles DatabaseCopy functionality" which is incorrect (copy-paste error from `DatabaseCopyViewModel`).
|
||||
|
||||
### Parameterless Constructors
|
||||
- All three ViewModels have public parameterless constructors in addition to the DI constructor. The parameterless constructors perform no initialization, which could lead to null reference exceptions if used incorrectly.
|
||||
|
||||
### Static Table Lists
|
||||
- `DatabaseCopyViewModel._allDBTables` and `_tablesWithIdentities` are hardcoded lists. Any database schema changes require code updates. Comment in source states: "I'd like to do this through SQL, but ran into problems".
|
||||
|
||||
### Thread Safety Concerns
|
||||
- `DatabaseCopyViewModel.CopyDatabase()` uses `Task.Run()` to execute `CopyFunc()` on a background thread, but `SetStatus()` publishes UI events directly. The `BusyIndicatorChangeNotification` subscription in `DatabaseStatusBarViewModel` uses `ThreadOption.PublisherThread` with `keepSubscriberReferenceAlive: true
|
||||
Reference in New Issue
Block a user