You are viewing limited content. For full access, please sign in.

Question

Question

SDK Release Lock

SDK
asked on June 26, 2014

Hi,

 

Trying to build a gui interface that allows me to release an entry lock(I know that this function already exists in the admin console but need another gui interface for our business).

 

How do I release a lock without locking it first? When ever I try to unlock the entry using:

 

lockeditemA.UnlockObject()

 

I get the error that  I need to first lock it, but I can't because it is already stuck in a locked state.

 

0 0

Answer

SELECTED ANSWER
replied on July 2, 2014

Here is sample code that gets the lock listing and unlocks an entry based on its id:

 

Dim idToUnlock = 100 ' The ID of the entry to unlock

Dim locklisting As LFPLockListing = db.GetLockListing(-1, 100, PLock_Column.PLOCK_COLUMN_ID, Sort_Direction.SORT_DIRECTION_ASC)
For i = 1 To locklisting.RowCount
    Dim lockdata As LFPLockData = locklisting.PLockData(i)
    If lockdata.Lifetime = Lock_Lifetime_Scope.LOCK_LIFETIME_SESSION Then
        Dim entry As ILFEntry = lockdata.Entry
        If entry.ID = idToUnlock Then ' Found the entry by id
            lockdata.IsLocked = False
            lockdata.Update()
        End If
    End If
Next

GetLockListing takes four parameters:

- connID: The Laserfiche connection ID, or -1 for all connections (you should be an admin to get all connections, or you can specify your own connection ID from your ILFConnection.ID

- RowsToPreload: The number of rows to retrieve in the first request. Not really important, 100 is a good value.

- SortColumn: The PLock_Column to sort on.

- Sort_Direction: SORT_DIRECTION_ASC or SORT_DIRECTION_DESC.

1 0

Replies

replied on June 26, 2014

The lock that UnlockObject refers to is a temporary lock.  These locks are automatically released when the user disconnects and can't be undone by another user.  You are probably talking about documents that have been checked out.  There is an UndoCheckout() function that should do what you want.  The function has the same name in LFSO and RA.

replied on June 26, 2014

You need to go through the PLock interface. Retrieve the list of locks with ILFDatabase::GetLockListing. This listing contains both temporary and permanent locks. Temporary locks are automatic locks that are used when modifying a document. Permament locks are are used when you manually check out a document. Find the lock in the listing object (temporary locks will have GetLifetime()==LOCK_LIFETIME_SESSION), then do

 

lockObj.PutIsLocked(VARIANT_FALSE);
lockObj.Update()

 

0 0
replied on June 26, 2014

Hi Robert,

 

What is the "Plock" interface?

 

 

0 0
replied on June 27, 2014

PLock stands for "persistent lock", the ILFPLockData class allows you to manage locks. The class was originally meant for persistent locks only, but was expanded to include support for managing session-lifetime locks as well. ILFDatabase::GetLockListing returns a listing of ILFPlockData objects, each one representing either a persistent or session-lifetime lock.

0 0
replied on July 1, 2014

Hi Long, 

 

If your question has been answered, please click the "This answered my question" button on the response.

 

If you still need assistance with this matter, just update this thread. Thanks!

0 0
replied on July 2, 2014 Show version history

Is there more documentation on this? For example, what arguments are specified for GetLockListing, and what each means? I don't see too much info on this within the LF 8.3 SDK documentation.

 

Is there some sample code? Am I on the right track by writing:

 

 

Dim getlocks As ILFPLockData = db.GetLockListing()

 

0 0
replied on July 28, 2015

Hi Robert Strickland

Where can I find LFPLockListing  ? Which is the namespace ? 

replied on July 28, 2015

LFSO92Lib if you are using the 9.2 SDK. It comes from LFSO92.dll.

You are not allowed to follow up in this post.

Sign in to reply to this post.