LogoLogo
HomePricingDocumentation
  • 💿Getting Started
    • Installation and Project Setup
    • Hello Perigee!
    • Perigee Application Design
    • Hello Configuration
    • Hello Logs
    • Hello Integration
    • Troubleshooting
    • Case Studies
  • 📃License + Notice
    • 📂Licensing
    • Notice of Third Party Agreements
  • 🚀Perigee and Beyond
    • Extending - Threads
    • Extending - Loaders
    • ⏳All about CRON
  • 🔮API Generation
    • What is API Generation?
    • API Builder
  • 🗺️Architecting YOUR App
    • Design and Requirements
    • Define Sources
    • Requirements
  • 🧩Core Modules
    • 🌐PerigeeApplication
    • 🪡Thread Registry
    • Event Sources
      • Scheduled/Logic
        • CRON Thread
        • Scheduler
        • Sync Agent
      • Watchers
        • SalesForce
        • Sharepoint
        • Directory Watch
        • Directory Notifier
        • IMAP
    • Credential Management
      • Connection Strings
      • Custom Refresh Logic
      • RestSharp Authenticator
      • Credential Store SDK
      • ⁉️Troubleshooting Credentials
    • Integration Utilities
      • HTTP(S) - RestSharp
      • Transaction Coordinator
      • Limiter
      • Watermarking
    • Alert Managers
      • SMS
      • Email
      • Discord
      • Teams
    • File Formats
      • Excel
      • CSV
    • 📁File System Storage
      • File Revision Store
      • Concurrent File Store
      • FileSync + Cache
    • Third Party
      • SmartSheets
      • Microsoft Graph
    • Perigee In Parallel
      • Parallel Processing Reference
      • Extensions
      • GroupProcessor
      • SingleProcessor
    • 🧱Utility Classes
      • Metrics
      • F(x) Expressions
      • Multi-Threaded Processor (Scatter Gather)
      • OpenAI - GPT
      • XML Converter
      • Dynamic Data Table
      • Debounce
      • Thread Conditions
      • Perigee Utility Class
      • Network Utility
      • Lists
      • FileUtil
      • Inclusive2DRange
      • Strings, Numbers, Dates
      • Nested Sets
      • Behavior Trees
      • JsonCompress
      • Topological Sorting
      • DBDownloader
    • 🈁Bit Serializer
  • 📣Examples and Demos
    • API + Perigee
    • 📰Excel Quick Load
    • SalesForce Watcher
    • Report Scheduler
    • Agent Data Synchronization
    • 📩IMAP Echo bot
    • Watch and load CSVs
    • Graph Delegated Authorization + DataVerse
    • Coordinator Demo
    • Azure Service Bus
    • QuickBooks Online
  • 📘Blueprints
    • Perigee With .NET Hosting
    • Web Host Utilities
    • 🔌Plugin Load Context
  • 🎞️Transforms
    • 🌟What is Transforms?
    • 📘Terminology
    • 🦾The Mapping Document
    • 👾Transformation Process
    • 😎Profile
    • 🎒Automation
      • 🕓Package Options
      • 🔳Configuration
    • 🔧Utilities
      • 🧹Clean
      • 📑Map File
      • 🔎File Identification
      • 🗺️Map Generation
      • 🪅Insert Statement Generation
  • 🗃️Transform SDK
    • 👋Quick Start Guide
    • 🥳MapTo
    • 🔌Authoring Plugins
      • 🔘File IO Process
      • 📢Data Quality
      • 🟢Transform Process
    • SDK Reference
      • 🔘FileIOProcessData
      • 📢DataQualityContext
      • 🎛️TransformDataContext
      • 🏅TransformResult
Powered by GitBook
On this page
  • Demo Scheduler
Export as PDF
  1. Examples and Demos

Report Scheduler

PreviousSalesForce WatcherNextAgent Data Synchronization

Last updated 2 years ago

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 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 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.

PerigeeApplication.ApplicationNoInit("Demo Scheduler", (c) =>
{
   
    //Declare a new memory source, remember to use a single instance of memory/file based sources or locking can occur
    using var MemSource = new MemoryScheduledSource("memSource.json", c.CTS.Token);

    //Add scheduled items.
    //If this was something like a DatabaseScheduledSource, we obviously would control these records from the database, not here.
    MemSource.AddIfNotExists(GenericScheduledItem<ushort>.MemoryItem(0, "A scheduler, 15sec", "A", "a;b;c", "*/15 * * * * *", TimeZoneInfo.Local));
    MemSource.AddIfNotExists(GenericScheduledItem<ushort>.MemoryItem(1, "B scheduler, 45sec", "B", "b;c;d", "45 * * * * *", TimeZoneInfo.Local));

    //Add a scheduler with the MemorySource, a single callback is given for anything required to run (multi-threaded)
    c.AddScheduler("Main", MemSource, (ct, l, item) => { 
        if (item.GetRunType() == "A")
        {
            l.LogInformation("Running A with {args}", item.GetRunArgs());
        }
        else if (item.GetRunType() == "B")
        {
            l.LogInformation("Running B with {args}", item.GetRunArgs());
        }

    });

});
  • 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 also GetRunArgs(), GetLastRunDate(), GetName(), etc.

The demo code uses the 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).

Scheduler
emailing
Memory Scheduler
📣
Page cover image