Easy.WorkFlow.JsonBuilder 2.3.17

dotnet add package Easy.WorkFlow.JsonBuilder --version 2.3.17
                    
NuGet\Install-Package Easy.WorkFlow.JsonBuilder -Version 2.3.17
                    
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="Easy.WorkFlow.JsonBuilder" Version="2.3.17" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Easy.WorkFlow.JsonBuilder" Version="2.3.17" />
                    
Directory.Packages.props
<PackageReference Include="Easy.WorkFlow.JsonBuilder" />
                    
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 Easy.WorkFlow.JsonBuilder --version 2.3.17
                    
#r "nuget: Easy.WorkFlow.JsonBuilder, 2.3.17"
                    
#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 Easy.WorkFlow.JsonBuilder@2.3.17
                    
#: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=Easy.WorkFlow.JsonBuilder&version=2.3.17
                    
Install as a Cake Addin
#tool nuget:?package=Easy.WorkFlow.JsonBuilder&version=2.3.17
                    
Install as a Cake Tool

Easy.WorkFlow.JsonBuilder

Easy.WorkFlow.JsonBuilder 是一个基于JSON的工作流构建包,为 Easy.WorkFlow.Core 提供从JSON文件或JSON字符串构建工作流定义的能力。本库支持 .NET 6、.NET 7、.NET 8 和 .NET 9。

功能特性

  • JSON文件解析:支持从JSON文件直接构建工作流定义
  • JSON字符串解析:支持从JSON字符串构建工作流定义
  • 路径配置:可配置JSON文件的基础路径
  • 无缝集成:与Easy.WorkFlow.Core工作流核心库无缝集成
  • 依赖注入支持:支持在ASP.NET Core应用中通过服务注册使用

更新日志

  • 2.3.17
    • 升级:升级Easy.WorkFlow.Core到2.3.17版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.16
    • 升级:升级Easy.WorkFlow.Core到2.3.16版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.15
    • 升级:升级Easy.WorkFlow.Core到2.3.15版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.14
    • 升级:升级Easy.WorkFlow.Core到2.3.14版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.13
    • 升级:升级Easy.WorkFlow.Core到2.3.13版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.12
    • 升级:升级Easy.WorkFlow.Core到2.3.12版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.11
    • 升级:升级Easy.WorkFlow.Core到2.3.11版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.10
    • 升级:升级Easy.WorkFlow.Core到2.3.10版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.9
    • 升级:升级Easy.WorkFlow.Core到2.3.9版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.8
    • 升级:Easy.WorkFlow.Core升级到2.3.8版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.7
    • 升级:Easy.WorkFlow.Core升级到2.3.7版本,具体见 [Easy.WorkFlow.Core 更新日志]
    • 调整:构建工作流定义时增加对创建用户信息的验证。
  • 2.3.6
    • 升级Easy.WorkFlow.Core到2.3.6版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.5
    • 升级Easy.WorkFlow.Core到2.3.5版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.4
    • 升级Easy.WorkFlow.Core到2.3.4版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.3
    • 升级Easy.WorkFlow.Core到2.3.3版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.2
    • 修复WorkFlowBuilderContext上下文参数AutoGenerateId未传递生效的问题
    • 升级Easy.WorkFlow.Core到2.3.1版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.3.1
    • 修复json字符串无法反序列化的问题;采用Easy.WorkFlow.Core的序列化器
  • 2.3.0
    • 升级Easy.WorkFlow.Core到2.3.0版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.2.2
    • 升级Easy.WorkFlow.Core到2.2.2版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.2.1
    • 升级Easy.WorkFlow.Core到2.2.1版本,具体见 [Easy.WorkFlow.Core 更新日志]
    • 添加注释文档
  • 2.2.0
    • 升级Easy.WorkFlow.Core到2.2.0版本,具体见 [Easy.WorkFlow.Core 更新日志]
  • 2.1.0
    • 升级Easy.WorkFlow.Core到2.1.0版本,具体见 [Easy.WorkFlow.Core 更新日志]

快速开始

1. 安装包

dotnet add package Easy.WorkFlow.JsonBuilder

2. 注册服务

Program.csStartup.cs 中注册 JsonBuilder 服务:

// 首先注册工作流核心服务
services.AddWorkFlow();

// 注册JSON构建器服务
services.AddJsonBuilder(options => 
{
    // 配置JSON文件的基础路径(可选)
    options.BasePath = Path.Combine(Directory.GetCurrentDirectory(), "WorkFlowDefinitions");
});

3. 使用JSON文件构建工作流

// 创建工作流构建上下文
var context = new WorkFlowBuilderContext<string>
{
    SourceType = "json",
    Source = "workflow-definition.json" // 相对于BasePath的文件路径
};

// 使用工作流服务构建
await _workflowService.BuildAsync(context);

4. 使用JSON字符串构建工作流

// JSON工作流定义字符串
string jsonWorkflow = @"{
  ""id"": 1001,
  ""name"": ""请假工作流"",
  ""description"": ""请假审批"",
  ""version"": 1,
  ""steps"": [
    {
      ""id"": 1,
      ""wfId"": 1001,
      ""number"": 0,
      ""name"": ""请假申请"",
      // ...其他步骤属性
    },
    // ...更多步骤
  ],
  ""formName"": ""请假表单.json"",
  ""createdTime"": ""2023-06-18"",
  ""createdUserName"": ""Admin"",
  ""createdUserId"": 10001
}";

// 创建工作流构建上下文
var context = new WorkFlowBuilderContext<string>
{
    SourceType = "json",
    Data = jsonWorkflow
};

