Epicor BPM 解析字符串得到List对象并转换为json字符串


EpicorBPM中有如下两个客观条件

  1. Epicor用的是C#6,不能定义匿名对象
  2. EpicorBPM中定义Class太麻烦

因此。我们可以使用List<Tuple<string, string>>

C# 全选
// 函数库
string functionLibrary =  "ZAPIServer";
// 方法名
string function =  "PostEx";

// 请求参数
var urlPath = $"/api/{callContextClient.CurrentCompany}/Part/PartBomExpandByMQ";

var list = new List<Tuple<string, string>>();
var regex = new System.Text.RegularExpressions.Regex(@"Part:\s*(\S+)\s+Rev:\s*(\S+)",
                      System.Text.RegularExpressions.RegexOptions.IgnoreCase);
foreach (System.Text.RegularExpressions.Match match in regex.Matches(opResultString))
{
    list.Add(Tuple.Create(
        match.Groups[1].Value, // Part
        match.Groups[2].Value  // Rev
    ));
}

var jsonBody = list.Select(x=>new {
    PartNum=x.Item1,
    RevisionNum=x.Item2
});
// 请求参数
string jsonStr = System.Text.Json.JsonSerializer.Serialize(jsonBody);

// 调用函数
var result = (Tuple<System.Boolean,System.String,System.String>)this.InvokeFunction(functionLibrary,function,Tuple.Create(urlPath,jsonStr));
bool success = result.Item1;
string message = result.Item2;
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
张国生
上一篇:Epicor在BPM中调用自定义函数
下一篇:没有了
评论列表

发表评论

评论内容
昵称:
关联文章

Epicor BPM 解析字符串得到List对象转换json字符串
Python对象json字符串
C# 根据DataTable 转换JSON 文本字符串数据
JQuery将form表单转换json提交后台处理
Python Flask返回JSON字符串,自定义对象JSON字符串
C#类型转换对象转换
C# 使用Newtonsoft对象JSON字符串的时候日期类型的处理
.NETCore和.NET5 MVC解析获取appsettings.json数据
EpicorBPM中调用自定义函数
JSON.stringify 输出JSON字符串时对日期Date类型的处理
C#格式化JSON字符串
Epicor BPM中自定义代码弹出错误提醒
c# 将数组或集合 转换成以逗号分隔的字符串
GZDBHelper中ExecuteDataReader方法,执行SQL语句,返回指定对象集合
C# Newtonsoft.Json.JsonConvert.SerializeObject生成格式化的JSON字符串
WPF对象级资源
C# 金额转换,金额数字转换人民币大写
NPOI 读取EXCEL(2003,2007)转换DataTable
C# 解析加载读取XML文件的正确姿势
Redis OM .NET Redis对象映射框架

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码