MeshWeaver.Activities 2.0.3

dotnet add package MeshWeaver.Activities --version 2.0.3                
NuGet\Install-Package MeshWeaver.Activities -Version 2.0.3                
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="MeshWeaver.Activities" Version="2.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MeshWeaver.Activities --version 2.0.3                
#r "nuget: MeshWeaver.Activities, 2.0.3"                
#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 MeshWeaver.Activities as a Cake Addin
#addin nuget:?package=MeshWeaver.Activities&version=2.0.3

// Install MeshWeaver.Activities as a Cake Tool
#tool nuget:?package=MeshWeaver.Activities&version=2.0.3                

MeshWeaver.Activities

MeshWeaver.Activities implements the activity tracking framework defined in MeshWeaver.Activities.Contract. It provides concrete implementations for activity monitoring, logging, and sub-activity management.

Overview

The library provides:

  • Implementation of IActivity interface
  • Activity lifecycle management
  • Sub-activity tracking
  • Integration with message hub system

Implementation

Activity Class

public class Activity : IActivity
{
    private readonly IMessageHub _messageHub;
    private readonly IDictionary<string, ActivityLog> _subActivities;

    public Activity(string name, IMessageHub messageHub)
    {
        Name = name;
        _messageHub = messageHub;
    }

    public string Name { get; }

    public IActivity StartSubActivity(string name)
    {
        // Creates and tracks a new sub-activity
        return new Activity(name, _messageHub);
    }

    public void LogInformation(string message)
    {
        // Logs activity information through message hub
    }

    public async Task<ActivityLog> Complete(Action<ActivityLog> onComplete = null)
    {
        // Completes the activity and all sub-activities
        var log = new ActivityLog
        {
            Status = ActivityStatus.Succeeded,
            SubActivities = _subActivities
        };
        
        onComplete?.Invoke(log);
        return log;
    }
}

Usage Examples

Basic Activity Tracking

// Create and use an activity
var activity = new Activity("MyActivity", messageHub);
activity.LogInformation("Processing started");
await activity.Complete();

Hierarchical Activities

// Main activity with sub-activities
var activity = new Activity("MainProcess", messageHub);
var subActivity1 = activity.StartSubActivity("SubProcess1");
var subActivity2 = activity.StartSubActivity("SubProcess2");

// Log information in different activities
activity.LogInformation("Main process running");
subActivity1.LogInformation("Sub-process 1 running");
subActivity2.LogInformation("Sub-process 2 running");

// Complete sub-activities
await subActivity1.Complete();
await subActivity2.Complete();

// Complete main activity
await activity.Complete(log => 
{
    // Access completion information
    var subActivities = log.SubActivities;
});

Auto-Completion Support

var activity = new Activity("AutoComplete", messageHub);
var subActivity = activity.StartSubActivity("SubProcess");

// Start completion of main activity
var completionTask = activity.Complete();

// Complete sub-activity - main activity will complete automatically
await subActivity.Complete();

Features

  1. Activity Management

    • Creation and tracking of activities
    • Hierarchical activity structure
    • Automatic sub-activity management
  2. Logging

    • Activity status tracking
    • Information logging
    • Completion state management
  3. Message Hub Integration

    • Activity events broadcasting
    • Message-based logging
    • Cross-component communication
  • MeshWeaver.Activities.Contract - Core activity interfaces
  • MeshWeaver.Import - Import functionality using activities
  • MeshWeaver.Data - Data management with activity tracking
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MeshWeaver.Activities:

Package Downloads
MeshWeaver.Data

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.3 141 3/24/2025
2.0.2 136 3/24/2025
2.0.1 179 3/21/2025
2.0.0 214 3/20/2025
2.0.0-preview3 169 2/28/2025
2.0.0-Preview2 198 2/10/2025
2.0.0-preview1 194 1/6/2025
1.0.1 211 10/8/2024
1.0.0 202 10/8/2024