問題:運行在服務器上以及有多個複本的數據庫難免會出現複製與保存衝突的情況。如何處理這種情況是所有Notes管理員和設計者都要面對的問題。
複製與保存衝突可由以下原因造成:
在兩次複製之間,如果有兩個用戶同時編輯或多個用戶編輯了不同數據庫複本上的相同文檔,就會出現複製衝突。如果有兩個或多個用戶同時編輯同一個數據庫的同一個文檔,則會出現保存衝突。
解決方法:
一、可以在表單屬性框中的基本付籤選中:“合併複製衝突”,並知底功能表單基本付籤中的版本選項。
二、在這裏介紹一些和處理複製與保存衝突情況有關的方法與技巧:
1、創建列出所有衝突文檔的視圖:(VewConflict)衝突文檔都包含一個名爲“$Conflict”的域,因此可以用下面的試圖選擇公式列出所有衝突文檔。
1 SELECT @ISAvailable("$Conflict")
2、將衝突文檔與主文檔同屏顯示以便比較兩者之間的差別:由於衝突文檔被保存爲主文檔的答覆文檔,在打開衝突文檔以後使用快捷圖標“顯示/隱藏預覽主文檔”,主文檔就會被顯示在預覽窗格中了。
3、附加菜單命令比較兩個文檔之間的差別:在Notes.ini文件中加入下面一行:
AddInMenus=C:\Notes\nntediff.dll
然後重起Notes,就回發現“操作”菜單中多了一項“Different of 2 document”.
4、找到衝突文檔的主文檔:
Sub Click(Source as Button)
Const FolderName="ReplicationConFlict"
dim s As New NotesSession
dim doccol as NotesDocumentCollection
dim doc as Notesdocument,topdoc as notesdocument
dim folder as notesView
set dbcur=s.currentdatabase
set doccol.dbcur.unprocesseddocuments
set doc=doccol.getfirstdocument
while not(doc is nothing)
set topdoc=gettopdoc(doc)
call topdoc.putinfolder(Foldername)
set doc=doccol.getnextdocument(doc)
wend
End Sub
Function GetTopDoc(DocSource as notesDocument) as NotesDocument
dim doctop as notesdocument dim strUNID as String
set doctop=docsource
strUNID=doctop.ParentDocumentUNID
Do While (strUNID<>"")
set DocTop=dbCur.GetDocumentByUNID(StrUNID)
strUNID=doctop.ParentdocumentUNID
loop
set GetTopDoc=doctop
End Functiong
5、將衝突文檔保存爲主文檔選種若干衝突文檔後運行下面代理。這個代理把選種的衝突文檔保存爲主文檔。
dim s as new notessession
set db=s.currentdatabase
set dc=db.unprocessedDocuments
set doc=dc.getfirstdocument '$conflict是衝突文檔的標誌
call doc.removeItem("$Conflict") '得到衝突文檔的主文檔
if doc.isResponse then
Set Parent=db.GetDocumentByUNID(doc.ParentDocumentUNID)
if parent.IsResponse then '如果文檔是答覆的答覆
dim GrandParant as Notesdocument
Set GrandParant=db.GetDocumentByUNID(Parent.ParentDocumentUNID)
call doc.MakeResponse(GrandParent) else '$Ref 域是答覆文檔的標誌
call doc.RemoveItem("$Ref")
end if
end if
call doc.save(True,True)
當使用LS在後臺創建文檔的時候,表單中“合併複製衝突”選項無效,在文檔中加入下面代碼: doc.$Conflicts="1"