Files

172 lines
11 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.CommonCore/Classes/TestMetaData/TestEngineerDetailsDbRecord.cs
- Common/DTS.CommonCore/Classes/TestMetaData/CustomerDetailsDbRecord.cs
- Common/DTS.CommonCore/Classes/TestMetaData/LabratoryDetailsDbRecord.cs
generated_at: "2026-04-16T02:39:45.898460+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "7adaa8e0587cfc54"
---
# Documentation: Test Metadata Database Record Classes
---
## 1. Purpose
These three classes—`TestEngineerDetailsDbRecord`, `CustomerDetailsDbRecord`, and `LabratoryDetailsDbRecord`—represent immutable data transfer objects (DTOs) for loading and encapsulating metadata about test engineers, customers, and laboratories from a database. They implement the `INotifyPropertyChanged` pattern via inheritance from `Base.BasePropertyChanged`, enabling data binding in UI layers, and provide constructors to initialize from an `IDataReader` (for database hydration) or from another instance of the same interface type (for cloning). Each class serves as a strongly-typed, schema-bound representation of rows in corresponding database tables, used throughout the test execution and reporting pipeline to ensure consistent metadata access.
---
## 2. Public Interface
All three classes share a common structural pattern. Below, each class is documented individually.
### `TestEngineerDetailsDbRecord`
- **Namespace**: `DTS.Common.Classes.TestEngineerDetails`
- **Interface**: `ITestEngineerDetailsDbRecord`
- **Base Class**: `Base.BasePropertyChanged`
#### Constructors
- `TestEngineerDetailsDbRecord()`
Default constructor; initializes all fields to their default values (`-1` for IDs, `""` for strings, `false` for booleans, `DateTime.MinValue` for dates).
- `TestEngineerDetailsDbRecord(ITestEngineerDetailsDbRecord testEngineerDetailsDbRecord)`
Copy constructor; copies all property values from the provided interface instance.
- `TestEngineerDetailsDbRecord(IDataReader reader)`
Database constructor; reads values from an `IDataReader` using `Utility.GetString`, `Utility.GetInt`, `Utility.GetDateTime`, and `Utility.GetBool` helper methods.
#### Properties
| Property | Type | Attributes | Description |
|---------|------|------------|-------------|
| `TestEngineerId` | `int` | `[Browsable(false)]`, `[ReadOnly(true)]` | Primary key identifier for the test engineer. Default: `-1`. |
| `Name` | `string` | `[Browsable(false)]`, `[ReadOnly(true)]` | Internal/system name (e.g., login or DB key). Default: `""`. |
| `TestEngineerName` | `string` | `[DisplayResource("TestEngineerName")]` | Display-friendly name (e.g., full name). Default: `"NOVALUE"`. |
| `TestEngineerPhone` | `string` | `[DisplayResource("TestEngineerPhone")]` | Contact phone number. Default: `"NOVALUE"`. |
| `TestEngineerFax` | `string` | `[DisplayResource("TestEngineerFax")]` | Contact fax number. Default: `"NOVALUE"`. |
| `TestEngineerEmail` | `string` | `[DisplayResource("TestEngineerEmail")]` | Contact email address. Default: `"NOVALUE"`. |
| `LocalOnly` | `bool` | `[Browsable(false)]`, `[ReadOnly(true)]` | Indicates if record is local-only (not synchronized). Default: `false`. |
| `LastModified` | `DateTime` | `[Browsable(false)]`, `[ReadOnly(true)]` | Timestamp of last modification. Default: `DateTime.MinValue`. |
| `LastModifiedBy` | `string` | `[Browsable(false)]`, `[ReadOnly(true)]` | User who last modified the record. Default: `""`. |
| `Version` | `int` | `[Browsable(false)]`, `[ReadOnly(true)]` | Concurrency/version token. Default: `-1`. |
#### Methods
- `bool IsInvalidBlank()`
Returns `true` if `Name` is `null`, empty, or whitespace; otherwise `false`.
---
### `CustomerDetailsDbRecord`
- **Namespace**: `DTS.Common.Classes.CustomerDetails`
- **Interface**: `ICustomerDetailsDbRecord`
- **Base Class**: `Base.BasePropertyChanged`
#### Constructors
- `CustomerDetailsDbRecord()`
Default constructor.
- `CustomerDetailsDbRecord(ICustomerDetailsDbRecord customerDetailsDbRecord)`
Copy constructor.
- `CustomerDetailsDbRecord(IDataReader reader)`
Database constructor.
#### Properties
| Property | Type | Attributes | Description |
|---------|------|------------|-------------|
| `CustomerId` | `int` | `[Browsable(false)]`, `[ReadOnly(true)]` | Primary key identifier. Default: `-1`. |
| `Name` | `string` | `[Browsable(false)]`, `[ReadOnly(true)]` | Internal/system name. Default: `""`. |
| `CustomerName` | `string` | `[DisplayResource("CustomerName")]` | Display name. Default: `""`. |
| `CustomerTestRefNumber` | `string` | `[DisplayResource("CustomerTestRefNumber")]` | Customer-provided test reference number. Default: `""`. |
| `ProjectRefNumber` | `string` | `[DisplayResource("ProjectRefNumber")]` | Project reference number. Default: `"NOVALUE"`. |
| `CustomerOrderNumber` | `string` | `[DisplayResource("CustomerOrderNumber")]` | Customer order number. Default: `"NOVALUE"`. |
| `CustomerCostUnit` | `string` | `[DisplayResource("CustomerCostUnit")]` | Cost center/unit. Default: `"NOVALUE"`. |
| `LocalOnly` | `bool` | `[Browsable(false)]`, `[ReadOnly(true)]` | Local-only flag. Default: `false`. |
| `LastModified` | `DateTime` | `[Browsable(false)]`, `[ReadOnly(true)]` | Last modification timestamp. Default: `DateTime.MinValue`. |
| `LastModifiedBy` | `string` | `[Browsable(false)]`, `[ReadOnly(true)]` | Last modifier. Default: `""`. |
| `Version` | `int` | `[Browsable(false)]`, `[ReadOnly(true)]` | Version token. Default: `-1`. |
#### Methods
- `bool IsInvalidBlank()`
Returns `true` if `Name` is `null`, empty, or whitespace.
---
### `LabratoryDetailsDbRecord`
- **Namespace**: `DTS.Common.Classes.LabratoryDetails`
- **Interface**: `ILabratoryDetailsDbRecord`
- **Base Class**: `Base.BasePropertyChanged`
#### Constructors
- `LabratoryDetailsDbRecord()`
Default constructor.
- `LabratoryDetailsDbRecord(ILabratoryDetailsDbRecord labratoryDetailsDbRecord)`
Copy constructor.
- `LabratoryDetailsDbRecord(IDataReader reader)`
Database constructor.
#### Properties
| Property | Type | Attributes | Description |
|---------|------|------------|-------------|
| `LabratoryId` | `int` | `[Browsable(false)]`, `[ReadOnly(true)]` | Primary key identifier. Default: `-1`. |
| `Name` | `string` | `[Browsable(false)]`, `[ReadOnly(true)]` | Internal/system name. Default: `""`. |
| `LabratoryName` | `string` | `[DisplayResource("LabratoryName")]` | Display name of lab. Default: `""`. |
| `LabratoryContactName` | `string` | `[DisplayResource("LabratoryContactName")]` | Primary contact name. Default: `""`. |
| `LabratoryContactPhone` | `string` | `[DisplayResource("LabratoryContactPhone")]` | Contact phone. Default: `"NOVALUE"`. |
| `LabratoryContactFax` | `string` | `[DisplayResource("LabratoryContactFax")]` | Contact fax. Default: `"NOVALUE"`. |
| `LabratoryContactEmail` | `string` | `[DisplayResource("LabratoryContactEmail")]` | Contact email. Default: `"NOVALUE"`. |
| `LabratoryTestRefNumber` | `string` | `[DisplayResource("LabratoryTestRefNumber")]` | Lab-provided test reference. Default: `""`. |
| `LabratoryProjectRefNumber` | `string` | `[DisplayResource("LabratoryProjectRefNumber")]` | Lab project reference. Default: `""`. |
| `LocalOnly` | `bool` | `[Browsable(false)]`, `[ReadOnly(true)]` | Local-only flag. Default: `false`. |
| `LastModified` | `DateTime` | `[Browsable(false)]`, `[ReadOnly(true)]` | Last modification timestamp. Default: `DateTime.MinValue`. |
| `LastModifiedBy` | `string` | `[Browsable(false)]`, `[ReadOnly(true)]` | Last modifier. Default: `""`. |
| `Version` | `int` | `[Browsable(false)]`, `[ReadOnly(true)]` | Version token. Default: `-1`. |
#### Methods
- `bool IsInvalidBlank()`
Returns `true` if `Name` is `null`, empty, or whitespace.
---
## 3. Invariants
- **`Name` is required**: All classes enforce that `Name` must be non-null and non-whitespace for a record to be considered valid. This is validated by the `IsInvalidBlank()` method.
- **Default sentinel values**: String properties not marked with `[DisplayResource]` default to `""` (e.g., `Name`, `LastModifiedBy`). String properties *with* `[DisplayResource]` default to `"NOVALUE"` (except `CustomerName` and `CustomerTestRefNumber`, which default to `""`).
- **Numeric defaults**: `*Id` and `Version` fields default to `-1`; `LastModified` defaults to `DateTime.MinValue`.
- **Read-only metadata fields**: Properties `*Id`, `Name`, `LocalOnly`, `LastModified`, `LastModifiedBy`, and `Version` are marked `[ReadOnly(true)]` and `[Browsable(false)]`, indicating they are not intended for user editing in UI contexts.
- **Property change notification**: All properties use `SetProperty`, implying `INotifyPropertyChanged` events will fire on changes (via base class `Base.BasePropertyChanged`).
---
## 4. Dependencies
### Internal Dependencies
- `DTS.Common.Base.Classes.BasePropertyChanged` — Base class providing `SetProperty` and `INotifyPropertyChanged` implementation.
- `DTS.Common.Interface.TestMetaData.*` — Interfaces `ITestEngineerDetailsDbRecord`, `ICustomerDetailsDbRecord`, `ILabratoryDetailsDbRecord`.
- `DTS.Common.Utilities.Logging` — Imported but *not used* in the provided code (likely legacy or for future use).
- `System.Data` — Required for `IDataReader` constructor.
- `System.ComponentModel` — Required for `[Browsable]`, `[ReadOnly]`, `[DisplayResource]` attributes.
### External Dependencies
- `Utility` class (static/internal) — Provides helper methods: `GetString`, `GetInt`, `GetDateTime`, `GetBool`. These are assumed to be safe null-handling wrappers around `IDataReader` accessors.
### Inferred Usage
- These classes are likely consumed by:
- Data access layers (DALs) that populate them from database queries.
- UI layers (e.g., WPF) via data binding (justified by `INotifyPropertyChanged` and `[DisplayResource]` attributes).
- Serialization layers (e.g., XML via `XmlSerializer`, inferred from `using System.Xml.Serialization`).
---
## 5. Gotchas
- **Typo in namespace/class name**: The namespace and class `LabratoryDetailsDbRecord` uses the misspelled "Labratory" (should be "Laboratory"). This is consistent across files and may be intentional legacy, but is a potential source of confusion.
- **Inconsistent default values for `[DisplayResource]` strings**:
- `CustomerName` and `CustomerTestRefNumber` default to `""`, while other `[DisplayResource]` fields default to `"NOVALUE"`. This inconsistency may indicate incomplete refactoring or differing business semantics.
- **`IsInvalidBlank()` only checks `Name`**: Validation is minimal and only considers the internal `Name` field. Other required fields (e.g., `TestEngineerName` for engineers) are not validated, potentially allowing partially populated records.
- **`[DisplayResource]` attribute behavior unknown**: The `[DisplayResource("...")]` attribute is used, but its implementation and how it interacts with localization/resource loading are not visible here. Its effect is assumed to be runtime (e.g., via a custom `TypeConverter` or binding converter), but this is not documented in the source.
- **No immutability enforcement**: Despite being used as DTOs, properties have public setters and are not immutable. The `Copy` constructor does not prevent mutation of the source object.
- **No null-safety guarantees in `Utility` methods**: The behavior of `Utility.GetString`, `Utility.GetBool`, etc., on `DBNull` or missing columns is not visible. Assumed safe (e.g., returning defaults), but not guaranteed by this code.
None identified beyond the above.