Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: RichardWright 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
-
What do you want to know, if a user has applied a user lock on the diagram?
I use this:
/// <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