Du musst zunachst einen ReplicaStub anlegen. Dafür gibt es in LS aber keinen direkten Befehl.
Über notesDatabase.CreateReplica( newServer$, newDbFile$ ) kann man zwar eine neue replik erstellen, es wird aber sofort repliziert.
Daher müssen wir mal wieder zur API greifen
Declaration
Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" _
(Byval dbname As String, dbHandle As Long ) As Long
Declare Function W32_NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" _
(Byval dbHandle As Long ) As Long
Declare Function W32_NSFDBCREATE Lib "NNOTES.DLL" Alias "NSFDbCreate" _
(Byval dbname As String, Byval dbClass As Single, Byval forceIt As Single) As Long
Declare Function W32_NSFDBREPLICAINFOSET Lib "NNOTES.DLL" Alias "NSFDbReplicaInfoSet" _
(Byval dbHandle As Long, replInfoStruct As Long) As Long
Declare Function W32_NSFDBREPLICAINFOGET Lib "NNOTES.DLL" Alias "NSFDbReplicaInfoGet" _
(Byval dbHandle As Long, replInfoStruct As Long) As Long
Function CreateReplStub
Function CreateReplStub(S_Server As String, S_Db As String, T_Server As String, T_Db As String, forceit As Single) As Long
Dim S_DbString As String
Dim T_DbString As String
Dim dbhandle As Long
Dim retNoteID As Long
Dim noteClass As Long
Dim replInfo(5) As Long
Select Case Ucase$(S_Server)
Case "LOCAL"
S_DbString = S_Db
Case "LOKAL"
S_DbString = S_Db
Case ""
S_DbString = S_Db
Case Else
S_DbString = S_Server + "!!" + S_Db
End Select
Select Case Ucase$(T_Server)
Case "LOCAL"
T_DbString = T_Db
Case "LOKAL"
T_DbString = T_Db
Case ""
T_DbString = T_Db
Case Else
T_DbString = T_Server + "!!" + T_Db
End Select
'get the replica info struct from Source DB
rc = W32_NSFDBOPEN(S_DbString, dbhandle)
rc = W32_NSFDBREPLICAINFOGET(dbhandle, replInfo(0))
rc = W32_NSFDBCLOSE(dbhandle)
'crete new DB and asign replikaInfo
rc = W32_NSFDBCREATE(T_DbString, DBCLASS_NOTEFILE, forceIt)
Print "Create",rc
rc = W32_NSFDBOPEN(T_DbString, dbhandle)
Print "Open", rc
rc = W32_NSFDBREPLICAINFOSET(dbhandle, replInfo(0))
Print "Set", rc
rc = W32_NSFDBCLOSE(dbhandle)
Print "close", rc
End Function
aufgerufen wird der code dann beispielsweise:
Sub Click(Source As Button)
rc = CreateReplStub("comm3/singultus/de", "mail\bgates.nsf", "comm2/singultus/de", "mail\bgates.nsf", True)
End Sub
Der code erstellt einen replica stub in dem du jetzt über
notesReplicationEntry.Formula = formula$ die Replikationsformel setzen kannst.
Ein bisschen ErrorHandling solltest du auch noch einbauen. Habe den Code auf das Nötigste abgespeckt.
Der Ansatz von Ulrich funktioniert einwandfrei, den setze ich hier auch ein. Nach Aufruf von CreateReplStub kannst Du dann ganz einfach die Replizierformel setzen:
Set dbTarget = New NotesDatabase( targetServer, targetPath )
Set repl = dbTarget.Replicationinfo
Set replEntry = repl.Getentry("-", "CN=TargetServerName/O=Certifier", True)
replEntry.Formula = replFormula
Call replEntry.Save
Call repl.Save