Files
2026-04-17 14:55:32 -04:00

5.6 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/DatabaseImporter/ConfigToDb/ConfigToDbMigrator.cs
2026-04-17T15:59:59.091141+00:00 zai-org/GLM-5-FP8 1 43b9fec3ece4689d

Documentation: ConfigToDbMigrator

1. Purpose

The ConfigToDbMigrator class is a migration utility responsible for transferring user and application settings from legacy DataPRO configuration files into a database. It reads settings from an older version's config file (located via a provided path), maps specific named settings to corresponding database property IDs, and persists them for all users in the system. This module exists to support version upgrades where settings storage was migrated from file-based configuration to database-backed storage.


2. Public Interface

migrateConfigToDb(string nextLowerPath, out string result)bool

Signature: public bool migrateConfigToDb(string nextLowerPath, out string result)

Orchestrates the full migration process. Loads both user and application settings from the config file at nextLowerPath, then inserts them into the database. Returns true on successful migration, false otherwise. The result output parameter contains a success/failure message.


ExportDesired(SupportedExportFormatBitFlags exportType, int settingValue)bool

Signature: public bool ExportDesired(SupportedExportFormatBitFlags exportType, int settingValue)

Determines whether a specific export format is enabled within a bitmask value. Uses bitwise AND comparison to check if the exportType flag is present in settingValue.


SupportedExportFormatBitFlags (public enum)

Defines bit flags for various export formats. Values include:

  • none = 0x0
  • csvunfiltered = 0x1
  • diademadc = 0x2
  • isounfiltered = 0x4
  • somatunfiltered = 0x8
  • tdmsadc = 0x10
  • toyotaunfiltered = 0x20
  • tsvunfiltered = 0x40
  • csvfiltered = 0x80
  • isofiltered = 0x200
  • somatfiltered = 0x400
  • tdasadc = 0x800
  • toyotafiltered = 0x1000
  • tsvfiltered = 0x2000
  • rdfadc = 0x4000
  • ChryslerDDAS = 0x8000
  • HDFUnfiltered = 0x10000
  • HDFFiltered = 0x20000
  • HDFMV = 0x40000
  • HDFADC = 0x80000
  • xlsxfiltered = 0x100000
  • xlsxunfiltered = 0x200000

3. Invariants

  • Config file location: The old config file path is constructed as nextLowerPath + Resources.RegistryDataPROExe.
  • Settings source: Only settings named "UserSettings" and "ApplicationSettings" section groups are processed.
  • Database storage: All settings are stored per-user; StoreInDb iterates over all user IDs returned by GetAllUserIds().
  • Stored procedures: Database operations use sp_UserPropertiesUpdateInsert for inserts/updates and sp_UserGetIdsAll for retrieving user IDs.
  • Error handling: If result contains either Resources.OldSettingsCouldNotBeFound or Resources.OldSettingsCouldNotBeProcessed, migration halts and returns false.
  • Unit conversion: DefaultTestExcitationWarmupMS is converted from milliseconds to seconds before storage.

4. Dependencies

This module depends on:

  • System.Configuration — For ConfigurationManager, Configuration, ClientSettingsSection, and configuration section group handling.
  • System.Data.SqlClient — For SqlConnection, SqlCommand, SqlParameter database operations.
  • ConfigToDb.Properties.Resources — For localized string resources (UserSettings, ApplicationSettings, OldSettingsCouldNotBeFound, OldSettingsCouldNotBeProcessed, RegistryDataPROExe).
  • DTS.Common.Storage — Inferred; likely contains DbOperations infrastructure.
  • DTS.Slice.Users.UserSettings — For SettingElementCollection and SettingElement types.
  • DatabaseImport.DbOperations — For GetSQLCommand(), Connection.QueryDataSet().
  • PropertyEnums.PropertyIds — Enum defining property IDs for database storage.
  • DbOperationsEnum.StoredProcedure — Enum for stored procedure names.
  • DbOperations.Users.UserFields — For user field name constants.

What depends on this module:

  • Unclear from source alone. No consumers are shown in this file.

5. Gotchas

  1. Silent failure in GetAllUserIds(): Exceptions are caught and swallowed; an empty list is returned, which would result in no settings being stored for any user without any indication of failure.

  2. Empty error handling block: In StoreInDb(), the condition if (int.Parse(errorNumberParam.Value.ToString()) != 0) has an empty body — database errors from the stored procedure are ignored.

  3. Hardcoded assumption about install location: The comment in GetOldConfigSettings() states: "this assumes that it was installed in the default folder!!!"

  4. Duplicate case handling: The setting key "DefaultTestTriggerCheckStep" appears twice in the switch statement, mapping to two different property IDs (DefaultTriggerCheckStep and DefaultTriggerCheckStep). The second case will never execute.

  5. Semantic name mismatch: DefaultTestAllowSensorIdToBlankChannel maps to DefaultRequireSensorIdFound — the inverted naming suggests possible logic inversion, but this is unclear from source alone.

  6. Unit conversion for one setting only: DefaultTestExcitationWarmupMS is explicitly converted from ms to seconds, but DefaultTestExcitationTOMWarmupDelayMS and DefaultTestExcitationIEPEWarmupDelayMS are stored as-is without conversion. Whether this is intentional is unclear from source alone.

  7. Export format expansion: The single DefaultTestExportFormat integer setting is expanded into 22 separate boolean database properties via bit flag checking.