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

160 Views Asked by At

Moving on from my previous problem, now I need to add Triggers to my transitions in State Machine diagram. How to acheive this using C#. The following creates a transition and its gaurd value but the trigger is not getting added.

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();
1

There are 1 best solutions below

2
Dah Sra On BEST ANSWER

I don't think that there is a direct API call available to update the trigger.

TransitionEvent property of connetor will only update specification value.

Workaround for updating trigger is to hit a direct query using below call.

Repsitory.Execute(TriggerQuery)

You need to update\add a value in t_xref with

  • name as MOFProps
  • Type as connector property
  • Behaviour as trigger and
  • Description column you need to update the GUID value of triggers ( it will also accept Comma separated value as shown in diagram below )

Sample Insert query: Insert into t_xref (Name,Type,Visibility,Behavior,Description,Client) values ('MOFProps','connector property','public','trigger','triggereaguid1,triggereaguid2','connectorid');

enter image description here