// 使用工作流服务构建
await _workflowService.BuildAsync(context);

JSON工作流定义格式

以下是一个完整的工作流JSON定义示例:

{
  "id": 1001,
  "name": "请假工作流",
  "description": "请假审批",
  "version": 1,
  "steps": [
    {
      "id": 1,
      "wfId": 1001,
      "number": 0,
      "name": "请假申请",
      "description": "请假申请",
      "when": null,
      "processor": "api/text",  
      "processorType": 3,
      "processorContext": "{\"method\":\"post\",\"content\":\"userid=[user.userid]&username=[user.username]\"}",
      "actors": null,
      "actorNames": null,
      "actorsExpression": null,
      "actorType": 1,
      "actionBtns": [
        {
          "name": "提交",
          "type": 1,
          "callback": null
        }
      ],
      "next": [
        2
      ]
    },
    {
      "id": 2,
      "wfId": 1001,
      "number": 1,
      "name": "审批",
      "description": "请假审批",
      "when": null, 
      "processor": "INSERT INTO WF_Text (Name,date) VALUES (@name,@date)",
      "processorType": 1,
      "processorContext": "name=[user.username]&date=[date]",
      "actors": null,
      "actorNames": null,
      "actorsExpression": "[user]",
      "actorType": 2,
      "actionBtns": [
        {
          "name": "同意",
          "type": 1,
          "callback": null
        },
        {
          "name": "拒绝",
          "type": 2,
          "callback": null
        }
      ],
      "next": null
    }
  ],
  "formName": "请假表单.json",
  "createdTime": "2023-06-18",
  "createdUserName": "Admin",
  "createdUserId": 10001
}

字段说明

工作流定义(根级别)
字段 类型 描述
id long 工作流唯一标识符
name string 工作流名称
description string 工作流描述
version int 工作流版本号
steps array 工作流步骤集合
formName string 关联的表单名称
createdTime string 创建时间
createdUserName string 创建人名称
createdUserId long 创建人ID
工作流步骤(steps 数组中的项)
字段 类型 描述
id long 步骤唯一标识符
wfId long 所属工作流ID
number int 步骤级别编号
name string 步骤名称
description string 步骤描述
when string 执行条件表达式
processor string 处理器内容(SQL语句、远程URL或方法名)
processorType int 处理器类型(1=SQL, 2=Action, 3=URL)
processorContext string 处理器上下文数据
actors array 固定处理人ID列表
actorNames array 固定处理人名称列表
actorsExpression string 动态处理人表达式
actorType int 处理人类型(1=用户, 2=表达式)
actionBtns array 步骤操作按钮
next array 下一步骤ID列表

与其他包集成

Easy.WorkFlow.JsonBuilder 可以与 Easy.WorkFlow 生态系统中的其他包一起使用:

  • Easy.WorkFlow.Core:工作流核心库
  • Easy.WorkFlow.SqlSugar:提供基于SqlSugar的工作流存储实现
  • Easy.WorkFlow.AspNetCore:提供ASP.NET Core集成

注意事项

  • JSON文件路径是相对于配置的 BasePath 的相对路径
  • 确保JSON文件使用UTF-8编码,以正确处理中文等字符
  • 处理器上下文中的表达式会在运行时被解析,可以引用表单数据中的字段

依赖项

  • Easy.WorkFlow.Core >= 2.2.2
  • System.Text.Json (内置于.NET运行时)

许可证

Easy.WorkFlow.JsonBuilder 使用 MIT 许可证。

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  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 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 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.  net10.0 was computed.  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
2.3.17 120 9/19/2025
2.3.16 245 9/19/2025 2.3.16 is deprecated because it has critical bugs.
2.3.15 231 9/11/2025 2.3.15 is deprecated because it has critical bugs.
2.3.14 246 9/4/2025 2.3.14 is deprecated because it has critical bugs.
2.3.13 272 8/29/2025 2.3.13 is deprecated because it has critical bugs.
2.3.12 313 8/7/2025 2.3.12 is deprecated because it has critical bugs.
2.3.11 264 7/29/2025 2.3.11 is deprecated because it has critical bugs.
2.3.10 178 7/28/2025 2.3.10 is deprecated because it is no longer maintained.
2.3.9 543 7/24/2025 2.3.9 is deprecated because it has critical bugs.
2.3.8 889 7/24/2025 2.3.8 is deprecated because it is no longer maintained.
2.3.7 964 7/22/2025 2.3.7 is deprecated because it is no longer maintained.
2.3.6 998 7/22/2025 2.3.6 is deprecated because it is no longer maintained.
2.3.5 705 7/20/2025 2.3.5 is deprecated because it is no longer maintained.
2.3.4 618 7/15/2025 2.3.4 is deprecated because it is no longer maintained.
2.3.3 620 7/14/2025 2.3.3 is deprecated because it is no longer maintained.
2.3.2 591 7/11/2025 2.3.2 is deprecated because it is no longer maintained.
2.3.1 588 7/11/2025 2.3.1 is deprecated because it is no longer maintained.
2.3.0 627 7/9/2025 2.3.0 is deprecated because it is no longer maintained.
2.2.2 617 6/30/2025 2.2.2 is deprecated because it is no longer maintained.
2.2.1 614 6/30/2025 2.2.1 is deprecated because it is no longer maintained.
2.2.0 577 6/28/2025 2.2.0 is deprecated because it is no longer maintained.
2.1.0 616 6/26/2025 2.1.0 is deprecated because it is no longer maintained.
2.0.0 616 6/25/2025 2.0.0 is deprecated because it is no longer maintained.