Files
DP44/docs/ai/Common/DTS.Common/Classes/Locking.md

53 lines
2.1 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common/Classes/Locking/LockRecord.cs
- Common/DTS.Common/Classes/Locking/LockError.cs
- Common/DTS.Common/Classes/Locking/SensorsLocking.cs
generated_at: "2026-04-17T15:39:34.129608+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "1d4f4345fc0d551d"
---
# Documentation: DTS.Common.Classes.Locking
## 1. Purpose
This module provides a locking mechanism for managing concurrent access to items (identified by category and ID) within the DTS system. It consists of three classes: `LockRecord` represents an individual lock's metadata, `LockError` encapsulates error states from lock operations, and `SensorsLocking` manages a collection of locks with periodic update capabilities. The system tracks who holds locks, on which machine, and when locks were created/updated, supporting scenarios where locks can be "stolen" or lost due to connectivity issues.
---
## 2. Public Interface
### LockRecord
**Constructor:**
```csharp
public LockRecord(string user, string machine, DateTime createTime, DateTime lastUpdate, string itemKey, int itemCategory, int itemId)
```
Initializes a new immutable lock record with all properties set via constructor parameters.
**Properties (all read-only):**
- `string LockingUserName` — The user who holds the lock.
- `string LockingMachineName` — The machine name where the lock originated.
- `DateTime CreationTime` — When the lock was created.
- `DateTime LastUpdated` — When the lock was last refreshed.
- `string ItemKey` — A string key identifying the locked item.
- `int ItemCategory` — Numeric category value (maps to `LockCategories` in the database).
- `int ItemId` — Numeric identifier for the locked item.
---
### LockError
**Constructor:**
```csharp
public LockError(int error, string message, string user = null, string machine = null)
```
Creates an error object with optional user and machine parameters (default to empty string if null).
**Properties:**
- `int ErrorCode` — Numeric error code (private setter).
- `string Message` — Error message (private setter).
- `string LockingUser` — User associated with the error (private setter).
- `string Lock