This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
---
source_files:
- DataPRO/Modules/Channels/ChannelCodes/ChannelCodesModule.cs
generated_at: "2026-04-17T16:47:17.153049+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "7676c98280386b11"
---
# ChannelCodesModule Documentation
## 1. Purpose
The `ChannelCodesModule` is a Prism module that provides Channel Codes functionality within the DTS application framework. It exists to modularize channel code management features, registering its views and view models with the Unity dependency injection container. The module is categorized under the "Prepare" assembly group and exposes metadata (name and image) for display in the main application's module summary screen.
## 2. Public Interface
### ChannelCodesModule
**Signature:** `public class ChannelCodesModule : IModule`
The main module class responsible for DI registration.
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `ChannelCodesModule(IUnityContainer unityContainer)` | Accepts a Unity container via constructor injection and stores it in `_unityContainer`. |
| Initialize | `void Initialize()` | Registers `IChannelCodesListViewModel``ChannelCodesListViewModel` and `IChannelCodesListView``ChannelCodesListView` with Unity. |
| OnInitialized | `void OnInitialized(IContainerProvider containerProvider)` | Empty implementation (no post-initialization logic). |
| RegisterTypes | `void RegisterTypes(IContainerRegistry containerRegistry)` | Delegates to `Initialize()`. |
### ChannelCodesModuleNameAttribute
**Signature:** `public class ChannelCodesModuleNameAttribute : TextAttribute`
Assembly-level attribute providing the module's display name.
| Member | Return Type | Description |
|--------|-------------|-------------|
| Constructor | `ChannelCodesModuleNameAttribute()` | Default constructor. |
| Constructor | `ChannelCodesModuleNameAttribute(string s)` | Overloaded constructor accepting a string (unused). |
| AssemblyName | `string` | Returns `AssemblyNames.ChannelCodes.ToString()`. |
| GetAttributeType | `Type` | Returns `typeof(TextAttribute)`. |
| GetAssemblyName | `string` | Returns the `AssemblyName` property value. |
### ChannelCodesModuleImageAttribute
**Signature:** `public class ChannelCodesModuleImageAttribute : ImageAttribute`
Assembly-level

View File

@@ -0,0 +1,38 @@
---
source_files:
- DataPRO/Modules/Channels/ChannelCodes/Model/ChannelCodeType.cs
- DataPRO/Modules/Channels/ChannelCodes/Model/ChannelCode.cs
generated_at: "2026-04-17T15:58:37.735103+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "d11e5910dac91aaa"
---
# Documentation: ChannelCodes.Model Namespace
## 1. Purpose
This module provides the domain model for managing channel codes within the DataPRO system. It consists of two classes: `ChannelCodeType`, an abstract class that retrieves channel code type lookups from the database, and `ChannelCode`, a concrete entity class that represents individual channel codes with CRUD operations. The module supports both database-backed channel codes and ISO channel codes loaded from a static file, merging them into a unified collection for application use.
---
## 2. Public Interface
### ChannelCodeType (abstract class)
| Member | Signature | Description |
|--------|-----------|-------------|
| `GetChannelCodeTypeLookup` | `public static IDictionary<short, string> GetChannelCodeTypeLookup()` | Retrieves all channel code types from the database via stored procedure `sp_ChannelCodeTypeGet`. Returns a dictionary mapping a short integer ID to a code type string. |
### ChannelCode
| Member | Signature | Description |
|--------|-----------|-------------|
| `HasValidId` | `public bool HasValidId()` | Returns `true` if `Id >= 0`. |
| `IsBlank` | `public bool IsBlank()` | Returns `true` if both `Name` and `Code` are null or empty. |
| `SelectedChannelType` | `public int SelectedChannelType { get; set; }` | Converts between `ChannelEnumsAndConstants.ChannelCodeType` enum and integer index (0 = ISO, 1 = User). Setter silently ignores values other than 0 or 1. |
| `PossibleChannels` | `public Dictionary<string, string> PossibleChannels { get; private set; }` | Property for storing possible channels. Not initialized in constructors visible in source. |
| `ChannelCode()` | `public ChannelCode()` | Default constructor. Sets `CodeType` to `ISO` and registers commands. |
| `ChannelCode(IChannelCode)` | `public ChannelCode(IChannelCode channelCode)` | Copy constructor that delegates to base class and registers commands. |
| `ChannelCode(IDataRecord, IDictionary<short, string>)` | `public ChannelCode(IDataRecord sqlReader, IDictionary<short, string> channelCodeLookup)` | Constructs instance from a database record. Maps `CodeTypeInt` to enum via the provided lookup dictionary. |
| `GetExistingChannelCodes` | `public static ChannelCode[] GetExistingChannelCodes(IDictionary<short, string> lookup)` | Retrieves all channel codes from the database via stored procedure

