- Code : Tout sélectionner
Function SetNewReplicaID_API (wdb As NotesDatabase, wNewRepliqueID As String) As String
%REM
'variableAPI pour la fonction SetNewReplicaID_API
Type TIMEDATE
Innards(1) As Long
End Type
Type DBREPLICAINFO
ID As TIMEDATE 'ID that is same for all replica files
Flags As Integer 'Replication flags
CutoffInterval As Integer 'Automatic Replication Cutoff
Cutoff As TIMEDATE 'Replication cutoff date
End Type
Declare Function NSFDbClose Lib "nnotes.dll" (Byval hDb As Long) As Integer
Declare Function NSFDbOpen Lib "nnotes.dll" (Byval dbName As String, rethDb As Long) As Integer
Declare Function NSFDbReplicaInfoGet Lib "nnotes.dll" Alias "NSFDbReplicaInfoGet" (Byval hdb As Long, hdbr As DBREPLICAINFO) As Integer
Declare Function NSFDbReplicaInfoSet Lib "nnotes.dll" Alias "NSFDbReplicaInfoSet" (Byval hdb As Long, hdbr As DBREPLICAINFO) As Integer
%END REM
'Déclaration Variable
Dim Session as NotesSession
Dim nbHDB As Long
Dim nbReturnValue As Long
Dim RepInfo As DBREPLICAINFO
Dim i As Integer
On Error Goto ErreurHandle
SetNewReplicaID_API = ""
'teste si la base cible est accéssible
If wDB Is Nothing Then
Exit Function
Elseif dbexists_ls(wdb) = False Then
Exit Function
End If
Set Session = New NotesSession
If session.Platform <> "Windows/32" Then
Error 9999,"Work Only on Windows/32 Platform"
Exit Function
End If
If Trim(wNewRepliqueID) = "" Then
'génére une nouvelle id de réplique
Randomize
For i = 1 To 8
SetNewReplicaID_API = SetNewReplicaID_API + Ucase(Chr(Int(Rnd*6) + 65))
Next
SetNewReplicaID_API = SetNewReplicaID_API+":"
For i = 1 To 8
SetNewReplicaID_API = SetNewReplicaID_API + Ucase(Chr(Int(Rnd*6) + 65))
Next
Else
SetNewReplicaID_API = Trim(wNewRepliqueID)
End If
If Trim(wdb.Server) = "" Then
nbReturnValue = NSFDbOpen(wdb.FilePath, nbHDB)
Else
nbReturnValue = NSFDbOpen(wdb.Server + "!!" + wdb.FilePath, nbHDB)
End If
If nbReturnValue <> 0 Then
Error 9999,"Couldn't open db : "+wdb.FilePath
Exit Function
End If
nbReturnValue = NSFDbReplicaInfoGet(nbHDB, RepInfo)
If nbReturnValue <> 0 Then
Error 9999,"Couldn't get Replica Info"
Exit Function
End If
RepInfo.ID.Innards(1) = Val( "&H"+Left$( SetNewReplicaID_API, 8 ) )
RepInfo.ID.Innards(0) = Val( "&H"+Right$( SetNewReplicaID_API, 8 ) )
nbReturnValue = NSFDbReplicaInfoSet(nbHDB, RepInfo) ' take a deep breath...
nbReturnValue = NSFDbReplicaInfoGet(nbHDB, RepInfo)
If nbReturnValue <> 0 Then
Error 9999,"Couldn't get Replica Info"
Exit Function
End If
nbReturnValue = NSFDbClose(nbHDB)
Exit Function
ErreurHandle:
Msgbox "("+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
SetNewReplicaID_API = ""
Exit Function
End Function