init
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Groups/GroupImport/Properties/AssemblyInfo.cs
|
||||
generated_at: "2026-04-16T04:45:50.776697+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "06eddeeb5b49ca9c"
|
||||
---
|
||||
|
||||
# Properties
|
||||
|
||||
## 1. Purpose
|
||||
This module (`GroupImportModule`) is an assembly containing metadata and configuration for a .NET component responsible for group import functionality within the larger DataPRO system. Based solely on the file name (`GroupImport`) and assembly title, its role is to encapsulate logic (not visible in this file) related to importing group data—likely from external sources (e.g., CSV, XML, or legacy systems)—into the application’s internal group management subsystem. This file itself contains only assembly-level attributes (e.g., versioning, COM visibility), not executable logic.
|
||||
|
||||
## 2. Public Interface
|
||||
**No public API surface is defined in this file.**
|
||||
This file (`AssemblyInfo.cs`) is strictly metadata and contains no types, functions, classes, or methods. It only declares assembly-level attributes via `System.Reflection` and `System.Runtime.InteropServices` attributes.
|
||||
|
||||
## 3. Invariants
|
||||
- The assembly identity is fixed:
|
||||
- `AssemblyTitle` = `"GroupImportModule"`
|
||||
- `AssemblyVersion` = `"1.0.0.0"`
|
||||
- `AssemblyFileVersion` = `"1.0.0.0"`
|
||||
- `ComVisible` = `false`
|
||||
- `Guid` = `"f3e176ef-8eaf-4277-95f2-c8546c254248"`
|
||||
- The assembly is not intended for COM interop (per `ComVisible(false)`), and the GUID is reserved for typelib identification *only if* COM exposure were enabled in the future.
|
||||
- No runtime invariants apply, as this file contributes no executable code.
|
||||
|
||||
## 4. Dependencies
|
||||
- **Dependencies**:
|
||||
- `System.Reflection`
|
||||
- `System.Runtime.CompilerServices`
|
||||
- `System.Runtime.InteropServices`
|
||||
These are standard .NET Framework/BCL namespaces (no external dependencies inferred).
|
||||
- **Dependents**:
|
||||
- Unknown from this file alone. This assembly is likely referenced by other modules in the `DataPRO` solution (e.g., a core group management module or a UI layer), but no explicit references are declared here.
|
||||
|
||||
## 5. Gotchas
|
||||
- **Assembly versioning is static**: Both `AssemblyVersion` and `AssemblyFileVersion` are hardcoded to `1.0.0.0`. This may indicate legacy or placeholder configuration; in practice, versioning should be updated for releases to avoid binding issues.
|
||||
- **COM visibility is disabled**: If COM interop is required (e.g., for legacy automation), `ComVisible(true)` and explicit `Guid` on *types* (not just the assembly) would be necessary—this file alone does not enable COM.
|
||||
- **No functional code**: Developers should not expect to find import logic here. The actual implementation resides in other files (e.g., `GroupImporter.cs`, `ImportHandler.cs`), which are not provided.
|
||||
- **Copyright year is 2017**: May indicate outdated metadata if the module has been recently modified.
|
||||
|
||||
None identified beyond the above.
|
||||
@@ -0,0 +1,87 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Groups/GroupImport/Resources/TranslateExtension.cs
|
||||
- DataPRO/Modules/Groups/GroupImport/Resources/StringResources.Designer.cs
|
||||
generated_at: "2026-04-16T04:45:43.131858+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "d8e7eb58224237bd"
|
||||
---
|
||||
|
||||
# Resources
|
||||
|
||||
## Documentation: `TranslateExtension` Markup Extension
|
||||
|
||||
---
|
||||
|
||||
### 1. **Purpose**
|
||||
|
||||
This module provides a WPF `MarkupExtension` (`TranslateExtension`) to enable declarative, localized string resolution in XAML. It allows UI elements to bind to localized resources using a string key, falling back to a visible placeholder if the key is missing or the resource is unavailable. Its role is to support internationalization (i18n) of the Group Import module’s UI by abstracting resource lookup away from code-behind and into XAML markup.
|
||||
|
||||
---
|
||||
|
||||
### 2. **Public Interface**
|
||||
|
||||
#### `TranslateExtension` class
|
||||
**Namespace:** `DBImportExport.Resources`
|
||||
**Base class:** `System.Windows.Markup.MarkupExtension`
|
||||
**Attribute:** `[MarkupExtensionReturnType(typeof(string))]`
|
||||
|
||||
##### Constructor
|
||||
```csharp
|
||||
public TranslateExtension(string key)
|
||||
```
|
||||
- **Parameters:**
|
||||
- `key`: The resource key (e.g., `"GroupTags"`, `"Import_Importing"`) used to look up a localized string in `StringResources`.
|
||||
- **Behavior:** Stores the key for later use in `ProvideValue`.
|
||||
|
||||
##### `ProvideValue` method
|
||||
```csharp
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
```
|
||||
- **Returns:** `string`
|
||||
- **Behavior:**
|
||||
- If `_key` is `null` or empty → returns `"#stringnotfound#"`.
|
||||
- Otherwise, attempts to retrieve the string via `StringResources.ResourceManager.GetString(_key)`.
|
||||
- If found → returns the localized string.
|
||||
- If not found (`null`) → returns `"#stringnotfound# " + _key` (e.g., `"#stringnotfound# Import_Importing"`).
|
||||
- **Note:** The `serviceProvider` parameter is unused.
|
||||
|
||||
---
|
||||
|
||||
### 3. **Invariants**
|
||||
|
||||
- `_key` is immutable after construction (no setter, no mutation).
|
||||
- `StringResources.ResourceManager.GetString(key)` is the *only* source of localized strings; no fallback logic beyond the `NotFound` constant is implemented.
|
||||
- The `NotFound` constant (`"#stringnotfound#"`) is used consistently for both missing keys and missing values.
|
||||
- If `StringResources.ResourceManager` fails to initialize (e.g., due to assembly/resource loading issues), `GetString` may throw — but this is not handled in the extension and would result in a runtime exception.
|
||||
|
||||
---
|
||||
|
||||
### 4. **Dependencies**
|
||||
|
||||
#### **Internal Dependencies**
|
||||
- `GroupImport.Resources.StringResources`:
|
||||
- Strongly-typed resource class generated from `.resx` files.
|
||||
- Provides access to localized strings via `ResourceManager.GetString(key)`.
|
||||
- Contains keys like `"GroupTags"`, `"Import_Importing"`, `"Preview_InvalidName"`, etc.
|
||||
|
||||
#### **External Dependencies**
|
||||
- `System.Windows.Markup.MarkupExtension`: Base class for WPF markup extensions.
|
||||
- `System`: Used for `string.IsNullOrEmpty`, `object.ReferenceEquals`, etc.
|
||||
|
||||
#### **Consumers (Inferred)**
|
||||
- XAML files in the `GroupImport` module (e.g., `*.xaml`) that use `{local:Translate KeyName}` syntax to bind UI text to localized resources.
|
||||
|
||||
---
|
||||
|
||||
### 5. **Gotchas**
|
||||
|
||||
- **No null-safety for `ResourceManager.GetString()`**: If `StringResources.ResourceManager` is misconfigured (e.g., wrong base name `"GroupImport.Resources.StringResources"`), `GetString` may return `null` or throw — the extension only handles `null` by appending the key to `#stringnotfound#`.
|
||||
- **Hardcoded `NotFound` string**: The placeholder `"#stringnotfound#"` is visible in the UI if a key is missing, which may confuse end users. No localization-aware fallback (e.g., returning the key itself) is implemented.
|
||||
- **No caching of resolved values**: `ProvideValue` is called repeatedly (e.g., during layout updates), and each call re-invokes `ResourceManager.GetString`. While `ResourceManager` caches internally, repeated calls are still inefficient.
|
||||
- **Namespace mismatch**: The class resides in `DBImportExport.Resources` but references `GroupImport.Resources.StringResources`. This may indicate legacy refactoring or intentional decoupling — developers should verify assembly/resource naming consistency.
|
||||
- **No support for format strings**: While `StringResources` contains format strings (e.g., `"Importing {0}:{1}"`), `TranslateExtension` does not accept or apply arguments — it only resolves the raw key. Formatting must be handled elsewhere (e.g., in code-behind or via `String.Format` after resolution).
|
||||
- **Auto-generated `StringResources.Designer.cs`**: Changes to `.resx` files require regeneration of `StringResources`. If keys are renamed/removed in `.resx` but not updated in XAML, `TranslateExtension` will return the `#stringnotfound#` fallback.
|
||||
|
||||
> **None identified from source alone** regarding thread-safety, disposal, or WPF-specific lifecycle quirks — but given the simplicity of the extension, it is likely safe for standard WPF usage.
|
||||
@@ -0,0 +1,100 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Groups/GroupImport/View/GroupImportImportView.xaml.cs
|
||||
- DataPRO/Modules/Groups/GroupImport/View/GroupImportOptionsView.xaml.cs
|
||||
- DataPRO/Modules/Groups/GroupImport/View/GroupImportPreviewView.xaml.cs
|
||||
generated_at: "2026-04-16T04:46:11.528450+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "4920dece220dd9a5"
|
||||
---
|
||||
|
||||
# View
|
||||
|
||||
### **Purpose**
|
||||
This module provides the WPF UI views for the group import workflow within the DataPRO system, specifically handling user interaction for selecting source files, configuring import options, previewing imported groups and channels, and validating the import state before proceeding. It serves as the presentation layer for the group import functionality, coordinating with a shared `GroupImportViewModel` to manage state and business logic, while enforcing UI-specific validation rules and user privilege checks (e.g., admin-only tag editing).
|
||||
|
||||
---
|
||||
|
||||
### **Public Interface**
|
||||
|
||||
#### **`GroupImportImportView`**
|
||||
- **Type**: `partial class` implementing `IGroupImportImportView`
|
||||
- **Constructor**: `GroupImportImportView()`
|
||||
- Initializes the WPF component via `InitializeComponent()`.
|
||||
- *No additional logic or public members exposed beyond initialization.*
|
||||
|
||||
#### **`GroupImportOptionsView`**
|
||||
- **Type**: `partial class` implementing `IGroupImportOptionsView`
|
||||
- **Constructor**: `GroupImportOptionsView()`
|
||||
- Initializes the WPF component via `InitializeComponent()`.
|
||||
- **`Validate(out List<string> errors, out List<string> warnings)`**
|
||||
- **Signature**: `public bool Validate(out List<string> errors, out List<string> warnings)`
|
||||
- **Behavior**: Validates that at least one source file is selected.
|
||||
- Returns `true` if `vm.SourceFiles.Length >= 1`.
|
||||
- Returns `false` and populates `errors` with `StringResources.Preview_NoFilesSelected` if no files are selected.
|
||||
- *Note*: Does not validate file contents or other options—only file presence.
|
||||
|
||||
#### **`GroupImportPreviewView`**
|
||||
- **Type**: `partial class` implementing `IGroupImportPreviewView`
|
||||
- **Constructor**: `GroupImportPreviewView()`
|
||||
- Initializes the WPF component via `InitializeComponent()`.
|
||||
- **Event Handlers** (WPF event wiring, not public API but critical for behavior):
|
||||
- `GroupName_Changed(object sender, TextChangedEventArgs e)`
|
||||
- Updates the `GroupName` property of the bound `GroupGRPImportGroup` instance.
|
||||
- Calls `GroupNameInvalidate()` on all channels in the group.
|
||||
- Triggers `vm.CheckGroupName()` on the `GroupImportViewModel`.
|
||||
- `GroupTags_Changed(object sender, TextChangedEventArgs e)`
|
||||
- Updates the `GroupTags` property of the bound `GroupGRPImportGroup` instance.
|
||||
- `IncludedChecked(object sender, RoutedEventArgs e)`
|
||||
- Calls `vm.InvalidateChannels()` on the `GroupImportViewModel`.
|
||||
- `IncludedUnchecked(object sender, RoutedEventArgs e)`
|
||||
- Calls `vm.InvalidateChannels()` on the `GroupImportViewModel`.
|
||||
- **`Validate(bool userIsAdmin, out List<string> errors, out List<string> warnings)`**
|
||||
- **Signature**: `public bool Validate(bool userIsAdmin, out List<string> errors, out List<string> warnings)`
|
||||
- **Behavior**: Performs comprehensive validation of groups and channels for import.
|
||||
- Checks admin-only tag compatibility: if `!userIsAdmin` and `GroupTags` contains tags not in `ImportingUserTags`, adds a formatted error and returns `false`.
|
||||
- Checks `GroupNameHasError`: adds `StringResources.Preview_InvalidName` error and returns `false`.
|
||||
- Checks `GroupErrors`: adds all `ExtraInfo` strings as errors and returns `false`.
|
||||
- Checks if group exists (`vm.CheckGroupExists`) and `!Overwrite`: adds `StringResources.Preview_InvalidName` error and returns `false`.
|
||||
- Iterates channels:
|
||||
- On `ch.Error != null`:
|
||||
- Adds warnings or errors based on `ErrorCode` (e.g., `InvalidISOCodeInput`, `InvalidFullScaleInput`, `SensorNotFound`).
|
||||
- Some errors (`FileEmpty`, `InvalidISOCodeInput`) set `bAnyValidChannels = true` but do *not* fail validation.
|
||||
- On `ch.Error == null`: sets `bValid = true` and `bAnyValidChannels = true`.
|
||||
- If no valid channels exist (`!bAnyValidChannels`), adds `StringResources.Preview_NoGroupsToImport` to errors and returns `false`.
|
||||
- Returns `true` only if no fatal errors occurred and at least one valid channel exists.
|
||||
|
||||
---
|
||||
|
||||
### **Invariants**
|
||||
- **File Selection**: `GroupImportOptionsView.Validate()` requires `SourceFiles.Length >= 1` for success; otherwise, it fails with a specific error.
|
||||
- **Admin Tag Enforcement**: Non-admin users cannot set `GroupTags` that include tags not present in `ImportingUserTags`; this causes immediate validation failure with a detailed error message.
|
||||
- **Group Name Validity**: A group with `GroupNameHasError == true`, existing group name without `Overwrite == true`, or non-empty `GroupErrors` causes immediate validation failure in `GroupImportPreviewView.Validate()`.
|
||||
- **Channel-Level Errors**:
|
||||
- `FileEmpty` and `InvalidISOCodeInput` errors do *not* prevent import (but may indicate partial failure).
|
||||
- `InvalidFullScaleInput`, `InvalidInvertInput`, `InvalidSensorInput`, and `SensorNotFound` produce warnings but do *not* block import.
|
||||
- **No-Import Guard**: If no channels are valid (`bAnyValidChannels == false`), validation fails with `StringResources.Preview_NoGroupsToImport`.
|
||||
|
||||
---
|
||||
|
||||
### **Dependencies**
|
||||
- **External Dependencies**:
|
||||
- `DTS.Common.Interface.Groups`: Defines interfaces `IGroupImportImportView`, `IGroupImportOptionsView`, `IGroupImportPreviewView`.
|
||||
- `DTS.Common.Classes.Groups`: Provides concrete types `GroupGRPImportGroup`, `GroupGRPImportError`.
|
||||
- `DTS.Common.Strings`: Provides `StringResources` for localized error/warning messages.
|
||||
- `GroupImport.Resources`: Contains `StringResources` (likely auto-generated `.resx`-based resources).
|
||||
- **Internal Dependencies**:
|
||||
- `GroupImportViewModel`: Used as `DataContext` in all three views; its methods (`CheckGroupName`, `InvalidateChannels`, `CheckGroupExists`) are called directly.
|
||||
- WPF framework (`System.Windows.Controls`, `System.Windows.RoutedEventArgs`, etc.).
|
||||
|
||||
---
|
||||
|
||||
### **Gotchas**
|
||||
- **Typo in XML comment**: `GroupImportPreviewView.xaml.cs` has `/// <summary> Interaction logic for GroupImportOptionsView.xaml </summary>` instead of `GroupImportPreviewView.xaml`.
|
||||
- **Ambiguous `bValid` logic**: In `GroupImportPreviewView.Validate()`, `bValid` is initialized to `true`, then set to `false` *before* checking channels, and only set to `true` if a channel has no error. This may be confusing—`bValid` is ultimately determined by whether *at least one* channel is valid *and* no fatal errors occurred.
|
||||
- **Tag validation is strict**: Non-admin users are blocked if *any* tag in `GroupTags` is not in `ImportingUserTags`. The error message lists both sets explicitly.
|
||||
- **Duplicate error suppression**: Errors/warnings are deduplicated via `!errors.Contains(...)` checks, but this is linear-time and may be inefficient for large error sets.
|
||||
- **No explicit handling for null `vm`**: All views cast `DataContext` to `GroupImportViewModel` without null checks; a null `DataContext` will cause a `NullReferenceException`.
|
||||
- **`GroupNameInvalidate()` and `InvalidateChannels()` are called on UI thread changes**: These likely trigger re-validation or UI refreshes; callers must ensure thread-safety if invoked off-thread (though WPF data binding typically handles this).
|
||||
- **`Split()` extension method**: Used on `ImportingUserTags` and `GroupTags` (e.g., `g.ImportingUserTags.Split()`), implying a custom extension method (not standard `string.Split()`); behavior depends on its implementation (e.g., whitespace delimiters? empty entries?).
|
||||
@@ -0,0 +1,188 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Groups/GroupImport/ViewModel/GroupImportViewModel.cs
|
||||
generated_at: "2026-04-16T04:45:51.906727+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "f514e88931e0b70e"
|
||||
---
|
||||
|
||||
# GroupImportViewModel Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
`GroupImportViewModel` is the central view model for the group and channel import functionality in the DTS application. It orchestrates the end-to-end workflow of importing data from `.grp` files—parsing file contents, validating sensor and field data, allowing user review and selection of groups/channels for import, and committing validated data to the database via background processing. It serves as the data context for three distinct views (`IGroupImportOptionsView`, `IGroupImportPreviewView`, `IGroupImportImportView`) and integrates with Prism’s region management, event aggregation, and Unity DI container to coordinate UI state and external service calls.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Constructor
|
||||
```csharp
|
||||
public GroupImportViewModel(
|
||||
IGroupImportOptionsView optionsView,
|
||||
IGroupImportPreviewView previewView,
|
||||
IGroupImportImportView importView,
|
||||
IRegionManager regionManager,
|
||||
IEventAggregator eventAggregator,
|
||||
IUnityContainer unityContainer)
|
||||
```
|
||||
Initializes the view model, assigns views and their `DataContext`, sets up interaction requests (`NotificationRequest`, `ConfirmationRequest`), and subscribes to `RaiseNotification` and `BusyIndicatorChangeNotification` events.
|
||||
|
||||
### Methods
|
||||
- **`void ParseSourceFiles(string userTags)`**
|
||||
Reads and parses all `.grp` files listed in `SourceFiles`. For each file:
|
||||
- Extracts group name from file name (strips extension).
|
||||
- Assigns `userTags` to `GroupTags` and `ImportingUserTags`.
|
||||
- Parses each non-empty line using `Parse()` (supports escaped commas via parentheses).
|
||||
- Validates fields: expects 5 fields per line (`SensorSerialNumber`, `DisplayName`, `ISOCode`, `Invert`, `FullScale`).
|
||||
- Reports errors for missing sensors (unless empty), invalid invert/full-scale values, wrong field count, or empty files.
|
||||
- Populates `Groups` and calls `ProcessChannels()`.
|
||||
|
||||
- **`void Import()`**
|
||||
Starts the import process on a background thread via `ThreadPool.QueueUserWorkItem(ImportFunc)`.
|
||||
|
||||
- **`private void ImportFunc(object o)`**
|
||||
Background method that:
|
||||
- Fetches default channel settings via `DbOperations.GetChannelSettingDefaults()`.
|
||||
- Updates UI progress state (`ImportProgressValue`, `ImportProgressBarVisibility`, `ImportProgressColor`, `DisableUI`).
|
||||
- Iterates over included groups and their channels:
|
||||
- Skips channels with critical errors (`FileEmpty`, `InvalidSensorInput`, `SensorNotFound`).
|
||||
- For non-critical errors, uses `null` for invalid `FullScale` or `Invert`.
|
||||
- Calls `CreateGroup`, `AddChannel`, and finally `CommitGroups`.
|
||||
- Restores UI state on completion (though commented-out lines suggest UI reset is incomplete).
|
||||
|
||||
- **`void SetStatus(string message, Color color)`**
|
||||
Updates `ImportProgressText`, `ImportProgressColor`, `ImportProgressBarVisibility` (collapsed), and invokes `EnableUI`.
|
||||
|
||||
- **`void Reset()`**
|
||||
Clears all imported data: `SourceFiles`, `Channels`, `Groups`, progress state, and resets `ImportProgressValue` to 0.
|
||||
|
||||
- **`void CheckGroupName()`**
|
||||
Validates group names:
|
||||
- Flags groups with duplicate names in the import set.
|
||||
- Flags groups whose name already exists in the application *and* `Overwrite` is `false`.
|
||||
- Sets `GroupNameHasError = true` on invalid groups.
|
||||
|
||||
- **`private static string[] Parse(string line)`**
|
||||
Parses a single `.grp` line, respecting parenthetical escaping (e.g., `"this(,)is"` → one field `"this(,)is"`).
|
||||
|
||||
- **`private void ProcessChannels()`**
|
||||
Flattens all channels from `Groups` into the `Channels` array.
|
||||
|
||||
- **`void InvalidateChannels()`**
|
||||
Raises `PropertyChanged` for `IncompleteChannels` and `CompleteChannels` computed properties.
|
||||
|
||||
- **`void Cleanup()` / `Task CleanupAsync()` / `void Initialize()` / `Task InitializeAsync()` / `void Activated()`**
|
||||
No-op stubs; likely required by Prism interfaces (`INavigationAware`, `IInitializeAsync`, etc.) but not implemented.
|
||||
|
||||
### Properties
|
||||
- **`IGroupImportOptionsView ImportOptionsView`**, **`IGroupImportPreviewView ImportPreviewView`**, **`IGroupImportImportView ImportView`**
|
||||
References to the three associated views.
|
||||
|
||||
- **`string[] SourceFiles`**
|
||||
Array of `.grp` file paths to parse.
|
||||
|
||||
- **`GroupGRPImportGroup[] Groups`**
|
||||
Parsed groups with their channels and errors.
|
||||
|
||||
- **`GroupGRPImportChannel[] Channels`**
|
||||
Flattened list of all channels from `Groups`.
|
||||
|
||||
- **`GroupGRPImportChannel[] IncompleteChannels`**
|
||||
Channels in included groups that have *non-recoverable* errors (e.g., `SensorNotFound`, `InvalidSensorInput`). These will *not* be imported.
|
||||
|
||||
- **`GroupGRPImportChannel[] CompleteChannels`**
|
||||
Channels in included groups that either have no errors *or* have recoverable errors (`InvalidFullScaleInput`, `InvalidInvertInput`). These *will* be imported (with `null` for invalid fields).
|
||||
|
||||
- **`string ImportProgressText`**, **`Color ImportProgressColor`**, **`Visibility ImportProgressBarVisibility`**, **`double ImportProgressValue`**
|
||||
UI state for the import progress bar.
|
||||
|
||||
- **`bool IsBusy`**
|
||||
Bound to busy indicator; set via `OnBusyIndicatorNotification`.
|
||||
|
||||
- **`InteractionRequest<Notification> NotificationRequest`**, **`InteractionRequest<Confirmation> ConfirmationRequest`**
|
||||
Prism interaction requests for showing notifications and confirmation dialogs.
|
||||
|
||||
- **`bool IsDirty`**
|
||||
Read-only; always `false` (never set to `true` in source).
|
||||
|
||||
- **`bool IsMenuIncluded`**, **`bool IsNavigationIncluded`**
|
||||
UI state flags (bound to menu/navigation visibility); no logic sets them beyond property change notifications.
|
||||
|
||||
- **`string HeaderInfo`**
|
||||
Returns `"MainRegion"`.
|
||||
|
||||
### Commands
|
||||
- **`DelegateCommand ImportBrowseCommand`**
|
||||
Opens a file dialog (`OpenFileDialog`) with `Multiselect=true`, `Filter` from `StringResources.ImportFileFilter`, sets `SourceFiles`, `BrowseOk=true`, and navigates to `Steps.Preview` via `SwitchNavSteps`.
|
||||
|
||||
### Delegates (Settable Properties)
|
||||
- **`CheckGroupExistsDelegate CheckGroupExists`**
|
||||
Function to check if a group exists in the application.
|
||||
|
||||
- **`CheckSensorExistsDelegate CheckSensorExists`**
|
||||
Function to check if a sensor exists.
|
||||
|
||||
- **`CreateGroupDelegate CreateGroup`**
|
||||
Action to create a group.
|
||||
|
||||
- **`AddChannelToGroupDelegate AddChannel`**
|
||||
Action to add a channel to a group.
|
||||
|
||||
- **`CommitGroupsDelegate CommitGroups`**
|
||||
Action to commit groups to the database.
|
||||
|
||||
- **`Disable_UIDelegate DisableUI`**, **`Enable_UIDelegate EnableUI`**
|
||||
Actions to disable/enable the UI during import.
|
||||
|
||||
- **`SwitchNavStepsDelegate SwitchNavSteps`**
|
||||
Action to navigate between import steps (e.g., `Steps.Preview`).
|
||||
|
||||
- **`FileUtils.LogDelegate Logger`**
|
||||
Optional logging delegate; invoked on exceptions.
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **File Parsing**: Each `.grp` line must contain 5 comma-separated fields (or be empty/whitespace). Lines with fewer or more fields are marked with `InvalidSensorInput`.
|
||||
- **Sensor Validation**: A channel is flagged `SensorNotFound` if `CheckSensorExists` is non-null, the sensor serial number is non-empty, and `CheckSensorExists(sensorSerialNumber)` returns `false`. Empty sensor serial numbers are *allowed* (per comment referencing FB13753).
|
||||
- **Invert Field**: Accepts `"yes"/"no"` (case-insensitive) or `bool.TryParse`-compatible strings. Invalid values trigger `InvalidInvertInput`.
|
||||
- **FullScale Field**: Must parse as `double`; otherwise, `InvalidFullScaleInput`.
|
||||
- **Group Name Uniqueness**: Within the import set, duplicate group names are flagged. Across the import set and application, group names must be unique *unless* `Overwrite=true`.
|
||||
- **Import Progress State**: During `ImportFunc`, `ImportProgressBarVisibility` is set to `Visible`, `DisableUI` is called, and progress is tracked. Completion logic is partially commented out, so UI may not fully reset.
|
||||
- **Channel Inclusion Logic**: Only channels from groups where `Included=true` are considered for import. Channels with critical errors (`FileEmpty`, `InvalidSensorInput`, `SensorNotFound`) are skipped entirely; others may be imported with `null` for invalid fields.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Imports/References
|
||||
- **DTS.Common**:
|
||||
- `Events` (`IEventAggregator`, `RaiseNotification`, `BusyIndicatorChangeNotification`)
|
||||
- `Utils` (`FileUtils.LogDelegate`)
|
||||
- `Classes.Groups` (`GroupGRPImportGroup`, `GroupGRPImportChannel`, `GroupGRPImportError`)
|
||||
- `Enums.Groups` (`GroupImportEnums.Steps`, `GroupGRPImportError.Errors`)
|
||||
- `Interface.Groups` (`IGroupImportOptionsView`, `IGroupImportPreviewView`, `IGroupImportImportView`, `IGroupImportViewModel`)
|
||||
- `Storage` (`DbOperations`)
|
||||
- `Interactivity` (`InteractionRequest<T>`)
|
||||
- **Prism**:
|
||||
- `Regions` (`IRegionManager`)
|
||||
- `Events` (`IEventAggregator`)
|
||||
- `DelegateCommand`
|
||||
- **Unity** (`IUnityContainer`)
|
||||
- **System.Windows** (`Visibility`, `Color`)
|
||||
- **System.Windows.Forms** (`OpenFileDialog`)
|
||||
- **StringResources** (resource strings for UI messages)
|
||||
|
||||
### Dependencies on External Services
|
||||
- `DbOperations.GetChannelSettingDefaults()` — for default channel settings.
|
||||
- `CheckSensorExists`, `CheckGroupExists`, `CreateGroup`, `AddChannel`, `CommitGroups` — injected delegates for database operations.
|
||||
- `SwitchNavSteps` — navigation delegate (likely from a parent view model or shell).
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
- **Incomplete UI Reset After Import**: `ImportFunc` sets `ImportProgressBarVisibility = Visibility.Visible` and `DisableUI`, but the corresponding reset (`Visibility.Collapsed`, `EnableUI`) is commented out. This may leave the UI in a disabled state if import completes without error.
|
||||
- **Empty Sensor Serial Numbers Are Allowed**: Despite `CheckSensorExists` validation, empty serial numbers bypass the `SensorNotFound` check (FB13753).
|
||||
- **Partial Error Tolerance**: Channels with `InvalidFullScaleInput` or `InvalidInvertInput` are included in `CompleteChannels` and imported, but with `null` for the invalid field. This may cause downstream issues if the database or business logic does not handle `null` gracefully.
|
||||
- **No Validation of Group Name Format**: Only existence and duplication are checked; no format validation (e.g., reserved characters, length limits) is implemented.
|
||||
- **`Parse()` Escaping Logic**: Parentheses are treated as literal characters *only* when nested (via `leftParenCount`). A single `(` or `)` without matching pairs is still treated as a delimiter if not balanced.
|
||||
- **`IsDirty` Never Set**: The `IsDirty` property is declared but never updated, so it always returns `false`.
|
||||
- **`Initialize*` and `Cleanup*` Methods Are No-ops**: These likely exist to satisfy Prism interfaces but contain no logic.
|
||||
- **`Channels` Property Triggers `InvalidateChannels()`**: Setting `Channels` raises property change notifications for `IncompleteChannels` and `CompleteChannels`, but these are computed properties—modifying `Channels` directly may not reflect changes in the UI if `Groups` is not updated.
|
||||
- **Thread Safety**: `ImportFunc` runs on a background thread but updates UI properties directly (e.g., `ImportProgressValue`). While Prism’s `INotifyPropertyChanged` may handle thread marshaling in some cases, this pattern is fragile and may cause cross-thread exceptions if the UI framework is strict.
|
||||
Reference in New Issue
Block a user