如何使用 C# 在 Enterprise Architect 中将触发器添加到转换

How to add Triggers to Transitions in Enterprise Architect using C#

继续我之前的问题,现在我需要将触发器添加到状态机图中的转换。如何使用 C# 实现此目的。以下创建了一个转换及其 gaurd 值,但未添加触发器。

EA.Connector trans = psosDiagramElement.Connectors.AddNew(tb1[i].Text, "StateFlow");
                    trans.ClientID = GetElementByName(txtSourceElement.Text);
                    trans.MetaType = "Transition";
                    trans.TransitionGuard = tb1[i].Text;
                    trans.SupplierID = GetElementByName(cmb1[i].SelectedItem.ToString());
                    trans.Direction = "Source -> Destination";
                    trans.Constraints.AddNew("A", "Signal");
                    trans.Update();

我认为没有可用于更新触发器的直接 API 调用。

TransitionEvent property of connetor will only update specification value.

更新触发器的解决方法是使用以下调用直接查询。

Repsitory.Execute(TriggerQuery)

您需要 update\add t_xref 中的值

  • 名称为 MOFProps
  • 类型为 连接器 属性
  • 作为触发器
  • 的行为
  • 您需要更新触发器的 GUID 值的描述列(它也将接受逗号分隔值,如下图所示)

示例插入查询:Insert into t_xref (Name,Type,Visibility,Behavior,Description,Client) values ('MOFProps','connector property','public','trigger','triggereaguid1,triggereaguid2','connectorid');