96 lines
6.2 KiB
Markdown
96 lines
6.2 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- Common/DTS.Common/Interface/Database/IDatabaseCopyView.cs
|
||
|
|
- Common/DTS.Common/Interface/Database/IDatabaseSwitchView.cs
|
||
|
|
- Common/DTS.Common/Interface/Database/IDatabaseStatusBarView.cs
|
||
|
|
- Common/DTS.Common/Interface/Database/IDatabaseSwitchViewModel.cs
|
||
|
|
- Common/DTS.Common/Interface/Database/IUserDbRecord.cs
|
||
|
|
- Common/DTS.Common/Interface/Database/IDatabaseCopyViewModel.cs
|
||
|
|
- Common/DTS.Common/Interface/Database/IDatabaseStatusBarViewModel.cs
|
||
|
|
generated_at: "2026-04-17T16:03:43.915495+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "41cfe90dcb841b35"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Database
|
||
|
|
|
||
|
|
### Purpose
|
||
|
|
This module defines the contract layer for database management operations within the DTS system, specifically handling database copying, switching between remote and local databases, and displaying database connection status. It provides the View and ViewModel interfaces that enable a Model-View-ViewModel (MVVM) architecture for database-related UI components, allowing applications to transfer remote databases to local instances and manage connection states.
|
||
|
|
|
||
|
|
### Public Interface
|
||
|
|
|
||
|
|
**IDatabaseCopyView**
|
||
|
|
- `interface IDatabaseCopyView : IBaseView` - Marker interface for database copy views. No members defined.
|
||
|
|
|
||
|
|
**IDatabaseSwitchView**
|
||
|
|
- `interface IDatabaseSwitchView : IBaseView` - Marker interface for database switch views. No members defined.
|
||
|
|
|
||
|
|
**IDatabaseStatusBarView**
|
||
|
|
- `interface IDatabaseStatusBarView : IBaseView` - Marker interface for database status bar views. No members defined.
|
||
|
|
|
||
|
|
**IDatabaseSwitchViewModel**
|
||
|
|
- `interface IDatabaseSwitchViewModel : IBaseViewModel` - ViewModel for transferring remote database to local database.
|
||
|
|
- `IDatabaseSwitchView View { get; set; }` - Associated view instance.
|
||
|
|
- `void Unset()` - Frees memory associated with the ViewModel.
|
||
|
|
- `bool RemoteIsActive { get; }` - Indicates if remote database is currently active.
|
||
|
|
- `string DefaultDbName { get; }` - Default database name.
|
||
|
|
- `void InitializeDbSettings(string defaultDbName, string dbHost, bool ntlmAuthentication, string dbUser, string dbPassword)` - Initializes database connection settings.
|
||
|
|
- `void SwitchRemote()` - Switches to remote database.
|
||
|
|
- `void SwitchLocal()` - Switches to local database.
|
||
|
|
- `string DbHost { get; }` - Database host address.
|
||
|
|
- `bool NTLMAuthentication { get; }` - Whether NTLM authentication is used.
|
||
|
|
- `string DbUser { get; }` - Database username.
|
||
|
|
- `string DbPassword { get; }` - Database password.
|
||
|
|
|
||
|
|
**IUserDbRecord**
|
||
|
|
- `interface IUserDbRecord` - Represents a user record in the database.
|
||
|
|
- `int ID { get; set; }` - Database ID of the user.
|
||
|
|
- `string UserName { get; set; }` - Unique username.
|
||
|
|
- `string DisplayName { get; set; }` - Display string for UI.
|
||
|
|
- `string Password { get; set; }` - Hashed and salted password value (not stored in database).
|
||
|
|
- `short Role { get; set; }` - User role identifier.
|
||
|
|
- `DateTime LastModified { get; set; }` - Last modification timestamp.
|
||
|
|
- `string LastModifiedBy { get; set; }` - Username of last modifier.
|
||
|
|
- `bool LocalOnly { get; set; }` - Deprecated field for local/remote synchronization flag.
|
||
|
|
|
||
|
|
**IDatabaseCopyViewModel**
|
||
|
|
- `interface IDatabaseCopyViewModel : IBaseViewModel` - ViewModel for copying remote database to local database.
|
||
|
|
- `IDatabaseCopyView View { get; set; }` - Associated view instance.
|
||
|
|
- `void Unset()` - Frees memory associated with the ViewModel.
|
||
|
|
- `void CopyDatabase()` - Copies from remote to local database using `DTS.Common.Storage` to determine locations.
|
||
|
|
- `void InitializeState(DbType dbType, string dbName)` - Initializes ViewModel state.
|
||
|
|
- `string DbName { get; }` - Database name.
|
||
|
|
- `IStatusAndProgressBarView OverallProgressBarView { get; }` - Overall progress/status view.
|
||
|
|
- `IStatusAndProgressBarView CurrentTaskProgressBarView { get; }` - Current task progress/status view.
|
||
|
|
- `DbType DatabaseType { get; }` - Type of database being copied.
|
||
|
|
- `bool CopyEnabled { get; }` - Whether copy operation is enabled.
|
||
|
|
- `bool IsCopyVisible { get; set; }` - Visibility state for copy operation.
|
||
|
|
|
||
|
|
**IDatabaseStatusBarViewModel**
|
||
|
|
- `interface IDatabaseStatusBarViewModel : IBaseViewModel` - ViewModel for database status bar UI.
|
||
|
|
- `IDatabaseStatusBarView View { get; set; }` - Associated view instance.
|
||
|
|
- `void Unset()` - Frees memory associated with the ViewModel.
|
||
|
|
- `DbType DatabaseType { get; }` - Current database type (requires `InitializeValues` call first).
|
||
|
|
- `bool RemoteConnected { get; }` - Remote database connection status (requires `InitializeValues` call first).
|
||
|
|
- `string ServerName { get; }` - Server name, not database name (requires `InitializeValues` call first).
|
||
|
|
- `void InitializeValues(DbType dbType, string serverName, bool remoteConnected)` - Sets initial values for display.
|
||
|
|
- `string ActiveDbName { get; }` - Current active database name based on type and connection status.
|
||
|
|
- `Brush BackgroundBrush { get; }` - Background brush for active database name display.
|
||
|
|
|
||
|
|
### Invariants
|
||
|
|
- `IUserDbRecord.UserName` must be unique across all users.
|
||
|
|
- `IUserDbRecord.Password` must be a hashed and salted value; plain text passwords are never stored.
|
||
|
|
- `IDatabaseSwitchViewModel` requires a local database with correct tables and stored procedures already configured before switching/copying operations.
|
||
|
|
- `IDatabaseStatusBarViewModel` properties (`DatabaseType`, `RemoteConnected`, `ServerName`) require `InitializeValues` to be called before their values are meaningful.
|
||
|
|
|
||
|
|
### Dependencies
|
||
|
|
- **Depends on**: `DTS.Common.Base` (IBaseView, IBaseViewModel), `DTS.Common.Enums.Database` (DbType), `System.Windows.Media` (Brush), `System` (DateTime).
|
||
|
|
- **Depended on by**: Concrete implementations of these interfaces (not shown in source).
|
||
|
|
|
||
|
|
### Gotchas
|
||
|
|
- `IUserDbRecord.LocalOnly` is marked as deprecated in the XML documentation; its use should be avoided.
|
||
|
|
- The XML documentation for `IDatabaseSwitchViewModel` and `IDatabaseCopyViewModel` both mention "transferring a remote database to a local database" and "clears the local database" - this is a destructive operation that overwrites local data.
|
||
|
|
- `IDatabaseCopyViewModel.CopyDatabase()` relies on `DTS.Common.Storage` to determine local and remote database locations, but this dependency is not visible in the interface signature.
|
||
|
|
|
||
|
|
---
|