Domino 9 und frühere Versionen > ND8: Entwicklung
"Notes-Fehler: Ein anderer Benutzer hat dieses Dokument zur gleichen Zeit..."
Bruce Willis:
--- Zitat von: Peter Klett am 10.01.12 - 12:51:23 ---Das ändert aber nichts daran...
--- Ende Zitat ---
Hallo Peter,
das ist mir klar, ich wollte zuerst mein Feedback liefern und dann bei Dir bedanken. Konnte aber nicht rechtzeitig, da ich unerwartete eilige Probleme fixen musste.
Vielen Dank für Deine ausführlichen Erklärungen und Deinen interessanten Vorschlag !
Ich probiere ihn heute oder morgen zu implementieren.
Gruß
Leo
ea234:
Moin,
alternative Lösung: In der Zieldatenbank ein neues Notesdokument erstellen und das zu kopierende Dokument dort reinschreiben.
Private Function notesCopyToDatabdaseV2( pNotesDokument As NotesDocument, pNotesDatenbank As NotesDatabase, pNotesOrdner As String ) As Boolean
On Error Goto errNotesCopyToDatabdaseV2:
'
' Dokument in Ziel-DB
' Die Variable fuer das zu erstellende Ziel-Dokument ist Funktionsglobal, da
' dieses Dokument bei einem Fehler aus der Ziel-Datenbank geloescht wird.
'
Dim neues_notes_dokument As NotesDocument
set neues_notes_dokument = Nothing
notesCopyToDatabdaseV2 = false
If ( pNotesDatenbank Is Nothing ) Then
'
' Zieldatenbank nicht gesetzt. Es wird keine Kopie erstellt.
'
Else
call print( "CopyToDatabaseV2: Erstellung des Zieldokumentes " )
'
' Notesfunktion "Copytodatabase"
'
' Fehler: "Someone else modified this document at the same time"
' "Ein anderer Benutzer hat dieses Dokument zur gleichen Zeit geändert"
'
' http://atnotes.de/index.php?action=printpage;topic=53412.0
'>
'> Zur Fehlermeldung:
'>
'> http://www-01.ibm.com/support/docview.wss?uid=swg21096316
'>
'> This issue was reported to Quality Engineering as SPR# ASHW4X9P8R and was fixed
'> in Lotus Notes/Domino 6.0.4, 6.5.2, 7.0, and later releases, by the addition of
'> an optional notes.ini parameter. The following notes.ini parameter forces a new
'> UNID to be created for a document after being copied to the destination database:
'>
'> CopyToDatabase_New_UNID=1
'>
'> Workaround for versions prior to 6.5.2 and 6.0.4:
'> If the CopyToDatabase method is used to copy the same document ( to the same database )
'> more than once, the additional document copies will be given entirely unique UNIDs
'> which will not repeat if the process itself is repeated. This fact can be used to
'> work around this issue by calling the method twice and then removing the first document
'> copied. The only possible detriment to the example below is the additional deletion
'> stubs that are created. This method is still recommended as it is very straightforward
'> and reliable.
'>
'> set tempdoc = doc.CopyToDatabase( db )
'>
'> set newdoc = doc.CopyToDatabase( db )
'>
'> Call tempdoc.Remove( true )
'>
'
' FAZIT: Die Funktion "Copytodatabase" von Lotus-Notes bereitet nur mehr Probleme als
' was sie hilft.
'
' Sich auf eine Einstellung in der INI-Datei zu verlassen ist eine schlechte Loesung
'
' Das zweimalige kopieren schlug fehl. Das ist wahrscheinlich auf eine zerspielte Umgebung
' zurueckzufuehren, aber zeigt, dass man sich auch darauf nicht verlassen sollte.
'
'
' LOESUNG: Es wird in der Zieldatenbank ein neues Notesdokument erstellt, welches
' die Notesfelder des zu kopierenden Dokumentes bekommt.
'
'set neues_notes_dokument = pNotesDokument.CopyToDatabase( pNotesDatenbank )
'
set neues_notes_dokument = pNotesDatenbank.CreateDocument()
If ( neues_notes_dokument Is Nothing ) Then
call print( "CopyToDatabaseV2: neues_notes_dokument Is Nothing - Es konnte kein Dokument in der Zieldatenbank erstellt werden. CTDF1" )
Else
call print( "CopyToDatabaseV2: neues_notes_dokument gesetzt - Neues Dokument wurde in der Zieldatenbank erstellt. CTDOK1" )
'
' Kopieren der Inhalte
' Alle Notesfelder aus dem Quelldokument werden in das neu erstellte
' Dokument in der Zieldatenbank kopiert. Die Universal-ID wird vor
' dem Kopieren gesichert, damit diese ID nach dem kopieren wieder
' restauriert werden kann.
'
' Ziel ist es hier, alle Items kopiert zu haben, aber die neue ID zu behalten.
'
Dim dokumenten_id_ziel_dok As String
dokumenten_id_ziel_dok = neues_notes_dokument.UniversalID
Call pNotesDokument.CopyAllItems( neues_notes_dokument, true )
neues_notes_dokument.UniversalID = dokumenten_id_ziel_dok
Call neues_notes_dokument.save( true, true )
DoEvents
'
' Optionales verschieben in einen Ordner
'
If ( pNotesOrdner = "" ) Then
'
' Wurde kein Ordner uebergeben, wird das Funktionsergebnis
' auf TRUE gestellt.
'
notesCopyToDatabdaseV2 = true
Else
'
' Wurde ein Ordner uebergeben, wird das Dokument in den
' Order ueberstellt. Wird die Funktion "PutInFolder" ohne
' Fehler ausgefuehrt, wird das Funktionsergebnis auf
' TRUE gestellt.
'
Call neues_notes_dokument.PutInFolder( pNotesOrdner, true )
call print( "CopyToDatabaseV2: neues_notes_dokument in Ordner verschoben. CTDOK3" )
notesCopyToDatabdaseV2 = true
End If
End If
End If
EndFunktion:
On Error Resume Next
'
' Dokumenteninstanz auf Nothing setzen
'
set neues_notes_dokument = Nothing
DoEvents
Exit Function
errNotesCopyToDatabdaseV2:
call print( "Fehler: errNotesCopyToDatabdaseV2: " & Err & " " & Error & " " & Erl )
'
' Fehlerbehandlung
' Ist es bei der Funktion "PutInFolder" zu einem Fehler gekommen, wird das
' kopierte Notes-Dokument in der Zieldatenbank geloescht.
'
' Die Fehlerbehandlung wird auf "On Error Resume Next" gestellt.
' Es wird nur ein Versuch gemacht, das kopierte Dokment zu loeschen.
'
If ( neues_notes_dokument Is Nothing ) Then
call print( "CopyToDatabaseV2: Fehler CTDF1B: neues_notes_dokument Is Nothing - Dokument wurde nicht in die Zieldatenbank kopiert. " )
Else
On Error Resume Next
If ( neues_notes_dokument.Remove( true ) ) Then
call print( "CopyToDatabaseV2: Fehler CTDF2A: neues_notes_dokument.Remove() = OK " )
Else
call print( "CopyToDatabaseV2: Fehler CTDF2B: Das schon kopierte Notesdokument konnte nicht aus der Zieldatenbank entfernt werden. DOPPELTES_DOKUMENT_IN_ZIELDATENBANK" )
End If
End If
Resume EndFunktion
End Function
Navigation
[0] Themen-Index
[*] Vorherige Sete
Zur normalen Ansicht wechseln