以编程方式清除复制历史记录

Clear Replication History programmatically

我正在寻找一种以编程方式清除“复制历史记录”的方法(通常我们会在需要时手动执行,请参见下图)

  1. 我检查了 LS 和 Java 类,没有发现任何有用的东西。
  2. 我会尝试找到一些 Notes C API 数据库,但我真的想避免使用 C API。

非常欢迎任何想法或建议。

这是一个解决方案(感谢 Richard Schwartz 帮助 C API 函数)。

(声明)

Public Const W32_LIB = {nnotes.dll}
Public Const LINUX_LIB = {libnotes.so}

Declare Function W32_NSFDbOpen Lib W32_LIB Alias {NSFDbOpen} (ByVal dbName As String, hDb As Long) As Integer
Declare Function W32_NSFDbClose Lib W32_LIB Alias {NSFDbClose} (ByVal hDb As Long) As Integer
Declare Function W32_NSFDbClearReplHistory Lib W32_LIB Alias {NSFDbClearReplHistory} (ByVal hDb As Long, flags As Integer) As Integer

Declare Function LINUX_NSFDbOpen Lib LINUX_LIB Alias {NSFDbOpen} (ByVal dbName As String, hDb As Long) As Integer
Declare Function LINUX_NSFDbClose Lib LINUX_LIB Alias {NSFDbClose} (ByVal hDb As Long) As Integer
Declare Function LINUX_NSFDbClearReplHistory Lib LINUX_LIB Alias {NSFDbClearReplHistory} (ByVal hDb As Long, flags As Integer) As Integer

Dim IS_WINDOWS As Boolean

初始化(找出平台:windows或linux)

Dim session As NotesSession
Set session = New NotesSession

IS_WINDOWS = InStr(session.Platform, "Windows") <> 0

清除复制历史

Function processDb(server As String, filename As String) As Boolean
    On Error GoTo errh
    
    Dim hdb As Long
    Dim rc As Integer

    If Server = "" Then
        If IS_WINDOWS Then
            rc = W32_NSFDbOpen(FileName, hDb)
        Else
            rc = LINUX_NSFDbOpen(FileName, hDb)
        End If
    Else
        If IS_WINDOWS Then
            rc = W32_NSFDbOpen(Server & "!!" & FileName, hDb)
        Else
            rc = LINUX_NSFDbOpen(Server & "!!" & FileName, hDb)
        End If
    End If

    If rc <> 0 Then
        Error 9001, "Database " & Server & "!!" & FileName & " - could not be opened"
    End If
    
    If IS_WINDOWS Then
        rc = W32_NSFDbClearReplHistory(hDb, 0)
    Else
        rc = LINUX_NSFDbClearReplHistory(hDb, 0)
    End If

    If rc <> 0 Then
        Error 9002, "Database " & Server & "!!" & FileName & " - replication history failed"
    End If

    If IS_WINDOWS Then
        rc = W32_NSFDbClose(hDb)
    Else
        rc = LINUX_NSFDbClose(hDb)
    End If
    
    processDb = true
    
final:
    Exit Function
errh:
    MsgBox "!! " & Error$ & " at line: " & erl
    Resume final
End Function

在 github 上发布的解决方案: https://github.com/dpastov/DominoReplicationHistoryCleaner