Book a Demo

Author Topic: C# - Adding "Add message from .. to .. "  (Read 8879 times)

Tomasz

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
C# - Adding "Add message from .. to .. "
« on: December 16, 2014, 03:44:59 am »
Hi,

I have created 2 connectors in C#;

First:

EA.Connector connector = previous.m_diagramElement.Connectors.AddNew("", "Association");

Second:

EA.Connector message = previous.m_diagramElement.Connectors.AddNew(functionData.GetMethodName(), "Collaboration");

All refresh and update parts of code have been added
It works fine but I can't connect those two with arrow.
( which you can easly do using options "Add message from .. to .. " from "Association" connector context menu.

I have found in exported xml file that for "Collaboration connector" in extProperties "message_link" variable has been added with 1st connector GUID as value.

<extendedProperties stateflags="IsReturn=false;" virtualInheritance="0" message_link="EAID_AC5CF663_AF22_41ec_80D2_BD526F97913B" diagram="EAID_0B72E9F3_1B43_4505_A059_87963183DB4C" privatedata1="Synchronous" privatedata2="retval=bool;params=;paramsDlg=nameSpace, Key, data;" privatedata3="Call" privatedata4="0.4" privatedata5="SX=-98;SY=3;EX=-68;EY=3;"/>

I have no access to extProperties.
Question is how to simulate that connection in C# (not by hand) ?

Please help me :) Thanks in advance.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #1 on: December 16, 2014, 04:59:06 am »
Quote
... I can't connect those two with arrow.....
Which two? The two connectors? :-?

q.

Tomasz

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #2 on: December 16, 2014, 07:45:34 pm »
I have been trying to simulate in C# the same "behaviour" which I have achieved adding element by hand.

1) I have 2 diagram object - Actor and WriteInt Object

EA.Element element = m_interaction.Elements.AddNew("", "Object");
EA.DiagramObject diagramObj = m_diagram.DiagramObjects.AddNew("","");

2) I have created 2 connectors:

a) Assocation connector between those elements.
b) Second connector ( from exported .xml I know that's connector with Collaboration setting ) can be added using "Add message from .. to .. " from "Association" connector context menu.

If you do that by hand you will see line between Assocation and Collaboration connectors. I want to do that in C#.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #3 on: December 16, 2014, 10:33:47 pm »
This is because EA creates an additional entry in t_xref. You can find that out in an empty repository where you create one such double-connector manually. You can then try to mimic that by adding the right entry in t_xref via Repository.Execute.

q.

Tomasz

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #4 on: December 16, 2014, 11:28:34 pm »
xref content hasn't change in exported xml file.
Only extendedProperties tag values have additional values as "message_link"

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #5 on: December 16, 2014, 11:30:06 pm »
Not in the exported xml. In the internal t_xref table. Use the SQL tab for a
Code: [Select]
SELECT * FROM t_xref
q.

Tomasz

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #6 on: December 17, 2014, 12:15:27 am »
Thank you for you support.

Unfortunately too many information appears after executing that query.
I can't find something useful there. More logical connection I can find in exported xml file.
And I don't know why I should search in whole repository.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: C# - Adding "Add message from .. to ..
« Reply #7 on: December 17, 2014, 12:21:58 am »
As said you need to create an empty EAP first. Then add two plain classes and add exactly that one connector.

This is (almost) the only way to find out such things.

q.
« Last Edit: December 17, 2014, 12:22:40 am by qwerty »

Tomasz

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: C# - Adding "Add message from .. to ..
« Reply #8 on: December 19, 2014, 02:11:15 am »
I have fixed that.

The solution is to run SQL command:

string sqlQuery =
"UPDATE t_connector SET SourceIsAggregate=" + connector.ConnectorID + " WHERE Connector_Id=" + message.ConnectorID;
m_repository.Execute(sqlQuery);

All thanks to 'qwerty' help. Thank you very much once again.

Maybe someone has idea how to do that without using SQL executions?

« Last Edit: December 19, 2014, 02:11:33 am by tomaszlewandowski »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #9 on: December 19, 2014, 02:46:20 am »
Check EAConnector.ClientEnd. It delivers a EAConnector object which holds a long Aggregation.

q.

Tomasz

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #10 on: December 19, 2014, 02:53:59 am »
Ooops, I tried it before, but it didn't work.
Because I forgot about calling update.

So now it's more simple:

message.ClientEnd.Aggregation = connector.ConnectorID;
message.ClientEnd.Update();

Thank you.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #11 on: December 19, 2014, 05:26:26 am »
There's something wrong with that. Aggregation takes
Quote
0 = None, 1 = Shared, 2 = Composite

q.

Tomasz

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: C# - Adding "Add message from .. to ..
« Reply #12 on: December 19, 2014, 07:53:51 pm »
Strange but it works only this way.

If I will add that "message connector" to "asscociate connector" by hand then in database field "SourceIsAggregate" for "message connector" is set to "associate connector" id.

In C# I have achieved the same result like that:

EA.Connector associateConnector = SOME_DIAGRAM_ELEMENT.Connectors.AddNew("", "Association");
        EA.Connector messageConnector = SOME_DIAGRAM_ELEMENT.Connectors.AddNew("", "Collaboration");
        ....
        EA.ConnectorTag tag = messageConnector.TaggedValues.AddNew("operation_guid", "String");
        tag.Value = method.MethodGUID;
        ....
        messageConnector.TransitionGuard = "retval=" +   method.ReturnType + ";params=;paramsDlg=" + ....;
        messageConnector.StyleEx = "aliasparamsTO=" + ..... + ";";
        messageConnector.TransitionAction = "Call";
        messageConnector.TransitionEvent = "Synchronous";
        messageConnector.Name = method.Name + .... + ")";
        messageConnector.ClientEnd.Aggregation = connector.ConnectorID;
        messageConnector.ClientEnd.Update();  
« Last Edit: December 19, 2014, 08:07:05 pm by tomaszlewandowski »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #13 on: December 19, 2014, 09:38:14 pm »
This is likely coincidence. Better use an enumeration with the named values to show none, shared or aggregate on the connector ends. It appears that all assignments above 2 are shown as aggregate. So if you assign the ConnectorID this is most likely a positive integer above 2.

q.

Tomasz

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: C# - Adding "Add message from .. to .. "
« Reply #14 on: December 19, 2014, 09:56:40 pm »
I have checked 0,1,2 and neither of those options works.

Maybe I have discovered some hidden feature :)