1.3 KiB
1.3 KiB
SERVICES DIRECTORY
Generated: 2026-02-06 Path: excel_pajak/Services/
OVERVIEW
Static service classes for database and configuration operations.
FILES
| File | Purpose |
|---|---|
DatabaseService.cs |
PostgreSQL query execution with sync operations |
ConfigurationService.cs |
Configuration access with lazy initialization |
CONVENTIONS
- Static classes with
Initialize()pattern for dependency injection - Lazy initialization in ConfigurationService: creates default config on first access
- Error handling via result tuples:
(bool success, string? result, Exception? error) - Schema name validation regex:
^[a-zA-Z0-9_-]+$ - Year validation regex:
^\d{4}$
ERROR HANDLING
// Pattern: TryExecute pattern for schema iteration
var (success, result, error) = DatabaseService.ExecuteEmployeeTaxQueryWithErrorHandling(schema, year);
if (success) { /* use result */ }
else { /* handle error, continue processing */ }
INITIALIZATION
// Before using services:
ConfigurationService.Initialize(configuration);
DatabaseService.Initialize(connectionString);
QUERY PATTERNS
- Use
json_agg(row_to_json(t))for PostgreSQL JSON aggregation - Placeholder replacement for schema/year:
query.Replace("{schema}", schema)