【发布时间】:2019-09-08 22:37:12
【问题描述】:
所以我在 BP 的代码阶段中有一些代码,它可以工作。
问题是它笨重、长而脆弱。我想知道如何在 BP 中使用类/es 将这段代码重构为更简洁和可扩展的东西,而不必编写外部类库然后引用它(这在我的环境)。
我知道可以使用 Global Code 选项卡编写方法,但是我可以在那里编写一个抽象类吗?子类会去哪里?接口呢?抱歉,如果这太基本了,我找不到以前的任何东西来指导我。任何帮助或指点表示赞赏,谢谢。
代码是一个基本决策阶段,它使用来自数据项“Main_Segment”的输入和 使用本地(私有)变量“parcel_label”和“found”将一些静态值输出到 BP 数据项“Parcel_Label”和“Found”中。
(BP数据项)找到=(局部变量)找到
(BP 数据项) Parcel_Label = (局部变量) parcel_label
(BP 数据项) Main_Segment = (局部变量) segdescript
string segdescript = Main_Segment;
found = false;
parcel_label = "";
if (segdescript.Contains("Segment 001") || segdescript.Contains("Segment 101"))
{
found = true; //if first condition is met, assign value of true to "found".
if (found = true) //as "found" is now true, the assignment below is carried out.
{
parcel_label = "Parcel0000";
}
}
//and again...
if (segdescript.Contains("Segment 002") || segdescript.Contains("Segment 202"))
{
found = true;
if (found = true)
{
parcel_label = "Parcel1111";
}
}
//and again another 97 times...zzz
【问题讨论】:
-
我想到了
Dictionary<string, string>。 -
嗯,我想到了……但我不是还需要创建一个基类和一些 99 个对象来填充
和 吗?问题是我在哪里可以在代码阶段之外创建基类,如果我要让它成为一个抽象类,我可以在哪里创建子类?请记住,目标是使 BluePrism 代码阶段内的代码更短,并使其更易于扩展(例如,添加新的 Segment - Parcel 关联)。