Files
2026-04-17 14:55:32 -04:00

5.8 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.CommonCore/Interface/Database/IDatabaseCopyView.cs
Common/DTS.CommonCore/Interface/Database/IDatabaseSwitchView.cs
Common/DTS.CommonCore/Interface/Database/IDatabaseStatusBarView.cs
Common/DTS.CommonCore/Interface/Database/IDatabaseSwitchViewModel.cs
Common/DTS.CommonCore/Interface/Database/IUserDbRecord.cs
Common/DTS.CommonCore/Interface/Database/IDatabaseCopyViewModel.cs
Common/DTS.CommonCore/Interface/Database/IDatabaseStatusBarViewModel.cs
2026-04-17T16:22:17.503077+00:00 zai-org/GLM-5-FP8 1 67bd14e2aba6132e

Database

Purpose

This module defines the contract layer for database management operations in a desktop application, specifically handling database switching (remote/local), database copying, and status bar display. It follows a Model-View-ViewModel (MVVM) pattern where views are abstracted behind interfaces to enable testability and loose coupling between UI components and business logic for database operations.

Public Interface

IDatabaseCopyView : IBaseView

  • Marker interface for the database copy view. No members defined.

IDatabaseSwitchView : IBaseView

  • Marker interface for the database switch view. No members defined.

IDatabaseStatusBarView : IBaseView

  • Marker interface for the database status bar view. No members defined.

IDatabaseSwitchViewModel : IBaseViewModel

  • IDatabaseSwitchView View { get; set; } - The associated view instance.
  • void Unset() - Releases memory/resources associated with the viewmodel.
  • bool RemoteIsActive { get; } - Indicates whether the remote database is currently active.
  • string DefaultDbName { get; } - Returns the default database name.
  • void InitializeDbSettings(string defaultDbName, string dbHost, bool ntlmAuthentication, string dbUser, string dbPassword) - Initializes database connection settings.
  • void SwitchRemote() - Switches to the remote database.
  • void SwitchLocal() - Switches to the local database.
  • string DbHost { get; } - Database host address.
  • bool NTLMAuthentication { get; } - Whether NTLM authentication is enabled.
  • string DbUser { get; } - Database username.
  • string DbPassword { get; } - Database password.

IUserDbRecord

  • int ID { get; set; } - Database ID of the user.
  • string UserName { get; set; } - Unique username.
  • string DisplayName { get; set; } - UI display name for the user.
  • string Password { get; set; } - Hashed and salted password value (not plaintext).
  • short Role { get; set; } - User role identifier.
  • DateTime LastModified { get; set; } - Timestamp of last modification.
  • string LastModifiedBy { get; set; } - Username of the user who made the last modification.
  • bool LocalOnly { get; set; } - Deprecated field for local/remote synchronization control.

IDatabaseCopyViewModel : IBaseViewModel

  • IDatabaseCopyView View { get; set; } - The associated view instance.
  • void Unset() - Releases memory/resources associated with the viewmodel.
  • void CopyDatabase() - Copies from remote database to local database using DTS.Common.Storage to determine locations.
  • void InitializeState(DbType dbType, string dbName) - Initializes viewmodel state.
  • string DbName { get; } - The database name.
  • IStatusAndProgressBarView OverallProgressBarView { get; } - Overall progress/status display.
  • IStatusAndProgressBarView CurrentTaskProgressBarView { get; } - Current task progress/status display.
  • DbType DatabaseType { get; } - The type of database.
  • bool CopyEnabled { get; } - Whether copy operation is enabled.
  • bool IsCopyVisible { get; set; } - Visibility state for copy UI.

IDatabaseStatusBarViewModel : IBaseViewModel

  • IDatabaseStatusBarView View { get; set; } - The associated view instance.
  • void Unset() - Releases memory/resources associated with the viewmodel.
  • DbType DatabaseType { get; } - The database type (populated via InitializeValues).
  • bool RemoteConnected { get; } - Whether remote database is connected (populated via InitializeValues).
  • string ServerName { get; } - Server name, not database name (populated via InitializeValues).
  • 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; } - WPF brush for background styling of the active database name.

Invariants

  • IUserDbRecord.UserName must be unique across all users.
  • IUserDbRecord.Password must always be a hashed and salted value, never plaintext.
  • IDatabaseCopyViewModel.CopyDatabase() requires a local database with correct tables and stored procedures pre-existing.
  • IDatabaseSwitchViewModel requires a local database with correct schema before switching to local.
  • IDatabaseStatusBarViewModel.InitializeValues must be called before accessing DatabaseType, RemoteConnected, ServerName, or ActiveDbName.

Dependencies

  • Depends on: DTS.Common.Base (IBaseView, IBaseViewModel), DTS.Common.Enums.Database (DbType), System.Windows.Media (Brush), System (DateTime).
  • Depended on by: Concrete view/viewmodel implementations, database management services, UI components displaying database status.

Gotchas

  • IUserDbRecord.LocalOnly is marked as deprecated in the source comments; avoid using it in new code.
  • IDatabaseSwitchViewModel has a commented-out method SetDefaultDbName suggesting API evolution; use InitializeDbSettings instead.
  • The IDatabaseCopyViewModel documentation states it "clears the local database and populates it with the remote database" - this is a destructive operation.
  • IDatabaseStatusBarViewModel.ServerName returns the server name, not the database name, despite the property name potentially being ambiguous.