Autor Thema: 2 Probleme: Shell() sowie NotesRichTextItem.EmbedObject  (Gelesen 2862 mal)

Offline machineslave

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Männlich
Hallo,

folgendes Szenario:

Ich möchte in einem Dokument über einen Button die Notes.ini eines Servers dem Dokument als Anhang zufügen.
In u.a. Script soll er folgendes tun: per FTP die notes.ini ins c:\temp Verzeichnis speichern und dann diese Datei in ein RichText-Feld als Anhang zufügen.

Nun zu den beiden Problemen:

1. Wenn das Script über Shell() aufgerufen wird (was funktioniert), weiss ich nicht, wann dieses fertig ist. Ich weiss also nicht, wann die Datei per ftp auf meinen Rechner übertragen wurde.

2. Wenn die Datei da ist und der Befehl
   Set object = rtitem.EmbedObject ( 1454, "", "c:\temp\notes.ini")
ausgeführt wird, so wird die Datei nicht im Richtext-Feld gespeichert, sondern unterhalb des Dokumentes angehängt.

Anbei mal mein Code aus dem onClick-Event des Buttons:

   Dim ws As New NotesUIWorkspace
   Dim uiDoc As NotesUIDocument
   Dim doc As NotesDocument
   Set uiDoc = ws.CurrentDocument
   Set doc = uiDoc.Document
   
   Dim rtitem As NotesRichTextItem
   Dim object As NotesEmbeddedObject
   Call doc.RemoveItem("notesIni")
   Set rtitem = doc.CreateRichTextItem("notesIni")
   
   If doc.ServerType(0) = "Sun" Then
      Dim fileNum As Integer
      fileNum% = Freefile()
      Open "c:\temp\ftp.txt" For Output As fileNum%
      Print #fileNum%, "open " + doc.hostname(0)
      Print #fileNum%, doc.Administrator(0)
      Print #fileNum%, doc.AdministratorPassword(0)
      Print #fileNum%, "prompt"
      Print #fileNum%, "lcd c:\temp"
      aPath = doc.DominoDataDirectory(0)
      If Right(aPath, 1) <> "/" Then
         aPath = aPath + "/"
      End If
      Print #fileNum%, "mget " + aPath + "notes.ini"
      Print #fileNum%, "quit"
      Close fileNum%
      Dim taskId As Integer      
      taskId% = Shell("ftp -s:c:\temp\ftp.txt", 1)
      found = True                       ' NUR FÜR TESTZWECKE
      If found Then
         Set object = rtitem.EmbedObject ( 1454, "", "c:\temp\notes.ini")
         Kill "c:\temp\notes.ini"
         Kill "c:\temp\ftp.txt"
      Else
         Messagebox "Notes.ini not found, please try again."
      End If   
   End If
Stefan

Das Leben ist ein Scheiß Spiel, aber die Grafik ist geil

Offline Fedaykin

  • Aktives Mitglied
  • ***
  • Beiträge: 229
  • Geschlecht: Männlich
  • Ya Hya Chouhada!
Re: 2 Probleme: Shell() sowie NotesRichTextItem.EmbedObject
« Antwort #1 am: 22.03.07 - 14:03:43 »
Zum Shell Problem, vielleicht hilft der Link http://www.freevbcode.com/ShowCode.Asp?ID=99 und das mit Anhang im FontEnd an RTItem Anhängen ist wirklich echt übel tricky. Aber hab hier mal eine Funktion.

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 False
   ' 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

Hoffe hilft weiter.

Gruss
Remo
Ich sage Euch: "Man muss noch Chaos in sich haben, um einen tanzenden Stern gebären zu können."

Offline machineslave

  • Senior Mitglied
  • ****
  • Beiträge: 328
  • Geschlecht: Männlich
Re: 2 Probleme: Shell() sowie NotesRichTextItem.EmbedObject
« Antwort #2 am: 27.03.07 - 10:05:07 »
Hallo Remo,

vielen Dank, beide Tips haben mir bei dem Problem geholfen.

Gruß

Stefan
Stefan

Das Leben ist ein Scheiß Spiel, aber die Grafik ist geil

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz