Topic
  • 3 replies
  • Latest Post - ‏2014-08-01T18:14:58Z by BeastBoysDad
Atomic007
Atomic007
2 Posts

Pinned topic Find out who has lock for sections in shareable edit mode?

‏2012-07-13T17:54:21Z |
I wrote a simple Layout DXL that basically shows me the locked state of every object in shareable edit mode. However its a bit limited. I know if things are locked, and I know if the current user has a lock.
Does anyone know of a way to find out who has a lock if canLock() fails?

e.g.

pragma encoding, "UTF-8"

// See if we can lock the object, if we can then it is unlocked
if (canLock(obj)) then
{
display("Unlocked")
}
else
{
// See if we have the lock or someone else has it.
if (isLockedByUser(obj)) then
{
string Me = doorsname()
display("Locked by " Me)
}
else
{
display("Locked")
}
}

So instead of printing Locked in the last else, I would like,

string LockedBy = doorsLockedByUser???
display("Locked by " LockedBy)

  • Tom
Updated on 2012-07-30T19:37:09Z at 2012-07-30T19:37:09Z by llandale
  • Atomic007
    Atomic007
    2 Posts

    Re: Find out who has lock for sections in shareable edit mode?

    ‏2012-07-30T18:33:09Z  
    Anyone? I guess it can't be done?

    I know Doors knows who has the lock if you click a locked item, just wish it was exposed in DXL.
  • llandale
    llandale
    3035 Posts

    Re: Find out who has lock for sections in shareable edit mode?

    ‏2012-07-30T19:37:09Z  

    Here is some unfinished work I did a few years ago. I have a nagging memory that you could not find out if someone else ALSO had the module open Shared.

    string LockModes[] = {"0-lockRemoved", "1-lockShare", "2-lockWrite"}
     
     
    string    BuildLockInfo(Lock lck)
    {     // build a string summarizing the lock
            Item    itm      = lck.item
            string  NameFull         = fullName(itm)
            string  UserLock     = lck.user
            string  ResourceLock = lck.resourceName
            string  Computer         = lck.host
            int     ProcessID        = lck.connectionId
            string          ID               = lck.id
            int     Mode             = lck.lockMode
            Date    DateLock     = lck.date
            
            return("User: " UserLock " \t" Computer " \t'" ResourceLock "'("NameFull ") \t" LockModes[Mode] " \t" ProcessID "\t" DateLock "")
    }     // end BuildLockInfo()
     
     
            Lock    lockItem
            string  UserLock, ResourceLock, ErrMess
            LockList        llist = getLocksInFolder(folder ("/"), true, true)
            for lockItem in llist do
            {  print BuildLockInfo(lockItem) "\n"
            }
            delete(llist)
    


    and...

     

    void    PrintLocksInModule(ModName_ mn)
    {
            LockList        lcklst = getLocksInModule(mn,false)
            Lock    lck
            string  s, NameUser, lt, scnResTemp = ""
            int     i
            User    usr
            print "before loop\n"
            for lck in lcklst do
            { 
               print "in loop\n"
               s = lck.user
               i = lck.lockMode
               if     (i == lockShare)      lt = "Shareable"
               elseif (i == lockWrite)      lt = "Exclusive"
               elseif (i == lockRemoved)    lt = "Removed"
               else                         lt = "Bad LockMode Found: [" i "]"
               if (existsUser(s))
               {
                  usr = find(s)
                  NameUser = usr.fullName
                  if (NameUser == null)
                       NameUser = "No FullName"
               }
               scnResTemp = scnResTemp s "\t\t" NameUser "\t\t\t" lt "\n"
            }
            print "[" scnResTemp "]\n"
    }    // end PrintLocksInModule()
     
    Module  mCurr = current
    ModName_        mn = module(fullName(mCurr))
     
    PrintLocksInModule(mn)
    


    -Louie

     

    Updated on 2014-01-09T14:34:59Z at 2014-01-09T14:34:59Z by iron-man
  • BeastBoysDad
    BeastBoysDad
    19 Posts

    Re: Find out who has lock for sections in shareable edit mode?

    ‏2014-08-01T18:14:58Z  

    Try this:

     

    Object curObj = current
    string lockErrorMsg = lock (curObj)
    if (!null lockErrorMsg) print lockErrorMsg "\n"
    else print "Lock succeeded\n"

     

    I obtained the following successive results:

     

    Item /My_Project/My_Formal_Module locked (unshared) by Jane Doe@computerName1 at 08/01/14 10:25:02
    Lock succeeded
    section already locked
    Item /My_Project/My_Formal_Module locked (unshared) by John Smith@computerName2 at 08/01/14 11:03:59
    Updated on 2014-08-01T18:16:21Z at 2014-08-01T18:16:21Z by BeastBoysDad