18 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T02:08:08.051368+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 695fcda61b684601 |
Documentation: DTS.Common.Import.Persist Module
1. Purpose
This module provides a family of concrete implementations for persisting various types of imported data during a data import workflow. Each class (Save*) corresponds to a distinct category of data (e.g., hardware, groups, test setups, users, custom channels) and encapsulates the logic required to commit that data to the target database or system. All implementations inherit from the abstract base class SaveVariantBase, which provides shared infrastructure for progress tracking, cancellation support, and dependency injection of core services (IPersistCalculator, IImportNotification). The module serves as the persistence layer of the import pipeline, transforming in-memory ImportObject data into persistent system state.
2. Public Interface
All classes listed below are public (except SaveServer, which is internal) and inherit from SaveVariantBase. Each implements the Save() method.
SaveVariantBase (abstract base class)
- Namespace:
DTS.Common.Import.Persist - Signature:
public abstract class SaveVariantBase : IPersistImport - Constructor:
protected SaveVariantBase(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Properties:
protected ImportObject _importObjectprotected readonly IPersistCalculator _persistCalculatorprotected readonly IImportNotification _importNotificationprotected readonly Func<bool> IsCancelled
- Methods:
public abstract void Save()
SaveServer (internal)
- Namespace:
DTS.Common.Import.Persist - Signature:
class SaveServer : SaveVariantBase - Constructor:
public SaveServer(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()→ ThrowsNotImplementedException. This class is a placeholder and not functional.
SaveGroupTemplates
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveGroupTemplates : SaveVariantBase - Constructor:
public SaveGroupTemplates(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()
Iterates over_importObject.GroupTemplates(). For each template:- Checks cancellation (
IsCancelled()), returns early if true. - Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(_persistCalculator.ProgressValue).
Note: Does not actually commit group templates to storage; only updates progress.
- Checks cancellation (
SaveGlobalSettings
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveGlobalSettings : SaveVariantBase - Constructor:
public SaveGlobalSettings(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()
Iterates over_importObject.GlobalSettings(). For each settingg:- Checks cancellation, returns early if true.
- Calls
SettingsDB.SetGlobalValue(g.Key, g.Value). - Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(...).
SaveSensorModels
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveSensorModels : SaveVariantBase - Properties:
public User CurrentUser { get; set; }
- Constructor:
public SaveSensorModels(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()
Iterates over_importObject.SensorModels(). For each modelst:- Checks cancellation, returns early if true.
- Calls
SensorModelCollection.SensorModelList.Commit(st, CurrentUser.UserName). - Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(...).
SaveTestEngineerDetails
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveTestEngineerDetails : SaveVariantBase - Constructor:
public SaveTestEngineerDetails(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()- First, calls
_importNotification.SetStatus.Invoke(...)withExtraStatus = ImportExtraStatus.ReadingEngineerDetails. - Iterates over
_importObject.TestEngineerDetails(). For each detailt:- Checks cancellation, returns early if true.
- Calls
TestEngineerDetailsList.TestEngineerList.AddTestEngineer(new TestEngineerDetails(t)). - Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(...).
- First, calls
SaveLabDetails
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveLabDetails : SaveVariantBase - Constructor:
public SaveLabDetails(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()- First, calls
_importNotification.SetStatus.Invoke(...)withExtraStatus = ImportExtraStatus.ReadingLabDetails. - Declares
bool invalidLabDetails = false;(but does not use it further). - Iterates over
_importObject.LabDetails(). For each detaill:- Checks cancellation, returns early if true.
- If
l.IsInvalidBlank()is true, setsinvalidLabDetails = true. - Otherwise, calls
LabratoryDetailsList.AddLab(new LabratoryDetails(l)). - Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(...).
- First, calls
SaveCustomerDetails
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveCustomerDetails : SaveVariantBase - Properties:
bool invalidCustomerDetails = false;(instance field, not used beyond assignment)
- Constructor:
public SaveCustomerDetails(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()- First, calls
_importNotification.SetStatus.Invoke(...)withExtraStatus = ImportExtraStatus.ReadingLabDetails(note: likely a copy-paste error; should beReadingCustomerDetails). - Iterates over
_importObject.CustomerDetails(). For each detailc:- Checks cancellation, returns early if true.
- If
c.IsInvalidBlank()is true, setsinvalidCustomerDetails = true. - Otherwise, calls
CustomerDetailsList.AddCustomer(new CustomerDetails(c)). - Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(...).
- First, calls
SaveUsers
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveUsers : SaveVariantBase - Properties:
public IUIItems[] UIItems { get; set; }public User CurrentUser { get; set; }
- Constructor:
public SaveUsers(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()- First, calls
_importNotification.SetStatus.Invoke(...)withExtraStatus = ImportExtraStatus.ReadingUsers. - Iterates over
_importObject.Users(). For eachuser:- Checks cancellation, returns early if true.
- Asserts
CurrentUser.IsAdminviaSystem.Diagnostics.Trace.Assert(...)(throws in debug if false). - Calls
UserCollection.UsersList.Commit(user, CurrentUser.UserName, UIItems). - Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(...).
- First, calls
SaveHardware
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveHardware : SaveVariantBase - Properties:
public Dictionary<int, int> OldDASIdToNewDASId { get; set; }public Dictionary<int, List<IISOHardware>> TestIdToHardware { get; set; }
- Constructor:
public SaveHardware(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()- First, calls
_importNotification.SetStatus.Invoke(...)withExtraStatus = ImportExtraStatus.ReadingHardware. - Calls
_importObject.Hardware().ToList().Sort()(sorts hardware list in-place). - Iterates over
_importObject.Hardware(). For each hardwareh:- Checks cancellation, returns early if true.
- Stores
oldId = h.DASId. - Calls
DASHardwareList.GetList().Commit(h, false, true). - If
h.DASId != oldId, adds mappingOldDASIdToNewDASId[oldId] = h.DASId. - Gets
iso = h.GetHardware(). Ifiso.TestId != null, addsisotoTestIdToHardware[(int)iso.TestId]. - Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_persistCalculator.AddDone(h.Channels?.Length ?? 0)(adds number of channels). - Calls
_importNotification.SetProgress(...).
- First, calls
SaveGroups
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveGroups : SaveVariantBase - Properties:
public bool CanCurrentUserCommitChannelCodes { get; set; } = truepublic IChannelSetting DefaultZeroMethod { get; set; }public IChannelSetting DefaultZeroStart { get; set; }public IChannelSetting DefaultZeroEnd { get; set; }public IChannelSetting DefaultInitialOffset { get; set; }public Dictionary<int?, int> OldGroupIdToNewGroupId { get; set; }private readonly SaveHardware _saveHardware
- Constructor:
public SaveGroups(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, SaveHardware saveHardware, Func<bool> isCancelled = null) - Methods:
public override void Save()- First, calls
_importNotification.SetStatus.Invoke(...)withExtraStatus = ImportExtraStatus.ReadingGroups. - Builds
idToDASIdlookup fromDASHardwareList.GetAllHardware(). - Retrieves channel defaults from
DbOperations.GetChannelSettingDefaults()and assigns toDefault*properties. - Iterates over
_importObject.StaticGroups(). For each groupg:- Checks cancellation, returns early if true.
- If
!g.Embedded:- For each channel
ching.GroupChannelList:- Updates
ch.SensorIdusing_importObject.OldSensorDatabaseIdsToNew(). - Updates
ch.DASIdusing_saveHardware.OldDASIdToNewDASId; if missing, setsch.DASId = -1and tracks group name inmissingDASGroupList. - Calls
SaveSensor.FixMissingZeroMethodParameter(...)andSaveSensor.FixMissingInitialOffset(...)(methods not defined in source).
- Updates
- Calls
SetGroupId(g)(static helper) to resolve group ID from DB. - Calls
FixGroupHardware(g, idToDASId)(static helper) to resolve hardware IDs. - Calls
g.Save(g.GroupChannelList.ToArray(), CanCurrentUserCommitChannelCodes). - Maps
OldGroupIdToNewGroupId[normalizedStaticGroupId] = g.Id.
- For each channel
- Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(...).
- If
missingDASGroupList.Any(), reports a warning via_importObject.AddError(...).
- First, calls
SaveCustomChannels
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveCustomChannels : SaveVariantBase - Properties:
public ISO13499FileDb IsoDb { get; set; }public Dictionary<string, string> CustomChannelTextIdToOldChannelId { get; set; }public Dictionary<string, TestObjectChannel> CustomChannelOldChannelIdToChannel { get; set; }
- Constructor:
public SaveCustomChannels(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, Func<bool> isCancelled = null) - Methods:
public override void Save()- Early return if
_importObject.CustomChannels()is null or empty. - Iterates over custom channels in reverse order. For each
cc:- Checks cancellation, returns early if true.
- Stores
oldid = cc.Id. - Tries to find existing channel by ISO code (
CustomChannelList.List.GetChannelByISOCode(...)). If found, uses its ID; otherwise, clearscc.Idand inserts. - Commits
new CustomChannel(cc). - For each group template in
_importObject.GroupTemplates():- If channel matches, updates its ID to
newid. - Updates group templates and associated groups, preserving sensor/hardware IDs.
- Populates
CustomChannelTextIdToOldChannelIdandCustomChannelOldChannelIdToChannelfor later remapping.
- If channel matches, updates its ID to
- Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(...). - Commented-out GC.Collect indicates memory pressure concerns.
- Calls
CustomChannelList.List.UpdateAll().
- Early return if
SaveTestSetup
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveTestSetup : SaveVariantBase - Properties:
private readonly SaveCustomChannels _saveCustomChannelsprivate readonly SaveHardware _saveHardwareprivate readonly SaveGroups _saveGroupspublic User CurrentUser { get; set; }public string TestSetupName { get; set; }
- Constructor:
public SaveTestSetup(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, SaveCustomChannels saveCustomChannels, SaveHardware saveHardware, SaveGroups saveGroups, Func<bool> isCancelled = null) - Methods:
private void ConfigureDefaultRunTestTestSetup(TestTemplate testSetup)
Sets many boolean/numeric properties (e.g.,DoROIDownload = true,ExportFormats = rdfadc, etc.) for run-test mode.public override void Save()- If
ImportFileFormat == SingleTestSetupandTestSetupNameis set, overridesName,TestId, and callsConfigureDefaultRunTestTestSetup(...). - Calls
SaveTestSetupHelper.UpdateLevelTriggers(...)to remap level trigger channel IDs. - Calls
SaveTestSetupHelper.DeleteExistingTestSetups(...)to delete existing test setups. - Calls
SaveTestSetupHelper.PopulateHarwareLookup()to buildhardwareLookup. - Iterates over
_importObject.TestSetups(). For eacht:- Calls
SaveTestSetupHelper.FixDasAff(...)to fix DAS AAF rates. - Stores
idPriorToCommit = t.Id, then setst.Id = 0. - For each channel in
t.ChannelsForGroup:- Updates
SensorIdandDASIdusing mappings from_importObjectand_saveHardware. - Calls
SaveSensor.FixMissingZeroMethodParameter(...)andSaveSensor.FixMissingInitialOffset(...).
- Updates
- Updates
hardwareIncluded/hardwareRemovedlists usingOldDASIdToNewDASId. - Calls
SaveTestSetupHelper.AddHardwareFromEmbeddedGroups(...). - Calls
t.ReplaceCalculatedChannel(oldIdToNewIdLookup). - Checks cancellation, returns early if true.
- Ensures
t.TestSetupUniqueIdis set (generates GUID if null). - Commits
tviaTestTemplateList.TestTemplatesList.Commit(t, false). - If
idPriorToCommit > 0, updatesTestIdon associated hardware in_saveHardware.TestIdToHardware. - Calls
_persistCalculator.AddDone()(increments by 1). - Calls
_importNotification.SetProgress(...).
- Calls
- Clears
oldIdToNewIdLookup. - Sets status to
ImportExtraStatus.None/PossibleStatus.Working.
- If
SaveCheckoutTestSetup
- Namespace:
DTS.Common.Import.Persist - Signature:
public class SaveCheckoutTestSetup : SaveVariantBase - Properties:
private readonly SaveCustomChannels _saveCustomChannelsprivate readonly SaveHardware _saveHardwareprivate readonly SaveGroups _saveGroupsprivate readonly string _setupNamepublic User CurrentUser { get; set; }
- Constructor:
public SaveCheckoutTestSetup(ImportObject importObject, IPersistCalculator persistCalculator, IImportNotification importNotification, SaveCustomChannels saveCustomChannels, SaveHardware saveHardware, SaveGroups saveGroups, Func<bool> isCancelled = null, string setupName = null) - Methods:
private void ConfigureCheckoutTestSetup(TestTemplate TestSetupCheckout)
Sets many boolean properties for checkout mode (e.g.,CheckoutMode = true,AllowMissingSensors = true,ExportFormats = none, etc.).