# KbsV3 Memory ## Architecture Guide - See [kbsv3-architecture.md](kbsv3-architecture.md) for: SAP RFC calls, gRPC communication, DB read/write patterns - See [job-system.md](job-system.md) for: full job lifecycle, scheduler pattern, ILongRunningJobService vs IKbsJob, InputData/Payload flow ## Plotly.Blazor (v7.0.0) - `ModeFlag` namespace: `Plotly.Blazor.Traces.ScatterLib` - `XAxis.Type` needs `Plotly.Blazor.LayoutLib.XAxisLib.TypeEnum.Date` (not string) - `Title` is ambiguous between `LayoutLib` and `LayoutLib.XAxisLib` — use fully qualified - Events (relayout) not implemented in library — use JS interop via `el.on('plotly_relayout', ...)` ## Service Layer Pattern - Services use `JobDbContext` injected directly - Interface in `Contract/`, implementation in `Services/` - Register in `Program.cs` as `builder.Services.AddScoped()` ## SAP NCo3 IRfcFunction - `IRfcFunction` does NOT implement `IDisposable` — `using var fnc` causes CS1674 compile error - NCo3 manages memory via GC; `fnc` vars in method scope are eligible for collection after method returns - Fix 1 from memory-optimization plan is NOT applicable via `using`; no explicit disposal mechanism available ## Job Worker Patterns (IKbsJob vs ILongRunningJobService) - **All KnownJobs** in Kbs3SqlService use `IKbsJob` (NOT `ILongRunningJobService`) - `IKbsJob` runs via `LongRunningJobServiceHost` with `JobType.CallServiceHost` - Auto-registered as keyed service by class name (e.g. `"SyncOpexPurchaseOrdersService"`) - `IKnownJob.ServiceName` format: `"modulename.ClassName"` → host splits on `.` and resolves last segment - Do NOT add new `JobType` enum entries for `IKbsJob` workers — they all share `CallServiceHost` - `ILongRunningJobService` is for services like AD sync, Hydra — they have dedicated JobType enum entries ## Naming - App is called **"KRAH-App"** internally (not "KBS" — that's only the technical project name) ## HydraArchiveData - Entity: HydraArchiveReloadId, AcquisitionTime, PdatrefPparamDatasupId, DecimalValue - Covering index: (HydraArchiveReloadId, AcquisitionTime, PdatrefPparamDatasupId) - SQL bucket aggregation: DATEDIFF/DATEADD pattern for time-bucket grouping - Raw SQL via `_dbContext.Database.SqlQueryRaw(sql, params)`