# Database Status Codes and Enums This document provides centralized documentation for all status codes and enums used in the JDE Scoping Tool database and application. ## Search Status (SearchStatus Enum) The `SearchStatus` enum tracks the lifecycle of a search request. **Source:** `JdeScoping.Core/Models/Enums/SearchStatus.cs` | Value | Name | Description | |-------|------|-------------| | 0 | `New` | Search created but not submitted | | 1 | `Queued` | Search submitted, waiting for processing | | 2 | `Running` | Search actively processing | | 3 | `Ended` | Search completed successfully | | 4 | `Error` | Search processing failed | ### State Transitions ``` ┌─────────┐ submit ┌─────────┐ picked up ┌─────────┐ │ New │ ───────────> │ Queued │ ────────────> │ Running │ └─────────┘ └─────────┘ └────┬────┘ │ ┌──────────┴──────────┐ │ │ success failure │ │ v v ┌─────────┐ ┌─────────┐ │ Ended │ │ Error │ └─────────┘ └─────────┘ ``` ### Transitions | From | To | Trigger | |------|----|---------| | `New` | `Queued` | User clicks "Run Search" | | `Queued` | `Running` | Worker service picks up search | | `Running` | `Ended` | Search completes successfully, results stored | | `Running` | `Error` | Exception during processing | ### Notes - Status stored in `Search.Status` column (tinyint) - SignalR hub broadcasts status changes in real-time - Error details stored in `Search.ErrorMessage` when status = `Error` --- ## Data Update Types (UpdateTypes Enum) The `UpdateTypes` enum categorizes data synchronization jobs. **Source:** `JdeScoping.Core/Models/Enums/UpdateTypes.cs` | Value | Name | Description | Typical Schedule | |-------|------|-------------|------------------| | 1 | `Hourly` | Incremental delta sync | Every hour | | 2 | `Daily` | Daily refresh | Once per day (overnight) | | 3 | `Mass` | Full table refresh | Weekly or on-demand | ### Usage The `DataUpdate` table tracks the last sync time for each entity and update type: ```sql SELECT EntityName, UpdateType, LastUpdateDt FROM DataUpdate WHERE UpdateType = 1 -- Hourly updates ORDER BY LastUpdateDt DESC ``` ### Notes - Value `0` is not defined (avoids default int confusion) - Mass updates typically run during maintenance windows - Hourly updates capture recent work order completions --- ## JDE Status Codes (StatusCode Lookup Table) Work order status codes synchronized from JD Edwards (JDE) system. **Entity:** `JdeScoping.Core/Models/Lookup/StatusCode.cs` **Table:** `StatusCode` ### Table Structure | Column | Type | Description | |--------|------|-------------| | `Code` | varchar(10) | Status code identifier | | `Description` | varchar(100) | Human-readable description | | `LastUpdateDate` | int | JDE Julian date of last update | | `LastUpdateTime` | int | JDE time of last update | ### Common JDE Status Codes | Code | Description | |------|-------------| | 10 | Work Order Created | | 20 | Parts Issued | | 40 | Work In Progress | | 90 | Closed | | 95 | Cancelled | | 99 | Purged | > **Note:** Actual codes vary by JDE configuration. The values above are examples; refer to your JDE system administrator for the authoritative list. ### Synchronization - Source: JDE F0004 / F0005 User Defined Codes tables - Sync frequency: Daily - Pipeline: `StatusCodePipeline` in DataSync project --- ## Database Column Mappings ### Search Table Status Column ```sql CREATE TABLE Search ( Id INT PRIMARY KEY, Status TINYINT NOT NULL DEFAULT 0, -- Maps to SearchStatus enum -- ... other columns ); ``` ### DataUpdate Table Type Column ```sql CREATE TABLE DataUpdate ( Id INT PRIMARY KEY, EntityName VARCHAR(100) NOT NULL, UpdateType TINYINT NOT NULL, -- Maps to UpdateTypes enum LastUpdateDt DATETIME2 NOT NULL, -- ... other columns ); ``` --- ## See Also - [SearchStatus.cs](../../NEW/src/JdeScoping.Core/Models/Enums/SearchStatus.cs) - [UpdateTypes.cs](../../NEW/src/JdeScoping.Core/Models/Enums/UpdateTypes.cs) - [StatusCode.cs](../../NEW/src/JdeScoping.Core/Models/Lookup/StatusCode.cs)