Files
DP44/docs/ai/DataPRO/WPF.DbAPI.md

61 lines
3.2 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DataPRO/WPF.DbAPI/App.xaml.cs
- DataPRO/WPF.DbAPI/AssemblyInfo.cs
- DataPRO/WPF.DbAPI/MainWindow.xaml.cs
generated_at: "2026-04-17T16:44:23.443606+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "aeb998f6a2657401"
---
# Documentation: WPF.DbAPI Module
## 1. Purpose
This module is a WPF-based desktop application that serves as a test client and demonstration UI for the `DbApiWrapper` database API. It provides a graphical interface for executing database queries related to test setups and DAS (Data Acquisition System) records, displaying results in JSON format. The application exists primarily as a development/testing tool for validating the `DTS.Core.DbAPIWrapper` functionality against a database named "DataPRO" on a server identified as "Burrito-Supreme".
---
## 2. Public Interface
### `App` (class)
**Signature:** `public partial class App : Application`
Standard WPF application entry point. Contains no custom logic beyond the auto-generated framework initialization.
---
### `MainWindow` (class)
**Signature:** `public partial class MainWindow : Window`
Primary window for the database API test client.
#### Constructor
**Signature:** `public MainWindow()`
Initializes the window components, instantiates a `DbApiWrapper` instance, and authenticates a user. The wrapper is configured with hardcoded server name "Burrito-Supreme", database "DataPRO", and authenticates with username "Admin" and password "DTSAdmin".
#### Methods
| Method | Signature | Description |
|--------|-----------|-------------|
| `Clear` | `private void Clear()` | Clears the `errors` and `result` text fields in the UI. |
| `EnableButtons` | `private void EnableButtons(bool enable)` | Enables or disables the `testsetupget`, `dasget`, `testId`, and `dasSerial` UI controls. |
| `GetTestSetups_Button_Click` | `private async void GetTestSetups_Button_Click(object sender, RoutedEventArgs e)` | Async event handler that calls `_dbApiWrapper.TestSetupsGetAsync(int?)`. Parses `testId.Text` as an optional integer filter. Displays up to 10 results as indented JSON in `result.Text`. Errors from `ts.Item2` are written to `errors.Text`. |
| `GetDAS_Button_Click` | `private async void GetDAS_Button_Click(object sender, RoutedEventArgs e)` | Async event handler that calls `_dbApiWrapper.DASGetAsync(string?)`. Uses `dasSerial.Text` as an optional serial filter. Displays up to 10 results as indented JSON. Shows error code from `ds.Item2` via `MessageBox` if non-zero. |
| `Responsive_Button_Click` | `private void Responsive_Button_Click(object sender, RoutedEventArgs e)` | Displays a `MessageBox` with text "Responsive UI". Appears to be a UI responsiveness test button. |
#### Fields
| Field | Type | Description |
|-------|------|-------------|
| `_dbApiWrapper` | `DbApiWrapper` (readonly) | Wrapper instance for database API calls. Initialized in constructor. |
---
## 3. Invariants
1. **Authentication Requirement:** The `DbApiWrapper` is authenticated immediately upon `MainWindow` construction. All subsequent API calls assume this authentication remains valid.
2. **UI Control Availability:** The following UI controls must exist in the XAML (not provided): `errors` (TextBox), `result` (TextBox), `testsetupget` (Button), `dasget` (Button), `testId` (TextBox),