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
  • Resources
  • Our first application
  • Step 1) The application starting point
  • Net 6++
  • Net 5 and lower
  • The application code
  • Step 2) Adding thread managed code
  • Hello Perigee - Extended
Export as PDF
  1. Getting Started

Hello Perigee!

PreviousInstallation and Project SetupNextPerigee Application Design

Last updated 17 days ago

Resources

Our first application

Go ahead and create a new .NET 5/6+ console application. Open up Program.cs, and head to the first step to get started!

If you haven't gone through the installation step, please do so first!

Step 1) The application starting point

Let's start with the basics. First let's create a new application in Program.cs. Depending on the version of .NET you started with, you'll see two different things when you open Program.cs

Net 6++

The .NET 6 ++ version looks like this:

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

//YOUR CODE HERE

If this is the case, delete Line 2 - Console.WriteLine("Hello, World!"); and start there.

Net 5 and lower

The .NET 5 and below versions looks like this:

class Program
{

    static void Main(string[] args)
    {
        //YOUR CODE HERE
    }
}

If this is the case, start coding on Line 6.

The application code

Now that we know where to start, here's a simple Perigee application.

//A fully managed perigee application! 
PerigeeApplication.ApplicationNoInit("FirstApp", 
(taskConfig) => { 

});

Let's look what what we have here in the constructor:

  • Line 2 - "FirstApp" - The name of the application, this can be whatever you like!

  • Line 3 - taskConfig block - This block is where we add any and all thread managed tasks.

using Microsoft.Extensions.Logging;
using Perigee;

Step 2) Adding thread managed code

//A fully managed perigee application! 
using Microsoft.Extensions.Logging;
using Perigee;

PerigeeApplication.ApplicationNoInit("FirstApp", (taskConfig) => {

    taskConfig.AddCRON("HelloWorld", "*/15 * * * * *", (ct, log) => {
        log.LogInformation("Hello Perigee from {appName}", taskConfig.AppName);
    });

});
  • Line 4 - We use fluent syntax to .AddCRON() - This method takes a name, CRON string, and a callback(cancelToken, ILogger).

  • Line 5 - We use the built in logger passed to us to log information in a templated format, passing in the name of the application to the logger.

Running the application produces a log new line every 15 seconds!

To close this application using graceful shutdown, press CTRL-C, it will start the safe shutdown procedure allowing the application to properly stop all running tasks before just exiting out.

Hello Perigee - Extended

PerigeeApplication.ApplicationNoInit("FirstApp", (taskConfig) => {

    taskConfig.AddDirectoryWatch("CSV", "C:\\Watch", "*.csv", SearchOption.TopDirectoryOnly, (ct, l, path) => {

        //Read the CSV
        var CSVData = CSVReader.ToDataTable(path, out var rRes);

        //Reprt on it
        l.LogInformation("Read CSV {file}[{encoding}]. Columns/Rows: {col}/{row}; Delimiter: {delChar}; Jagged? {jagged}",
            Path.GetFileName(path), rRes.FileEncoding.EncodingName, rRes.ColumnCount,
            CSVData.Rows.Count, rRes.FinalDelimiter, rRes.RowShifts.Count > 0 ? "YES" : "NO");

        //Remove it - OR let the failed folder policy kick in
        //File.Delete(path);

    }, policy: ThreadRegistry.DirectoryWatchFailurePolicy.MoveToFailedFolder);

});

Here's a sample.csv:

Name, Age, Email, Phone
John Doe, 30, john.doe@example.com, 123-456-7890
Jane Smith, 25, jane.smith@example.com, 987-654-3210
Bob Johnson, 40, bob.johnson@example.com, 555-555-5555
Mary Lee, 28, mary.lee@example.com, 111-222-3333
Hash Brown, 35, hash.brown@example.com, 444-444-4444
using Microsoft.Extensions.Logging;
using Perigee;
using Perigee.FileFormats.CSV;
using System.Data;

Voila! You're now watching for CSV files, reading them in, and reporting on the number of rows and columns.

For an intro to Perigee we accomplished quite a lot.

  • How to configure Perigee.

  • What "Graceful Shutdown" looks like.

Let's hop over to the next section and continue!

Make sure you have everything included in your using statements by clicking the icon or press ctrl+. to find missing namespaces

This wouldn't be a hello tutorial without writing "Hello, World!", so let's add a method to Hello Perigee every 15 seconds!

The .AddCron method adds a new thread to the system. Each thread is managed by Perigee and is independent of every other thread. This is an important aspect of as it allows for individual thread management. Threads do not affect each other, and Perigee's internal thread management system has mechanisms in place to automatically restart downed threads.

My oh my, we logged something! Exciting right? Let's take our first demo application a step further and watch for files, read them in, and report the row and data counts.

Simply replace .AddCron() with the instead, full code below:

Make sure you have everything included in your using statements by clicking the icon or press ctrl+. to find missing namespaces

We learned about - how they're added and independent of each other.

We learned about information to the available sinks.

strings and how to use a CRON thread.

We even got to see the reader in action.

💡
💡
Installation and Project Setup
logging
💿
👍
CSV
CSV
directory watcher
Want to watch the intro to Perigee instead?
log
Perigee Application Design
threads
CRON
CRON
Page cover image
2KB
1_HelloWorld.zip
archive
Completed Project Files