Domino 9 und frühere Versionen > ND7: Entwicklung

Code per Skript exportieren und einbinden

<< < (3/5) > >>

Johnson:
Das interessiert mich jetzt selber. Ich probiere das heute mal aus.

Johnson:
Und eh ich es vergesse. Kompilieren geht mit der Funktion NSFNoteLSCompile bzw. NSFNoteLSCompileExt.
Aber eine Library einzeln zu kompilieren kann auch noch andere "nette" Nebeneffekte haben. Wie z.B. "type mismatch on external name"....

Dann ist es besser die gesamte Datenbank zu komilieren.

Johnson:
Also. Ich wollte erst noch was anderes versuchen. Und siehe da:  :o Mit einem DXL-Export bekommt man eine sauberes lss-File.


--- Code: ---Sub Initialize
   
    Dim db As NotesDatabase
    Dim doc_lss As NotesDocument
    Dim nddn As NotesDOMDocumentNode
    Dim nde As NotesDXLExporter
    Dim ndp As NotesDOMParser
    Dim nnc As NotesNoteCollection
    Dim ns As NotesStream
    Dim s As NotesSession
    Dim str_dxl As String
    Dim str_noteid As String
    Dim var_lotusscript As Variant
   
    Const LSS_FILEPATH = "C:\lib.lss"
    Const LIB_NAME = "lss"
   
   
' ### initialize ###
   
    Set s = New NotesSession
    Set db = s.CurrentDatabase
   
   
' ### build note collection ###
   
    Set nnc = db.CreateNoteCollection(False)
    nnc.SelectScriptLibraries = True
    Call nnc.BuildCollection
   
   
' ### get lss library ###
   
    str_noteid = nnc.GetFirstNoteId
    Do Until str_noteid = ""
       
        Set doc_lss = db.GetDocumentByID(str_noteid)
        If Not(doc_lss Is Nothing) Then
            If doc_lss.~$Title(0) = LIB_NAME Then Exit Do
        End If
       
        str_noteid = nnc.GetNextNoteId(str_noteid)
    Loop
    If doc_lss Is Nothing Then Goto terminate
   
   
' ### get lotus script code ###
   
' create dxl exporter
    Set nde = s.CreateDXLExporter
    nde.ValidationStyle = VALIDATIONSTYLE_NONE
    nde.OutputDOCTYPE = True
    nde.DoctypeSYSTEM = ""
   
' export to string
    str_dxl = nde.Export(doc_lss)
   
' create a new dom parser object
    Set ndp = s.CreateDOMParser(str_dxl)
    Call ndp.Parse
   
' get the noted dom document note
    Set nddn = ndp.Document
   
' get lotus script code
    var_lotusscript = GetLotusScriptCode(nddn)
   
   
' ### create lss file ###
   
    Set ns = s.CreateStream
    If ns.Open(LSS_FILEPATH) = False Then Goto terminate
   
    Forall str_line In var_lotusscript
        Call ns.WriteText(Cstr(str_line))
    End Forall
   
    Call ns.Close
   
   
' ### terminate ###
   
terminate:
    Set db = Nothing
    Set doc_lss = Nothing
    Set nddn = Nothing
    Set nde = Nothing
    Set ndp = Nothing
    Set nnc = Nothing
    Set ns = Nothing
    Set s = Nothing
   
End Sub

Function GetLotusScriptCode(nddn As NotesDOMDocumentNode) As Variant
   
    Dim astr_code() As String
    Dim lng_code As Long
    Dim ndnl As NotesDOMNodeList
    Dim ndelement As NotesDOMElementNode
    Dim ndn_code As NotesDOMNode
   
   
' ### search lotusscript tags ###
   
    Set ndnl = nddn.GetElementsByTagName("lotusscript")
    If ndnl.NumberOfEntries = 0 Then Goto terminate
   
    Redim astr_code(ndnl.NumberOfEntries - 1)
    For lng_code = 1 To ndnl.NumberOfEntries
        Set ndelement = ndnl.GetItem(lng_code)
        If ndelement.HasChildNodes Then
            Set ndn_code = ndelement.FirstChild
            If Not(ndn_code.IsNull) Then
                astr_code(lng_code - 1) = ndn_code.NodeValue
            End If
        End If
    Next
   
   
' ### return value ###
   
    If lng_code > 1 Then GetLotusScriptCode = astr_code
   
   
' ### terminate ###
   
terminate:
    Set ndnl = Nothing
    Set ndelement = Nothing
    Set ndn_code = Nothing
    Exit Function
   
End Function
--- Ende Code ---

Aber dein größeres Problem ist der Import. Den kannst du auch über einen DXL Export/Import erledigen:
1. Designelement als DXL exportieren.
2. DXL bearbeiten.
3. DXL in das Designelement wieder importieren.
4. Kompilieren (Viel Spaß)

Dafür noch mal eine dumme Frage (denn ich glaube, dass ihr auch schon daran gedacht habt). Wenn es so wichtig ist, dass euer Kunde den Code nicht sehen kann, warum versteckt ihr nicht einfach das Design der Templates?

Denn dir ist schon klar, dass dabei der Code überall da "includet" wird, wo die Library (Libraries) aufgerufen wird (werden).
=> Das Design der Datenbank wird aufgebläht.

Ebenso kann das Designelement, dass das lss-File "includet", nicht geändert/gespiechert/kompiliert werden, wenn man das lss-File nicht im Programmverzeichnis von Notes hat.
=> Änderungen am Design sind dann unmöglich. Also warum nicht gleich das Design verstecken?

koehlerbv:
Statt "hide design" kann man auch einfach den Klartext des LotusScript-Routinen entfernen (Tool / eigenes Programm vorausgesetzt). Mit "hide design gibt es ja immer mal wieder Probleme und schliesst den Kunden zudem ganz von Änderungen aus ...

Bernhard

Johnson:
Dumme Frage die 2.: Was meinst du mit "Klartext des LotusScript-Routinen entfernen" Bernhard?

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln