1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
Option Declare
Type TIMEDATE
Innards(0 To 1) As Long
End Type
Type dbIdType
innards (0 To 1) As Long
End Type
Type DBREPLICAINFO
ID As TIMEDATE
Flags As Integer
CutoffInterval As Integer
Cutoff As TIMEDATE
End Type
Declare Function NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" _
(Byval dbname As Lmbcs String, dbHandle As Long ) As Integer
Declare Function NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" _
(Byval dbHandle As Long ) As Integer
Declare Function NSFDBReplicaInfoSet Lib "nnotes.dll" Alias "NSFDbReplicaInfoSet" _
(Byval dbHandle As Long, replInfoStruct As DBREPLICAINFO) As Integer
Declare Function NSFDBReplicaInfoGet Lib "nnotes.dll" Alias "NSFDbReplicaInfoGet" _
(Byval dbHandle As Long, replInfoStruct As DBREPLICAINFO) As Integer
Declare Function NSFDBCreate Lib "nnotes.dll" Alias "NSFDbCreate" _
(Byval dbname As Lmbcs String, Byval dbClass As Single, Byval forceIt As Single) As Integer
Declare Function NSFNoteDelete Lib "NNOTES.DLL" Alias "NSFNoteDelete" _
(Byval dbHandle As Long, Byval noteid As Long, updateflags As Long) As Integer
Declare Function NSFDbCopyACL Lib "nnotes.dll" Alias "NSFDbCopyACL" _
(Byval dbHandle As Long, Byval dbHandle2 As Long ) As Integer
Declare Function NSFDbIDGet Lib "nnotes.dll" Alias "NSFDbIDGet" _
(Byval dbHandle As Long, DbID As dbidtype ) As Integer
Declare Function TimeConstant Lib "nnotes.dll" Alias "TimeConstant" (Byval TimeConstantType As Integer, td As TIMEDATE) As Integer
Declare Function NSFDbGetModifiedNoteTable Lib "nnotes.dll" Alias "NSFDbGetModifiedNoteTable" ( _
Byval hDb As Long, _
Byval NoteClassMask As Integer, _
Byval Innards1 As Long, _
Byval Innards2 As Long, _
retUntil As TIMEDATE, _
rethTable As Long _
) As Integer
Declare Function NSFDbInfoGet Lib "nnotes.dll" Alias "NSFDbInfoGet" _
(Byval hDB As Integer, Byval retBuffer As Lmbcs String) As Integer
Declare Sub NSFDbInfoModify Lib "nnotes.dll" Alias "NSFDbInfoModify" _
(Byval retBuffer As Lmbcs String, Byval Konst As Integer, Byval NewTemplateName As String)
Declare Function NSFDbInfoSet Lib "nnotes.dll" Alias "NSFDbInfoSet" _
( Byval hDB As Integer, Byval retBuffer As Lmbcs String) As Integer
Declare Function IDScan Lib "nnotes" Alias "IDScan" (Byval hTable As Long, Byval fFirst As Integer, retID As Long) As Integer
Declare Function IDDestroyTable Lib "nnotes" Alias "IDDestroyTable" (Byval hTable As Long ) As Integer
Declare Function NSFDbCopyNote Lib "nnotes" Alias "NSFDbCopyNote" (Byval input_handle As Long, DbID As dbidtype, _
replInfoStruct As DBREPLICAINFO, Byval note_id As Long,Byval output_handle As Long, _
DbID2 As dbidtype, replInfoStruct2 As DBREPLICAINFO, Byval LN5 As Long, Byval LN6 As Long) As Integer
Declare Function NSFDbGetSpecialNoteID Lib "nnotes.dll" Alias "NSFDbGetSpecialNoteID"_
(Byval dbhandle As Long, Byval NoteClass As Long, retNoteID As Long) As Integer
' *******************************************************************************************************************************
Const DBCLASS_NOTEFILE = &Hff01
Const UPDATE_NOSTUB= &H0200
Const INFOPARSE_TITLE= 0
Const INFOPARSE_DESIGN_CLASS = 3
Const SPECIAL_ID_NOTE = &H8000 ' use in combination w/NOTE_CLASS when calling NSFDbGetSpecialNoteID
Const NOTE_CLASS_INFO = &H0002 ' notefile info (help-about) note
Const NOTE_CLASS_ICON = &H0010 ' icon note
Const NOTE_CLASS_HELP = &H0100 ' designer's help note
Const NOTE_CLASS_ALL = &H7fff
Const TIMEDATE_WILDCARD = 2
Sub Initialize
Dim var As Variant
Dim input_dbhandle As Long
Dim output_dbhandle As Long
Dim rc As Integer
Dim infoBuffer As DBREPLICAINFO
Dim DinfoBuffer As DBREPLICAINFO
Dim stexte As String, dtexte As String
Dim output_title As String
' For NSFDbIDGet
Dim DBId_In As DbIDType
Dim DBId_Out As DbIDType
'For Function Time Constant
Dim tdStart As TIMEDATE, tdEnd As TIMEDATE, tdModified As TIMEDATE
Dim hTable As Long
'For Function IdScan
Dim NoteID As Long
Dim bFlag As Integer
stexte = "G-EMA07/SRV/ALSTOM"+ "!!" + "wgcw/devs/blank.nsf"
'stexte = "HCE02/HCE/DTR/GECALSTHOM" + "!!" + "names.nsf"
dtexte = "copy_names_alsom.nsf"
' Open the input database Server Source : ( stexte = sserver + pathname )
rc = NSFDbOpen(stexte, input_dbhandle)
If rc <> 0 Then
Print " Cannot open database erreur :" & rc 'erreur
Exit Sub
End If
' Create and open the desination database. dtexte
' Create Database destination
rc = NSFDbCreate(dtexte, DBCLASS_NOTEFILE, 1)
If rc <> 0 Then
Print " Cannot create database, erreur : " & rc
Exit Sub
End If
'Ouverture Database sur le serveur Destination
rc =NSFDbOpen(dtexte, output_dbhandle)
If rc <> 0 Then
Print " Cannot open database erreur : " & rc
Exit Sub
End If
' Copy the replication settings (not the replication history) from
'the input database to the output database. The replication settings
'include the database replica ID. This makes the destination database
'a replica copy of the source database.
'Get Replica Info on server source
rc = NSFDbReplicaInfoGet(input_dbhandle, infoBuffer)
If rc <> 0 Then
Print " Cannot get replica info, erreur : " & rc
' Fermeture des bases ouvertes pour libérer la mémoire
NSFDbClose (input_dbhandle)
NSFDbClose (output_dbhandle)
Exit Sub
End If
' Set replica on server destination
rc = NSFDbReplicaInfoSet(output_dbhandle, DinfoBuffer)
If rc <> 0 Then
Print " Cannot set repilca erreur : " & rc
' Fermeture des bases ouvertes pour libérer la mémoire
NSFDbClose (input_dbhandle)
NSFDbClose (output_dbhandle)
Exit Sub
End If
'Copy the ACL from the input database to the output database.
rc = NSFDbCopyACL(input_dbhandle, output_dbhandle)
If rc <> 0 Then
Print " Cannot copy lca erreur : " & rc
' Fermeture des bases ouvertes pour libérer la mémoire
NSFDbClose (input_dbhandle)
NSFDbClose (output_dbhandle)
Exit Sub
End If
' /* Set a time/date structure that will determine the date of the earliest
'note copied in the next call. Use TimeConstant with TIMEDATE_WILDCARD
'specified to indicate that we do not want any cutoff date. */
rc = TimeConstant (TIMEDATE_WILDCARD, tdStart)
'Do not use NSFDbCopy to copy all notes in the input database to the
' output database. Such copies are not guaranteed to be replicas of
' the original notes. Instead get an IDTABLE of all notes in the
' database, use IDScan to obtain each NOTEID, and then call
' NSFDbCopyNote to copy each note from one database to the other.
rc= NSFDbIDGet (input_dbhandle, DBId_In)
rc= NSFDbIDGet (output_dbhandle, DBId_Out)
'Get the NoteID table for all notes in the input database
rc = NSFDbGetModifiedNoteTable( input_dbhandle, NOTE_CLASS_ALL, tdStart.Innards(0), tdStart.Innards(1), tdEnd, hTable )
If rc <> 0 Then
Print " Cannot get all noteid documents : " & rc
NSFDbClose (input_dbhandle)
NSFDbClose (output_dbhandle)
End If
bFlag = True
Do While IDScan( hTable, bFlag, NoteID )
bFlag = False
rc = 0
If rc <> NSFDbCopyNote (input_dbhandle, DBId_In , infoBuffer , _
NoteID, output_dbhandle, DBId_Out, infoBuffer, 0, 0) Then
' Destroy table
IDDestroyTable (hTable)
NSFDbClose (input_dbhandle)
NSFDbClose (output_dbhandle)
' Mettre la nature de l erreur retourné
End If
Loop
IDDestroyTable (hTable)
NSFDbClose (input_dbhandle )
NSFDbClose (output_dbhandle)
End Sub |
Partager