RE: Get deletion stubs JY Riverin 5.Apr.07 08:30 a Web browser Domino Server All ReleasesAll Platforms
Hi,
don't know if it can be done in VB , but by script you can get the stubs. You will have to tweak it a little bit, but it's working
' --- custom user-defined type for storing deletion stub information
Type DELETION_STUB
NoteID As String
NoteClass As String
Datte As String
DBID As String
End Type
' --- Notes C API declares and constants (translated from the header files)
Type TIMEDATE
Innards(1) As Long
End Type
Type OID
FileDBID As TIMEDATE
Note As TIMEDATE
Sequence As Long
SequenceTime As TIMEDATE
End Type
Declare Sub W32OSPathNetConstruct Lib "nnotes" Alias "OSPathNetConstruct" ( _
Byval portName As Lmbcs String, _
Byval ServerName As Lmbcs String, _
Byval FileName As String, _
Byval retPathName As String _
)
Declare Function W32NSFDbOpen Lib "nnotes" Alias "NSFDbOpen" ( _
Byval PathName As Lmbcs String, _
rethDb As Long _
) As Integer
Declare Function W32NSFDbClose Lib "nnotes" Alias "NSFDbClose" ( _
Byval hDb As Long _
) As Integer
Declare Sub W32TimeConstant Lib "nnotes" Alias "TimeConstant" ( _
Byval TimeConstantType As Integer, _
td As TIMEDATE _
)
Declare Function W32NSFDbGetModifiedNoteTable Lib "nnotes" 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 W32IDEntries Lib "nnotes" Alias "IDEntries" ( _
Byval hTable As Long _
) As Long
Declare Function W32IDScan Lib "nnotes" Alias "IDScan" ( _
Byval hTable As Long, _
Byval fFirst As Integer, _
retID As Long _
) As Integer
Declare Function W32IDDestroyTable Lib "nnotes" Alias "IDDestroyTable" ( _
Byval hTable As Long _
) As Integer
Declare Function W32OSLoadString Lib "nnotes" Alias "OSLoadString" (Byval hModule As Long, _
Byval StringCode As Integer, _
Byval retBuffer As Lmbcs String, _
Byval BufferLength As Integer _
) As Integer
Declare Function W32NSFDbGetNoteInfo Lib "nnotes" Alias "NSFDbGetNoteInfo" ( _
Byval hDb As Long, _
Byval NoteID As Long, _
retNoteOID As OID, _
retModified As TIMEDATE, _
retNoteClass As Integer _
) As Integer
' --- open the database
iStatus = W32NSFDbOpen( sPath, hDb )
If iStatus <> NOERROR Then
' --- display any errors returned from C API call
Msgbox GetCAPIErrorMsg( iStatus ), 48, "Notes C API Error"
Else
' --- generate an array of deletion stubs
DumpDeletionStubs hDb, stubs
' --- close the database
W32NSFDbClose hDb
' --- print out all the stubs to the status bar
Forall note In stubs
Print "Deletion stub found: Note ID = " + note.NoteID + ", Note class = " + note.NoteClass + ", Date = " + note.datte
End Forall
End If
End Sub
Function GetNoteClass( iNoteClass As Integer ) As String
%REM
GetNoteClass - This function takes a note type and returns a text string representing the note class type to the caller.
%END REM
Dim sNoteType As String
Select Case iNoteClass
Case NOTE_CLASS_DOCUMENT
sNoteType = "Document"
Case NOTE_CLASS_INFO
sNoteType = "Help-about"
Case NOTE_CLASS_FORM
sNoteType = "Form"
Case NOTE_CLASS_VIEW
sNoteType = "View"
Case NOTE_CLASS_ICON
sNoteType = "Icon"
Case NOTE_CLASS_DESIGN
sNoteType = "Design collection"
Case NOTE_CLASS_ACL
sNoteType = "ACL"
Case NOTE_CLASS_HELP_INDEX
sNoteType = "Help index"
Case NOTE_CLASS_HELP
sNoteType = "Help-using"
Case NOTE_CLASS_FILTER
sNoteType = "Filter"
Case NOTE_CLASS_FIELD
sNoteType = "Field"
Case NOTE_CLASS_REPLFORMULA
sNoteType = "Replication formula"
Case NOTE_CLASS_PRIVATE
sNoteType = "Private design"
Case Else
sNoteType = "Unknown"
End Select
GetNoteClass = sNoteType
End Function
Function GetCAPIErrorMsg( iStatus As Integer ) As String
%REM
GetCAPIErrorMsg - This function takes a status code returned from a C API call, retrieves the corresponding
error message from Notes' internal string tables, and returns the string to the caller.
%END REM
Dim iLen As Integer
Dim sBuffer As String
' --- initialize a buffer of adequate length to accept the error string
sBuffer = String$( 256, 0 )
' --- get the API error message from the internal Notes/Domino string tables
iLen = W32OSLoadString( NULLHANDLE, iStatus, sBuffer, Len( sBuffer ) - 1 )
If iLen > 0 Then
' --- remove any trailing characters from the string and return it to the caller
GetCAPIErrorMsg = Left$( sBuffer, Instr( 1, sBuffer, Chr$(0) ) - 1 )
Else
' --- couldn't locate the error message in the string tables
GetCAPIErrorMsg = "Unknown error"
End If
End Function
Sub DumpDeletionStubs( hDb As Long, stubs() As DELETION_STUB )
%REM
DumpDeletionStubs - This Sub takes a C API handle to a database and dynamically builds an array of DELETION_STUB
types containing information about all the deletion stubs in the database.
%END REM
Dim s As String
Dim ns As Integer
Dim hTable As Long, NoteID As Long, DeletedNoteID As Long, ct As Long
Dim iStatus As Integer, bFlag As Integer, iNoteClass As Integer
Dim tdStart As TIMEDATE, tdEnd As TIMEDATE, tdModified As TIMEDATE
Dim NoteOID As OID
Dim retStr As String*81
Dim retLen As Integer
Dim retCode As Integer
' --- get all notes modified since the database was created (including deletion stubs)
W32TimeConstant TIMEDATE_WILDCARD, tdStart
' --- get an ID table of all the notes in the database
iStatus = W32NSFDbGetModifiedNoteTable( hDb, NOTE_CLASS_ALL, tdStart.Innards(0), tdStart.Innards(1), tdEnd, hTable )
If iStatus <> NOERROR Then
Msgbox GetCAPIErrorMsg( iStatus ), 48, "Notes C API Error"
Else
ct = 0
bFlag = True
' --- scan all notes in the ID table
Do While W32IDScan( hTable, bFlag, NoteID )
' --- test for deleted flag bit
If ( NoteID And RRV_DELETED ) Then
' --- clear flag bit so we won't get an error indicating an invalid note
DeletedNoteID = NoteID And ( Not RRV_DELETED )
' --- get the information we need about the note
iStatus = W32NSFDbGetNoteInfo( hDb, DeletedNoteID, NoteOID, tdModified, iNoteClass )
' --- check to see that this note is in fact a deletion stub
If iStatus = ERR_NOTE_DELETED Then