Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Pedro

Pages: [1]
1
General Board / Performance and scalability issues multi-country
« on: May 07, 2013, 01:06:05 am »
Hello,

I'm facing a new issue regarding EA performance over a database storage.

My company has two teams, one in Europe and another in USA. We have a single database (Postgres) storage, which is located in Europe. The USA team are facing HUGE lag when trying to access the elements in their EA (which is connected to the database in EU). Ping and speedtests show that the network should not be a problem here, since RTT is usually 135 ms, 200 maximum.

I would like some suggestions in what to explore here. What could the problems, and possible actions, be?

We thought about replicating our Postgress. However, a lazy sync strategy would imply in loss of integrity, and some different teams  work on the same element sometimes. Using a eager syncronization strategy I'm afraid I came back to the original problem.

Maybe the problem is the Postgres itself? Or maybe EA is not handling well the locks? The team are right now 15/5 (EU/USA) but should achieve 50/30 in no more than two quarters.

Any help is appreciated.

Best,

Pedro

2
Hello,

I have a Package hierarchy in a given model. I'm trying to use the p.FindObject(dottedID) method to get a reference for a desired package in that hierarchy.

I'm obtaining the dotted IDs directly from EA by right click -> copy reference -> copy Node path to clipboard.

Every time I got the same error: Can't find matching object.

Please, advise. My current code:

 
Code: [Select]
Repository r = new Repository();
            r.OpenFile(projectPath);

            foreach (Package m in r.Models)
            {
                foreach (var name in packageList)
                {
                    var a = m.FindObject(name);
}
}

3
Hello,

I'm currently using the RunHTMLReport method of Repository object to automatize the report generation.

The reports, however, are not loading in any web browser. I have enable JavaScript in all of them, but I only get a "Loading..." message and nothing more.

Thus, I tried to export the HTML report directly from EA (shift + F8). And, surprisingly, the result was the same.

In the javascript console from Chrome, I have the following message: Uncaught TypeError: Cannot read property 'length' of null . It appears to happen in the following method:

Code: [Select]
function changeCSS(theClass, element, value, target)
{
      var cssRules;
      target = eval(target + '.document.styleSheets');

      if (browser == 'ie6' || browser == 'ie7')
      {
            cssRules = 'rules';
      } else if (browser == 'ff' || browser == 'op')
      {
            cssRules = 'cssRules';
      }

      for (var S = 0; S < target.length; S++)
      {
            for (var R = 0; R < target[S][cssRules].length; R++)
//Uncaught TypeError: Cannot read property 'length' of null
            {
                  if (target[S][cssRules][R].selectorText == theClass)
                  {
                        try
                        {
                              target[S][cssRules][R].style[element] = value;
                        }
                        catch (e)
                        {
                        }
                  }
            }
      }
}

What can I do about it? I'm generating the report with the following method call:

Code: [Select]
r.GetProjectInterface().RunHTMLReport(r.GetProjectInterface().GUIDtoXML(modelGuid), outputPath, imageFormat, "<default>", ".html");

4
Hello guys,

