Autor Thema: NotesDocumentCollection.Merge - Bug?  (Gelesen 2691 mal)

Offline wrangel

  • Aktives Mitglied
  • ***
  • Beiträge: 100
    • Homepage
NotesDocumentCollection.Merge - Bug?
« am: 05.08.11 - 16:07:25 »
Ich habe ja bislang einen Bogen um das Rechnen mit den NDCs gemacht. Zurecht?

Nun versuche ich, zwei DCs zusammen zu bringen. Merge sollte funktionieren. Ich stoße alledings auf ein interessantes Phänomen.
Nehme ich den Code aus der Designer Hilfe, ändere das ein wenig, damit es in meine Datenbank passt, funktioniert es.

Code
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim dc1 As NotesDocumentCollection
Dim dc2 As NotesDocumentCollection
Dim doc1 As NotesDocument
Dim monthago As New NotesDateTime("")
monthago.SetNow
Call monthago.AdjustMonth(-1)
' Not the most efficient way to find all customers where LastSale
' or LastCall was < one month ago, but it's just an example.
Dim searchFormula As String
searchFormula = {Subject="Test1"}
Set dc1 = db.Search(searchFormula,Nothing,0)
searchFormula = {Subject="Test2"}
Set dc2 = db.Search(searchFormula,Nothing, 0)
Call dc1.Merge(dc2)
MessageBox "dc1: " & dc1.count & Chr(10) & "dc2: " & dc2.count
   
Das ergibt als Antwort dc1: 2 und dc2: 1. Funktioniert also, wie erwartet.

Ändere ich jedoch die Suche und gehe auf den FT

Code
searchFormula = {Test1}
Set dc1 = db.FTSearch(searchFormula,0)

dann bekomme ich die Fehlermeldung:

Zitat
"Invalid object type for method argument"

beim Aufruf von Merge.

Wisst ihr, was das soll?
Jan Michael Wrangel | IT Beratung
Lotus Notes/Domino Administration, Entwicklung und Systemarchitektur

jan.michael@wrangel.de

Offline wrangel

  • Aktives Mitglied
  • ***
  • Beiträge: 100
    • Homepage
Re: NotesDocumentCollection.Merge - Bug?
« Antwort #1 am: 05.08.11 - 16:40:16 »
Hier mein schneller Workaround für das Merge Problem:

Code
Sub dcmerge( dc1 As NotesDocumentCollection, dc2 As NotesDocumentCollection )
On Error GoTo ErrorThrower
On Error 4469 Resume Next '// Document already in collection
Dim doc As NotesDocument
Set doc = dc2.Getfirstdocument()
While Not doc Is Nothing
Call dc1.addDocument( doc )
Set doc = dc2.getnextdocument( doc )
Wend
Exit Sub
ErrorThrower:
Error Err, CStr( Err) & " " & Error & Chr(13) + "Module: " &_
CStr( GetThreadInfo(1) ) & ", Line: " & CStr( Erl )
End Sub

Je nach Größe der Collection kann das schon mal dauern...  :P
Jan Michael Wrangel | IT Beratung
Lotus Notes/Domino Administration, Entwicklung und Systemarchitektur

jan.michael@wrangel.de

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz