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字符串
评论列表

发表评论

评论内容
昵称:

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