The add-in project (C#) I'm working on is getting bigger, and it claims for some refactoring. One of the mean issues appointed by the developers is the amount of methods to handle EA functions with regards to their Objects.

I explain: right now, in our code, there are a lot of methods in the CreateX(Y _y, string name, string stereotype). For example:

Code: [Select]
CreateDiagram(Package p, bla, bla);
CreatePackage(Package p, bla, bla);
CreateElement(Package p, bla, bla);
CreateElement(Element e, bla, bla);

I call your attention for the numerous combinations possible, which turns to be impractical to handle... All those methods are static and have more or less the same shape:

Code: [Select]
CreatePackage(Package p, bla, bla){
var p = (Package)null;
           try
            {
                p = inThis.Packages.GetByName(createThis);
            }
            catch
            {
                // inThis does not contain createThis
            }

            if (p == null)
            {
                p = inThis.Packages.AddNew(createThis, withThisType);
            }

            p.Update();
            inThis.Packages.Refresh();
            inThis.Update();
}

When we decided to do something about, we got stopped just in the begging. Some ideas were to Build a static class (say "EAHelper" with public, static methods (say Create *). But this approach simply does not work from the begging. We thought about using generics, something like:

Code: [Select]
public static void Create<T> (T obj, string name, string type){ }
But this won't work because a object T won't have a "Packages" or "Elements" list.

In summary, I'm asking for assistance in order to code a proper class to handle this EA packages, elements, objects, etc from the inside the c# code nicely. If something like this already exist, great! Please, advise. If not, I will do my best to make it as generic and public as possible, since it is very hard to find good programming material for EA.

Thanks in advance,

Pedro Dusso

5
It worked like a charm, amazing! Thank you very q!

6
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

7
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!

8
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

9
Just to keep in the same thread: it is possible to change the size of the hyperlink from the code? They are too wide, like:

"[This is may hyperlink                                               ]"

And then, in the end, they seem not well positioned since the arrows point to the middle.

I just see position properties when creating the diagram object...

Best,

Dusso

10
Thanks for all the feedback! It is working as I wish now, but I'm not using the Repository.Execute. For the record, I'm doing the following:

Create the element which will be the hyperlink:
Code: [Select]
hyperlink = (Element)package.Elements.AddNew("$inet://" + usNotelinkAddress, "Text");
 hyperlink.Subtype = 19;
 hyperlink.Alias = "To US in Rally";
 hyperlink.Name = "$inet://" + usNotelinkAddress;
 hyperlink.Update();
 package.Update();

I call attention for the subtype 19. It is what the difference in the end. Unfortunately, it is not documented in the Sparx (terrible) documentation. Also, the  "$inet://" string makes the hyperlink to open inside EA owns "web browser", which is what I want. If you do not add it, the hyperlink will open in your default browser.

Create the Diagram Object in the diagram and link the hyperlink element created before to it:
Code: [Select]
DiagramObject diaObject = (DiagramObject)rootDiagram.DiagramObjects.AddNew(position, "");
 rootDiagram.Update();
 diaObject.ElementID = hyperlink.ElementID;
 diaObject.Style = "DUID=6CDA3456;HideIcon=1;";
 diaObject.Update();
 package.Elements.Refresh();

Set the Style was necessary for me, since I do not want the hyperlink icon appearing. But I have no idea what the DUID is about :P

Last step, we need to make a connector.
Code: [Select]
Connector con = (Connector)element.Connectors.AddNew("", "NoteLink");
con.SupplierID = hyperlink.ElementID;
con.Update();
element.Connectors.Refresh();

My connector has my element as origin and my hyperlink as destination; you can switch that by creating the connector in the hyperlink element and setting the SupplierID property with your element ID. I believe makes no difference, but all I know is that I know nothing...

Thanks again for the help!

11
Quote
It might be necessary to set PDATA3 to 0 as well.

I understood the relation between the MiscData and PDATA; MiscData is how you access the PDATA properties. But I'm struggling in this part. The MiscData property is readonly. If I am creating a new text element, how to set them?

Sorry for the broken link, but was just a print from a element connected to a hyperlink, precisely.

Best,

Pedro

12
God, I really did not understand you answer. Maybe I wasn't clear:



This is what I want to achieve. Currently, I am trying by using this code:

Code: [Select]
private static void AddTextElementToDiagram(Package package, Element element, int fatherIdInTheDiagram,string usNotelinkAddress, Diagram rootDiagram)
        {
            Element elemHyperlink = null;
            try
            {
                
                elemHyperlink = (Element)package.Elements.AddNew("$inet://" + usNotelinkAddress, "Text");
                elemHyperlink.StyleEx = "DUID=6CDA3456;HideIcon=1;";
                elemHyperlink.Notes = "To US in Rally";
                elemHyperlink.Update();
                package.Update();
            }
            catch { }
            // get the position of the Element
            DiagramObject diaObj = null;
            foreach (DiagramObject dObj in rootDiagram.DiagramObjects)
            {
                if (dObj.ElementID == fatherIdInTheDiagram)
                {
                    diaObj = dObj;
                    break;
                }
            }
            int left = diaObj.left + 2 * (diaObj.right - diaObj.left);
            int right = diaObj.right + 2 * (diaObj.right - diaObj.left);

            string position = String.Format("l={0};r={1};t={2};b={3};", left, right, diaObj.top, diaObj.bottom);
            DiagramObject diaObject = (DiagramObject)rootDiagram.DiagramObjects.AddNew(position, "");
            rootDiagram.Update();
            diaObject.ElementID = elemHyperlink.ElementID;
            diaObject.Update();
            package.Elements.Refresh();
            // make a connector
            Connector con = (Connector)element.Connectors.AddNew("test", "NoteLink");
            con.SupplierID = elemHyperlink.ElementID;
            con.Update();
            element.Connectors.Refresh();

Which results in a single Text, without the link.

Please, can you be a little more clear?

13
As in this similar question (http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1373547380), this also seems pretty easy, but I cannot do it...

Suppose I have a Diagram wlog with one element. I would like to create a Hyperlink and connect this Hyperlink with the element with a NoteLink. The Hyperlink would of Type == 'Web Site', and also have the Hide Icon option checked.

When I try this:

Code: [Select]
try
            {
                elemHyperlink = (Element)package.Elements.AddNew("test", "Hyperlink");
                elemHyperlink.Update();
                package.Update();
            }
            catch { }

I receive a exception saying that the type Hyperlink does not exist. I believe the logic for adding it is pretty similar to the linked question.

What I also tried was to add a Hyperlink in a eap project with a diagram and navigate through the DiagramObjects. This did not help very much.   I figured out this property Style = "DUID=6CDA3456;HideIcon=1;", but that all.

Thank you

14
Automation Interface, Add-Ins and Tools / Create a composite diagram
« on: June 25, 2013, 12:41:30 am »
I have the following code, which works creating a diagram:

Code: [Select]
 private static void CreateDiagram(string _name, Package _root)
        {
            var tmp = (Diagram)null;

            try
            {
                tmp = _root.Diagrams.GetByName(_name);
            }
            catch
            {
            }

            if (tmp == null)
            {
                tmp = _root.Diagrams.AddNew(_name, "Component");

                tmp.HighlightImports = false;
                tmp.Update();

                _root.Diagrams.Refresh();

                _root.Update();
                _root.Diagrams.Refresh();
            }

            ///The diagram already exists, and we do not create it. (Empty else)
        }

HOW can I make it composite? Please, this is extreme easy in the in EA but looks impossible for me in my addin code.

15
Hello,

I have a multiproject add-in solution. Also, I have a setup Wix project, which I use to install my addin.

I wanted to log the execution of my add-in, and so I've  chosen log4net. After researching in how to log libraries with it, I deployed a version which used a configuration file. It did not worked. Then, I created a second version which loads programmaticaly https://logging.apache.org/log4net/release/manual/configuration.html my configuration to then start logging. It also did not worked.

Finally, I coded my addin to just create a simple file using StreamWriter and the files are not being created, but without any error or message. I started thinking that this may be a permission issue, and I granted full permissions for trusted installers, my user, everyone, without success.

I appreciate any help. How do you usually deploy your add-ins? And how do you log then, if you do? I can give more code details if needed.

Best,

Pedro

Pages: [1]