Book a Demo

Author Topic: Script check userlock  (Read 3985 times)

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Script check userlock
« on: October 25, 2012, 08:56:34 pm »
Hi,

At the start of a (J)Script I want to check if there is a User Lock applied to the project.

Is there a way to do that ?

thanks in advance

gr

Danny
Reg.

Danny

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Script check userlock
« Reply #1 on: October 25, 2012, 10:03:29 pm »
bool Locked — Indicates if the element has been locked against further change. This attribute is only evaluated set when security is enabled.

Property of EAElement.

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: Script check userlock
« Reply #2 on: October 25, 2012, 10:28:13 pm »
Code: [Select]
Repository.SQLQuery("select * from t_seclocks")will return all locks for the project.

Geert

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: Script check userlock
« Reply #3 on: October 25, 2012, 10:29:49 pm »
Thanks - that's what I thought ..... however  :'(

This is on a MySQL repository
The element is the root package

when I navigate to Project/security/manage my locks  it states :
Type : Element
Name : myProject
User : me
timestamp : .....

when I run the script :
      project = Repository.GetTreeSelectedObject();
      Session.Output("project name " +project.Name);      
        Session.Output("project locked ? "+project.Locked);
      Session.Output("project element locked ?  "+project.Element.Locked);

it returns
project name myProject      
project locked ? undefined      
testscript: Object required, Line:41      

 :question

thanks


Reg.

Danny

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Script check userlock
« Reply #4 on: October 25, 2012, 10:34:02 pm »
The root package is a bit an exception because there's only a EA.Package and no EA.Element.

Check this post for an extensive explanation of how I handle locks in my add-ins:
http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1326475510/2#2

Geert



Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: Script check userlock
« Reply #5 on: October 25, 2012, 10:47:35 pm »
Thanks Geert

Success via SQLQuery

I guess there will be no excaping SQLQuery and a sound knowledge of the EA tables  ::)
I better dive into it  8-)

gr

Danny
Reg.

Danny