Domino 9 und frühere Versionen > Entwicklung
Protokkolierung der Löschdokumente
nyen:
Hallo zusammen,
für die Protokkolierung der Löschdokumente habe ich mit foldem Code versucht, klappt es irgent wie nicht. Auch keine Fehlermeldungen, der Agen läuft durch aber ohne Ergebnis.
Was mache ich hier falsch? Kann jemad hier näher diesen Code reinschauen?
Grüß
Nyen
Step 1 : create your new database. For the exemple, I'll name it «FastDeletion». I'll make also a view named «Deleted Documents» categorized on the new field name «FromDatabase».
Step 2 : modify the «QueryDocumentDelete» event
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
Dim Collection As NotesDocumentCollection
Dim Document As NotesDocument
Dim DeletedDoc As NotesDocument
'retreiving all documents that the current NotesUIDatabase event is working on
Set Collection = Source.Documents
Set Document = Collection.GetFirstDocument
Dim DBDeletion As New NotesDatabase ("", "FastDeletion.nsf")
Dim DateTime As New NotesDateTime (Today)
Dim Item As NotesItem
Do While Not (Document Is Nothing)
Set DeletedDoc = Document.CopyToDatabase (DBDeletion)
'Create a flag to tell the view from where that document has been proceed to be destroyed
DeletedDoc.FromDatabase = Document.ParentDatabase.FilePath
DeletedDoc.FromServer = Document.ParentDatabase.Server
Set Item = New NotesItem (DeletedDoc, "WhenDeleted", "")
Set Item.DateTimeValue = DateTime
'dont forget this property if you want to be able to use this item in the search
Item.IsSummary = True
Call DeletedDoc.Save (True, False)
Set Document = Collection.GetNextDocument (Document)
Loop
End Sub
Step 3 : purge and retreive (put them in the «FastDeletion» Database)
The agent for purge should work every day at 4 am to avoid conflic with admin process on server during night
Sub Initialize
Dim Session As New NotesSession
Dim Coll As NotesDocumentCollection
Dim DateTime As New NotesDateTime (Session.CurrentDatabase.Created)
'Adjust date for last 2 weeks
Set Coll = Session.CurrentDatabase.Search ("WhenDeleted < @Adjust (@Today;0; 0; -14; 0; 0; 0)", DateTime, 0)
'if there is at last one or more documents to purge
If Coll.Count > 0 Then Call Coll.RemoveAll (True)
End Sub
The action for retreive should be place in the «Deleted Documents» view
Sub Click(Source As Button)
Dim Session As New NotesSession
Dim Coll As NotesDocumentCollection
Dim DocRestore As NotesDocument
Dim Doc As NotesDocument
Dim DB As NotesDatabase
'Get all documents selected by user
Set Coll = Session.CurrentDatabase.UnprocessedDocuments
'if there is no document selected
If Coll.Count = 0 Then End
Set Doc = Coll.GetFirstDocument
Do While Not (Doc Is Nothing)
'Get the Database property
Set DB = Session.GetDatabase (Doc.FromServer (0), Doc.FromDatabase (0))
'Make the copy and delete the field used for deletion
Set DocRestore = Doc.CopyToDatabase (DB)
Call DocRestore.RemoveItem ("FromServer")
Call DocRestore.RemoveItem ("FromDatabase")
Call DocRestore.RemoveItem ("WhenDeleted")
Call DocRestore.Save (True, False)
Set Doc = Coll.GetNextDocument (Doc)
Loop
Call Coll.RemoveAll (True)
Dim WorkSpace As New NotesUIWorkSpace
Call WorkSpace.ViewRefresh
End Sub
Don Pasquale:
Hallo Nyen,
jeder Agent liefert ein Ergebnis, vielleicht ist die Auswahl auf welchen Dokumenten der Agent laufen soll falsch.
Wenn Du Agenten mit der rechten Maustaste anwählt kann Du "testen"
oder Protokoll anwählen.
Ist der Agent jemals gelaufen ?
Entsprachen überhaupt irgendwelche Kriterien dem des Agenten ?
Existieren die DBs die der Agent anspricht ?
Ciao
Don Pasquale
Glombi:
Du spricht von einem Agenten, es handelt sich aber um Script, welche an diversen Stellen eingetragen müssen.
Der Code ist auf den ersten Blick i.O. Natürlcih sind einige Dinge drin, die geprüft werden müssen.
Der Agent hat nur folgenden Code:
Sub Initialize
Dim Session As New NotesSession
Dim Coll As NotesDocumentCollection
Dim DateTime As New NotesDateTime (Session.CurrentDatabase.Created)
'Adjust date for last 2 weeks
Set Coll = Session.CurrentDatabase.Search ("WhenDeleted < @Adjust (@Today;0; 0; -14; 0; 0; 0)", DateTime, 0)
'if there is at last one or more documents to purge
If Coll.Count > 0 Then Call Coll.RemoveAll (True)
End Sub
Frage: Gibt es ein Dokument, in dem das Feld WhenDeleted da ist?
Andreas
nyen:
Hi Don,
wenn den Agen starte, steht leider nicht viel im Protokoll drin:
Folgendes passiert, wenn dieser Agent gestartet wird:
Agent 'Protokoll_Agent' wurde am 04.12.2003 10:32:38 gestartet
Testen: LotusScript Code ausgeführt
Agent 'Protokoll_Agent' wurde am 04.12.2003 10:32:38 beendet
Gruß
Nyen
nyen:
Hallo Andreas,
also, ich kann bei kein Dokument mi dem Feld mit WhenDeleted fesstelllen. Meinst du hängt es möglicheweise damit zusammen?
Gruß
Nyen
Navigation
[0] Themen-Index
[#] Nächste Seite
Zur normalen Ansicht wechseln