init
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/SLICEDBMerge/SLICEDBMerge/Program.cs
|
||||
- DataPRO/SLICEDBMerge/SLICEDBMerge/Form1.cs
|
||||
- DataPRO/SLICEDBMerge/SLICEDBMerge/Form1.Designer.cs
|
||||
generated_at: "2026-04-16T04:28:15.975483+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "352f915421417df4"
|
||||
---
|
||||
|
||||
# SLICEDBMerge Module Documentation
|
||||
|
||||
## 1. Purpose
|
||||
This module is a Windows Forms desktop application designed to merge sensor data and calibration records from a source sensor database directory into a destination sensor database directory. It provides a user interface to browse and select directories, display available sensors in both source and destination locations, allow selective inclusion of sensors via checkboxes, and perform the merge operation by appending selected sensor data and their latest calibration records to the destination database. The tool is intended for database consolidation or migration scenarios where sensor metadata and calibration history need to be transferred between physical database folders.
|
||||
|
||||
## 2. Public Interface
|
||||
The module exposes only one public class: `Form1`, which serves as the main application window. All interaction occurs through UI controls; there are no other public APIs.
|
||||
|
||||
- **`Form1()`**
|
||||
Constructor. Initializes the form and its components via `InitializeComponent()`.
|
||||
|
||||
- **`btnBrowse_Click(object sender, EventArgs e)`**
|
||||
Event handler for the *Source* folder browse button. Opens a `FolderBrowserDialog`, sets `tbSourceLocation.Text` to the selected path, and calls `LoadSourceDG()` to populate the source sensor grid.
|
||||
|
||||
- **`btnDestinationBrowse_Click(object sender, EventArgs e)`**
|
||||
Event handler for the *Destination* folder browse button. Opens a `FolderBrowserDialog`, sets `tbDestination.Text` to the selected path, and calls `LoadDestinationDG()` to populate the destination sensor grid.
|
||||
|
||||
- **`button1_Click(object sender, EventArgs e)`**
|
||||
Event handler for the *Merge* button. Iterates over rows in the source grid (`dgSource`) starting at index 1 (skipping header), and for each row where column index 1 (checkbox) is `true`, it retrieves the `SensorData` object from `UserData`, adds it to `_destination`, saves the destination database, retrieves the latest calibration for that sensor’s serial number, adds the calibration, and saves again. Errors are collected and displayed in a `MessageBox`. After processing, `LoadDestinationDG()` is called to refresh the destination grid.
|
||||
|
||||
- **`lbSelectAll_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)`**
|
||||
Sets the checkbox value (column 1) to `true` for all sensor rows in `dgSource`.
|
||||
|
||||
- **`lbInvertSelection_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)`**
|
||||
Toggles the checkbox value (column 1) for all sensor rows in `dgSource`.
|
||||
|
||||
- **`lbClearAll_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)`**
|
||||
Sets the checkbox value (column 1) to `false` for all sensor rows in `dgSource`.
|
||||
|
||||
## 3. Invariants
|
||||
- The source and destination directories must contain a valid `SensorDBTables.DataTableFilename` (exact filename not specified in source, but required for `LoadSourceDG()` to succeed).
|
||||
- `_sourceDB` and `_destination` are instance fields of type `DTS.SensorDB.SensorDBTables`; `_sourceDB` is only initialized in `LoadSourceDG()`, `_destination` only in `LoadDestinationDG()`.
|
||||
- Grid rows are indexed starting at 0, but data rows begin at index 1 (row 0 is assumed to be a header row).
|
||||
- Column 1 of each grid row is used as a boolean checkbox for selection.
|
||||
- Column indices for sensor data in the grid are fixed:
|
||||
- `1`: selection checkbox
|
||||
- `2`: `SerialNumber`
|
||||
- `3`: `Comment`
|
||||
- `4`: `Id`
|
||||
- `5`: `Range.High.ToString()`
|
||||
- `6`: `MeasurementUnit`
|
||||
- The `Save(null)` method is called twice per selected sensor: once after adding `SensorData`, once after adding `SensorCalibration`. This implies the destination database file is overwritten on each save (no incremental updates).
|
||||
- `GetLatestCalibrationBySerialNumber()` is called only if `_sourceDB` is non-null and the sensor data was successfully loaded.
|
||||
|
||||
## 4. Dependencies
|
||||
- **External Libraries**:
|
||||
- `System.Windows.Forms` (for `Form`, `Button`, `FolderBrowserDialog`, `MessageBox`, etc.)
|
||||
- `C1.Win.C1FlexGrid` (for `C1FlexGrid` control used for `dgSource` and `dgDestination`)
|
||||
- `DTS.SensorDB` (custom namespace; used via `SensorDBTables` and `SensorData`, `SensorCalibration` types)
|
||||
- **Internal Dependencies**:
|
||||
- `DTS.SensorDB.SensorDBTables` is assumed to provide:
|
||||
- Static field `DataTableFilename` (used to check existence of database file)
|
||||
- Instance method `Load(string path, bool flag1, object flag2, int flag3, int flag4)`
|
||||
- Instance method `GetAllSensors()` returning `SensorData[]`
|
||||
- Instance method `Add(object)` (used for both `SensorData` and `SensorCalibration`)
|
||||
- Instance method `Save(object)` (called with `null`)
|
||||
- Instance method `GetLatestCalibrationBySerialNumber(string serialNumber)` returning `SensorCalibration`
|
||||
- **Consumers**:
|
||||
- Only consumed by `Program.Main()` (entry point launching `Form1`). No other modules reference it.
|
||||
|
||||
## 5. Gotchas
|
||||
- **Partial initialization risk**: If `LoadSourceDG()` fails or is never called, `_sourceDB` remains `null`, and `button1_Click()` silently skips sensor/ calibration processing for all rows (due to `if (null == _sourceDB) { continue; }`).
|
||||
- **No validation of destination database structure**: The code assumes `_destination.Add()` and `_destination.Save()` will succeed regardless of whether the destination folder already contains a valid database or conflicting entries.
|
||||
- **Overly broad exception handling**: Exceptions during merge are caught per-sensor, but only the message is shown; stack traces and context are lost. Also, a failure in one sensor does not abort the entire merge.
|
||||
- **Hardcoded grid row/column assumptions**: Logic assumes row 0 is header and data starts at row 1; column indices (1–6) are hardcoded. Changes to grid layout in the designer will break functionality silently.
|
||||
- **No concurrency protection**: If the destination database is accessed concurrently (e.g., by another process), `Save(null)` may cause corruption or exceptions.
|
||||
- **No rollback on partial failure**: If adding sensor `N` succeeds but adding its calibration fails, sensor `N` remains in the destination database, leading to inconsistent state.
|
||||
- **No duplicate detection**: The code does not check if a sensor or calibration already exists in the destination before adding, potentially causing duplicates or errors depending on `SensorDBTables.Add()` behavior.
|
||||
- **`Save(null)` semantics unclear**: Passing `null` to `Save()` may imply saving to a default path or in-place; behavior depends on `DTS.SensorDB` implementation.
|
||||
- **No progress feedback**: Merging many sensors provides no UI feedback during the operation, risking perceived unresponsiveness.
|
||||
- **No cleanup on error**: If an exception occurs mid-merge, the partially modified destination database may be left in an inconsistent state.
|
||||
|
||||
None identified from source alone beyond those listed.
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/SLICEDBMerge/SLICEDBMerge/Properties/Settings.Designer.cs
|
||||
- DataPRO/SLICEDBMerge/SLICEDBMerge/Properties/AssemblyInfo.cs
|
||||
- DataPRO/SLICEDBMerge/SLICEDBMerge/Properties/Resources.Designer.cs
|
||||
generated_at: "2026-04-16T04:28:16.935057+00:00"
|
||||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||||
schema_version: 1
|
||||
sha256: "c0c93c253ce2e7f1"
|
||||
---
|
||||
|
||||
# Properties
|
||||
|
||||
## Documentation: `SliceDBMerge.Properties` Module
|
||||
|
||||
### 1. Purpose
|
||||
This module provides auto-generated .NET application infrastructure for the `SliceDBMerge` assembly—specifically, strongly-typed settings and resources management. It does not contain business logic for database merging; rather, it supports configuration persistence (via `Settings`) and localized string/resource retrieval (via `Resources`). It serves as a supporting layer for the main application, enabling centralized access to user/application settings and localized UI assets.
|
||||
|
||||
### 2. Public Interface
|
||||
All types are `internal` and intended for internal use only. No public APIs are exposed beyond the static accessors defined below.
|
||||
|
||||
- **`Settings.Default`**
|
||||
```csharp
|
||||
public static Settings Default { get; }
|
||||
```
|
||||
Returns the singleton instance of the `Settings` class, thread-safe via `ApplicationSettingsBase.Synchronized`. Used to read/write application/user settings. *Note: No settings properties are defined in this file; they must be declared in the corresponding `.settings` designer file (not provided here).*
|
||||
|
||||
- **`Resources.ResourceManager`**
|
||||
```csharp
|
||||
internal static ResourceManager ResourceManager { get; }
|
||||
```
|
||||
Returns a cached `ResourceManager` instance for the `SliceDBMerge.Properties.Resources` resource file. Used to look up localized strings, images, or other resources at runtime.
|
||||
|
||||
- **`Resources.Culture`**
|
||||
```csharp
|
||||
internal static CultureInfo Culture { get; set; }
|
||||
```
|
||||
Gets or sets the UI culture used for resource lookups. Allows overriding the current thread’s culture for resource resolution.
|
||||
|
||||
- **`Resources()`**
|
||||
```csharp
|
||||
internal Resources();
|
||||
```
|
||||
Private constructor—prevents instantiation. Class is static in behavior (all members are static).
|
||||
|
||||
### 3. Invariants
|
||||
- `Settings.Default` is lazily initialized once and reused for the lifetime of the app domain.
|
||||
- `Resources.ResourceManager` is initialized exactly once per app domain (caching is enforced).
|
||||
- Thread safety for `Settings.Default` is ensured via `ApplicationSettingsBase.Synchronized`, but *no guarantees are provided for atomicity of multi-property writes* (standard for .NET settings).
|
||||
- Resource lookups are case-sensitive and culture-aware (unless `Culture` is explicitly set).
|
||||
|
||||
### 4. Dependencies
|
||||
**Depends on:**
|
||||
- `System.Configuration` (for `ApplicationSettingsBase`)
|
||||
- `System.Resources` (for `ResourceManager`, `Resources`)
|
||||
- `System.Globalization` (for `CultureInfo`)
|
||||
- `System.CodeDom.Compiler`, `System.Runtime.CompilerServices`, `System.Diagnostics`, `System.ComponentModel` (for attributes and tooling support)
|
||||
|
||||
**Depended upon by:**
|
||||
- The main `SliceDBMerge` application (inferred from namespace and assembly name), likely via `Properties.Settings.Default` and `Properties.Resources` usage elsewhere in the codebase.
|
||||
- Not directly consumed by external assemblies (assembly is marked `[ComVisible(false)]`).
|
||||
|
||||
### 5. Gotchas
|
||||
- **No settings properties defined here**: The `Settings` class has no explicit properties in this file. Actual settings (e.g., `InputPath`, `OutputPath`) must be defined in `Settings.Designer.cs`’s corresponding `.settings` file (not included), or the class is incomplete.
|
||||
- **Auto-generated code**: Both `Settings.Designer.cs` and `Resources.Designer.cs` are tool-generated. Manual edits will be overwritten on rebuild.
|
||||
- **Thread-safety nuance**: While `Settings.Default` is thread-safe for *reading*, concurrent *writes* to settings properties may require external synchronization.
|
||||
- **Resource naming**: Resource keys are derived from `.resx` entries (not visible here); mismatches in key names between `.resx` and usage will cause runtime failures (e.g., `MissingManifestResourceException`).
|
||||
- **No versioning info exposed**: `AssemblyInfo.cs` defines version `1.0.0.0` but provides no runtime version-checking API—consumers must use reflection (`Assembly.GetExecutingAssembly().GetName().Version`) to inspect.
|
||||
|
||||
None identified beyond the above.
|
||||
Reference in New Issue
Block a user