Book a Demo

Author Topic: Internal Error while using AddNew  (Read 5657 times)

ALL_IN_ONE

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Internal Error while using AddNew
« on: March 04, 2010, 10:07:48 pm »
Hello all,

I ma trying to Add a new element under a element. but I get a error as "Internal Error". This is done on the server database. But If I try to use the same on a local database (i.e. eap file) then it works fine.
Please find the code snippet below.


EA.Element parentElement =Repository.GetElementByID(_elementID);
_elemType = "Class";
_elemName = "Test";
EA.Element _newElement = null;
_newElement = (EA.Element)parentElement.Elements.AddNew(_elemName, _elemType);

Regards.

ALL_IN_ONE

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Internal Error while using AddNew
« Reply #1 on: March 04, 2010, 10:19:01 pm »
I would like to further inform you that I am using 7.5.847 version of EA

regards

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Internal Error while using AddNew
« Reply #2 on: March 04, 2010, 10:46:05 pm »
Do you get the error when retrieving the parent element, or when adding the new element?

Have you tried on 7.5.850 or 8.0 (beta2)?

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Internal Error while using AddNew
« Reply #3 on: March 04, 2010, 10:46:42 pm »
Ah, and check the dbError.txt in the application folder.

Geert

ALL_IN_ONE

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Internal Error while using AddNew
« Reply #4 on: March 05, 2010, 04:42:54 pm »
Hello Geert,

1) The error occurs at line while adding a new element i.e.
at the below statement.
_newElement = (EA.Element)parentElement.Elements.AddNew(_elemName, _elemType);
I suspect it to be the lock issue. But I am getting mad in debugging the issue.
While debugging I found that the "parentElement.Locked" does not provide the right information.Even if my parent element is locked, the statement "parentElement.Locked" says its False. Can any body explain me the functionality of "elem.Locked". I can add elements under package but am facing issue with adding element under element on a security enabled project.

2) I also checked in DBError.txt but its empty. It does not give me any DAO.Recordeset error no. But I have put a try catch statement arround the "AddNew" statement. The error it catches is simply "Internal Error"

3) I have tried it on 7.5.849 and its the same issue.


Can any body help me in the above problem? I have seen in the past forum topics where users faced issue in EA 6.5, but that forum topic didnt help much.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Internal Error while using AddNew
« Reply #5 on: March 05, 2010, 07:33:19 pm »
I've encountered a similar issue (crash, not error message) when trying to lock an element that was locked by another user.
The bizarre thing was that EA only crashed the second time I tried, never the first time.

Indeed, the "locked" attribute doesn't really help.
What I did to figure out if an element is readonly is to call update() in a try-catch block. If EA throws an error the element is not writeable.

My (safe) operation to lock an element (and make it writeable) is as follows:
Code: [Select]
      /// <summary>
        /// locks the element by the current user
        /// </summary>
        /// <returns>true if successful</returns>
        public override bool enableWrite()
        {
            //because of some nasty bug in EA the application will crash if the element is already locked
            // by another user.
            // therefore we check first if this element is locked before even trying.
            string SQLQuery = "select s.entityID from t_seclocks s where s.entityID = '" + this.wrappedElement.ElementGUID + "'";
            XmlDocument result = ((EAModel)this.model).SQLQuery(SQLQuery);
            XmlNode lockNode = result.SelectSingleNode("//entityID");
            if (lockNode == null)
            {
                //no lock found, go ahead and try to lock the element
                try
                {
                    return this.wrappedElement.ApplyUserLock();
                }
                catch (Exception)
                {
                    return false;
                }
            }
            else  
            {
                //lock found, don't even try it.
                return false;
            }
        }

I'm not sure if this related to your issue, but it is possible.

Geert

ALL_IN_ONE

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Internal Error while using AddNew
« Reply #6 on: March 20, 2010, 08:13:37 pm »
Dear folks,

I am still facing with the problem of AddNew elements under a element.

@Geert : your reply was valuable but did'nt solve my problem. I tried your code but it will only identify whether the element is locked or not. Thus I always lock the element and package through automation before adding any elements. Thus the code pasted by you will definitely indicate that the element is locked. As the element is locked by myself.

Strange thing is that some ocassions I am able to add new element under a element. For eg I have two elements "x_interface" and "y_interface". The addin developed by me does adding of class elements, operations and attributes under interface elements.

Thus what I notice is that the tool is able to add new items (elements, operations,attributes ) under "x_interface" but not on "y_interface".

Does any body have any idea why is this so?

Regards.