Lotus教程、Java教程、Java虚拟机、Java软件综合开发社区

Lotus、Domino、Java、C#、Web、数据库综合开发教程、资料社区

Lotusscript中维护复制冲突文档



Published by admin on 05月 30, 2010

This tip shows you three different ways to remove replication conflicts from
a database by using LotusScript.The first two examples use the new Notes entry.
IsConflict property now available in LotusScript for R5.
This new property makes detecting and removing replication conflicts easy.
The final example shows you an R4.x method for resolving replication conflicts.

Example One: Removing all replication conflicts (R5)
The following script uses the Notes entry.IsConflict property to remove all
replication conflicts from the current R5 database.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim entry As NotesViewEntry
Set db = session.CurrentDatabase
Dim Vec As notesViewEntryCollection

j=1
Set view = db.GetView( “($All)” )
Set vec = view.AllEntries
Set entry = vec.GetNthEntry( j )
Set doc = entry.Document

While Not (doc Is Nothing)
If entry.isconflict = True Then
Call doc.remove(True)
End If

j=j+1
Set entry = vec.GetNthEntry( j )
If entry Is Nothing Then
Exit Sub
End If
Set doc = entry.Document
Wend

Example Two: Monitoring for replication conflicts (R5)
The following script uses the Notes entry.IsConflict property to monitor for replication conflicts in the current R5 database, and to send an e-mail message if any exist.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim entry As NotesViewEntry
Set db = session.CurrentDatabase
Dim Vec As notesViewEntryCollection

j=1
conflictCount = 0
Set view = db.GetView( “($All)” )
Set vec = view.AllEntries
Set entry = vec.GetNthEntry( j )
Set doc = entry.Document

If session.isonserver = True Then
serverName = db.server
Else
serverName = “local”
End If
While Not (doc Is Nothing)
If entry.isconflict = True Then
conflictCount = conflictCount + 1
End If

j=j+1
Set entry = vec.GetNthEntry( j )
If entry Is Nothing Then
If conflictCount > 0 Then
temp = “Count Rep Conflicts Agent detected ” & conflictCount & ” conflicts in database ” & db.title & ” on ” & serverName
Set doc = New NotesDocument( db )
doc.Subject = “Replication conflict alert message”
doc.Body = temp
Call doc.Send( False, “Joe Smith/Acme” ) “Enter the name of the person to be notified here
End If
Exit Sub
End If
Set doc = entry.Document
Wend

Example Three: Resolving replication conflicts (R4.x)
The following script finds replication conflicts by looking for $Conflict, and then resolves the conflict by promoting the loser of the conflict to be the winner. (Editor”s Note: To increase the performance of this code, use the GetNextDocument method instead of GetNthDocument.)

Dim s As New notessession
Dim db As notesdatabase
Dim col As notesdocumentcollection
Dim doc As notesdocument
Dim parent As notesdocument

Set db=s.CurrentDatabase
Set col=db.UnprocessedDocuments

If col.Count > 0 Then
For i=1 To col.Count
Set doc=col.GetNthDocument(i)

“Check to see if the selected document is a conflict response
If doc.HasItem(”$Conflict”) Then

docId$=doc.UniversalId
parentId$=doc.GetItemValue(”$REF”)(0)
“Promote the loser to a document
Call doc.RemoveItem(”$Ref”)
Call doc.RemoveItem(”$Conflict”)

“Get original winner
Set parent=db.GetDocumentByUnid(parentId$)
If Not parent Is Nothing Then

“Remove original winner
Call parent.Remove(True)
End If

“Reset the DocumentUniqueID, responses are still pointing to correct document, and replication is done on the correct document
doc.UniversalId=parentId$
Call doc.Save(True, True)

“Somehow instead of overwriting the ID, a copy is created so it is necessary to delete the original loser
Set doc=db.GetDocumentByUNID(docId$)
If Not doc Is Nothing Then
Call doc.Remove(True)
End If
End If
Next
End If



【版权说明】:本网页上有部分内容来源于网上收集,但不能保证资料的完整性和准确性,仅提供参考和学习。如有侵权请立即通知我们,我们将立即删除,谢谢合作!

Comments are closed.