Habe das Gerüst noch einmal geändert:
Es gibt jetzt eine neue Public Function GetTicketsByStatus ( status As String ) As TicketCollection
Das bietet ein wenig mehr Flexibilität.
Dadurch reduziert sich der Code zur Ermittlung der neuen Tickets auf
%REM
#####################################################
Public Function GetNewTickets ( ) As TicketCollection
#####################################################
%END REM
Public Function GetNewTickets ( ) As TicketCollection
Set GetNewTickets = GetTicketsByStatus ("0")
End Function
In der gleichen weise lassen sich dann leicht Functions für Closed Tickets etc bauen.
Auch bisher noch nicht verwendete Stati lassen sich clientseitig über die neue Funktion bedienen; daher public und nicht private...
%REM
#####################################################
INCLUDES
#####################################################
%END REM
%INCLUDE "lsxsd.lss"
%REM
#####################################################
CONSTANTS
#####################################################
%END REM
Private Const CREATE_TICKET_FORM = "BugReport"
Private Const CREATE_TICKET_INITIAL_STATUS = "0"
Private Const CREATE_TICKET_VIA_WEBSERVICE = 1
Private Const CREATE_TICKET_ERR_NOERROR = 0
Private Const CREATE_TICKET_ERR_MISC_ERROR = 1
Private Const CREATE_TICKET_ERR_MANDANTORY = 2
Private Const ASSIGN_TICKET_ERR_NOERROR = 0
Private Const ASSIGN_TICKET_ERR_MISC_ERROR = 1
Private Const ASSIGN_TICKET_ERR_MANDANTORY = 2
Private Const CLOSE_TICKET_ERR_NOERROR = 0
Private Const CLOSE_TICKET_ERR_MISC_ERROR = 1
Private Const CLOSE_TICKET_ERR_MANDANTORY = 2
Private Const MISC_ERROR = 1
Private Const NOERROR = 0
Private Const MANDANTORY = 2
Const DEFAULT_RETURN_VALUE ="-"
%REM
#####################################################
VARIABLES
#####################################################
%END REM
Private s As NotesSession
Private db As NotesDatabase
Private doc As NotesDocument
Private success As Variant
Private SearchFormula As String
Private strPersonName As String
Private nn As NotesName
Private dc As NotesDocumentCollection
Private count As Integer
Private i As Integer
Private TicketValues As Ticket
Class TicketCollection
Public Tickets() As Ticket
Public TicketCount As Integer
Public ErrorCode As Integer
End Class
Class Ticket
Public User As String
Public TicketNumber As String
Public Problem As String
Public Status As String
End Class
Class TicketDetails
Public User As String
Public TicketNumber As String
Public Problem As String
Public Status As String
'... eine Ahnung was sonst noch
Public AssociatedTodo As ToDoCollection
End Class
Class ToDoCollection
Public ToDos() As ToDo
Public ToDoCount As Integer
End Class
Class ToDo
Public ToDoNumber As String
Public Problem As String
Public Status As String
End Class
%REM
#####################################################
WEBSERVICES 0.01 (c) 2005,2006, Ulrich Krause, Thomas Schulte, Axel Janssen
----------------------------------------------------------------------------------------------------------
# Public functions and subs:
----------------------------------------------------------------------------------------------------------
Public Sub New
Public Function GetNewTickets ( ) As TicketCollection
Public Function GetTicketDetails ( TicketNumber as String ) As TicketDetails
Public Function GetAllTicketsBySupporter ( strSupporter As String ) As TicketCollection
Public Function CreateTicket ( strUser As String, strProblem As String ) As Integer
Public Function AssignTicket (strTicket As String, strAssignTo As String) As Integer
Public Function CloseTicket ( strTicket As String ) As Integer
----------------------------------------------------------------------------------------------------------
# Private functions and subs:
----------------------------------------------------------------------------------------------------------
Private Function CommonNameString (strName As String) As String
Private Function getItemValue ( strItem As String ) As String
Private Function GetTickets ( status As String ) As TicketCollection
#####################################################
%END REM
Class wsTicket
%REM
#####################################################
Public Sub New
#####################################################
%END REM
Public Sub New
' initialize some stuff
Set s = New NotesSession()
Set db = s.currentDatabase
End Sub
%REM
#####################################################
Public Function GetNewTickets ( ) As TicketCollection
#####################################################
%END REM
Public Function GetNewTickets ( ) As TicketCollection
Set GetNewTickets = GetTicketsByStatus ("0")
End Function
%REM
#####################################################
Public Function GetClosedTickets ( ) As TicketCollection
#####################################################
%END REM
Public Function GetClosedTickets ( ) As TicketCollection
Set GetClosedTickets = GetTicketsByStatus ("99")
End Function
%REM
#####################################################
Public Function GetOpenTickets ( ) As TicketCollection
#####################################################
%END REM
Public Function GetOpenTickets ( ) As TicketCollection
Set GetOpenTickets = GetTicketsByStatus ("1")
End Function
%REM
#####################################################
Public Function GetResubmittedTickets ( ) As TicketCollection
#####################################################
%END REM
Public Function GetResubmittedTickets ( ) As TicketCollection
Set GetResubmittedTickets = GetTicketsByStatus ("98")
End Function
%REM
#####################################################
Public Function GetTicketDetails ( TicketNumber as String ) As TicketDetails
#####################################################
%END REM
Public Function GetTicketDetails ( TicketNumber As String ) As TicketDetails
On Error Goto ERRHANDLE
EXITPOINT:
Exit Function
ERRHANDLE:
xProc = Getthreadinfo(LSI_THREAD_PROC)
xError = xProc & ": " &Trim$(Str$(Err)) & " on line " & Cstr(Erl) & ": " & Error$
If UseOpenLog Then
Call LogError
Elseif LogScriptErrors Then
Call ThrowException ( xProc, xError )
End If
Print xError 'In all cases
If ResumeMethodNext Then
Resume Next
Else
Resume EXITPOINT
End If
End Function
%REM
#####################################################
Public Function GetAllTicketsBySupporter ( strSupporter As String ) As TicketCollection
#####################################################
%END REM
Public Function GetAllTicketsBySupporter ( strSupporter As String ) As TicketCollection
On Error Goto ERRHANDLE
If Trim(strSupporter) = "" Then
Set GetAllTicketsBySupporter = New TicketCollection
GetAllTicketsBySupporter.TicketCount = 0
GetAllTicketsBySupporter.ErrorCode = MANDANTORY
Exit Function ' nothing else to do, get outa here !
Else
SearchFormula =_
|@UpperCase(Form) ="BUGREPORT" & @UpperCase(@Name([CN];supporter)) ="|_
& Ucase(CommonNameString (strSupporter )) & |"|
Dim dateTime As New NotesDateTime(_
Cstr(Datenumber(2000, 5, 1)))
Dim dc As NotesDocumentCollection
Set dc = db.Search( SearchFormula, dateTime,0)
count = dc.count
If count = 0 Then Exit Function
Set GetAllTicketsBySupporter = New TicketCollection
GetAllTicketsBySupporter.TicketCount = count
GetAllTicketsBySupporter.ErrorCode = NOERROR
If (count = 0) Then
Redim GetAllTicketsBySupporter.Tickets(count)
Else
Redim GetAllTicketsBySupporter.Tickets(count - 1)
End If
i = 0
Set doc = dc.GetFirstDocument
Do Until (doc Is Nothing)
Set TicketValues = New Ticket
TicketValues.User = CommonNameString(getItemValue ("user"))
TicketValues.TicketNumber = getItemValue ("ReqNumber")
TicketValues.Problem = getItemValue ("problem")
TicketValues.Status = getItemValue ("status")
Set GetAllTicketsBySupporter.Tickets(i) = TicketValues
i = i +1
Set doc = dc.GetNextDocument(doc)
Loop
%REM
For i = 1 To dc.Count
Set doc = dc.GetNthDocument ( i )
Set TicketValues = New Ticket
TicketValues.User = CommonNameString(getItemValue ("user"))
TicketValues.TicketNumber = getItemValue ("ReqNumber")
TicketValues.Problem = getItemValue ("problem")
TicketValues.Status = getItemValue ("status")
Set GetAllTicketsBySupporter.Tickets ( i -1 ) = TicketValues
Next
%END REM
End If
EXITPOINT:
Exit Function
ERRHANDLE:
xProc = Getthreadinfo(LSI_THREAD_PROC)
xError = xProc & ": " &Trim$(Str$(Err)) & " on line " & Cstr(Erl) & ": " & Error$
If UseOpenLog Then
Call LogError
Elseif LogScriptErrors Then
Call ThrowException ( xProc, xError )
End If
Print xError 'In all cases
If ResumeMethodNext Then
Resume Next
Else
Set GetAllTicketsBySupporter = New TicketCollection
GetAllTicketsBySupporter.TicketCount = count
GetAllTicketsBySupporter.ErrorCode = MISC_ERROR
Resume EXITPOINT
End If
End Function
%REM
#####################################################
Public Function CreateTicket ( strUser As String, strProblem As String ) As Integer
#####################################################
%END REM
Public Function CreateTicket ( strUser As String, strProblem As String ) As Integer
CreateTicket = CREATE_TICKET_ERR_NOERROR
On Error Goto ERRHANDLE
If Trim(strUser) = "" Or Trim(strProblem) = "" Then
CreateTicket = CREATE_TICKET_ERR_MANDANTORY ' mandantory fields
Exit Function ' nothing else to do, get outa here !
Else
Dim doc As NotesDocument
Dim dateTime As New NotesDateTime( "" )
Call dateTime.SetNow
Set doc = db.CreateDocument
doc.Form = CREATE_TICKET_FORM
doc.User = strUser
doc.Problem = strProblem
doc.Status = CREATE_TICKET_INITIAL_STATUS ' new Ticket, unassigned
doc.Webservice = CREATE_TICKET_VIA_WEBSERVICE
doc.DateCreated = Cstr(dateTime.DateOnly)
doc.TimeCreated = Cstr(dateTime.TimeOnly)
success = doc.ComputeWithForm( False, False )
Call doc.Save (True,True)
End If
EXITPOINT:
Exit Function
ERRHANDLE:
xProc = Getthreadinfo(LSI_THREAD_PROC)
xError = xProc & ": " &Trim$(Str$(Err)) & " on line " & Cstr(Erl) & ": " & Error$
If UseOpenLog Then
Call LogError
Elseif LogScriptErrors Then
Call ThrowException ( xProc, xError )
End If
Print xError 'In all cases
If ResumeMethodNext Then
Resume Next
Else
CreateTicket = CREATE_TICKET_ERR_MISC_ERROR
Resume EXITPOINT
End If
End Function
%REM
#####################################################
Public Function AssignTicket (strTicket As String, strAssignTo As String) As Integer
#####################################################
%END REM
Public Function AssignTicket (strTicket As String, strAssignTo As String) As Integer
On Error Goto ERRHANDLE
AssignTicket = ASSIGN_TICKET_ERR_NOERROR
If Trim(strTicket) = "" Or Trim(strAssignTo) = "" Then
AssignTicket = ASSIGN_TICKET_ERR_MANDANTORY 'mandantory fields
Exit Function ' nothing else to do, get outa here !
Else
' Your Code goes here
End If
EXITPOINT:
Exit Function
ERRHANDLE:
xProc = Getthreadinfo(LSI_THREAD_PROC)
xError = xProc & ": " &Trim$(Str$(Err)) & " on line " & Cstr(Erl) & ": " & Error$
If UseOpenLog Then
Call LogError
Elseif LogScriptErrors Then
Call ThrowException ( xProc, xError )
End If
Print xError 'In all cases
If ResumeMethodNext Then
Resume Next
Else
AssignTicket = ASSIGN_TICKET_ERR_MISC_ERROR
Resume EXITPOINT
End If
End Function
%REM
#####################################################
Public Function CloseTicket ( strTicket As String ) As Integer
#####################################################
%END REM
Public Function CloseTicket ( strTicket As String ) As Integer
On Error Goto ERRHANDLE
CloseTicket = CLOSE_TICKET_ERR_NOERROR
If Trim(strTicket) = "" Then
CloseTicket = CLOSE_TICKET_ERR_MANDANTORY 'mandantory fields
Exit Function ' nothing else to do, get outa here !
Else
' Your Code goes here
End If
EXITPOINT:
Exit Function
ERRHANDLE:
xProc = Getthreadinfo(LSI_THREAD_PROC)
xError = xProc & ": " &Trim$(Str$(Err)) & " on line " & Cstr(Erl) & ": " & Error$
If UseOpenLog Then
Call LogError
Elseif LogScriptErrors Then
Call ThrowException ( xProc, xError )
End If
Print xError 'In all cases
If ResumeMethodNext Then
Resume Next
Else
CloseTicket = CLOSE_TICKET_ERR_MISC_ERROR
Resume EXITPOINT
End If
End Function
%REM
#####################################################
Public Function GetTicketsByStatus ( status As String ) As TicketCollection
#####################################################
%END REM
Public Function GetTicketsByStatus ( status As String ) As TicketCollection
On Error Goto ERRHANDLE
SearchFormula =_
|@UpperCase(Form) ="BUGREPORT" & Status = "| & status & |"|
Dim dateTime As New NotesDateTime(_
Cstr(Datenumber(2000, 5, 1)))
Dim dc As NotesDocumentCollection
Set dc = db.Search( SearchFormula, dateTime,0)
count = dc.count
If count = 0 Then Exit Function
Set GetTicketsByStatus = New TicketCollection
GetTicketsByStatus.TicketCount = count
GetTicketsByStatus.ErrorCode = NOERROR
Redim GetTicketsByStatus.Tickets(count - 1)
i = 0
Set doc = dc.GetFirstDocument
Do Until (doc Is Nothing)
Set TicketValues = New Ticket
TicketValues.User = CommonNameString(getItemValue ("user"))
TicketValues.TicketNumber = getItemValue ("ReqNumber")
TicketValues.Problem = getItemValue ("problem")
TicketValues.Status = getItemValue ("status")
Set GetTicketsByStatus.Tickets(i) = TicketValues
i = i +1
Set doc = dc.GetNextDocument(doc)
Loop
EXITPOINT:
Exit Function
ERRHANDLE:
xProc = Getthreadinfo(LSI_THREAD_PROC)
xError = xProc & ": " &Trim$(Str$(Err)) & " on line " & Cstr(Erl) & ": " & Error$
If UseOpenLog Then
Call LogError
Elseif LogScriptErrors Then
Call ThrowException ( xProc, xError )
End If
Print xError 'In all cases
If ResumeMethodNext Then
Resume Next
Else
Resume EXITPOINT
End If
End Function
%REM
#####################################################
Private Function CommonNameString (strName As String) As String
#####################################################
%END REM
Private Function CommonNameString (strName As String) As String
Set nn = New NotesName( strName )
strPersonName = nn.Common
CommonNameString = strPersonName
End Function
%REM
#####################################################
Private Function getItemValue ( strItem As String ) As String
#####################################################
%END REM
Private Function getItemValue ( strItem As String ) As String
If doc.HasItem(strItem) Then
getItemValue = doc.GetItemValue( strItem )(0)
Else
getItemValue = DEFAULT_RETURN_VALUE
End If
End Function
End Class
Damit sieht das Gerüst im Web Services Explorer nun so aus