« Domino Versioning Discussion | Main| Domino Document Locking Class 1.1 »

Domino Document Locking Class

Bookmark : del.icio.us  Technorati  Digg This  Add To Furl  Add To YahooMyWeb  Add To Reddit  Add To NewsVine 

Updated version of Document Locking Class is now available.

To easy the pain of working with document locking I created a class that makes life a litlle easier. Here is the list of methods:
Public Sub new()
Public Function LockingEnabled() As Boolean
Public Function IsDocumentLockedByCurrentUser (doc As NotesDocument ) As Boolean
Public Function IsUIDocumentLockedByCurrentUser (uiDoc As NotesUIDocument ) As Boolean
Public Function LockUIDocument (uiDoc As NotesUIDocument ) As Boolean
Public Function LockDocument (doc As NotesDocument ) As Boolean
Public Function UnLockUIDocument (uiDoc As NotesUIDocument ) As Boolean
Public Function UnLockDocument (doc As NotesDocument ) As Boolean

So why the class? Easy it did not want have to worry about the if the documents was new, if locking was enabled, and if the document was already locked by the user and I try to lock it again. There is not much else to the code. So check it out.

Domino Document Locking

Select All


Comments

1 - Nice stuff, Chad, but why "static" functions, instead of using it as a real locking wrapper class, like this:
Dim docLock As New DocumentLock(doc)
If docLock.isLocked() Then
' Do something... perhaps unlock it:
Call docLock.unlock() ' Throws an "exception" if wrong user
Else
' Do something else...perhaps lock it:
Call docLock.lock() ' Throws an "exception" if doc locking is disabled
End If
The methods you have, would be rewritten as:
Public Sub new(doc As Variant) ' To be able to send both NotesDocument and NotesUIDocument
Public Function isLockingEnabled() As Boolean
Public Function isLockedByCurrentUser () As Boolean
Public Function lock() As Boolean
Public Function unlock() As Boolean
Public Function toString() As String ' Returns something like "Document XYZ locked by ABC", to get simple debug logging and such.

The reason I bug you with this, is that I have my own DocumentLock class, that contains the same methods, but with support for R5 (using specific lock documents)

2 - There are examples out there on how to do this, try { Link } My objective is to make the R6 document locking better and easier to use.

3 - Johan - Thanks for your suggestions, I usually shy away from using Variants but in this case I see the advantage. I will incorporate these changes also.

4 -
Chad,

Can we implement this on web, if yes can u please help in how to use this code for the wen

5 - Chad

Sorry for one more question

I used the class in the webquery open like
flag = DocLock.IsDocumentLocked (wdoc)

it is giving "False" if the document is opened in web by user and is not locked
I am locking it by "Call DocLock.LockDocument(wdoc)" in the same webqueryopen agent

if is save i can unlock it like "call DocLock.UnLockDocument(wdoc) in webquerysave but how can i unlock if i just close the document without saving

Please help




6 - How to give document locking in Lotusnotes R5

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)