8.3 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T04:56:25.345352+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 8041292bb801532f |
Model
Documentation: ChannelCode Module
1. Purpose
This module provides data access and modeling for channel codes—lookup values used to categorize or classify channels in the system (e.g., ISO-standardized codes vs. user-defined codes). It defines a base abstract class ChannelCodeType for retrieving static type metadata and a concrete class ChannelCode that represents individual channel code entries, including persistence operations (insert/update/delete) and caching of ISO codes from a static text file. The module serves as the data layer for channel code management, bridging the database (sp_ChannelCodeTypeGet, sp_ChannelCodesGet) and file-based ISO code definitions.
2. Public Interface
ChannelCodeType.GetChannelCodeTypeLookup()
public static IDictionary<short, string> GetChannelCodeTypeLookup()
Retrieves all channel code types from the database via stored procedure sp_ChannelCodeTypeGet. Returns a dictionary mapping Id (short) to CodeType (string), representing the type categories (e.g., ISO, User). Parameters passed to the stored procedure (@Id, @CodeType) are null, indicating no filtering.
ChannelCode class
Inherits from DTS.Common.Classes.ChannelCodes.ChannelCode and implements IChannelCode.
-
Constructors
ChannelCode()
Initializes a newChannelCodewithCodeType = ISOand registers thePasteCommand.ChannelCode(IChannelCode channelCode)
Copies properties from an existingIChannelCodeinstance and registersPasteCommand.ChannelCode(IDataRecord sqlReader, IDictionary<short, string> channelCodeLookup)
Populates the instance from a database row (sqlReader) using the providedchannelCodeLookup. MapsCodeTypeInt(short) to aChannelCodeTypeenum value (ISOorUser) via string comparison againstChannelEnumsAndConstants.IsoCodeTypeStringandChannelEnumsAndConstants.UserCodeTypeString.
-
Properties
bool HasValidId()
ReturnstrueifId >= 0.bool IsBlank()
Returnstrueif bothNameandCodearenullor empty.int SelectedChannelType
Gets/sets a legacy dropdown index (0 = ISO, 1 = User) based onCodeType. Deprecated per inline comment.Dictionary<string, string> PossibleChannels { get; private set; }
Publicly readable dictionary (currently unused in source; likely intended for channel mappings).static IList<IChannelCode> ChannelCodes { get; }
Returns a combined list of all channel codes: user-defined codes (from DB viaGetExistingChannelCodes) + ISO codes (fromISOChannelCodes). Uses a shared lookup fromGetChannelCodeTypeLookup().static IList<IChannelCode> ISOChannelCodes { get; }
Lazily loads ISO codes fromISOPossibleChannels.txt(comma-separated:Code,Name). Caches in_isoChannelCodesafter first access. Thread-safe vialock(RefreshLock).
-
Methods
static ChannelCode[] GetExistingChannelCodes(IDictionary<short, string> lookup)
Fetches all user-defined channel codes from DB viasp_ChannelCodesGet, returning an array ofChannelCodeinstances. Parameters passed to the stored procedure (@Id,@Code,@Name,@CodeType) are null (no filtering).void Delete()
CallsDbOperations.ChannelCodesDelete(Id, null, null, null)to remove the channel code from the lookup table only (does not affect existing channel instances referencing it).void Save(IDictionary<ChannelEnumsAndConstants.ChannelCodeType, short> lookup)
CallsDbOperations.ChannelCodesUpdate(restrictedLookup, this)to persist changes to the channel code lookup table.void Insert(IDictionary<ChannelEnumsAndConstants.ChannelCodeType, short> lookup)
CallsDbOperations.ChannelCodesInsert(restrictedLookup, this, out id)to insert a new channel code. On success (hr == 0), setsIdto the returned value.protected static long GetLong(OleDbDataReader reader, string field)
Helper for legacy OleDb access; returnslong.MinValueonDBNull. Not used in current code.protected static DateTime GetDate(OleDbDataReader reader, string field)
Helper for legacy OleDb access; returnsDateTime.MinValueonDBNull. Not used in current code.
Command
PasteCommand(public property, typeICommand)
Initialized asPasteCommandClass(PASTE_ID)inRegisterCommands(). A no-opPastehandler is defined but empty. Registered viaCommandManager.RegisterClassCommandBinding.
3. Invariants
Idvalidity:HasValidId()requiresId >= 0. Negative IDs are considered invalid.- Code type mapping:
CodeTypemust be eitherChannelEnumsAndConstants.ChannelCodeType.ISOorChannelEnumsAndConstants.ChannelCodeType.User. Mapping from DBCodeTypeIntrelies on exact string matches againstIsoCodeTypeStringandUserCodeTypeString. - ISO codes are static:
ISOChannelCodesare loaded once and cached in_isoChannelCodes. They are not persisted to the database. - Persistence scope:
Insert,Save, andDeleteoperations affect only the channel code lookup table, not any channels that may reference the code. - Thread safety: ISO code loading uses
lock(RefreshLock)to ensure single initialization. - Null handling:
IsBlank()treatsnulland empty strings identically.
4. Dependencies
Dependencies of this module
- Database:
- Stored procedures:
sp_ChannelCodeTypeGet,sp_ChannelCodesGet - Table columns:
Id,Code,Name,CodeTypeInt
- Stored procedures:
- File system:
ISOPossibleChannels.txt(comma-separated:Code,Name) in app base directory.
- External types:
DTS.Common.Storage.DbOperations(providesGetSQLCommand,ChannelCodesDelete,ChannelCodesUpdate,ChannelCodesInsert)DTS.Common.Classes.ChannelCodes.ChannelCode(base class)DTS.Common.Interface.Channels.ChannelCodes.IChannelCode(interface)DTS.Common.Enums.Channels.ChannelEnumsAndConstants(definesChannelCodeType,IsoCodeTypeString,UserCodeTypeString)System.Data.SqlClient,System.Data,System.IO,System.Windows.Input
Dependencies on this module
- Any module needing channel code metadata or management (e.g., UI dropdowns, channel assignment logic).
ISOChannelCodesimplies a hard dependency on the presence and format ofISOPossibleChannels.txt.
5. Gotchas
SelectedChannelTypeis legacy/deprecated: The property is tied to a dropdown that may no longer exist. Its use is discouraged.PasteCommandis non-functional: ThePastehandler is empty; the command is registered but does nothing.PossibleChannelsis unused: The property is declared but never populated in the source.- ISO codes are not persisted: Changes to
ISOChannelCodes(e.g., viaInsert/Save) will not affectISOPossibleChannels.txt. This file is read-only at runtime. Delete/Save/Insertdo not cascade: Operations affect only the channel code definition (lookup), not any existing channels that reference the code.- Thread-safety limitation: ISO code loading is thread-safe for initialization, but no caching invalidation mechanism exists (codes are assumed immutable).
GetLong/GetDateare dead code: OleDb-specific helpers with no callers in this module. Likely remnants of legacy migration code.ChannelCodesproperty is expensive: Each access callsGetChannelCodeTypeLookup()andGetExistingChannelCodes(), which hit the database. Caching externally is recommended if used repeatedly.- No validation on
Code/Name: The module does not enforce uniqueness or non-empty values beyondIsBlank(). Business rules may be enforced elsewhere. Idassignment is conditional:Insertonly setsIdifhr == 0; callers must check the return value or handle failure.
None identified from source alone. (Note: The above are inferred from explicit comments and code structure—not hallucinated.)