![]() |
VOOZH | about |
dotnet add package Msm.Module.DynamicRecords.Infrastructure --version 1.0.35
NuGet\Install-Package Msm.Module.DynamicRecords.Infrastructure -Version 1.0.35
<PackageReference Include="Msm.Module.DynamicRecords.Infrastructure" Version="1.0.35" />
<PackageVersion Include="Msm.Module.DynamicRecords.Infrastructure" Version="1.0.35" />Directory.Packages.props
<PackageReference Include="Msm.Module.DynamicRecords.Infrastructure" />Project file
paket add Msm.Module.DynamicRecords.Infrastructure --version 1.0.35
#r "nuget: Msm.Module.DynamicRecords.Infrastructure, 1.0.35"
#:package Msm.Module.DynamicRecords.Infrastructure@1.0.35
#addin nuget:?package=Msm.Module.DynamicRecords.Infrastructure&version=1.0.35Install as a Cake Addin
#tool nuget:?package=Msm.Module.DynamicRecords.Infrastructure&version=1.0.35Install as a Cake Tool
Một thư viện Workflow Engine mạnh mẽ được xây dựng theo Clean Architecture, hỗ trợ multi-tenancy và cung cấp đầy đủ các tính năng để quản lý quy trình phê duyệt và workflow phức tạp.
ContextData sang payload của hệ thống khác, mapping ngược response về kết quả workflow, và lưu trong ResultDataMsm.Module.Workflow), triển khai (Msm.Module.Workflow.Infrastructure), và HTTP (Msm.Module.Workflow.AspNetCore)Project được xây dựng theo Clean Architecture với 4 layers chính:
framework/module/Workflow/
├── Msm.Module.Workflow/ # Domain: entities, enums, exceptions (NuGet: Msm.Module.Workflow)
├── Msm.Module.Workflow.Infrastructure/ # MediatR, services, DTOs, EF Core (NuGet: …Infrastructure)
└── Msm.Module.Workflow.AspNetCore/ # REST controllers (NuGet: …AspNetCore)
AspNetCore → Infrastructure → Domain (Msm.Module.Workflow)
Nguyên tắc:
Msm.Core.Abstractions)Msm.Core.Persistence: contracts chuẩn cho IRepository<T> và IUnitOfWork.Msm.Core.EntityFrameworkCore.PostgreSql: implementation EF Core/Npgsql cho contracts ở trên.Msm.Core.EFCore: legacy API để tương thích ngược cho các service cũ; ưu tiên code mới theo 2 package phía trên để dễ maintain lâu dài.Xem chi tiết tại
git clone <repository-url>
cd msm-workflow-lib
dotnet restore
dotnet build
<PackageReference Include="Msm.Module.Workflow" Version="1.0.0" />
<PackageReference Include="Msm.Module.Workflow.Infrastructure" Version="1.0.0" />
<PackageReference Include="Msm.Module.Workflow.AspNetCore" Version="1.0.0" />
build-packages.sh)<Version> trong từng .csproj của package bạn muốn phát hành (ví dụ framework/module/DynamicRecords/..., framework/module/Workflow/...).version_label) chỉ dùng cho log và tên thư mục output; phiên bản thực tế của .nupkg luôn lấy từ <Version> trong csproj (script không truyền /p:Version hay /p:PackageVersion để tránh NuGet ghi sai version của các ProjectReference, ví dụ Core vẫn 1.0.15 trong khi module đã 1.0.18).cd msm-workflow-lib
# Tất cả nhóm: core + dynamic + workflow
./build-packages.sh 1.0.18 ./artifacts/nuget-1.0.18 all
# Chỉ Core
./build-packages.sh 1.0.18 ./artifacts/nuget-1.0.18 core
# Chỉ DynamicRecords
./build-packages.sh 1.0.18 ./artifacts/nuget-1.0.18 dynamic
# Chỉ Workflow
./build-packages.sh 1.0.18 ./artifacts/nuget-1.0.18 workflow
# DynamicRecords + Workflow vào cùng một thư mục (chạy hai lần, cùng output)
./build-packages.sh 1.0.18 ./artifacts/nuget-1.0.18 dynamic
./build-packages.sh 1.0.18 ./artifacts/nuget-1.0.18 workflow
Nếu không truyền đủ tham số, xem hướng dẫn: ./build-packages.sh (thiếu version_label sẽ in usage).
Kết quả: các file .nupkg và .snupkg nằm trong thư mục output bạn chỉ định (ví dụ ./artifacts/nuget-1.0.18/).
Tạo API key tại NuGet API Keys. Không commit key vào git; dùng biến môi trường hoặc secret CI.
cd msm-workflow-lib
export NUGET_API_KEY='your-key-here'
# Đẩy toàn bộ .nupkg trong thư mục (bỏ qua nếu version đã tồn tại trên feed)
dotnet nuget push "./artifacts/nuget-1.0.18/*.nupkg" \
--source "https://api.nuget.org/v3/index.json" \
--api-key "$NUGET_API_KEY" \
--skip-duplicate
# Symbol packages (tùy chọn, sau khi push .nupkg)
dotnet nuget push "./artifacts/nuget-1.0.18/*.snupkg" \
--source "https://api.nuget.org/v3/index.json" \
--api-key "$NUGET_API_KEY" \
--skip-duplicate
Chỉ đẩy một nhóm package (ví dụ chỉ Workflow):
dotnet nuget push "./artifacts/nuget-1.0.18/Msm.Module.Workflow"*.nupkg \
--source "https://api.nuget.org/v3/index.json" \
--api-key "$NUGET_API_KEY" \
--skip-duplicate
Feed nội bộ (Azure Artifacts, v.v.): đổi --source sang URL feed của bạn (hoặc dùng tên source đã dotnet nuget add source).
Tạo file appsettings.json trong Infrastructure project:
{
"Database": {
"Host": "localhost",
"Port": "5432",
"Name": "msm_workflow",
"Username": "postgres",
"Password": "your_password"
}
}
cd framework/module/Workflow/Msm.Module.Workflow.Infrastructure
dotnet ef migrations add InitialCreate --startup-project .
dotnet ef database update --startup-project .
using Msm.Module.Workflow.Infrastructure;
using Msm.Module.Workflow.AspNetCore;
// Trong Program.cs hoặc Startup.cs
services.AddApplication();
services.AddInfrastructure(configuration);
services.AddWorkflowApiControllers();
[ApiController]
[Route("api/[controller]")]
public class MyController : ControllerBase
{
private readonly IWorkflowProcessService _processService;
private readonly IWorkflowInstanceService _instanceService;
public MyController(
IWorkflowProcessService processService,
IWorkflowInstanceService instanceService)
{
_processService = processService;
_instanceService = instanceService;
}
[HttpPost("create-process")]
public async Task<IActionResult> CreateProcess(CreateWorkflowProcessDto dto)
{
var process = await _processService.CreateProcessAsync(dto);
return Ok(process);
}
}
Xem chi tiết tại
var processDto = new CreateWorkflowProcessDto
{
Name = "Purchase Order Approval",
Code = "PO_APPROVAL",
ObjectType = "PURCHASE_ORDER",
Description = "Workflow for approving purchase orders",
EntryCriteria = "amount > 10000",
AllowSubmitterToRecall = true
};
var process = await _processService.CreateWorkflowProcessFromDtoAsync(processDto);
var stepDto = new CreateWorkflowStepDto
{
ProcessId = process.Id,
Name = "Manager Approval",
StepType = WorkflowStepType.Approval,
StepOrder = 1,
WorkflowBehavior = WorkflowBehavior.ALL_MUST_APPROVE,
ApprovalTimeoutDays = 1, // 1 day
TimeoutBehavior = TimeoutBehavior.Escalate
};
var step = await _processService.AddStepFromDtoAsync(process.Id, stepDto);
// Lấy process theo code trước
var process = await _processService.GetWorkflowProcessesAsync()
.FirstOrDefaultAsync(p => p.Code == "PO_APPROVAL");
var contextData = JsonDocument.Parse(JsonSerializer.Serialize(new
{
amount = 15000,
department = "IT"
}));
var instance = await _instanceService.SubmitWorkflowInstanceAsync(
workflowProcessId: process.Id,
targetRecordId: purchaseOrderId,
targetObjectType: "PURCHASE_ORDER",
submittedBy: currentUserId,
contextData: contextData
);
// instance.Status và instance.History cho biết trạng thái phê duyệt
Xem thêm ví dụ tại
Ví dụ một workflow dùng để validation Order trước khi lưu:
WorkflowProcess có Code = "ORDER_VALIDATION" và ObjectType = "ORDER", loại process là Validation.ExternalApiCall với ActionConfig:
WorkflowInstance.ContextData sang payload của API (qua UI Designer).WorkflowInstance.ResultData để trả lại cho caller.Khi tạo Order, hệ thống chỉ cần trigger workflow:
var contextData = JsonDocument.Parse(JsonSerializer.Serialize(new
{
orderId = orderId,
totalAmount = 1500000,
customerCode = "C001"
}));
var instance = await _instanceService.SubmitWorkflowInstanceAsync(
workflowProcessId: validationProcess.Id, // ORDER_VALIDATION
targetRecordId: orderId.ToString(),
targetObjectType: "ORDER",
submittedBy: currentUserId,
contextData: contextData
);
// Sau khi workflow chạy xong (các step validation tự động, không cần approver):
// - instance.Status: thành công/failed tùy theo logic validation
// - instance.Metadata / ResultData (tùy implement) chứa chi tiết lỗi/cảnh báo để hiển thị trên UI
Trong UI Designer, bạn có thể:
ExternalApiCall.Project bao gồm một React-based UI designer để thiết kế workflow trực quan:
cd Example/workflow-designer-ui
npm install
npm run dev
Truy cập tại http://localhost:5173
# Chạy tests (khi có)
dotnet test
# Build solution
dotnet build
# Restore packages
dotnet restore
Chúng tôi hoan nghênh mọi đóng góp! Vui lòng đọc để biết cách đóng góp.
[Specify your license here]
Lưu ý: Đây là version 1.0.0. API có thể thay đổi trong các phiên bản tương lai.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.35 | 52 | 6/18/2026 |
| 1.0.34 | 123 | 6/13/2026 |
| 1.0.33 | 109 | 6/12/2026 |
| 1.0.32 | 115 | 6/12/2026 |
| 1.0.31 | 94 | 6/12/2026 |
| 1.0.30 | 101 | 6/11/2026 |
| 1.0.29 | 133 | 6/6/2026 |
| 1.0.28 | 99 | 6/6/2026 |
| 1.0.27 | 113 | 6/5/2026 |
| 1.0.26 | 92 | 6/5/2026 |
| 1.0.25 | 150 | 5/27/2026 |
| 1.0.24 | 112 | 5/22/2026 |
| 1.0.23 | 108 | 5/22/2026 |
| 1.0.22 | 93 | 5/21/2026 |
| 1.0.21 | 125 | 5/18/2026 |
| 1.0.20 | 111 | 5/18/2026 |
| 1.0.19 | 104 | 5/17/2026 |
| 1.0.18 | 134 | 5/10/2026 |
| 1.0.17 | 104 | 5/10/2026 |
| 1.0.16 | 110 | 5/8/2026 |