Author Topic: Generating daily HTML report of entire repository  (Read 16225 times)

rmonangi

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Generating daily HTML report of entire repository
« on: December 27, 2012, 10:00:29 am »
How can we automate the publishing of models stored in the EA Sparx repository as HTML pages to an internal web server on a daily basis (so that non Sparx users can access the models from a browser)?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #1 on: December 27, 2012, 12:06:31 pm »
Create a task in the Windows Scheduler running a script that creates an instance of EA, connects to the model and runs a HTML report.

The main tricks are ensuring that the user you run on has permission to create COM objects and has a license for EA set up.

rmonangi

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #2 on: December 27, 2012, 12:16:52 pm »
Are there any sample/example script you can share that can be used as a starting point?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #3 on: December 28, 2012, 08:24:31 am »
There are code samples in the EA directory.
There are (a couple of) samples in the help.
A number of people have provided samples on the community site.

PartenaJH

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #4 on: December 28, 2012, 07:43:02 pm »
I am currently working on the same topic for my project: we would like to have a nightly HTML generation.

Unfortunately, even though I was searching for "RunHTMLReport"
- I don't find any explanation / examples on the forum neither in the EA Help
- I don't find any related code in the EA installation directory

I do found a little piece of code while searching the net: http://stackoverflow.com/questions/221654/how-to-automate-the-generation-of-html-output-in-enterprise-architect

Hence I was able to create this little script, but I am stuck on the PackageGUID (as now it renders an almost empty webpage and no XML files with content are in the directories). I found the used ID string in the XMI export...
Even using a local file on my C drive does not give me more, so may be the SQL connection string is not correct either as I was not able to test this yet...
FYI, we created a web style template "value chain" as well (4th parameter of the function).

Code: [Select]
import org.sparx.Repository;

public class valuecircle2html {
  public static void main(String[] args) {
     org.sparx.Repository r = new org.sparx.Repository();

     r.OpenFile("SparxEa --- DBType=1;Connect=Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SparxEa;Data Source=SS-BXL-DBSQL10");
     r.GetProjectInterface().RunHTMLReport("<packagedElement xmi:type=\"uml:Package\" xmi:id=\"EAPK_3C05F74F_D0A2_4a18_A38B_A32E95896923\" name=\"Value Circle\" visibility=\"public\">", "C:\\Users\\usjolb\\Desktop\\export", "PNG", "Value Circle", ".htm");
     r.CloseFile();
  }
}

Please help!  :-/ :'(

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Generating daily HTML report of entire reposit
« Reply #5 on: December 31, 2012, 05:46:38 pm »
No, that packageGUID format is definitely wrong.

What you should do is first use the repository object to get the package you want to report on.
If it is one of the root packages then you can use Repository.Models to select the one you need.

Once you have the package object you get its GUID using Package.PackageGUID.

Now in most cases that is the one you need, except when using the project interface. Then you need the GUID in xml format.
To convert a regular GUID into an xml-GUID you can use Project Interface.GUIDtoXML()

Geert

Stoppy

  • EA User
  • **
  • Posts: 115
  • Karma: +0/-0
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #6 on: January 11, 2013, 04:01:56 pm »
Hi rmonangi,

I posted this a while back http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1351579060/2#2 with limited response.

So had to teach myself VB and how to build exe's and got a little help from a mate. Here is my code set in VB

=============================================
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.IO
Imports System.Threading
Imports System.Configuration
Imports System.Diagnostics
Imports EA


Module Module1

    Sub Main()
        ShowRepository()
    End Sub

    Public Sub ShowRepository()

        Dim EA As New EA.Repository
        Dim SQL As String
        SQL = "Insert Your SQL String"
        EA.OpenFile(SQL)
        EA.GetProjectInterface().RunHTMLReport(PackageGUID:="{Insert Your GUID - Make Sure you have the brackets}", ImageFormat:="PNG", ExportPath:="Your Path", Style:="<default>", Extension:=".htm")
        EA.Exit()

    End Sub

End Module

=============================================

As simon mention a EA key needs to be assigned to the User and they need a SQL DB account set up too.

I have the exe running on a schedule task but the user has to be logged on, but I might look into the post from Simon to see I can get it to run without being logged on.

Hope this helps

Stoppy  ;)
Skills: Business Process | Business Analysts | Product Configuration Manager | Business Intelligence

PartenaJH

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #7 on: January 11, 2013, 10:29:47 pm »
Just FYI, this is how we did it here (I only have some Java knowledge from yeeeeeaaars ago at school, but it does the trick :) ).

Code: [Select]
import org.sparx.*;

