Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: kotrick on September 05, 2011, 01:50:36 pm
-
hi,
if i try to lock an object in EA through automation which is already locked by other user then i get an exception .so is there any way or api to identify whether i can lock that object or not.i.e. is there any api to identify who has locked the object
-
The only way I found was by querying the database directly.
Here's the code I use:
/// <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;
}Geert