Das Notes Forum
Domino 9 und frühere Versionen => ND7: Entwicklung => Thema gestartet von: Fedaykin am 23.05.07 - 08:12:43
-
Hallo zusammen
Warscheinlich hat von euch auch niemand eine Idee. Aber suche eine Möglichkeit zu unterscheiden ob ein QuerySave wegen Speichern aufgerufen wurde oder vor dem Schliessen eines Dokumentes. Geht dabei darum, dass ich im Fontend beim Speichern einen Anhang austauschen will (um Dokument editieren in LotusScript nachzubauen). Nur ohne diese Information ist das ziemlich Hoffnungslos.
Gruss
Remo
-
Wenn die Steuerung über Aktionen ausgeführt wird kannst du ein Feld entsprechend setzen und auswerten. Passiert das Ganze aber über das Menü oder über Tastaturbefehle (z.B. ESC-Taste) sehe ich wenig Chancen.
Was soll denn das werden? Vielleicht findet sich ja noch ein anderer Weg.
Axel
-
den einzigsten weg den ich sehe ist wie von axel beschrieben, ein feld zu setzen und im querysave dann darauf zu reagieren. allerdings musst du das feld dann immer am ende des query save löschen.
aber schreib mal was genau wann passieren soll im query save, eigentlich könntest du unterbinden das der user strg+s saved dann muss er immer den button benutzen, dann baust dort die logik ein.
-
Soll die Routine ImportNewerAttachment aufgerufen werden. Hier der Code dazu.
Sub ImportNewerAttachment()
Dim ws As NotesUIWorkspace
Dim Source As NotesUIDocument
Dim fso As Variant
Dim doc As NotesDocument
Dim varFile As Variant
Dim item As NotesItem
Dim rtitem As NotesRichTextItem
Dim eo As NotesEmbeddedObject
Set ws=New NotesUIWorkspace
Set Source=ws.CurrentDocument
Set doc=source.Document
If doc.HasItem("DateLastModified") Then
Set fso=createobject("Scripting.FileSystemObject")
Set varFile=fso.getFile(doc.FilePath(0))
If Not varFile.DateLastModified=doc.DateLastModified(0) Then
AddAttachment ws,"frmNeedAnalysis","fdAttachment",doc.FilePath(0)
Set doc=ws.CurrentDocument.Document
Print "Neu Importiert!"
' doc.ReplaceItemValue "DateLastModified", varFile.DateLastModified
' doc.ReplaceItemValue "FilePath", FileName
' doc.RemoveItem "DateLastModified"
' doc.RemoveItem "FilePath"
End If
'Print Source.Document.DateLastModified(0)
End If
End Sub
Sub AddAttachment(uiws As NotesUIWorkspace, FormName As String,ItemName As String,FileName As String)
Dim uidoc As NotesUIDocument
Dim ws As New NotesUIWorkspace
Dim thisdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim olduidoc As NotesUIDocument
Set olduidoc=uiws.CurrentDocument
Set thisdoc = uiws.CurrentDocument.Document ' doc in memory but hasn't been saved yet
thisdoc.RemoveItem ItemName
Set rtitem = New NotesRichTextItem (thisdoc,ItemName)
rtitem.EmbedObject EMBED_ATTACHMENT, "", FileName
rtitem.Update
thisdoc.Form=FormName
' set the SaveOptions field so that when the uidoc is closed, the user won't be asked to save
thisdoc.SaveOptions = "0"
' close the uidoc. It won't actually happen until the code is finished executing
olduidoc.Close True
' create a new uidoc and open the backend doc that is still in memory with added doc link
Set uidoc = uiws.EditDocument(True, thisdoc)
' delete the reference to the old uidoc
' this is necessary because the code below affects it if left in memory
Delete olduidoc
' re-associate the variable with the backend doc
' have to do this because the olduidoc reference was deleted
Set thisdoc = uidoc.Document
' remove the SaveOptions field so the doc can be saved
thisdoc.RemoveItem "SaveOptions"
uidoc.Refresh
End Sub
Damit nach der Routine EditAttachment das Zeug wieder importiert wird.
Sub EditAttachment
Dim ws As NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim rtitem As NotesRichTextItem
Dim strFileName As String
Dim fso As Variant
Dim wsh As Variant
Dim varFile As Variant
Dim ret As Variant
Set ws=New NotesUIWorkspace
Set uidoc=ws.CurrentDocument
Set doc=uidoc.Document
Set item=doc.GetFirstItem("fdAttachment")
If item.Type=1 Then
Set rtitem=item
Forall eo In rtitem.EmbeddedObjects
Set fso=createobject("Scripting.FileSystemObject")
Set wsh=createobject("WScript.Shell")
strFileName=Environ("Temp") & "\" & eo.Name
eo.ExtractFile strFileName
Set varFile=fso.getfile(strFileName)
doc.ReplaceItemValue "DateLastModified", varFile.DateLastModified
doc.ReplaceItemValue "FilePath",strFileName
ret=wsh.run (strFileName,1)
Exit Forall
End Forall
End If
End Sub
Das Problem ist klar. NOTESUIDOCUMENT MUSS GESCHLOSSEN WERDEN UM IM FONTEND WAS ANZUHAENGEN. Nur dadurch geht natürlich das Schliessen was danach ablaufen sollte verloren. :'(
Gruss
Remo
-
Hallo zusammen
Danke für die Antworten, habe alles nochmal verworfen und mit anderem Ansatz nochmal versucht. Bisher konnt ich den gut verfolgen und scheint als ob ich es nun ziemlich hin bekomme.
Gruss
Remo
-
hi!
sorry bin erst jetzt dazugekommen mit den script anzusehen. eigentlich war ja da schon alles fertig. wenn du darauf verzichten hättest können das attachment sofort sichtbar zu machen...
weil schließen und wieder öffnen musst ja nur damit das ergebniss gleich siehst, nicht damits gespeichert ist...