Private s As NotesSession
Private db As NotesDatabase
Private m_key As String
Const V_ISAVAILABLE="vIsAvailable"
Const V_LIST="vLstXMLGrid"
Const V_DETAILS="vLstXMLDetail"
Const ALOG="alog.nsf"
Const SEPARATOR="#%"
Class Skeleton
Private result As Variant
Private strErrMsg As String
Private Sub throwFault (fault As WS_FAULT, faultText As String)
Call fault.setFault(True)
Call fault.setFaultString(faultText)
End Sub
Private Function chkElements(isNo As Integer, ShouldBe As Integer, returnFault As WS_FAULT) As Boolean
If(isNo=shouldBe) Then
chkElements=True
Else
strErrMsg=m_key & " - Returned " & isNo+1 & " elements, but should have returned: " & shouldBe+1 & " elements"
Dim logIt As New logError(Lsi_info(2), Lsi_info(12), "Unexpected number of elements", strErrMsg, Lsi_info(1))
Call throwFault(returnFault, strErrMsg)
chkElements=False
End If
End Function
Private Function strIsEmpty(strInfo As String, returnFault As WS_FAULT) As Boolean
If(strInfo="") Then
strErrMsg=m_key & " - doesn't contain any data!"
Dim logIt As New logError(Lsi_info(2), Lsi_info(12), "Missing Data", strErrMsg, Lsi_info(1))
Call throwFault(returnFault, strErrMsg)
strIsEmpty=True
Else
strIsEmpty=False
End If
End Function
Private Function viewIsAvailable(view As NotesView, viewName As String, returnFault As WS_FAULT) As Boolean
If(view Is Nothing) Then
strErrMsg=viewName & " - doesn't exist in database " & db.FilePath &"!"
Dim logIt As New logError(Lsi_info(2), Lsi_info(12), "Missing Data", strErrMsg, Lsi_info(1))
Call throwFault(returnFault, strErrMsg)
viewIsAvailable=False
Else
viewIsAvailable=True
End If
End Function
Private Function entryIsAvailable(obj As Variant, key As String, returnFault As WS_FAULT) As Boolean
If(obj Is Nothing) Then
strErrMsg=key & " - doesn't exist!"
Dim logIt As New logError(Lsi_info(2), Lsi_info(12), "Missing Data", strErrMsg, Lsi_info(1))
Call throwFault(returnFault, strErrMsg)
entryIsAvailable=False
Else
entryIsAvailable=True
End If
End Function
Private Function getdate(strDate As String) As XSD_DATETIME
If(strDate<>"") Then
Dim dt As New NotesDateTime(strDate)
Set getdate = New XSD_DATETIME
Call getdate.SetValueFromNotesDateTime(dt)
End If
End Function
End Class
Class Detail As Skeleton
Public action_comment As String
Public action_cost As String
Public action_responsible As String
Public complainer_adress As String
Public complainer_epost As String
Public complainer_fnr As String
Public complainer_namn As String
Public complainer_postadress As String
Public complainer_tele As String
Public doc_action As String
Public doc_description As String
Public doc_loggedby As String
Public doc_recap As String
Public doc_rubrik As String
Public end_datefinished As XSD_DATETIME
Public end_terminatedby As String
Public info_category As String
Public info_complaint_date As XSD_DATETIME
Public info_complaint_nr As String
Public info_state As String
Public info_subcategory As String
Public info_type As String
Public other_info As String
Function setItems(strInfo As Variant, key As String, returnFault As WS_FAULT) As Detail
Const NO_ELEMENTS=22
On Error Goto handler
If(strIsEmpty(Cstr(strInfo), returnFault)=False) Then
result=Split(strInfo, SEPARATOR)
If(chkElements(Ubound(result), NO_ELEMENTS, returnFault)) Then
action_comment=result(17)
action_cost=result(18)
action_responsible=result(19)
complainer_adress=result(3)
complainer_epost=result(6)
complainer_fnr=result(7)
complainer_namn=result(2)
complainer_postadress=result(4)
complainer_tele=result(5)
doc_action=result(15)
doc_description=result(14)
doc_loggedby=result(12)
doc_recap=result(16)
doc_rubrik=result(13)
Set end_datefinished=getDate(result(20))
end_terminatedby=result(21)
info_category=result(9)
Set info_complaint_date=getDate(result(0))
info_complaint_nr=result(11)
info_state=result(1)
info_subcategory=result(10)
info_type=result(8)
other_info=result(22)
End If
End If
exitFunc:
Exit Function
handler:
Dim NotesError As New NotesError(Lsi_info(2),Lsi_info(12), returnFault)
Resume exitFunc
End Function
End Class
Class Entry As Skeleton
Public complaint_date As XSD_DATETIME
Public complaint_number As String
Public complaint_type As String
Public headline As String
Public logged_by As String
Function setItems(strInfo As Variant, key As String, returnFault As WS_FAULT) As Integer
Const NO_ELEMENTS=4
m_key=key
On Error Goto handler
If(strIsEmpty(Cstr(strInfo), returnFault)=False) Then
result=Split(strInfo, SEPARATOR)
If(chkElements(Ubound(result), NO_ELEMENTS, returnFault)) Then
Set complaint_date=getDate(result(0))
complaint_number=result(1)
complaint_type=result(2)
logged_by=result(3)
headline=result(4)
End If
End If
setItems=1
exitFunc:
Exit Function
handler:
Dim NotesError As New NotesError(Lsi_info(2),Lsi_info(12), returnFault)
Resume exitFunc
End Function
End Class
Class wsInfo As Skeleton
Sub New
Set s = New NotesSession
Set db=s.CurrentDatabase
End Sub
Public Function hasErrands(fNr As Double, returnFault As WS_FAULT) As Boolean
Dim view As NotesView
Dim doc As NotesDocument
Dim response As Boolean
On Error Goto handler
Set db=s.CurrentDatabase
Set view=db.GetView(V_ISAVAILABLE)
m_key=Cstr(fNr)
response=False
If viewIsAvailable(view, V_ISAVAILABLE, returnFault) Then
Set doc=view.GetDocumentByKey(m_key, True)
If(Not doc Is Nothing) Then
If(doc.IsValid) Then
response=True
End If
End If
Else
End If
hasErrands=response
exitFunc:
Exit Function
handler:
Dim NotesError As New NotesError(Lsi_info(2),Lsi_info(12), returnFault)
Resume exitFunc
End Function
Public Function getDetails(errandNr As String, returnFault As WS_FAULT) As Detail
Dim view As NotesView
Dim ve As NotesViewEntry
Dim response As New Detail
Set view=db.GetView(V_DETAILS)
m_key=errandNr
If(viewIsAvailable(view, V_DETAILS, returnFault)) Then
Set ve=view.GetEntryByKey(m_key, True)
If(entryIsAvailable(ve, m_key, returnFault)) Then Call response.setItems(ve.ColumnValues(2), m_key, returnFault)
End If
Set getDetails=response
End Function
Public Function getList(fNr As Double, returnFault As WS_FAULT) As VARIANTARRAY_HOLDER
Dim view As NotesView
Dim doc As NotesDocument
Dim vc As NotesViewEntryCollection
Dim ve As NotesViewEntry
Dim response As Entry
Dim reply As New VARIANTARRAY_HOLDER
Dim i As Integer
On Error Goto handler
Set view=db.GetView(V_LIST)
m_key=fNr
If(viewIsAvailable(view, V_LIST, returnFault)) Then
Set vc=view.GetAllEntriesByKey(m_key, True)
Set ve=vc.GetFirstEntry
If(entryIsAvailable(ve, m_key, returnFault)) Then
Redim reply.Value(vc.Count)
While Not ve Is Nothing
If(ve.IsValid) Then
Set response=New Entry
Call response.setItems(ve.ColumnValues(2), m_key, returnFault)
Set reply.Value(i)=response
i=i+1
End If
Set ve=vc.GetNextEntry(ve)
Wend
End If
End If
Set getList=reply
exitFunc:
Exit Function
handler:
Dim NotesError As New NotesError(Lsi_info(2), Lsi_info(12), returnFault)
Resume exitFunc
End Function
End Class
Class logError As Skeleton
Private s As NotesSession
Private db As NotesDatabase
Sub new(location As String, caller As String, strErr As String, strError As String, strErl As String)
Set s=New NotesSession
Set db=New NotesDatabase("", ALOG )
If(db.IsOpen) Then
Dim currentLog As New NotesLog(s.CurrentAgent.ServerName & " - " & s.CurrentDatabase.FileName & " / " & s.CurrentAgent.Name)
Call currentLog.OpenNotesLog( "", ALOG)
Call currentLog.LogError(1001, caller & " / " & location & " - Error: " & strErr & " - " & strError & " at line: " & strErl & " - "_
& "Memory allocated: " & Lsi_info(50) & " / Memory from OS: " & Lsi_info(51) & " / Memory blocks used: " & Lsi_info(52))
Call currentLog.Close
Else
Msgbox |ERROR: Database - "| & ALOG & |" needs to be created for agent error logging to work...|
End If
End Sub
End Class
Class notesError As Skeleton
Sub new(location As String, caller As String, returnFault As WS_FAULT)
Dim logIt As New logError(location ,caller, Str(Err), Error$, Cstr(Erl))
Call throwFault(returnFault, caller & " / " & location & " - Error: " & Str(Err) & " - " & Error$ & " at line: " & Cstr(Erl))
Msgbox caller & " / " & location & " - Error: " & Str(Err) & " - " & Error$ & " at line: " & Cstr(Erl) & Chr(10)_
& "Memory allocated: " & Lsi_info(50) & " / Memory from OS: " & Lsi_info(51) & " / Memory blocks used: " & Lsi_info(52), 0+48, "Error"
End Sub
End Class
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.