Author Topic: Running EA in batch mode - Limitations  (Read 262 times)

adepreter

  • EA User
  • **
  • Posts: 128
  • Karma: +2/-2
    • View Profile
Running EA in batch mode - Limitations
« on: August 19, 2019, 12:58:44 am »
I need to generate HTML using an MDG loaded from my addin. And this needs to run in batch mode.
But OnInitializeTechnologies is not called when running in batch mode.
It works perfectly well when running in normal/user interface mode.

As a workaround I tried to start another instance and call RunHTMLReport() on that other instance (code below)
But RunHTMLReport() returns an error.

Did anybody encounter the same problem... and found a solution :-) ?

Thank you in advance
Alain

-------------

Process externalEaProcess = Process.Start(repositoryFileInfo.FullName)
object obj = Marshal.GetActiveObject("EA.App");
EA.App app = obj as EA.App;
Repository repo = app.Repository;
repo.GetProjectInterface().RunHTMLReport(...)
externalEaProcess.Kill();



Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6827
  • Karma: +65/-7
    • View Profile
Re: Running EA in batch mode - Limitations
« Reply #1 on: August 19, 2019, 09:11:43 am »
https://sparxsystems.com/enterprise_architect_user_guide/14.0/automation/repository3.html

AttributeRemarks
LoadAddins ()Notes: Loads all Add-Ins from a repository when Enterprise Architect is opened from automation.
Eve

support@sparxsystems.com

adepreter

  • EA User
  • **
  • Posts: 128
  • Karma: +2/-2
    • View Profile
Re: Running EA in batch mode - Limitations
« Reply #2 on: August 19, 2019, 05:20:39 pm »
Hello Eve,

Thank you very much for your quick answer.
I tried to use Repository.LoadAddins (see code below) but that does not make the OnInitializeTechnologies to be called.

To summarize:
- If I just open the repository from the Windows UI, it calls OnInitializeTechnologies properly (it has being doing this for years).
- But when a batch program opens the repository then OnInitializeTechnologies is not called, even when Repository.LoadAddins() is called after opening the repository.

What would you suggest?

------------

if (eaRepo.OpenFile(sFullPath))
{
    eaRepo.LoadAddins();
    return true;
}

smendonc

  • EA User
  • **
  • Posts: 148
  • Karma: +5/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Running EA in batch mode - Limitations
« Reply #3 on: August 20, 2019, 02:49:55 am »
Hi Alain,

I think there is a bug in your code. The first line below will cause a new instance of EA to start. In this case I think the GetActiveObject call is returning a pointer to the newly started COM object and not the Workaround instance you started interactively that should have your MDG loaded.  As a test can you remove that line and make sure there is only a single instance of EA running - the one that you started interactively.

Code: [Select]
Process externalEaProcess = Process.Start(repositoryFileInfo.FullName)
Some caveats with using GetActiveObject - it will attach to either the first or last instance of EA that has been started.  There is no way for a user to specify which instance to attach too - the behavior is OS/version/build dependent.  If you have multiple instances of EA started this call will give you all kinds of headaches.

Stan.

qwerty

  • EA Guru
  • *****
  • Posts: 10591
  • Karma: +232/-194
  • I'm no guru at all
    • View Profile
Re: Running EA in batch mode - Limitations
« Reply #4 on: August 20, 2019, 08:03:32 am »
Some caveats with using GetActiveObject - it will attach to either the first or last instance of EA that has been started.  There is no way for a user to specify which instance to attach too - the behavior is OS/version/build dependent.  If you have multiple instances of EA started this call will give you all kinds of headaches.

Stan.
True. Though, I think that most of the users have only a single instance running. Especially in an environment with shared keys. But honestly, I had been fooled by that also in the past.

q.

adepreter

  • EA User
  • **
  • Posts: 128
  • Karma: +2/-2
    • View Profile
Re: Running EA in batch mode - Limitations
« Reply #5 on: August 25, 2019, 10:42:17 pm »
Thank you very much for trying to resolve this.

However there is only one instance running. It is a command line program that start a single new instance using that line "Process externalEaProcess = Process.Start(repositoryFileInfo.FullName)".

So it cannot get the wrong instance since there is only one.

Thank you anyway,
Alain