Book a Demo

Author Topic: How to automate the generation of HTML output  (Read 8698 times)

Pedro

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
How to automate the generation of HTML output
« on: August 22, 2013, 07:14:46 pm »
This question comes from Stackoverflow http://stackoverflow.com/questions/221654/how-to-automate-the-generation-of-html-output-in-enterprise-architect, but I though it would be better to bring it here.

I want to automate the generation of HTML reports. Since EA does no provide a command line interface, I went for the code. Here it is:

Code: [Select]
Repository r = new Repository();
 r.OpenFile(@"C:\PathTo\Model.eap");
 r.GetProjectInterface().RunHTMLReport("E9EB7335-C586-4bc2-84E8-CFAD6A856362", @"C:\Output\", "GIF", "<default>", ".html");
 r.CloseFile();

The first argument in the RunHTMLReport is a PackageGUID. What does this means? From EA it is possible to export the HTML report directly from the Model level. Anyway, I tried both. I obtained the GUID from the model (and the package) by "To obtain the GUID, right-click on the diagram, package or element in the Project Browser and select the Copy Reference context menu option.", as stated in the EA documentation.

Well, Model or package, my results are the same - a error mesage saying: "Enterprise Architect - Encountered an improper argument." and a COMException HRESULT: 0xE06D7363.

Update
I just notice the code (which is in C# by the way) is producing an output, despite the error mesage I told before - index, black and toc files and js, images, files, EARoot and css folders. However, when I try to open the index, I got this new message:

Code: [Select]
[Exception... "Access to restricted URI denied"  code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"  location: "file:///C:/Users/dusso/Documents/Visual%20Studio%202010/Projects/EARunHTMLReport/output/js/displayToc.js Line: 235"]

Thanks in advance
« Last Edit: August 22, 2013, 07:44:59 pm by pmdusso »

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: How to automate the generation of HTML output
« Reply #1 on: August 22, 2013, 08:30:09 pm »
Hello Pedro,

I think you have to convert the GUID to XMLguid.

Code: [Select]
GUIDxml = GetProjectInterface().GUIDtoXML(selectedPackage.PackageGUID)

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: How to automate the generation of HTML output
« Reply #2 on: August 22, 2013, 08:45:19 pm »
Hello Pedro,

a working VB script snippet. Make sure that the target folder exists.
Code: [Select]
     if not selected is nothing AND selectedPackage.ObjectType = otPackage then
        Dim GUIDxml
        Dim s
      GUIDxml = GetProjectInterface().GUIDtoXML(selectedPackage.PackageGUID)
        s = GetProjectInterface().RunHTMLReport(GUIDxml, path, ".PNG", "<default>", ".html")
          exit sub
      end if

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Pedro

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: How to automate the generation of HTML output
« Reply #3 on: August 22, 2013, 11:32:24 pm »
Oh, thanks very much for the reply. It worked. But the point is, it worked because the property *.PackageGUID return the GUID WITH "{}" arount it, and I was giving the arg only with the letters and the numbers...

Thanks very much!

Pedro

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: How to automate the generation of HTML output
« Reply #4 on: August 26, 2013, 09:50:08 pm »
One related questions: is it possible to consume a database repository? (Instead a *.eap file as I am doing)

In ideal case, something like:
Code: [Select]
Repository r = new Repository();

r.OpenDatabase("path-to-db-repository");
...

I'm still quering the API, but though it would be better to ask here also.

Thanks

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to automate the generation of HTML output
« Reply #5 on: August 26, 2013, 10:01:16 pm »
The filename can be

Quote
A connection string: This will try to connect to the according RDBMS to open the repository. A valid connection string can be obtained from the Open Project dialog via context Edit Connection String for any stored recent repository.
From my Scripting book.

q.

Pedro

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: How to automate the generation of HTML output
« Reply #6 on: August 27, 2013, 06:32:45 pm »
It worked like a charm, amazing! Thank you very q!