View File

@@ -0,0 +1,21 @@
---
source_files:
- DataPRO/Modules/Channels/ChannelCodes/Properties/Settings.Designer.cs
- DataPRO/Modules/Channels/ChannelCodes/Properties/AssemblyInfo.cs
generated_at: "2026-04-17T16:12:31.642089+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "d58492d70941aed0"
---
# Properties
### Purpose
This module contains auto-generated infrastructure code for the `ChannelCodes` assembly, providing application settings management and assembly metadata. It serves as the build-generated properties layer for the ChannelCodes component, which appears to handle channel coding/identification functionality within the DTS product line.
### Public Interface
- **`Settings` class** (internal sealed partial) - Inherits from `global::System.Configuration.ApplicationSettingsBase`. Provides thread-safe singleton access to application settings.
- `static Settings Default { get; }` - Returns the synchronized singleton instance of the settings class via `defaultInstance` field.
### Invariants
- The `Settings` class is generated by `Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator` version `17.10.0.0` targeting .NET Framework 4.0 runtime (`4.

View File

@@ -0,0 +1,15 @@
---
source_files:
- DataPRO/Modules/Channels/ChannelCodes/Resources/TranslateExtension.cs
- DataPRO/Modules/Channels/ChannelCodes/Resources/StringResources.Designer.cs
generated_at: "2026-04-17T15:58:30.134380+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "74b6a6a3d15aa294"
---
# Documentation: ChannelCodes Resources Module
## 1. Purpose
This module provides localization infrastructure for the

View File

@@ -0,0 +1,40 @@
---
source_files:
- DataPRO/Modules/Channels/ChannelCodes/View/ChannelCodesListView.xaml.cs
generated_at: "2026-04-17T16:01:12.024561+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "765fffde6c4125b2"
---
# ChannelCodesListView Documentation
## 1. Purpose
This module is a WPF code-behind view component for managing channel codes within the system. It provides the interaction logic for `ChannelCodesListView.xaml`, handling user interactions for two distinct lists: ISO channel codes and User-defined channel codes. The view supports filtering, sorting, selection tracking, and modification marking, delegating all business logic to an `IChannelCodesListViewModel` via data binding.
---
## 2. Public Interface
### Class: `ChannelCodesListView`
**Implements:** `IChannelCodesListViewModel`
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `public ChannelCodesListView()` | Initializes the view component via `InitializeComponent()`. |
### Private Event Handlers (wired to XAML)
| Method | Event Context | Behavior |
|--------|---------------|----------|
| `GridViewColumnHeaderSearchable_OnSearch` | Search event on `GridViewColumnHeaderSearchable` | Extracts search term from `e.OriginalSource` and column tag from sender, calls `viewModel.Filter(columnTag, searchTerm)`. |
| `GridViewColumnHeader_OnClick` | Click on column header | Extracts column tag and calls `vm.Sort(columnTag, true)`. Uses `Utils.FindChild<T>` as fallback for tag resolution. |
| `ChannelCodeTextBox_KeyDown` | Key down on channel code text box | Extracts `IChannelCode` from `e.Source` DataContext, calls `vm.MarkModified(channelCode)`. |
| `ChannelCodeTextBoxUser_TextChanged` | Text changed on user channel code | Calls `vm.MarkModified(channelCode)` and `vm.ValidateUser(ref notUsed1, ref notUsed2)`. |
| `ChannelCodeTextBoxIso_TextChanged` | Text changed on ISO channel code | Calls `vm.MarkModified(channelCode)` and `vm.ValidateISO(ref notUsed1, ref notUsed2)`. |
| `DisplayNameTextBox_KeyDown` | Key down on display name | Calls `vm.MarkModified(channelCode)`. |
| `DisplayNameTextBoxUser_TextChanged` | Text changed on user display name | Calls `vm.MarkModified(channelCode)` and `vm.ValidateUser(ref notUsed1, ref notUsed2)`. |
| `DisplayNameTextBoxIso_TextChanged` | Text changed on ISO display name | Calls `vm.MarkModified(channelCode)` and `vm.ValidateISO(ref notUsed1, ref notUsed2)`. |
| `ISO_Checked` | ISO radio button checked | Sets `vm.ViewMode = ChannelCodesListViewModel.ViewModes.ISO`. |
| `User_Checked` | User radio button checked | Sets `vm.ViewMode = Channel

View File

@@ -0,0 +1,148 @@
---
source_files:
- DataPRO/Modules/Channels/ChannelCodes/ViewModel/ChannelCodesListViewModel.cs
generated_at: "2026-04-17T16:02:02.258497+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "4a52e53369e1f84f"
---
# ChannelCodesListViewModel Documentation
## 1. Purpose
`ChannelCodesListViewModel` is a Prism-based ViewModel that manages the display, editing, validation, and persistence of Channel Codes in a WPF application. It handles two distinct categories of channel codes—ISO and User—providing separate views for each via a `ViewMode` toggle. The ViewModel supports CRUD operations, multi-selection, copy/paste functionality, sorting, filtering, and event-driven communication with other application components. It implements `IChannelCodesListViewModel` and follows the MVVM pattern with `INotifyPropertyChanged` support.
---
## 2. Public Interface
### Properties
| Property | Type | Description |
|----------|------|-------------|
| `View` | `IChannelCodesListView` | The associated view instance; DataContext is set to this ViewModel in constructor. |
| `NotificationRequest` | `InteractionRequest<Notification>` | Used to raise notification dialogs. |
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | Used to raise confirmation dialogs. |
| `AllISOChannelCodes` | `List<IChannelCode>` | Complete list of ISO channel codes (unfiltered). |
| `AllUserChannelCodes` | `List<IChannelCode>` | Complete list of User channel codes (unfiltered). |
| `ISOChannelCodes` | `ObservableCollection<IChannelCode>` | Filtered ISO channel codes bound to the view. |
| `UserChannelCodes` | `ObservableCollection<IChannelCode>` | Filtered User channel codes bound to the view. |
| `SelectedCodes` | `IChannelCode[]` | Returns selected codes based on current `ViewMode`. |
| `Page` | `object` | Page identifier used in event payloads. |
| `IsDirty` | `bool` | Indicates unsaved changes. |
| `IsBusy` | `bool` | Controls busy indicator state. |
| `IsMenuIncluded` | `bool` | Controls menu inclusion. |
| `IsNavigationIncluded` | `bool` | Controls navigation inclusion. |
| `IsReadOnly` | `bool` | When `true`, disables editing (FB14098). |
| `ViewMode` | `ViewModes` | Current view mode (`ISO` or `User`). |
| `ISOVisibility` | `Visibility` | Returns `Visible` when `ViewMode.ISO`, else `Collapsed`. |
| `UserVisibility` | `Visibility` | Returns `Visible` when `ViewMode.User`, else `Collapsed`. |
| `ChannelCodesFunc` | `Func<IList<IChannelCode>>` | Returns `ChannelCode.ChannelCodes`. |
| `ShowISOStringBuilder` | `bool` | Controls ISO string builder visibility. |
| `UniqueISOCodesRequired` | `bool` | Indicates whether unique ISO codes are required. |
| `ShowChannelCodeLookupHelper` | `bool` | Controls channel code lookup helper visibility. |
### Methods
| Method | Signature | Description |
|--------|-----------|-------------|
| `OnPropertyChanged` | `void OnPropertyChanged(string propertyName)` | Raises `PropertyChanged` event. |
| `Remove` | `void Remove(IChannelCode channel)` | Removes a channel code; routes to `RemoveISOChannel` or `RemoveUserChannel` based on `CodeType`. Publishes `PageModifiedEvent`. |
| `MarkModified` | `void MarkModified(IChannelCode channel)` | Marks a channel as modified; adds a new blank row if modifying the last item. Publishes `PageModifiedEvent`. |
| `Unset` | `void Unset()` | Clears all channel code collections. |
| `SetPage` | `void SetPage(object page)` | Sets the `Page` identifier for event routing. |
| `OnSetActive` | `void OnSetActive()` | Loads existing channel codes from database, populates collections, sorts and filters. |
| `Cleanup` | `void Cleanup()` | Empty cleanup method. |
| `CleanupAsync` | `Task CleanupAsync()` | Returns `Task.CompletedTask`. |
| `Initialize` | `void Initialize()` / `void Initialize(object parameter)` / `void Initialize(object parameter, object model)` | Empty initialization methods. |
| `InitializeAsync` | `Task InitializeAsync()` / `Task InitializeAsync(object parameter)` | Return `Task.CompletedTask`. |
| `Activated` | `void Activated()` | Empty activation method. |
| `ReportErrors` | `void ReportErrors(string[] errors)` | Publishes `PageErrorEvent` with errors and `Page`. |
| `Save` | `bool Save()` | Persists all changes using a 4-step process: delete removed codes, update existing, insert new, update IDs. Returns `true` on success. |
| `ValidateISO` | `void ValidateISO(ref List<string> errors, ref List<string> warnings)` | Validates ISO channel codes. |
| `ValidateUser` | `void ValidateUser(ref List<string> errors, ref List<string> warnings)` | Validates User channel codes. |
| `Validate` | `bool Validate(bool bDisplayWindow)` | Validates all codes; optionally displays errors/warnings. Returns `true` if no errors. |
| `CopySelected` | `void CopySelected()` | Copies selected codes; inserts copies before the last (blank) row. |
| `DeleteSelected` | `void DeleteSelected()` | Deletes selected codes; ensures a blank row remains at the end. |
| `SetISOSelection` | `void SetISOSelection(IChannelCode[] channelCodes)` | Sets ISO selection; publishes `PageSelectionChanged` if `ViewMode.ISO`. |
| `SetUserSelection` | `void SetUserSelection(IChannelCode[] channelCodes)` | Sets User selection; publishes `PageSelectionChanged` if `ViewMode.User`. |
| `Filter` | `void Filter(object columnTag, string searchTerm)` | Filters codes based on column tag (`"ISOCode"`, `"ISOChannelName"`, `"UserCode"`, `"UserChannelName"`). |
| `Sort` | `void Sort(object columnTag, bool bColumnClick)` | Sorts codes by column; toggles direction on repeated clicks. |
### Nested Types
| Type | Description |
|------|-------------|
| `enum Fields` | `IsoCode`, `IsoChannelName`, `UserCode`, `UserChannelName` — used for sorting/filtering. |
| `enum ViewModes` | `ISO`, `User` — toggles between channel code types. |
| `class ChannelComparer : IComparer<IChannelCode>` | Custom comparer using `NaturalStringComparer`; handles null/blank items by sorting them last. |
---
## 3. Invariants
1. **Blank Row Guarantee**: The last item in both `AllISOChannelCodes` and `AllUserChannelCodes` is always a blank `ChannelCode` instance (both `Code` and `Name` are empty). This serves as the "new row" for data entry.
2. **ISO Code Length**: ISO codes are silently truncated to 16 characters maximum in `ParseText()`.
3. **Blank Item Sorting**: Items with both `Code` and `Name` empty are always sorted to the end of the list (see `ChannelComparer.Compare`).
4. **Selection Handling**: Empty selection arrays are ignored and not assigned (FB 18906 guard in `SetISOSelection` and `SetUserSelection`).
5. **Save Operation Ordering**: The `Save()` method executes in strict order: (1) delete removed codes, (2) update existing codes, (3) insert new codes. This prevents primary key conflicts.
6. **Event Subscription Pattern**: The static `_bAddListeners` flag ensures event listeners are only registered on the second constructor invocation (see Gotchas).
---
## 4. Dependencies
### External Dependencies (Imports)
| Namespace | Purpose |
|-----------|---------|
| `ChannelCodes.Model` | `ChannelCode` model, `ChannelCodeType` lookup |
| `DTS.Common.Enums` | General enumerations |
| `DTS.Common.Enums.Channels` | `ChannelEnumsAndConstants` |
| `DTS.Common.Events` | `PageModifiedEvent`, `PageErrorEvent`, `PageSelectionChanged` |
| `DTS.Common.Events.ChannelCodes` | `RaiseNotification`, `BusyIndicatorChangeNotification`, `TextPastedEvent`, `ChannelCodeCommittedEvent` |
| `DTS.Common.Interface.Channels.ChannelCodes` | `IChannelCode`, `IChannelCodesListView`, `IChannelCodesListViewModel` |
| `DTS.Common.Utilities.Logging` | `APILogger` |
| `DTS.Common.Interactivity` | `InteractionRequest<T>`, `Notification`, `Confirmation` |
| `Prism.Events` | `IEventAggregator`, `ThreadOption` |
| `Prism.Regions` | `IRegionManager` |
| `Unity` | `IUnityContainer` |
### Event Subscriptions
| Event | Thread Option | Keep Subscriber Reference |
|-------|---------------|---------------------------|
| `RaiseNotification` | Default | Default |
| `BusyIndicatorChangeNotification` | `PublisherThread` | `true` |
| `TextPastedEvent` | Default | Default |
| `ChannelCodeCommittedEvent` | `PublisherThread` | `true` |
### Event Publications
| Event | Payload |
|-------|---------|
| `PageModifiedEvent` | `PageModifiedArg` with status (`Modified`/`Saved`) and `Page` |
| `PageErrorEvent` | `PageErrorArg` with error messages and `Page` |
| `PageSelectionChanged` | `PageSelectionChangedArg` with selection count and `Page` |
---
## 5. Gotchas
1. **Static Listener Flag Hack**: The constructor uses a static `_bAddListeners` field to prevent duplicate event subscriptions. The comment explicitly states: *"this is a hack, the app startup is calling this, then the app itself, we only want the app itself to be handling the listeners."* This implies the constructor is invoked twice during application lifecycle, and only the second invocation should register `TextPastedEvent` and `ChannelCodeCommittedEvent` handlers.
2. **Silent ISO Code Truncation**: In `ParseText()`, ISO codes exceeding 16 characters are silently truncated without warning or error. Users are not notified of this modification.
3. **Paste Behavior Depends on Tag**: The `PasteIso` and `PasteUser` methods interpret the `tag` parameter to determine whether pasted text should populate the `Code` or `Name` field when single-column data is pasted. The tag must equal `"ISOCode"` or `"UserCode"` (string comparison) to populate the code field.
4. **Filter Uses Case-Insensitive Contains**: Filtering uses `IndexOf(term, StringComparison.CurrentCultureIgnoreCase)` which performs a substring match, not an exact or startswith match.
5. **Save Returns False Only on Exception**: The `Save()` method returns `false` only if an exception is caught. Validation errors do not prevent save; callers should call `Validate()` before `Save()`.
6. **Remove vs DeleteSelected Behavior Difference**: `Remove()` does not automatically add a blank row if removing a non-last item, but `DeleteSelected()` and `RemoveISOChannel`/`RemoveUserChannel` do add a blank row when removing the last item. This ensures the blank row invariant is maintained.