Book a Demo

Author Topic: Definition of User locks programmatically  (Read 5474 times)

don.camillo

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Definition of User locks programmatically
« on: July 09, 2008, 12:12:26 am »
Hello,

I would like to ask you about the way, how can I apply / release user lock programmatically. I have stored my model in the DB and my security is set to require the user lock to edit the model. I have created the addin that imports some information into the model (creates packages, diagrams, elements, etc. ). This addin works perfectly without the security option requiring locking the model. When this option is set, the addin does not work.

I assume that problem is that the newly created packages are not locked for me and therefore I am not allowed to work with them. Is there any chance that I would programmatically create the package, lock it, do something with it and release the lock at the end? I was looking for such feature in the SDK but I was not successful.

Thanks for your answers / ideas...

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Definition of User locks programmatically
« Reply #1 on: July 09, 2008, 12:33:16 am »
Hi Don,

Are you talking about version control locking? If so, take a look at the methods of the Package class and you should be fine.

If you mean diagram locks, then set the IsLocked attribute of the diagram object in question.

If you mean locking by EA Security I really don't know. This information is stored (somewhat) centrally, so perhaps it is in the registry or something.

David
No, you can't have it!

don.camillo

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Definition of User locks programmatically
« Reply #2 on: July 09, 2008, 06:24:17 pm »
Hi,
I am talking about user locks that are being applied, when the model is stored in Database ( I am using DB, not version control system – but these locks may by the same). The idea of these locks is that when you (as a user) want to edit something, you need to lock it, do what you need with it and after you finish your work, you unlock it. While the things are locked by you, the other users cannot touch them, so you avoid problems typical for concurrent access. You can do this via GUI but I need to do such thing programmatically. I know, that there is attribute isLocked for elements, but even if I modify its values, I do not get any results. What is more Package does not have the attribute isLocked, but it can be locked by the user via GUI. Therefore I think that isLocked attribute is not solution for this problem.
DC

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Definition of User locks programmatically
« Reply #3 on: July 09, 2008, 06:56:28 pm »
I think I get the picture now. [You were clear the first time, but I somehow excluded this possibility.]

Set or clear the Locked attribute of the element in question. This is a read-write attribute, so you should be able to manipulate it as you need.
No, you can't have it!

don.camillo

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Definition of User locks programmatically
« Reply #4 on: July 09, 2008, 07:29:19 pm »
I have tried to set the element’s attribute Locked to true or false but in both cases I get error message “EA_MenuClick: Element locked” after I try to call Update on such element. I suppose the problem is that when I want add something to the package, I need to lock that package first. When working with GUI – unlocked package does not allow adding new elements to it. But I cannot find any attribute/method of the package that would lock it for me.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Definition of User locks programmatically
« Reply #5 on: July 09, 2008, 10:13:13 pm »
Use the Package.Element attribute to return the 'element' of the package.
No, you can't have it!

don.camillo

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Definition of User locks programmatically
« Reply #6 on: July 09, 2008, 10:46:40 pm »
It seems that the Package.Element.Locked does not lock in the way I need. Now, when I have applied the package lock, the addin falls when I try to create an element in the package (before it was able to create element, but it was not able to call update on it).
I think the problem is that there are 4 different types of locks (according the GUI - Menu: Diagram->Lock Diagram)

1 - No lock, general editing allowed
2 - Full lock, no one may edit
3 - User lock, locking user may still edit
4 - Group lock, locking group may still edit

It seems that Package.Element.Locked = true means the Full lock, where no one may edit the package. But I need the third option – user lock…

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Definition of User locks programmatically
« Reply #7 on: July 10, 2008, 12:32:13 am »
Here's a guess at a similar approach.

What about the IsProtected attribute of the Package itself (not the Package.Element)?

[edit]No, this won't work, at least not yet. It seems this is being worked on.

See below.[/edit]
« Last Edit: July 10, 2008, 01:16:27 pm by Midnight »
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Definition of User locks programmatically
« Reply #8 on: July 10, 2008, 08:21:36 am »
The current version of EA doesn't include the ability to set user or group locks through the automation interface.  This is currently being worked on.

don.camillo

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Definition of User locks programmatically
« Reply #9 on: July 10, 2008, 06:05:01 pm »
Thanks for trying and for info...