2.7 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-17T16:45:42.084519+00:00 | zai-org/GLM-5-FP8 | 1 | 42f8132355cda838 |
DbWrapper Documentation
1. Purpose
DbWrapper is a singleton class that provides database access to the DASFactory database. It manages connection string construction, command creation, and basic database operations for device lookup. The class is designed with future extensibility in mind, supporting flags for centralized database deployment and authentication method switching, though currently it is hardcoded for local database access with NTLM authentication.
2. Public Interface
Static Properties
| Property | Type | Description |
|---|---|---|
_usingCentralizedDB |
bool |
Configuration flag for future centralized DB support. Currently always false. |
_usingNTLMAuthentication |
bool |
Authentication mode flag. Currently always true (NTLM/Windows auth). |
Connected |
bool |
Passive connection status indicator. Getter always returns false; setter is a no-op. |
Connection |
DbWrapper |
Singleton instance accessor with thread-safe lazy initialization. |
Instance Properties
| Property | Type | Default | Description |
|---|---|---|---|
Server |
string |
null |
Database server address. |
DBName |
string |
null |
Database name (not currently used in connection string construction). |
Username |
string |
"" |
SQL authentication username. |
Password |
string |
null |
SQL authentication password. |
Methods
public static int GetDeviceId(string serialNumber)
Looks up a device record by serial number. Calls the stored procedure sp_IDASCommunicationTableGetRecordId and returns the RecordId if found, or -1 if no match exists. Throws Exception("Not connected") if Connected is false.
public void ResetLocalDASFactoryConnection()
Clears the cached connection string and resets _usingNTLMAuthentication to true.
public string GetLocalDASFactoryConnectionString()
Builds and caches the connection string for the DASFactory database. Uses NTLM authentication (Trusted_Connection=TRUE) when _usingNTLMAuthentication is true, otherwise uses SQL authentication with Username and Password. Throws Exception("Empty Server") if Server is null or whitespace.
Internal Methods
internal static IDbCommand GetDASFactoryCommand()
Creates a new SqlCommand with an open SqlConnection using the local DASFactory connection string. Caller is responsible for disposing the connection.