-2

I have a C# script performing create/update operations to EA diagrams. It's working good with EA 15. But when I run it with EA 16, it fails with the error - "No such diagram found having diagram GUID:"

Here is the details of example user case. Script is connecting with one user to EA and creating diagram. Now next time script runs and connects with another user to EA and try to update earlier created diagram.

Based on the new version 16 document, I know that it's required to be reloaded. When I try to update the same diagram from the EA UI, I get the error and it asked to reload that diagram. After reload I am able to update the diagram from the UI.

Same thing I tried from the code to reload the diagram (using Repository.ReloadDiagram (currentDiagram.DiagramID);) and then update (diagram.Update()), but still I am getting same error.

Also tried to login with 2nd user in UI and set the reload changed diagram to true from Design->Diagram->Options->auto reload changed diagram. This also does not reload the diagram and shows pop up to reload before updating entity.

Update: Here is the code snippet that I am using. It gives error on second diagram.Update() i.e. after connecting to user2 and trying to update diagram from his connection with following error "No such diagram found having diagram GUID: "

{
//connect to user1
    EAConnection connection = new EAConnection();
    connection.EARepository = new Repository();
    connection.EARepository.SuppressSecurityDialog = true;
    connection.EARepository.SuppressEADialogs = true;
    bool isOpened = connection.EARepository.OpenFile2("path", "user1", "password");
    
//update diagram with user1
    diagram = repository.GetDiagramByGuid(guid);
    repository.ReloadDiagram(diagram.DiagramID);  //reload diagram object
    //update attribute values
    diagram.Name = "xyz";
    diagram.Update();    
    

//connect to user2
    EAConnection connection = new EAConnection();
    connection.EARepository = new Repository();
    connection.EARepository.SuppressSecurityDialog = true;
    connection.EARepository.SuppressEADialogs = true;
    bool isOpened = connection.EARepository.OpenFile2("path", "user2", "password");
    
//update diagram with user2
    diagram = repository.GetDiagramByGuid(guid);
    repository.ReloadDiagram(diagram.DiagramID);  //reload diagram object
    diagram.Name = "abc";
    diagram.Update();    

}
Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
Niraj Chapla
  • 2,149
  • 1
  • 21
  • 34
  • 1
    Please add the actual code you are using. Now we can only guess what you are doing. – Geert Bellekens Oct 21 '22 at 13:31
  • @GeertBellekens, Sorry, I should have added code snippet while asking. Now I have updated the question to include the code snippet. – Niraj Chapla Oct 27 '22 at 09:33
  • You are saying you **create** a new diagram with user1, but the code only shows you getting an existing diagram from a certain guid. Also repository.ReloadDiagram doesn't affect the diagram object in any way. It will only refresh the diagram in the GUI. – Geert Bellekens Oct 27 '22 at 09:51
  • @GeertBellekens Does it even if it's not loaded (as that is not done)? – qwerty_so Oct 27 '22 at 16:21

2 Answers2

1

It looks like you have not posted the part of the code where the actual problem is.

This code is tested on version 16.1 (64 bit) and works without any problems.

namespace EA_console_app
{
    internal class Program
    {
        static void Main(string[] args)
        {
            // connect to user1
            var path = @"C:\temp\test project.qea";
            var repository =  new EA.Repository();
            repository.SuppressSecurityDialog = true;
            repository.SuppressEADialogs = true;
            var isOpened = repository.OpenFile2(path, "user1", "user1");

            var guid = "{9585B09C-28C5-485b-AF25-79F1D70EAA18}";

            //update diagram with user1
            var diagram = repository.GetDiagramByGuid(guid);
            //repository.ReloadDiagram(diagram.DiagramID);  
            diagram.name = "xyz";
            var user1Update =  diagram.Update(); 
            
            //connect to user2
            var repository2 = new EA.Repository();
            repository2.SuppressSecurityDialog = true;
            repository2.SuppressEADialogs = true;
            isOpened = repository2.OpenFile2(path, "user2", "user2");

            //update diagram with user1
            diagram = repository.GetDiagramByGuid(guid);
            //repository.ReloadDiagram(diagram.DiagramID);  
            diagram.name = "abc";
            var user2Update = diagram.Update();
        }
    }
}

You might want to check the permissions of your user1 and user2. If they don't have permission to update diagrams, the Update() operation will return false.

What I'm guessing is that you actually try to create a diagram as well (as indicated in the text, but not present in the code), but that your user1 doesn't have the permission to create diagrams. That means that the Update() for user1 fails, and doesn't create the diagram after all. That means the GetDiagramByGuid for user2 will fail.

In that case you would get error like: System.Runtime.InteropServices.COMException: 'Can't find matching ID' instead of the error you mentioned: No such diagram found having diagram GUID:

The method repository.ReloadDiagram does not do what you think it does. It will refresh the visual rendering of the diagram in the GUI, but it will not affect your diagram object in any way. Since you are not even showing the GUI this is completely useless in this context.

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
0

You are using the same GUID on two different repositories. That does not make any sense since GUIDs are designed to be different everywhere. So no wonder you don't find the diagram with the GUID from the first repo in the second.

Assuming "path" is different in both Open statements since opening the same repo as two instances would be nonsense as well.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86