Book a Demo

Author Topic: C# Add-In problem with connection to EA-Repository  (Read 3897 times)

AndreasBaur

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
C# Add-In problem with connection to EA-Repository
« on: April 10, 2012, 06:32:04 pm »
Hello everyone,

i am writing an add-in using c# where i want to create a kind of a navigation for all the diagrams in a model.
I implement some methods where i create new diagrams for each package and on that diagram i want hyperlinks referring to the diagrams in that package.
Since the API doesn't support the creation of a hyperlink i instead create text elements and set the PDATA1 field "manually". This is the point where i have the issue: Since my test model has about 700 elements to create i need to manually change the PDATA1 field manually about 700 times, too.
I use the OleDbConnection for communication with the repository and run the command for setting the PDATA1 field in an using(OleDbConnection .....){//command etc.} block. I think we all agree that opening the connection every time an element needs to be changed is nonsense - and by the way: this way has a long execution time for that test model - , so i changed my Add-In and opened the connection once at the beginning of the element creation and closed it at the end. But then there is only one element changed to an hyperlink.
Does anyone of you has any ideas why this is? I hand over the connection to the respective methods where i need to and i also tried it with "ref", but this didn't changed anything. I scratched my head upon this for about 15 hours and i have no clue.
I hope anyone of you won't tell me, that there is no other way than opening the connection each time an element is changed.

Thanks in advance
Andreas

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: C# Add-In problem with connection to EA-Reposi
« Reply #1 on: April 10, 2012, 11:01:23 pm »
Andreas,

You just need to use Repository.Execute(SQLUpdateString)

Geert

AndreasBaur

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: C# Add-In problem with connection to EA-Reposi
« Reply #2 on: April 10, 2012, 11:09:18 pm »
Thank you Geert for your quick answer.
Did this require anything else, or is it really so simple?

(Sometimes i doubt upon the easy way ;-), like ockham's razor)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: C# Add-In problem with connection to EA-Reposi
« Reply #3 on: April 10, 2012, 11:14:38 pm »
It is in fact that simple to execute an sql update string to the database.

Geert