8.8 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T02:17:57.680551+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 142a1b67b74ee9e9 |
Database
Documentation: Database View/ViewModel Interfaces
1. Purpose
This module defines a set of interfaces for database-related UI components in a Model-View-ViewModel (MVVM) architecture. It provides contracts for views and viewmodels that manage database connection status, database switching (local ↔ remote), and database copying operations. These interfaces decouple UI presentation logic from implementation details, enabling modular UI development and testability. The interfaces are part of the DTS.Common.Interface.Database namespace and extend base contracts (IBaseView, IBaseViewModel) to integrate with the broader DTS framework.
2. Public Interface
Interfaces (View Contracts)
-
IDatabaseCopyView : IBaseView
Marker interface for the view associated withIDatabaseCopyViewModel. Represents the UI layer for database copy operations. -
IDatabaseSwitchView : IBaseView
Marker interface for the view associated withIDatabaseSwitchViewModel. Represents the UI layer for switching between local and remote databases. -
IDatabaseStatusBarView : IBaseView
Marker interface for the view associated withIDatabaseStatusBarViewModel. Represents the UI layer for displaying database connection status (e.g., active database name, connection state).
Interfaces (ViewModel Contracts)
-
IDatabaseSwitchViewModel : IBaseViewModel
Manages state and logic for switching between local and remote databases.IDatabaseSwitchView View { get; set; }
Gets/sets the associated view.void Unset()
Releases resources (e.g., event handlers, view references).bool RemoteIsActive { get; }
Indicates whether the remote database is currently active.string DefaultDbName { get; }
Gets the default database name.void InitializeDbSettings(string defaultDbName, string dbHost, bool ntlmAuthentication, string dbUser, string dbPassword)
Initializes database connection settings (note:SetDefaultDbNameis commented out and unused).void SwitchRemote()/void SwitchLocal()
Initiates switching to the remote or local database, respectively.string DbHost { get; },bool NTLMAuthentication { get; },string DbUser { get; },string DbPassword { get; }
Exposes current database connection configuration.
-
IDatabaseCopyViewModel : IBaseViewModel
Manages state and logic for copying data from a remote database to a local database.IDatabaseCopyView View { get; set; }
Gets/sets the associated view.void Unset()
Releases resources.void CopyDatabase()
Performs the copy operation (clears local DB, populates from remote). UsesDTS.Common.Storageto resolve local/remote locations.void InitializeState(DbType dbType, string dbName)
Initializes viewmodel state with database type and name.string DbName { get; }
Gets the target database name.IStatusAndProgressBarView OverallProgressBarView { get; }
Gets progress view for the overall copy operation.IStatusAndProgressBarView CurrentTaskProgressBarView { get; }
Gets progress view for the current subtask.DbType DatabaseType { get; }
Gets the type of database being copied.bool CopyEnabled { get; }
Indicates whether the copy operation is enabled.bool IsCopyVisible { get; set; }
Controls visibility of the copy UI.
-
IDatabaseStatusBarViewModel : IBaseViewModel
Manages state and logic for displaying database connection status in the UI.IDatabaseStatusBarView View { get; set; }
Gets/sets the associated view.void Unset()
Releases resources.DbType DatabaseType { get; }
Gets the database type (e.g., local, remote).bool RemoteConnected { get; }
Indicates whether the remote database is connected.string ServerName { get; }
Gets the server name (not database name).void InitializeValues(DbType dbType, string serverName, bool remoteConnected)
Sets initial values for status display.string ActiveDbName { get; }
Gets the currently active database name (e.g., local or remote, depending on state).Brush BackgroundBrush { get; }
Gets the background color brush for the active database name display.
Data 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; }
User-friendly display name.string Password { get; set; }
Hashed and salted password (never stored in plaintext).short Role { get; set; }
User role (numeric code).DateTime LastModified { get; set; }
Timestamp of last modification.string LastModifiedBy { get; set; }
Username of the modifier.bool LocalOnly { get; set; }
Deprecated flag indicating whether the user should be local-only (not synchronized).
3. Invariants
- All view interfaces (
IDatabaseCopyView,IDatabaseSwitchView,IDatabaseStatusBarView) extendIBaseView, implying they are part of a consistent UI abstraction layer. - All viewmodel interfaces (
IDatabaseSwitchViewModel,IDatabaseCopyViewModel,IDatabaseStatusBarViewModel) extendIBaseViewModel, implying they follow the MVVM pattern and requireUnset()for resource cleanup. IDatabaseSwitchViewModelandIDatabaseCopyViewModelshare overlapping functionality (e.g., clearing and repopulating local DB), butIDatabaseCopyViewModelincludes progress tracking viaIStatusAndProgressBarView.IUserDbRecord.Passwordis explicitly documented as hashed and salted; implementations must never store plaintext passwords.IUserDbRecord.LocalOnlyis marked deprecated; its usage should be avoided.IDatabaseStatusBarViewModel.ActiveDbNamedynamically reflects the active database (local/remote) based onDatabaseTypeandRemoteConnectedstate.
4. Dependencies
-
Internal Dependencies:
DTS.Common.Base: All interfaces inherit fromIBaseVieworIBaseViewModel.DTS.Common.Enums.Database:IDatabaseCopyViewModelandIDatabaseStatusBarViewModeluseDbType(enum not shown; assumed to define database types likeLocal,Remote).System.Windows.Media:IDatabaseStatusBarViewModelusesBrush(WPF-specific), indicating this module targets WPF UI.DTS.Common.Storage: Referenced inIDatabaseCopyViewModel.CopyDatabase()documentation as the source for resolving local/remote database locations.
-
External Dependencies:
- WPF (
System.Windows.Media) forBrushtype. System(viaDateTime,string).
- WPF (
-
Depended Upon:
- Concrete implementations of these interfaces are expected in UI-layer projects (e.g., WPF views/viewmodels).
- Likely consumed by UI controllers or services that manage database operations (e.g., a main window or database manager module).
5. Gotchas
SetDefaultDbNameis commented out inIDatabaseSwitchViewModel; the propertyDefaultDbNameis read-only, and initialization relies solely onInitializeDbSettings.LocalOnlyis deprecated inIUserDbRecordbut not removed; implementations should ignore this property.IDatabaseStatusBarViewModel.BackgroundBrushhas no documentation on how it is computed (e.g., based on connection state). Its value is implementation-defined.CopyDatabase()assumes pre-existing schema: BothIDatabaseSwitchViewModelandIDatabaseCopyViewModelrequire the local database to have tables and stored procedures already created.IStatusAndProgressBarViewis used but not defined here: Its contract is assumed to be defined elsewhere (likely inDTS.Common.Baseor a related module).- No async methods: All operations (
SwitchRemote,CopyDatabase) are synchronous; implementations may need to offload work to background threads to avoid UI blocking. DbPasswordis exposed directly: TheIDatabaseSwitchViewModelexposes the plaintext password viaDbPassword { get; }, which may be a security risk if not handled carefully.