Report Scheduler
Let's say your web app allows users to schedule reports to email off. These items are configurable and the user can add or remove them at any time.
The front-end web app saves a database record back with all the information needed to run the specific report and it's parameters.
Then the Scheduler reads the table for those database records every few minutes and updates, removes, reschedules any changed items.
You get a simple callback when it's time to execute the event task
Demo Scheduler
The demo below hooks up everything but actually generating reports, and emailing them off.
The
RunType
argument could easily contain what reports to generate.The
RunArgs
could easily contain additional user information like who it's being sent to, a database ID of the job to lookup, etc.
The demo code uses the Memory Scheduler
as it does not require a remote source. Typically speaking you would tie the event task descriptions back to a database record (like the MSSQL Scheduler Source).
Line 5 - Declare a new event source. This demo uses the memory scheduler.
Line 9-10 - Add the two scheduled items, A, and B, to schedule and execute
Line 13 - Add a scheduler using the source we defined, and declare the callback.
You're given a CancellationToken for respecting graceful shutdown event.
An ILogger for logging to the system and defined sink sources.
And the GenericScheduledItem<ushort> Which is the interfaced item that allows you to access it's definition values.
Line 14 - You can execute or perform any tasks you need. Like generating a report with parameters.
You can see the call to
GetRunType()
. There's alsoGetRunArgs()
,GetLastRunDate()
,GetName()
, etc.
Last updated