public class valuecircle2html {
  public static void main(String[] args) {
      org.sparx.Repository       repo             =       new org.sparx.Repository();
      org.sparx.Package      corporate      =      null;
      org.sparx.Package      bpm            =      null;
      org.sparx.Package      bpm_vc            =      null;
      org.sparx.Package      vc            =      null;
      org.sparx.Package      pack             =       null;

// Connect to database
      
      String conn      = "SparxEa --- DBType=1;Connect=Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SparxEa;Data Source=SS-BXL-DBSQL10";

      repo.OpenFile(conn);

// Browse through structure

      corporate       = repo.GetModels().GetByName("Corporate");
      bpm             = corporate.GetPackages().GetByName("BPM");
      bpm_vc             = bpm.GetPackages().GetByName("BPM Value Circle)");
      vc             = bpm_vc.GetPackages().GetByName("Value Circle");

// Generate HTML Documentation
      
      String guid      = "" + vc.GetPackageGUID() + "";
      String tmppath      = "C:\\Users\\usjolb\\Desktop\\export";
      String image      = "PNG";
      String template = "Value Circle";
      String ext      = ".htm";

      repo.GetProjectInterface().RunHTMLReport(guid, tmppath, image, template, ext);

// Close connection to database

      repo.CloseFile();
  }
}

The connection string is easy to find by right clicking the project in the popup when starting EA.

We have a few models, my required package is in the "Corporate" model, then browsing through a few package directories until you got at the one you would be right clicking on when doing it yourself.

The tmppath is just to publish this locally (afterwards I have a scheduled bat-file that runs the java program and copy pastes the HTML files to our SharePoint).

The template is a copy of the default web template with a few modifications, called "Value Circle".

Hopefully it helps you, I would have been happy to find that kind of script when I was looking for it :)

Stoppy

  • EA User
  • **
  • Posts: 115
  • Karma: +0/-0
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #8 on: January 14, 2013, 10:37:14 am »
Quote
Create a task in the Windows Scheduler running a script that creates an instance of EA, connects to the model and runs a HTML report.

The main tricks are ensuring that the user you run on has permission to create COM objects and has a license for EA set up.

Hi Simon,

We have our application running with the task scheduler, the task has to be set to logged on user and the user has to be logged onto the server at all times.

When we attempt to run the application running the task scheduler with the the user logged off, the application fails.

Do you have any suggestion or solution to this?

Stoppy
Skills: Business Process | Business Analysts | Product Configuration Manager | Business Intelligence

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #9 on: January 15, 2013, 08:49:33 am »
The two most common causes of that (as far as I know) are:

  • Windows not allowing the user the script is running as to create COM objects.
  • The user it is running as does not have a license for EA set up.

Stoppy

  • EA User
  • **
  • Posts: 115
  • Karma: +0/-0
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #10 on: January 15, 2013, 12:10:53 pm »
Hi Simon,

Thanks for the reply.

It is definately not item number 2.

I am not a techie, but if you could supply some reference documents/sites or further details for item 1 this would be appreciated.

Regards,

Stoppy
Skills: Business Process | Business Analysts | Product Configuration Manager | Business Intelligence

jdoran-anglo

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #11 on: January 25, 2013, 03:03:02 pm »
I am not sure how big your repos usually are, but the one I wanted to automate is quite big. I found that generating the HTML straight out of the DB was extremely slow. Instead I do a project transfer from DBMS to local EAP, and html the local file.

I cobbled my code together quickly borrowing snippets of code from all over the internet, so there are potentially even more improvements that could be made. (Not claiming ownership of this code, but it works which is all I cared about)

I thought I would share for the next person that could use a C# implementation.

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EA;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            EA.Repository repo = new EA.Repository();
            EA.Package package = null;

            // PARAMETERS !!!UPDATE THESE!!!
                String conn = "Enterprise_Architect --- DBType=1... etc"; //PUT WHOLE SQL STRING IN
                String username = "user";
                String password = "pass";

    
            //Transfer DBMS to EAP
                String eapfile = "C:\\Temp\\html\\model.eap";
                String eaplog = "C:\\Temp\\html\\transfer_log.log";
                repo.GetProjectInterface().ProjectTransfer(conn, eapfile, eaplog);
    
            // Browse through structure
                repo.OpenFile2(eapfile, username, password);
                package = repo.GetPackageByGuid("{HARDCODED_GUI}"); //I PUT MY NODE GUI HERE TO GET WHOLE MODEL

            // Generate HTML Documentation
                    String guid = "" + package.PackageGUID + "";
                    String tmppath = "C:\\Temp\\html";
                    String image = "PNG";
                    String template = "Feedback";
                    String ext = ".htm";

                    repo.GetProjectInterface().RunHTMLReport(guid, tmppath, image, template, ext);


            // Close connection to database
                repo.CloseFile();
        }
    }
}

« Last Edit: January 25, 2013, 03:07:21 pm by jdoran-anglo »

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #12 on: February 09, 2013, 04:37:10 am »
Is it possible using RunHTMLReport to specify a head graphic and title as you can on the html gen dialogue within Sparx itself ?

Regards,

Jon.

smendonc

  • EA User
  • **
  • Posts: 148
  • Karma: +5/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #13 on: February 09, 2013, 02:33:37 pm »
I haven't looked at this in a while, I think this is how I got it to work for the graphic. I suspect it's because it saves the image location in the registry.

I generate the website once interactively and set the 'Header Image' to point to my custom header and use my customized 'Style'.  Running the job from the scheduler after that picks up the last used graphic assuming you have set the 'Style' to your custom one.

Stan.

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Generating daily HTML report of entire reposit
« Reply #14 on: February 13, 2013, 03:47:39 am »
Tried this and it doesn't appear to work; so i've copied my gif over the ea.gif in the images folder - not the most elegant solution - but seems to work.