Examples: NotesDXLImporter class

  1. This agent imports DXL from a file into a newly created database.
    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim dbCopy As NotesDatabase
      Set db = session.CurrentDatabase
      filename$ = Left(db.FileName, Len(db.FileName) - 4)
      
      REM Open dxl file named after current database
      Dim stream As NotesStream
      Set stream = session.CreateStream
      If Not stream.Open("c:\dxl\" & filename$ & ".dxl") Then
        Messagebox "Cannot open " & filename$,, "Error"
        Exit Sub
      End If
      If stream.Bytes = 0 Then
        Messagebox "File did not exist or was empty",, filename$
        Exit Sub
      End If
      
      REM Create new database named current database   + "Copy"
      Set dbCopy = New NotesDatabase("", "")
      Call dbCopy.Create("", filename$ & "Copy", True)
      
      REM Import DXL into new database
      Dim importer As NotesDXLImporter
      Set importer = session.CreateDXLImporter(stream, dbCopy)
      importer.ReplaceDBProperties = True
      importer.ReplicaRequiredForReplaceOrUpdate = False
      importer.ACLImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE
      importer.DesignImportOption = DXLIMPORTOPTION_CREATE
      Call importer.Process
    End Sub

    The file generated by the NotesDXLExporter class example can be imported using this code.

  2. This agent exports DXL to a stream then imports the DXL into a newly created database.
    Dim session As NotesSession
    Dim db As NotesDatabase
    Dim stream As NotesStream
    
    Sub Initialize
      Set session = New NotesSession
      Set db = session.CurrentDatabase
      Set stream = session.CreateStream
      Call exportDatabase
      Call importDatabaseCopy
    End Sub
    
    Sub exportDatabase
      Dim exporter As NotesDXLExporter
      Set exporter = session.CreateDXLExporter
      Call exporter.SetInput(db)
      Call exporter.SetOutput(stream)
      Call exporter.Process
    End Sub
    
    Sub importDatabaseCopy
      REM Create new database named after current database
      Dim dbCopy As NotesDatabase
      filename$ = Left(db.FileName, Len(db.FileName) - 4)
      Set dbCopy = New NotesDatabase("", "")
      Call dbCopy.Create("", filename$ & "Copy", True)
      
      REM Import DXL into new database
      Dim importer As NotesDXLImporter
      Set importer = session.CreateDXLImporter
      Call importer.SetInput(stream)
      Call importer.SetOutput(dbCopy)
      importer.ReplaceDBProperties = True
      importer.ReplicaRequiredForReplaceOrUpdate = False
      importer.ACLImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE
      importer.DesignImportOption = DXLIMPORTOPTION_CREATE
      Call importer.Process
    End Sub
  3. This agent creates a DXL export (containing only documents) then pipelines the DXL into an existing database.
    Sub Initialize
      Dim session As NotesSession
      Dim db As NotesDatabase
      Dim nc As NotesNoteCollection
      Dim exporter As NotesDXLExporter
      Dim importer As NotesDXLImporter
    
    
      Set session = New NotesSession
      Set db = session.CurrentDatabase
      Set nc = db.CreateNoteCollection(False)
      nc.SelectDocuments = True
      Call nc.BuildCollection
    
      REM Set up importer to receive DXL piped from exporter
      REM and to re-import the documents back into the 
      REM current database as copies.
      Set exporter = session.CreateDXLExporter(nc)
      Set importer = session.CreateDXLImporter(exporter, db)
      exporter.Process
    End Sub