Solution: TELS.BuildingServices.RelatedOrderSync.sln
| Project | Type | Framework | Description |
|---|---|---|---|
| TELS.BuildingServices.RelatedOrderSync | Console App (Worker Service) | .NET 8.0 | Batch job for syncing related orders |
| TELS.BuildingServices.RelatedOrderSync.Tests | Unit Tests | .NET 8.0 | Service tests |
RelatedOrderSync is a scheduled batch processing service that maintains comprehensive financial records for TBS (Building Services) tickets by linking related MDID orders.
| Category | Technology |
|---|---|
| Runtime | .NET 8.0 |
| Data Access | Dapper 2.1.44 + Microsoft.Data.SqlClient 5.2.2 |
| Database | SQL Server (TELS database) |
| HTTP Clients | TELS.WebServiceClients v4.5.2 |
| Resilience | Polly 8.4.2 (exponential backoff, 3 retries) |
| Logging | NLog 5.3.14 |
| Configuration | Microsoft.Extensions.Configuration |
| Hosting | Nomad (scheduled job) |
TELS.WebServiceClients.BuildingServices.V1 v4.50.0TELS.WebServiceClients.Auth.V1 v1.0.2Tables:
- TELS.BuildingServices.RelatedOrderSyncProcessTargets - Tracks processing targets and dates
- MDID Orders tables (queried for child orders, PMT-linked orders)
- TBS ticket/order link tables (updated via API)
Pattern: Direct Dapper queries for read, HTTP API calls for write
Query RelatedOrderSyncProcessTargets
→ Find next unprocessed date range
→ Mark as "claimed" (prevent concurrent processing)
Query MDID database
→ Find child orders of already-linked orders
→ Find orders linked to same PMT project
→ Exclude already-linked orders
→ Exclude explicitly-unlinked orders
For each eligible order:
→ Find related TBS ticket/project
→ Call Building Services API to create link
→ Handle errors (retry with Polly)
→ Update tracking table
Mark processing target as "completed"
→ Update timestamp
→ Log summary statistics
| Setting | Source | Description |
|---|---|---|
| Database Connection | Environment/Config | SQL Server connection string |
| Building Services API | TELS.WebServiceClients config | API base URL |
| Auth Service | TELS.WebServiceClients config | Auth service URL |
| Service Account | Environment | Credentials for API calls |
| Retry Policy | Code | 3 retries, exponential backoff |
| Processing Batch Size | Config | Number of orders per batch |
| File | Purpose |
|---|---|
/src/Program.cs |
Application entry point, host configuration |
/src/Services/RelatedOrderSyncService.cs |
Core sync logic |
/src/Data/RelatedOrderSyncRepository.cs |
Database queries (Dapper) |
/src/Clients/BuildingServicesApiClient.cs |
API client wrapper |
/README.md |
Service documentation |
/nomad.yml |
Nomad job definition |
/Dockerfile |
Container image definition |