Option Public
Option Declare
Sub Initialize
Dim session As New NotesSession
Dim serverName As String
Dim commandString As String
Dim returnString As String
serverName = ""
commandString = "show tasks -xml"
returnString = session.SendConsoleCommand(serverName, commandString)
Dim inputStream As NotesStream
Dim outputStream As NotesStream
Dim domParser As NotesDOMParser
Dim docNode As NotesDOMDocumentNode
Dim taskNode As NotesDOMNode
Dim taskdataNode As NotesDOMNode
Dim taskName As String
Dim taskDesc As String
Dim taskAddinName As String
Dim taskPid As String
Dim taskTid As String
Dim taskList List As String
Dim pidtid As String
Dim crlf As String
crlf = Chr(13) & Chr(10)
Set inputStream = session.CreateStream
Call inputStream.WriteText(returnString)
inputStream.Position = 0
Set outputStream = session.CreateStream
Set domParser=session.CreateDOMParser(inputStream, outputStream)
domParser.Process
Set docNode = domParser.Document
Set taskNode = findChildNode(docNode, "tasks")
If (taskNode.IsNull) Then
Print "Sorry, I didn't find any <task> nodes. Here's what I found:<p><hr><p>"
Print "<pre>" & returnString & "</pre>"
Exit Sub
End If
Set taskdataNode = taskNode.FirstChild
Do Until (taskdataNode.IsNull)
If (taskdataNode.NodeType = DOMNODETYPE_ELEMENT_NODE) And _
(taskdataNode.NodeName = "taskdata") Then
taskName = getNodeText(findChildNode(taskdataNode, "name"))
taskDesc = getNodeText(findChildNode(taskdataNode, "description"))
taskAddinName = getAttributeText(taskdataNode, "addin")
taskPid = getAttributeText(taskdataNode, "pid")
taskTid = getAttributeText(taskdataNode, "tid")
If (taskAddinName <> "") Then
taskName = taskName & " (" & taskAddinName & ")"
End If
pidtid = "<ul><li>pid: " & taskPid & "</li><li>tid: " & taskTid & "</li></ul>"
taskList(taskName) = taskList(taskName) & "<li class='closed'>" & taskDesc & _
pidtid & "</li>" & crlf
End If
Set taskdataNode = taskdataNode.NextSibling
Loop
If (serverName = "") Then
Dim sname As New NotesName(session.CurrentDatabase.Server)
serverName = sname.Abbreviated
End If
Print |<ul class='tree'><h3>Task List for Server | & serverName & |</h3>|
Forall task In taskList
Print "<li class='closed'><b>" & Listtag(task) & "</b>" & crlf & "<ul>" & task & "</ul></li>"
End Forall
Print |</ul>|
End Sub
Function getNodeText (node As NotesDOMNode) As String
Dim child As NotesDOMNode
Dim childText As String
If (node Is Nothing) Then
Exit Function
Elseif (node.IsNull) Then
Exit Function
End If
Set child = node.FirstChild
Do Until (child.IsNull)
If (child.NodeType = DOMNODETYPE_TEXT_NODE) Then
childText = childText + child.NodeValue
Elseif (child.NodeType = DOMNODETYPE_CDATASECTION_NODE) Then
childText = childText + child.NodeValue
End If
Set child = child.NextSibling
Loop
getNodeText = childText
End Function
Function getAttributeText (node As NotesDOMNode, attrName As String) As String
Dim attrList As NotesDOMNamedNodeMap
Dim attr As NotesDOMNode
Dim attrValue As String
Dim i As Integer
If (node Is Nothing) Then
Exit Function
Elseif (node.IsNull) Then
Exit Function
End If
Set attrList = node.Attributes
For i = 1 To attrList.NumberOfEntries
Set attr = attrList.GetItem(i)
If (attr.NodeName = attrName) Then
attrValue = attr.NodeValue
End If
Next
getAttributeText = attrValue
End Function
Function findChildNode (node As NotesDOMNode, childName As String) As NotesDOMNode
Dim child As NotesDOMNode
If (node Is Nothing) Then
Exit Function
Elseif (node.IsNull) Then
Exit Function
End If
Set child = node.FirstChild
Do Until (child.IsNull)
If (child.NodeName = childName) Then
Exit Do
End If
Set child = child.NextSibling
Loop
Set findChildNode = child
End Function
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.