Book a Demo

Author Topic: Diagram.Islocked -> what does it return  (Read 3129 times)

pal.kovacs

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Diagram.Islocked -> what does it return
« on: April 08, 2013, 09:35:30 pm »
Hello All,

I'm trying to automate some tasks in EA, and to prevent access issues, I want to check if the elements/packages/diagrams that I want to modify are in editable status.

My problem is that the Diagram IsLocked attribute always gives 'false', no matter if the diagram is
- not locked
- locked by me
- locked by someone else

So it seems I'm missing something here or this can be a bug. Has anyone a suggestion how to check if I can modify a diagram?

(I tried it with EA 9.2.920 and 10.0.1006, the 'Require User Lock to Edit' setting is turned on)

thanks,
Pal Kovacs



Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram.Islocked -> what does it return
« Reply #1 on: April 08, 2013, 10:08:14 pm »
Pal,

I think the isLocked property refers to another feature that is not available  when using the security option:
From the help file:
Quote
Lock Diagram
 Lock a diagram to protect it from inadvertent changes.

This does not apply if security is enabled in the Corporate, Business and Software Engineering, Systems Engineering and Ultimate editions, in which case you lock the model elements.
My implementation looks like this:

Code: [Select]
       /// <summary>
        /// returns true if locked
        /// </summary>
        /// <returns></returns>
        public bool isLocked()
        {
            return (this.getLockedUser() != string.Empty);
        }
        /// <summary>
        /// returns the name of the user currently locking the diagram
        /// </summary>
        /// <returns>the name of the user currently locking the diagram</returns>
        public string getLockedUser()
        {
            string lockedUser = string.Empty;

            string SQLQuery = @"select u.FirstName, u.Surname from t_seclocks s
                                inner join t_secuser u on s.userID = u.userID
                                where s.entityID = '" + this.wrappedDiagram.DiagramGUID + "'";
            XmlDocument result = ((EAModel)this.model).SQLQuery(SQLQuery);
            XmlNode firstNameNode = result.SelectSingleNode("//FirstName");
            XmlNode lastNameNode = result.SelectSingleNode("//Surname");
            if (firstNameNode != null && lastNameNode != null)
            {
                lockedUser = firstNameNode.InnerText + " " + lastNameNode.InnerText;
            }

            return lockedUser;
        }

 But you might not even need that. The API will happily allow you to edit any diagram, even if it's locked by another user.

Geert

pal.kovacs

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Diagram.Islocked -> what does it return
« Reply #2 on: April 08, 2013, 10:42:41 pm »
Hello Geert,

Thanks for the info/script. I'll implement it with SQLQuery then.

regards,
Pal