Skip to content

Kitto.Notification.ToolJob

Bridges the KittoX tool controllers to the background job runner. The data store is always built on the request thread (via TKXToolExecutor.BuildStore) where the auth/ACL context (TKAuthenticator/TKAccessController.Current, per-thread) is available; TKXToolExecutor.RunToolWithStore then runs the tool against an already-built store, so a background TKXToolJob can execute it on a worker thread — which has no request context — writing the artifact to the job directory instead of the HTTP response. This deliberately avoids rebuilding the store (and thus re-checking field ACL) on the worker, which would dereference the nil per-request Current authenticator/access controller.

TKXToolExecutor class

Shared executor: builds a tool's data store (request thread) and runs the tool against a given store (request or worker thread).

pascal
class function BuildStore(const AViewName, ALoadFilter: string): TKViewTableStore;

Creates and loads the data store for the given view with the given load filter (record-key WHERE clause or grid filter expression). MUST be called on the request thread: TKViewTable.CreateStore sets up the fields and checks field-level ACL, which needs the per-request auth context. The caller owns the returned store.

pascal
class procedure RunToolWithStore(const AViewName, AToolName: string;

Runs a tool view against an already-built store. When ABackgroundDir is empty the tool runs foreground (produces its own HTTP response); otherwise the tool must be a download-file controller and its artifact is written into ABackgroundDir (safe on a worker thread — no HTTP response, no store rebuild). The store is not freed here (the caller owns it).

pascal
class procedure ExecuteToolCore(const AViewName, AToolName, ALoadFilter, ABackgroundDir: string;

Foreground convenience: builds the store on the calling (request) thread and runs the tool, then frees the store.

TKXToolJob class

Background job that runs a KittoX download tool (Export, Report, MergePDF…) on a worker thread and declares the produced file as the job result. The store is built (and ACL-checked) on the request thread at submit time and its ownership is transferred to the job.

pascal
constructor Create(const AViewName, AToolName: string;

Creates the job; ownership of AStore is transferred to the job.

Released under Apache License, Version 2.0.