Book a Demo

Author Topic: Package and Element Locking  (Read 5274 times)

georgie

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Package and Element Locking
« on: January 14, 2012, 04:25:10 am »
Hello

We are working on a project with security set to Require User Lock To Edit.

I want to manipulate packages and elements via the Automation Interface from a VB.NET program. As far as I understood, a user lock has to be applied to an element (.ApplyUserLock) before it can be edited and updated (.Update). Same would apply to a package before a child package or element can be added or deleted.

When I try to .ApplyUserLock to a package that is already locked by another user, the EA server throws an exception. I cannot avoid this because I'm unable to check if the package is locked and by whom.

An element can be tested for being locked, but no user information is available.

I should say that we are still using EA 9.1.

How can I come out of this dilemma?

Is there documentation where I can find more information on the EA object model(s)?

Help is very much appreciated.
« Last Edit: January 14, 2012, 04:48:10 am by georg.tsamis »
Greetings from Vienna & Servus,
georgie

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Package and Element Locking
« Reply #1 on: January 14, 2012, 08:49:50 am »
Hack: check the contents of the table t_seclocks prior to your operation. It will reveal which user has a lock.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Package and Element Locking
« Reply #2 on: January 16, 2012, 08:04:27 pm »
Here's my code for getting the locked user, islocked() and isReadOnly()

      
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;
        }
Code: [Select]
       /// <summary>
        /// returns true if currently locked
        /// </summary>
        /// <returns>true if currently locked</returns>
        public override bool isLocked()
        {
            return (this.getLockedUser() != string.Empty);
        }
Code: [Select]
       /// <summary>
        /// returns true if this element is readonly
        /// </summary>
        /// <returns>true if this element is readonly</returns>
        public override bool isReadOnly()
        {
            if (this.isLocked())
            {
                string SQLQuery = @"select s.UserID from t_seclocks s
                                    where s.entityID = '" + this.wrappedElement.ElementGUID + "'";
                XmlDocument result = ((EAModel)this.model).SQLQuery(SQLQuery);
                XmlNode userIDNode = result.SelectSingleNode("//UserID");
                if (userIDNode.InnerText.Equals(((EAModel)this.model).getWrappedModel().GetCurrentLoginUser(true), StringComparison.InvariantCultureIgnoreCase))
                    return false;
            }
            //else
            return true;
        }

Geert

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Package and Element Locking
« Reply #3 on: January 17, 2012, 04:32:58 am »
Have you tried just running your vb.net code ? I've noticed that when i'm adding updating requirments (and other elements) in a package (or creating new sub packages) that is locked by another user via the automation interface all is ok ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Package and Element Locking
« Reply #4 on: January 17, 2012, 04:42:40 am »
I think it works when adding things to a locked element or package, but not when trying to update() the element/package that is locked.

Geert