Msm.Workflow.Lib.Api.Controllers 1.9.0

dotnet add package Msm.Workflow.Lib.Api.Controllers --version 1.9.0
                    
NuGet\Install-Package Msm.Workflow.Lib.Api.Controllers -Version 1.9.0
                    
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="Msm.Workflow.Lib.Api.Controllers" Version="1.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Msm.Workflow.Lib.Api.Controllers" Version="1.9.0" />
                    
Directory.Packages.props
<PackageReference Include="Msm.Workflow.Lib.Api.Controllers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Msm.Workflow.Lib.Api.Controllers --version 1.9.0
                    
#r "nuget: Msm.Workflow.Lib.Api.Controllers, 1.9.0"
                    
#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.
#:package Msm.Workflow.Lib.Api.Controllers@1.9.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Msm.Workflow.Lib.Api.Controllers&version=1.9.0
                    
Install as a Cake Addin
#tool nuget:?package=Msm.Workflow.Lib.Api.Controllers&version=1.9.0
                    
Install as a Cake Tool

Msm.Workflow.Lib.Api.Controllers

Pre-built REST API controllers cho MSM Workflow Engine - cung cấp CRUD endpoints sẵn có.

📦 Installation

<PackageReference Include="Msm.Workflow.Lib.Api.Controllers" Version="1.0.0" />
dotnet add package Msm.Workflow.Lib.Api.Controllers

📋 Overview

Package này cung cấp pre-built API controllers để tích hợp nhanh workflow engine vào ASP.NET Core application. Có thể sử dụng trực tiếp hoặc inherit để customize.

Contents

  • WorkflowProcessesController: CRUD operations cho workflow processes
  • WorkflowInstancesController: CRUD operations và workflow execution
  • WorkflowTriggerController: Trigger workflow instances
  • TenantsController: Multi-tenancy management

🎯 Usage

Register Controllers

using Msm.Workflow.Lib.Api.Controllers;

// In Program.cs or Startup.cs
services.AddWorkflowApiControllers();

Use Controllers Directly

Controllers sẽ tự động được map với routes (kebab-case):

WorkflowProcessesController (/api/workflow-processes):

  • GET /api/workflow-processes - List all processes
  • POST /api/workflow-processes - Create new process
  • GET /api/workflow-processes/{id} - Get process by ID
  • PUT /api/workflow-processes/{id} - Update process
  • DELETE /api/workflow-processes/{id} - Delete process
  • GET /api/workflow-processes/{processId}/steps - Get process steps
  • POST /api/workflow-processes/{processId}/steps - Add step to process
  • PUT /api/workflow-processes/steps/{stepId} - Update step
  • DELETE /api/workflow-processes/steps/{stepId} - Delete step
  • POST /api/workflow-processes/steps/{stepId}/approvers - Add approver to step
  • POST /api/workflow-processes/steps/{stepId}/actions - Add action to step
  • GET /api/workflow-processes/{processId}/transitions - Get transitions
  • POST /api/workflow-processes/{processId}/transitions - Create transition
  • PUT /api/workflow-processes/{processId}/transitions/{transitionId} - Update transition
  • DELETE /api/workflow-processes/{processId}/transitions/{transitionId} - Delete transition

WorkflowInstancesController (/api/workflow-instances):

  • POST /api/workflow-instances/submit - Submit workflow instance
  • GET /api/workflow-instances - List instances (with filters)
  • GET /api/workflow-instances/{id} - Get instance by ID
  • GET /api/workflow-instances/pending/{userId} - Get pending items for user
  • POST /api/workflow-instances/items/{itemId}/approve - Approve workflow item
  • POST /api/workflow-instances/items/{itemId}/reject - Reject workflow item
  • POST /api/workflow-instances/{instanceId}/recall - Recall workflow instance
  • POST /api/workflow-instances/items/{itemId}/delegate - Delegate item
  • POST /api/workflow-instances/items/{itemId}/reassign - Reassign item
  • POST /api/workflow-instances/{instanceId}/adhoc-steps - Add ad-hoc step

WorkflowTriggerController (/api/workflow):

  • POST /api/workflow/trigger - Trigger workflow instance

TenantsController (/api/tenants):

  • GET /api/tenants - List all tenant schemas
  • GET /api/tenants/{tenantKey}/exists - Check if schema exists
  • POST /api/tenants/{tenantKey} - Create tenant schema
  • DELETE /api/tenants/{tenantKey} - Delete tenant schema

Inherit and Customize

[ApiController]
[Route("api/[controller]")]
public class MyWorkflowController : BaseWorkflowController
{
    public MyWorkflowController(
        IWorkflowProcessService processService,
        IWorkflowInstanceService instanceService)
        : base(processService, instanceService)
    {
    }

    // Add custom endpoints
    [HttpPost("custom-action")]
    public async Task<IActionResult> CustomAction()
    {
        // Your custom logic
    }
}

Example API Calls

# Create workflow process
POST /api/workflow-processes
Content-Type: application/json
{
  "name": "Purchase Order Approval",
  "code": "PO_APPROVAL",
  "objectType": "PURCHASE_ORDER",
  "description": "Workflow for approving purchase orders"
}

# Submit workflow instance
POST /api/workflow-instances/submit
Content-Type: application/json
{
  "processId": "guid-here",
  "targetRecordId": "po-123",
  "targetObjectType": "PURCHASE_ORDER",
  "submittedBy": "user123",
  "contextDataJson": "{\"amount\": 15000, \"department\": \"IT\"}",
  "comments": "Requesting approval"
}

# Approve workflow item
POST /api/workflow-instances/items/{itemId}/approve
Content-Type: application/json
{
  "approverId": "user456",
  "comments": "Approved"
}

🔗 Dependencies

  • Msm.Workflow.Lib.Application (required)
  • Microsoft.AspNetCore.App (framework reference)
  • Msm.Workflow.Lib.Application - Required dependency
  • Msm.Workflow.Lib.Infrastructure - Required for data access
  • Msm.Workflow.Lib.Domain - Required for domain entities

🔒 Multi-Tenancy

Controllers hỗ trợ multi-tenancy qua x-tenant header:

# Request với tenant header
curl -H "x-tenant: tenant1" \
     -H "Content-Type: application/json" \
     http://localhost:5000/api/workflow-processes

📖 Documentation

For more information, see the main README.md and GETTING_STARTED.md.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  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.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.9.0 93 3/5/2026
1.8.0 87 3/2/2026
1.6.0 100 1/11/2026
1.5.0 98 1/11/2026
1.4.0 93 1/11/2026
1.3.0 99 1/9/2026
1.2.0 97 1/7/2026
1.1.0 91 1/6/2026
1.0.0 96 1/6/2026