7.6 KiB
7.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T04:46:11.528450+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 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 classimplementingIGroupImportImportView - Constructor:
GroupImportImportView()- Initializes the WPF component via
InitializeComponent(). - No additional logic or public members exposed beyond initialization.
- Initializes the WPF component via
GroupImportOptionsView
- Type:
partial classimplementingIGroupImportOptionsView - Constructor:
GroupImportOptionsView()- Initializes the WPF component via
InitializeComponent().
- Initializes the WPF component via
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
trueifvm.SourceFiles.Length >= 1. - Returns
falseand populateserrorswithStringResources.Preview_NoFilesSelectedif no files are selected.
- Returns
- Note: Does not validate file contents or other options—only file presence.
- Signature:
GroupImportPreviewView
- Type:
partial classimplementingIGroupImportPreviewView - Constructor:
GroupImportPreviewView()- Initializes the WPF component via
InitializeComponent().
- Initializes the WPF component via
- Event Handlers (WPF event wiring, not public API but critical for behavior):
GroupName_Changed(object sender, TextChangedEventArgs e)- Updates the
GroupNameproperty of the boundGroupGRPImportGroupinstance. - Calls
GroupNameInvalidate()on all channels in the group. - Triggers
vm.CheckGroupName()on theGroupImportViewModel.
- Updates the
GroupTags_Changed(object sender, TextChangedEventArgs e)- Updates the
GroupTagsproperty of the boundGroupGRPImportGroupinstance.
- Updates the
IncludedChecked(object sender, RoutedEventArgs e)- Calls
vm.InvalidateChannels()on theGroupImportViewModel.
- Calls
IncludedUnchecked(object sender, RoutedEventArgs e)- Calls
vm.InvalidateChannels()on theGroupImportViewModel.
- Calls
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
!userIsAdminandGroupTagscontains tags not inImportingUserTags, adds a formatted error and returnsfalse. - Checks
GroupNameHasError: addsStringResources.Preview_InvalidNameerror and returnsfalse. - Checks
GroupErrors: adds allExtraInfostrings as errors and returnsfalse. - Checks if group exists (
vm.CheckGroupExists) and!Overwrite: addsStringResources.Preview_InvalidNameerror and returnsfalse. - Iterates channels:
- On
ch.Error != null:- Adds warnings or errors based on
ErrorCode(e.g.,InvalidISOCodeInput,InvalidFullScaleInput,SensorNotFound). - Some errors (
FileEmpty,InvalidISOCodeInput) setbAnyValidChannels = truebut do not fail validation.
- Adds warnings or errors based on
- On
ch.Error == null: setsbValid = trueandbAnyValidChannels = true.
- On
- If no valid channels exist (
!bAnyValidChannels), addsStringResources.Preview_NoGroupsToImportto errors and returnsfalse. - Returns
trueonly if no fatal errors occurred and at least one valid channel exists.
- Checks admin-only tag compatibility: if
- Signature:
Invariants
- File Selection:
GroupImportOptionsView.Validate()requiresSourceFiles.Length >= 1for success; otherwise, it fails with a specific error. - Admin Tag Enforcement: Non-admin users cannot set
GroupTagsthat include tags not present inImportingUserTags; this causes immediate validation failure with a detailed error message. - Group Name Validity: A group with
GroupNameHasError == true, existing group name withoutOverwrite == true, or non-emptyGroupErrorscauses immediate validation failure inGroupImportPreviewView.Validate(). - Channel-Level Errors:
FileEmptyandInvalidISOCodeInputerrors do not prevent import (but may indicate partial failure).InvalidFullScaleInput,InvalidInvertInput,InvalidSensorInput, andSensorNotFoundproduce warnings but do not block import.
- No-Import Guard: If no channels are valid (
bAnyValidChannels == false), validation fails withStringResources.Preview_NoGroupsToImport.
Dependencies
- External Dependencies:
DTS.Common.Interface.Groups: Defines interfacesIGroupImportImportView,IGroupImportOptionsView,IGroupImportPreviewView.DTS.Common.Classes.Groups: Provides concrete typesGroupGRPImportGroup,GroupGRPImportError.DTS.Common.Strings: ProvidesStringResourcesfor localized error/warning messages.GroupImport.Resources: ContainsStringResources(likely auto-generated.resx-based resources).
- Internal Dependencies:
GroupImportViewModel: Used asDataContextin 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.cshas/// <summary> Interaction logic for GroupImportOptionsView.xaml </summary>instead ofGroupImportPreviewView.xaml. - Ambiguous
bValidlogic: InGroupImportPreviewView.Validate(),bValidis initialized totrue, then set tofalsebefore checking channels, and only set totrueif a channel has no error. This may be confusing—bValidis 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
GroupTagsis not inImportingUserTags. 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 castDataContexttoGroupImportViewModelwithout null checks; a nullDataContextwill cause aNullReferenceException. GroupNameInvalidate()andInvalidateChannels()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 onImportingUserTagsandGroupTags(e.g.,g.ImportingUserTags.Split()), implying a custom extension method (not standardstring.Split()); behavior depends on its implementation (e.g., whitespace delimiters? empty entries?).