Book a Demo

Author Topic: Locked diagram not detectable with VB script  (Read 3405 times)

RichardWright

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Locked diagram not detectable with VB script
« on: September 16, 2014, 11:30:41 pm »
How can I detect if an object is locked. It looks like it works for elements using

dim currentElement as EA.Element
if (currentElement.Locked) Then


For diagrams it does not work as for
dim currentElement as EA.Diagram
if (currentElement.IsLocked) Then


Any suggestions?

I am using EA 11, Thx

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Locked diagram not detectable with VB script
« Reply #1 on: September 16, 2014, 11:44:54 pm »
What do you want to know, if a user has applied a user lock on the diagram?
I use 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;
}

Geert