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

Question

Question

Determining in the SDK the user name holding a lock.

SDK
asked on May 27, 2016

I have a Windows app that takes an Entry Id as a parameter and attempts to lock the entry.  If the entry is already locked I would like to display the user id that already has the entry locked.

So far, I cannot determine how to accomplish this in the SDK.  Can anyone point me in the right direction.

Thanks Everyone,

Bruce

0 0

Replies

replied on May 27, 2016

I am not an expert in this field but looking at sdk documentation i found out couple things that may be helpful to you. 

public EntryLock EntryLock { get; }

member of repository access. it Gets an EntryLock instance which represents the entry lock, if any, associated with this EntryInfo instance, or null if no entry lock is associated.

Entry lock class has session property whereas session object has username property that you could use.

 

 

 

0 0
replied on May 27, 2016

Ah - I needed to drill down into the session property.  That was simple enough.

Much Thanks Junaid

0 0
replied on May 27, 2016

Use the EntryLockListing to find the lock info:

static string GetEntryLockHolder(Session session, int docId)
{
    EntryLockListingSettings lockListSettings = new EntryLockListingSettings();
    lockListSettings.IdentityReference = null; // Set to null to get locks for all users
    lockListSettings.PersistentLocksOnly = false; // Get normal locks and persistent locks
    lockListSettings.SortColumn = PersistentLockColumn.Path;
    lockListSettings.SortDirection = Laserfiche.RepositoryAccess.SortDirection.Ascending;

    EntryLockListing lockListing = EntryLockListing.GetListing(0, lockListSettings, session);

    for (int lockRow = 1; lockRow <= lockListing.RowCount; lockRow++)
    {
        EntryLockListingRow row = lockListing.GetRow(lockRow);
        if (row.EntryId == docId)
        {
            AccountReference account = new AccountReference(row.Sid, session);
            return account.AccountName;
        }
    }

    return "";
}

 

0 0
replied on May 27, 2016

that is a very clean code. Could you please help me find out from where exactly i could write/get code like this in the future by myself. i have always seemed to struggle with sdk documentation. may be i am not looking hard enough or in the right place.  

thanks

0 0
replied on May 27, 2016

That was exactly what I needed. 

I already tested it and it works as expected.

Thanks for the code snippet!

Bruce

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.