init
This commit is contained in:
98
docs/ai/DataPRO/Modules/Groups/GroupImport/ViewModel.md
Normal file
98
docs/ai/DataPRO/Modules/Groups/GroupImport/ViewModel.md
Normal file
@@ -0,0 +1,98 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/Groups/GroupImport/ViewModel/GroupImportViewModel.cs
|
||||
generated_at: "2026-04-17T16:01:00.422137+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "ea98f9d39127a201"
|
||||
---
|
||||
|
||||
# GroupImportViewModel Documentation
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
`GroupImportViewModel` is the ViewModel responsible for importing Groups and TestObjects from `.grp` files in a WPF/Prism-based application. It orchestrates the complete import workflow: file browsing, parsing source files into group/channel structures, validating data, previewing import contents, and executing the import on a background thread. The class implements `IGroupImportViewModel` and serves as the data context for three views (`IGroupImportOptionsView`, `IGroupImportPreviewView`, `IGroupImportImportView`).
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Constructor
|
||||
```csharp
|
||||
public GroupImportViewModel(
|
||||
IGroupImportOptionsView optionsView,
|
||||
IGroupImportPreviewView previewView,
|
||||
IGroupImportImportView importView,
|
||||
IRegionManager regionManager,
|
||||
IEventAggregator eventAggregator,
|
||||
IUnityContainer unityContainer)
|
||||
```
|
||||
Initializes the ViewModel, wires up view DataContexts, creates interaction requests, and subscribes to `RaiseNotification` and `BusyIndicatorChangeNotification` events.
|
||||
|
||||
### Public Methods
|
||||
|
||||
| Method | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `ParseSourceFiles` | `void ParseSourceFiles(string userTags)` | Reads `.grp` files from `SourceFiles`, parsing groups and channels. Populates `Groups` and `Channels` arrays. |
|
||||
| `Import` | `void Import()` | Queues the import operation on a background thread via `ThreadPool.QueueUserWorkItem`. |
|
||||
| `SetStatus` | `void SetStatus(string message, Color color)` | Updates `ImportProgressColor`, hides progress bar, sets `ImportProgressText`, and invokes `EnableUI`. |
|
||||
| `Reset` | `void Reset()` | Re-initializes the ViewModel to default state (clears `SourceFiles`, `Channels`, `Groups`, resets progress UI). |
|
||||
| `CheckGroupName` | `void CheckGroupName()` | Validates group names for duplicates within the import and against existing groups (if `Overwrite` is false). Sets `GroupNameHasError` on each group. |
|
||||
| `OnPropertyChanged` | `void OnPropertyChanged(string propertyName)` | Raises the `PropertyChanged` event. |
|
||||
| `InvalidateChannels` | `void InvalidateChannels()` | Raises PropertyChanged for `IncompleteChannels` and `CompleteChannels`. |
|
||||
| `Cleanup` | `void Cleanup()` | Empty implementation. |
|
||||
| `CleanupAsync` | `Task CleanupAsync()` | Returns `Task.CompletedTask`. |
|
||||
| `Initialize` | `void Initialize()` / `void Initialize(object parameter)` / `void Initialize(object parameter, object model)` | Empty implementations. |
|
||||
| `InitializeAsync` | `Task InitializeAsync()` / `Task InitializeAsync(object parameter)` | Return `Task.CompletedTask`. |
|
||||
| `Activated` | `void Activated()` | Empty implementation. |
|
||||
|
||||
### Commands
|
||||
|
||||
| Property | Type | Description |
|
||||
|----------|------|-------------|
|
||||
| `ImportBrowseCommand` | `DelegateCommand` | Opens an `OpenFileDialog` for selecting `.grp` files. Sets `SourceFiles` and `BrowseOk`, then invokes `SwitchNavSteps` with `Preview` step. |
|
||||
|
||||
### Public Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
|----------|------|-------------|
|
||||
| `ImportOptionsView` | `IGroupImportOptionsView` | The options view instance. |
|
||||
| `ImportPreviewView` | `IGroupImportPreviewView` | The preview view instance. |
|
||||
| `ImportView` | `IGroupImportImportView` | The import view instance. |
|
||||
| `NotificationRequest` | `InteractionRequest<Notification>` | Interaction request for notifications. |
|
||||
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | Interaction request for confirmations. |
|
||||
| `IsDirty` | `bool` | Always returns `false` (private setter never called). |
|
||||
| `IsBusy` | `bool` | Bound to `BusyIndicatorChangeNotification` event. |
|
||||
| `IsMenuIncluded` | `bool` | Menu inclusion flag. |
|
||||
| `IsNavigationIncluded` | `bool` | Navigation inclusion flag. |
|
||||
| `HeaderInfo` | `string` | Returns `"MainRegion"`. |
|
||||
| `ImportProgressText` | `string` | Status text for import progress bar. |
|
||||
| `ImportProgressColor` | `Color` | Color of the import progress bar. |
|
||||
| `ImportProgressBarVisibility` | `Visibility` | Controls progress bar visibility. |
|
||||
| `ImportProgressValue` | `double` | Percentage complete of import process. |
|
||||
| `SourceFiles` | `string[]` | Array of `.grp` file paths to parse. Initialized to empty array. |
|
||||
| `BrowseOk` | `bool` | Indicates if file browse completed successfully. Default `false`. |
|
||||
| `Groups` | `GroupGRPImportGroup[]` | All parsed groups. Initialized to empty array. |
|
||||
| `Channels` | `GroupGRPImportChannel[]` | All channels from all groups. Setter calls `InvalidateChannels()`. |
|
||||
| `IncompleteChannels` | `GroupGRPImportChannel[]` | Computed: channels that will NOT be imported (errors other than `InvalidFullScaleInput` or `InvalidInvertInput`). |
|
||||
| `CompleteChannels` | `GroupGRPImportChannel[]` | Computed: channels that WILL be imported (no error, or only `InvalidFullScaleInput`/`InvalidInvertInput`). |
|
||||
| `Logger` | `FileUtils.LogDelegate` | Logging facility. If `null`, no logging occurs. |
|
||||
| `SwitchNavSteps` | `SwitchNavStepsDelegate` | Command for switching navigation steps. |
|
||||
| `CheckGroupExists` | `CheckGroupExistsDelegate` | Command to check if a group exists in the application. |
|
||||
| `CheckSensorExists` | `CheckSensorExistsDelegate` | Command to check if a sensor exists. |
|
||||
| `CreateGroup` | `CreateGroupDelegate` | Command to create a group. |
|
||||
| `AddChannel` | `AddChannelToGroupDelegate` | Command to add a channel to a group. |
|
||||
| `CommitGroups` | `CommitGroupsDelegate` | Command to commit groups to the database. |
|
||||
| `DisableUI` | `Disable_UIDelegate` | Command to disable the UI during import. |
|
||||
| `EnableUI` | `Enable_UIDelegate` | Command to enable the UI after import. |
|
||||
|
||||
### Events
|
||||
```csharp
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- **File Format**: `.grp` files
|
||||
Reference in New Issue
Block a user