BinderDyn.OrchardCore.EventSourcing 1.2.2

dotnet add package BinderDyn.OrchardCore.EventSourcing --version 1.2.2
NuGet\Install-Package BinderDyn.OrchardCore.EventSourcing -Version 1.2.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BinderDyn.OrchardCore.EventSourcing" Version="1.2.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BinderDyn.OrchardCore.EventSourcing --version 1.2.2
#r "nuget: BinderDyn.OrchardCore.EventSourcing, 1.2.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BinderDyn.OrchardCore.EventSourcing as a Cake Addin
#addin nuget:?package=BinderDyn.OrchardCore.EventSourcing&version=1.2.2

// Install BinderDyn.OrchardCore.EventSourcing as a Cake Tool
#tool nuget:?package=BinderDyn.OrchardCore.EventSourcing&version=1.2.2

BinderDyn.OrchardCore.EventSourcing

Build and test on main Build and test on develop

This package is meant to be used with OrchardCore. List events, handle them and get a history in a relational table besides your other tables.

Hint

This will work only with SQL-Server, Postgres and MySQL and with a unique database for each tenant. I didn't find a way to get this working with SQLite or with multiple tenants in one database.

Usage

  1. Install the package via nuget in the project that consumes the API
  2. Add code that interacts with the event service. This is the main interface for storing, reading and processing the events.
     // Example from the repository with a content part handler
     public class BookHandler : ContentPartHandler<Book>
     {
       private readonly IServiceProvider _serviceProvider;
    
       public BookHandler(IServiceProvider serviceProvider)
       {
           _serviceProvider = serviceProvider;
       }
    
       public override async Task PublishedAsync(PublishContentContext context, Book instance)
       {
           var eventService = _serviceProvider.GetRequiredService<IEventService>();
    
           await eventService.Add(instance.BookTitle.Text, "BookAddedEvent", instance.ContentItem.ContentItemId);
    
           await base.PublishedAsync(context, instance);
       }
     }
    
  3. Activate the feature in the tenant you want to use it for
  4. You can view the created events in the 'Events' menu point in the admin frontend

Create Events

Directly taken from the interface:

Task<Guid> Add(object payload, string friendlyName, string? referenceId = null, Guid? originalEventId = null);

The payload can be any object as long as it is serializable. You can use referenceId to query via the event repository (e.g. for linking content items or storing other information).

Get pending events

// Gets the oldest event pending from the event store
Task<Event> GetNextPending(string? referenceId = null);

Again, you can use the referenceId for querying a specific event.

Event states

// Set the event state of a specific event
Task SetInProcessing(Guid eventId);
Task SetAsProcessed(Guid eventId);
Task SetAsFailed(Guid eventId);
Task SetAsAborted(Guid eventId);
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.2 240 10/29/2023
1.2.1 107 9/15/2023
1.2.0 98 9/15/2023
1.1.0 113 9/14/2023
1.0.1 115 9/9/2023
1.0.0 130 9/9/2023