Replication détecter suppression d'un document dans un agent

Forum destiné aux questions sur le développement : Formules, LotusScript, Java ...

Replication détecter suppression d'un document dans un agent

Messagepar Michael DELIQUE » 15 Juin 2011 à 14:39

Bonjour

je suis obligé de reprendre le combat avec inetlockout. Mon agent de syncho entre les membres du cluster fonction parfaitement (même trop bien)

le souci, lorsqu'un document de verrouillage est supprimé l'agent le recréé immadiatement... youpi ! il faut que je modifie mon traitement. j'ai bien essayé de récupérer la liste des talon suppresion histoire de voir ce que je pouvais faire. mais lorsque je lance mon agent en schédulé ou via un run on server j'ai un souci d'opération interdite dans la session (pour la construction du chemin de la base) et quand je le lance a la main il ne me trouve rien...

quelqu'un aurai une idée pour détecter/avoir les liste des documents supprimés ?

mon code (merci les api)

Code : Tout sélectionner
Option Public
Option Declare
Const Structure_Log = {Agent : Test}
Dim Session As NotesSession
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 Function OSPathNetConstruct Lib "nnotes.dll" (ByVal portName As Integer, ByVal serverName As String, ByVal fileName As String, ByVal pathName As String) As Integer
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 Sub TimeConstant Lib "nnotes.dll" (ByVal TimeConstantType As Integer,td As TIMEDATE)
Declare Function NSFDbGetModifiedNoteTable Lib "nnotes.dll" (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 IDScan Lib "nnotes.dll" (ByVal hTable As Long,ByVal fFirst As Integer,retID As Long) As Integer
Declare Function NSFDbGetNoteInfo Lib "nnotes.dll" (ByVal hDb As Long,ByVal NoteID As Long,retNoteOID As OID,retModified As TIMEDATE,retNoteClass As Integer) As Integer
Declare Function OSLoadString Lib "nnotes.dll" (ByVal hModule As Long, ByVal stringCode As Integer, ByVal retBuffer As String, ByVal bufferLength As Integer) As Integer
Sub Initialize()
   Dim vrValue As Variant
   vrValue = API_ListDeletionStub(Nothing,True)
   ForAll value In vrvalue
      MsgBox CStr(value)
   End ForAll
   stop
End Sub

Function GetNoteClass(wnbNoteClass As Integer) As String
   %REM
      renvois le nom (texte) du type de notes (numerique) passé en paramètre
   %END REM
   On Error GoTo CatchError
   Select Case wnbNoteClass
   Case &H0001
      GetNoteClass = "Document"
   Case &H0002
      GetNoteClass = "Help-about"
   Case &H0004
      GetNoteClass = "Form"
   Case &H0008
      GetNoteClass = "View"
   Case &H0010
      GetNoteClass = "Icon"
   Case &H0020
      GetNoteClass = "Design collection"
   Case &H0040
      GetNoteClass = "ACL"
   Case &H0080
      GetNoteClass = "Help index"
   Case &H0100
      GetNoteClass = "Help-using"
   Case &H0200
      GetNoteClass = "Filter"
   Case &H0400
      GetNoteClass = "Field"
   Case &H0800
      GetNoteClass = "Replication formula"
   Case &H1000
      GetNoteClass = "Private design"
   Case Else
      GetNoteClass = "Unknown"
   End Select
   Exit Function
CatchError:
   MsgBox "("+Structure_Log+" : "+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 !"
   Exit Function
End Function


Function GetAPIError (nbErrorCode As Integer) As String
   %rem   
      convertit un numero d'erreur renvoyer par une api en un libellé
      Declare Function OSLoadString Lib "nnotes.dll" (Byval hModule As Long, Byval stringCode As Integer, Byval retBuffer As String, Byval bufferLength As Integer) As Integer
   %END REM
   Dim errorString As String*256
   Dim nbResultStringLength As Long
   Dim nbErrorCodeTranslated As Integer
   
   Const ERR_MASK = &H3fff
   Const PKG_MASK = &H3f00
   Const ERRNUM_MASK = &H00ff
   
   On Error GoTo CatchError
   
   GetAPIError = ""
   
   rem conversion du code erreur
   nbErrorCodeTranslated = (nbErrorCode And ERR_MASK)
   
   rem génére le libelle
   nbResultStringLength = OSLoadString(0, nbErrorCodeTranslated, errorString, Len(errorString) - 1)
   
   If (InStr(errorString, Chr(0)) > 0) Then
      GetAPIError  = Left$(errorString, InStr(errorString, Chr(0)) - 1)
   Else
      GetAPIError = errorString
   End If
   
   Exit Function
CatchError:
   MsgBox "("+Structure_Log+" : "+Cstr(GetThreadInfo (1))+" Call by "+Cstr(GetThreadInfo(10))+")"+Chr(10)+"Erreur " + CStr(Err) + " : "+Chr(10) + CStr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
   GetAPIError = ""
   Exit Function
End Function
Function API_ListDeletionStub(wDBCible As NotesDatabase,wnbReturnNotesIDOnly As Boolean) As Variant
   %REM
      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 Function OSPathNetConstruct Lib "nnotes.dll" (ByVal portName As Integer, ByVal serverName As String, ByVal fileName As String, ByVal pathName As String) As Integer
      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 Sub TimeConstant Lib "nnotes.dll" (ByVal TimeConstantType As Integer,td As TIMEDATE)
      Declare Function NSFDbGetModifiedNoteTable Lib "nnotes.dll" (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 IDScan Lib "nnotes.dll" (ByVal hTable As Long,ByVal fFirst As Integer,retID As Long) As Integer
      Declare Function NSFDbGetNoteInfo Lib "nnotes.dll" (ByVal hDb As Long,ByVal NoteID As Long,retNoteOID As OID,retModified As TIMEDATE,retNoteClass As Integer) As Integer
   %END REM

   Dim DBCible As NotesDatabase
   Dim pathName As String * 1024
   Dim i As Integer
   Dim nbResult As Integer
   Dim nbFlag As Integer
   Dim nbNoteClass As Integer
   Dim nbHandleDb As Long
   Dim nbHandleTable As Long   
   Dim nbNoteID As Long
   Dim nbDeletedNoteID As Long   
   Dim tdStart As TIMEDATE
   Dim tdModified As TIMEDATE
   Dim tdEnd As TIMEDATE
   Dim NoteOID As OID
   Dim lstRetour List As String

   Const Separator = ";"
   Const TIMEDATE_WILDCARD = 2
   Const NOTE_CLASS_ALL = &H7fff
   Const RRV_DELETED = &H80000000&
   Const PKG_NSF = &H200
   Const ERR_NOTE_DELETED = PKG_NSF + 37
   On Error GoTo CatchError

   lstRetour(0) = ""

   If Session Is Nothing Then
      Set Session = New NotesSession
   End If

   If wDBCible Is Nothing Then
      Set DBCible  = Session.Currentdatabase
   Else
      Set DBCible = wDBCible
   End If
   REM ouverture la base de document
   Call OSPathNetConstruct(0, DBCible.Server, DBCible.FilePath, pathName)
   
   nbResult = NSFDbOpen(pathName, nbHandleDB)
   If nbResult <> 0 Then
      Error  nbResult ,"API NSFDbOpen Database not found ("+DBCible.Server+":"+DBCible.FilePath+") : ("+CStr(nbResult)+") "+GetAPIError(nbResult )
      Exit Function
   End If

   Set DBCible = Nothing

   REM récupère tous les Notes modifiés depuis la création de la bas (talons de suppression inclus)
   TimeConstant TIMEDATE_WILDCARD, tdStart
   
   REM récupère l'ID de la tables contenant toutes les Notes
   nbResult = NSFDbGetModifiedNoteTable( nbHandleDB, NOTE_CLASS_ALL, tdStart.Innards(0), tdStart.Innards(1), tdEnd, nbHandleTable )
   If nbResult <> 0 Then
      Error  9999 ,"API NSFDbGetModifiedNoteTable : ("+CStr(nbResult)+") "+GetAPIError(nbResult )
      Resume Next
      Call NSFDbClose(nbHandleDB)
      Exit Function
   End If
   
   nbFlag = True
   REM parcours la table
   i=0
   Do While IDScan( nbHandleDB, nbFlag, nbNoteID )
      i=i+1
      REM clear flag bit so we won't get an error indicating an invalid note
      nbDeletedNoteID = nbNoteID And ( Not RRV_DELETED )      
      lstRetour(CStr(Hex$( nbDeletedNoteID ))) = CStr(Hex$( nbDeletedNoteID ))
      %rem
      nbResult = NSFDbGetNoteInfo( nbHandleDB, nbDeletedNoteID, NoteOID, tdModified, nbNoteClass)
      If nbResult = ERR_NOTE_DELETED Then
         If wnbReturnNotesIDOnly = True Then
            lstRetour(CStr(Hex$( nbDeletedNoteID ))) = CStr(Hex$( nbDeletedNoteID ))
         Else
            lstRetour(CStr(Hex$( nbDeletedNoteID ))) = CStr(Hex$( nbDeletedNoteID ))+Separator _
            +CStr(Hex$( NoteOID.FileDBID.Innards(1))) + ":" + CStr(Hex$( NoteOID.FileDBID.Innards(0)))_
            +cstr(CDat(NoteOID.sequencetime.Innards(1) + 2061182549))+GetNoteClass( nbNoteClass )
         End If
      ElseIf nbResult <> 0 Then
         Error  9999 ,"API NSFDbGetNoteInfo '"+CStr(Hex$(nbDeletedNoteID))+"' : ("+CStr(nbResult)+") "+GetAPIError(nbResult )
         Call NSFDbClose(nbHandleDB)
      End If      
      %end rem
      nbFlag = False
   Loop
   If i > 0 Then
      If wnbReturnNotesIDOnly = True Then
         lstRetour(0) = "NOTESID"+Separator+CStr(i)
      Else
         lstRetour(0) = "NOTESID"+Separator+"DBID"+Separator+"DATE"+Separator+"NOTECLASS"+Separator+CStr(i)
      End If
   End If
   Call NSFDbClose(nbHandleDB)
   API_ListDeletionStub = lstRetour
   Erase lstRetour
   Exit Function
CatchError:
   MsgBox "("+Structure_Log+" : "+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 !"
   Erase lstRetour
   lstRetour(0) = ""
   API_ListDeletionStub = lstRetour
   Erase lstRetour
   Exit Function
End Function
Cordialement

Michael (SMS-Phobique)
----------------------------
"La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi."
Albert EINSTEIN
Avatar de l’utilisateur
Michael DELIQUE
Administrateur
Administrateur
 
Message(s) : 12183
Inscrit(e) le : 16 Déc 2004 à 10:36
Localisation : Paris/Cergy

Messagepar abertisch » 15 Juin 2011 à 14:44

Hello,

Es-tu obliger de supprimer ton document de verrouillage ?!?
"Lotus, il n'y a qu'en rouleaux que ça fait pas mal au cul"
abertisch
Roi des posts
Roi des posts
 
Message(s) : 763
Inscrit(e) le : 25 Oct 2006 à 13:51
Localisation : Suisse

Messagepar Michael DELIQUE » 15 Juin 2011 à 14:47

re,

ce n'est pas moi qui le supprime mais la tache serveur. Il faut donc que je le gère.
Cordialement

Michael (SMS-Phobique)
----------------------------
"La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi."
Albert EINSTEIN
Avatar de l’utilisateur
Michael DELIQUE
Administrateur
Administrateur
 
Message(s) : 12183
Inscrit(e) le : 16 Déc 2004 à 10:36
Localisation : Paris/Cergy

Messagepar Michael DELIQUE » 15 Juin 2011 à 16:13

bon j'ai laissé tombé l'option API/DeleteStubs j'ai trouvé une autre solution sans api (pas moins tordu) je mettrais a jours le tips sur le sujet
Cordialement

Michael (SMS-Phobique)
----------------------------
"La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi."
Albert EINSTEIN
Avatar de l’utilisateur
Michael DELIQUE
Administrateur
Administrateur
 
Message(s) : 12183
Inscrit(e) le : 16 Déc 2004 à 10:36
Localisation : Paris/Cergy


Retour vers Développement

cron