--- source_files: - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Users/IUIItems.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Users/ITagAware.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Users/Tags.cs - DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Users/User.cs generated_at: "2026-04-17T15:54:08.207380+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "3cdbf9b023e772e8" --- # Documentation: DatabaseExport Users Module (Version 57) ## 1. Purpose This module provides the user management subsystem for the `DatabaseExport` namespace, handling user identity, roles, permissions, visibility settings, and tag associations. It implements a tag caching system for efficient tag lookups, supports serialization of user data for XML storage, and manages per-user permissions on UI items. The module is part of a legacy database version (Version 57) and contains abstractions for database-backed user entities with timestamp and tagging capabilities. --- ## 2. Public Interface ### `IUIItems` (Interface) **File:** `IUIItems.cs` ```csharp string GetName(); ``` - Returns the name of a UI item. Implementers provide a string identifier used for permission and visibility lookups in the `User` class. --- ### `TagAwareBase` (Abstract Class) **File:** `ITagAware.cs` **Inherits from:** `DbTimeStampBase` **Properties:** ```csharp byte[] TagsBlobBytes { get; set; } int[] TagIDs { get; set; } ``` - `TagsBlobBytes`: Converts `TagIDs` to/from a byte array (4 bytes per int). The setter silently catches exceptions during conversion. - `TagIDs`: Backed by `_tagIDs`, defaults to empty array. Setter null-coalesces to empty array. **Methods:** ```csharp string GetTagsCommaSeperatedString(); virtual string[] GetTagsArray(); ``` - `GetTagsCommaSeperatedString()`: Returns comma-separated string of tag text by delegating to `GetTagsArray()`. - `GetTagsArray()`: Returns string array of tag text by calling `Tags.GetTagTextFromIDs(TagIDs)`. --- ### `Tags` (Class) **File:** `Tags.cs` **Nested Class `Tag`:** ```csharp public const int INVALID_ID = -1; int ID { get; set; } string Text { get; set; } bool IsObsolete { get; set; } ``` - Implements `ICloneable`. Constructor from `DataRow` reads fields via `DbOperations.Tags.TagFields` enum. Copy constructor available. **Static Properties:** ```csharp static Tags TagsInstance { get; } ``` - Singleton accessor, lazily instantiated. **Static Methods:** ```csharp static string GetTagTextFromID(int tagID); static string[] GetTagTextFromIDs(int[] tagID); ``` - `GetTagTextFromID(int)`: Returns tag text for a valid ID (> 0 and not `Tag.INVALID_ID`), or `null` if invalid/not found. - `GetTagTextFromIDs(int[])`: Returns array of tag texts, skipping invalid IDs and null/whitespace results. **Constructor:** ```csharp Tags(); // Initializes _tagsLookup and calls UpdateList() ``` --- ### `User` (Class) **File:** `User.cs` **Inherits from:** `TagAwareBase` **Nested Enums:** ```csharp public enum DefaultRoles { Administrator = 0, PowerUser = 1, User = 2, Guest = 3 } public enum UserPermissionLevels { Deny = 0, Read = 1, ReadAndExecute = 2, Edit = 3, Admin = 4 } public enum Tags { User, Role, Version, LastModified, LastModifiedBy, Name, UserName, Password, LocalOnly, Permissions, Visibility, Id } public enum XmlFields { ID, UserName, DisplayName, Password, IUIItemPermissions, IUIItemVisibility, Role, LastModified, LastModifiedBy, Version, LocalOnly, UserTags } ``` **Constants:** ```csharp private const string DEFAULT_LAST_MODIFIED_BY = "---"; private const string DEFAULT_ADMIN_USERNAME = "Admin"; private const string DEFAULT_GUEST_USERNAME = "Guest"; private const string DEFAULT_POWERUSER_USERNAME = "PowerUser"; private const string DEFAULT_USER_USERNAME = "User"; private const int INVALID_ID = -1; ``` **Properties:** ```csharp bool IsADefaultUser { get; } string Name { get; set; } string UserName { get; set; } int Id { get; set; } DefaultRoles Role { get; set; } int Version { get; set; } DateTime LastModified { get; set; } string LastModifiedBy { get; set; } bool LocalOnly { get; set; } ``` - `Role` setter throws `NotSupportedException` if user is a default user and role changes. - All setters use `SetProperty(ref field, value, Tags.EnumName.ToString())`. **Constructor:** ```csharp User(DataRow row); ``` - Populates user from `DbOperations.Users.UserFields` columns. **Methods:** ```csharp override ConstraintHelper[] GetConstraints(); override string LookupTable { get; } string GetPermissionSerialized(); static string GetDefaultUserName(DefaultRoles role); string GetVisibilitySerialized(); Dictionary GetValues(); ``` - `GetConstraints()`: Returns single constraint on `UserName` column. - `LookupTable`: Returns `DbOperations.Users.USERS_TABLE`. - `GetPermissionSerialized()`: Returns `"ItemName=PermissionValue,..."` string from `_tabPermissions` dictionary. - `GetDefaultUserName(DefaultRoles)`: Maps role enum to default username string; throws `NotSupportedException` for unknown roles. - `Get