Epicor BPM 解析字符串得到List对象并转换为json字符串
EpicorBPM中有如下两个客观条件
- Epicor用的是C#6,不能定义匿名对象
- 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 张国生


