Author Topic: Is it possible to get, which user locked element?  (Read 3263 times)

vladimir.liba

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Is it possible to get, which user locked element?
« on: April 25, 2014, 12:37:34 am »
In the EA.Element class there is boolean atrribute Locked, which identifies some user has locked the element. How is it possible to check in code, who locked the element?

Also, the method ApplyUserLock() just returns true/false, but no identification, who locked the element.

Thanks for hints.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Is it possible to get, which user locked eleme
« Reply #1 on: April 25, 2014, 09:57:29 am »
You can find that out with a query. I'm off-site atm but will post tomorrow if nobody else was faster :)

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Is it possible to get, which user locked eleme
« Reply #2 on: April 25, 2014, 03:23:36 pm »
Here's what I use
Code: [Select]
/// <summary>
/// returns the name of the user currently locking this element
/// </summary>
/// <returns>the name of the user currently locking this element</returns>
public override string getLockedUser()
{
      string lockedUser = string.Empty;
      //if (this.wrappedElement.Locked)
      //{
            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.wrappedElement.ElementGUID + "'";
            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;
}

This works on SQL Server. I haven't tested it on other backends.

Geert
« Last Edit: April 25, 2014, 03:24:29 pm by Geert.Bellekens »