Examples: Process method

  1. This agent, demonstrating the NotesDXLExporter process, generates DXL from a note collection based on the content of the current database.
    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Set db = session.CurrentDatabase
      
      REM Open xml file named after current database
      Dim stream As NotesStream
      Set stream = session.CreateStream
      filename$ = "c:\dxl\" & _
      Left(db.FileName, Len(db.FileName) - 3) & "xml"
      If Not stream.Open(filename$) Then
        Messagebox "Cannot open " & filename$,, "Error"
        Exit Sub
      End If
      Call stream.Truncate
      
      REM Create note collection for current database
      Dim nc As NotesNoteCollection
      Set nc = db.CreateNoteCollection(False)
      Call nc.SelectAllDesignElements(True)
      Call nc.BuildCollection
      
      REM Export note collection as DXL
      Dim exporter As NotesDXLExporter
      Set exporter = session.CreateDXLExporter(nc, stream)
      Call exporter.Process
    End Sub
  2. This example demonstrates the NotesDXLImporter process. The code is on a form. Two fields provide the pathname of an input file and the name of an output database. A "Process" button sets the input and output parameters for a NotesDXLImporter object and calls its Process method.
    Dim session As NotesSession
    Dim ws As NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim importer As NotesDXLImporter
    Dim stream As NotesStream
    Dim db As NotesDatabase
    
    Sub Initialize
      Set session = New NotesSession
      Set ws = New NotesUIWorkspace
      Set importer = session.CreateDXLImporter
    End Sub
    
    Function SetInput As Boolean
      Set stream = session.CreateStream
      fileName$ = uidoc.FieldGetText("InputFile")
      If Not stream.Open(fileName$) Then
        Messagebox "Cannot open file",, fileName$
        SetInput = False
        Exit Function
      End If
      If stream.Bytes = 0 Then
        Messagebox "File did not exist or was empty",, fileName$
        SetInput = False
        Exit Function
      End If
      Call importer.SetInput(stream)
      SetInput = True
    End Function
    
    Function SetOutput As Boolean
      Set db = New NotesDatabase("", "")
      fileName$ = uidoc.FieldGetText("OutputDatabase")
      If Not db.Open("", fileName$) Then
        Call db.Create("", fileName$, True)
      End If
      Call importer.SetOutput(db)
      SetOutput = True
    End Function
    
    Sub Postopen(Source As Notesuidocument)
      Set uidoc = ws.CurrentDocument
    End Sub
    
    Sub Click(Source As Button)
    REM This is the "Process" button
      If Not SetInput Then Exit Sub
      If Not SetOutput Then Exit Sub
      Call importer.Process
    End Sub