| Sub Initialize |
| |
| On Error Goto ErrHandler |
| Dim session As New NotesSession |
| Dim TicketDB As NotesDatabase |
| Dim SupportDB As NotesDatabase |
| Dim TicketView As NotesView |
| Dim SupportView As NotesView |
| Dim MyAgent As NotesAgent |
| Dim dateTime As New NotesDateTime("") |
| Dim selection As String |
| Dim collection As NotesDocumentCollection |
| Dim TicketDoc As NotesDocument |
| Dim SupportDoc As NotesDocument |
| Dim SupportID As String |
| Dim TicketID As String |
| |
| dateTime.LocalTime = Datenumber(2000, 1, 1) |
| |
| Set SupportDB = session.CurrentDatabase |
| Set MyAgent = session.CurrentAgent |
| |
| LogIt("Start des Agenten") |
| |
| Set SupportView = SupportDB.GetView("(v_ReqNumber)") |
| iCounter = SupportView.AllEntries.Count |
| LogIt(iCounter + " Dokumente zum Bearbeiten gefunden") |
| LogIt("Hole erstes Dokument aus der SupportTracking Datenbank") |
| Set SupportDoc = SupportView.GetFirstDocument |
| |
| LogIt( "Ticket-DB holen") |
| Set TicketDB = session.GetDatabase("Maria_Notes","it-troubticket.nsf",False) |
| LogIt( "View aus der Ticket-DB holen") |
| Set TicketView = TicketDB.GetView("(v_ReqNumber)") |
| |
| While Not (SupportDoc Is Nothing) |
| LogIt( "Support-ID holen") |
| SupportID = SupportDoc.ReqNumber(0) |
| LogIt( "Support-ID: " + SupportID) |
| LogIt( "Selektion zusammensetzen") |
| selection = |@Contains( ReqNumber; "| + SupportID+ |" )| |
| Print "Suche in der TroubelTicket-Datenbank Ticket " + SupportID |
| |
| LogIt( "Collection bilden indem Selection in der TroubleTicket-Datenbank gesucht wird") |
| Set collection = TicketDB.Search( selection, dateTime, 0 ) |
| LogIt( "Erstes (und einziges) Dokument aus der Collection holen") |
| Set TicketDoc = collection.GetFirstDocument() |
| |
| LogIt( "Prüfung ob Dokument in TicketDB vorhanden") |
| If (TicketDoc Is Nothing) Then |
| LogIt( "Ticket mit der Support-ID " + SupportID + " in der TIcketDB nicht gefunden!") |
| Print "Ticket " + SupportID + " wurde nicht in der Ticket-DB gefunden! Nächstes Dokument (" + iCounterX + " / "+iCounter+")" |
| LogIt( "Nächstes Dokument nehmen") |
| Goto EndeIf |
| End If |
| |
| LogIt( "While TicketDoc is not nothing") |
| While Not TicketDoc Is Nothing |
| LogIt( "Ticket-ID holen") |
| TicketID = TicketDoc.ReqNumber(0) |
| LogIt( "Ticket-ID mit Support-ID vergleichen") |
| If (SupportID = TicketID) Then |
| LogIt( "Ticket-ID == Support-ID ("+ SupportID +")") |
| LogIt( "Solution holen ("+ SupportID +")") |
| tmpString=TicketDoc.GetItemValue("solution") |
| LogIt( "Solution in Dok schreiben ("+ SupportID +")") |
| Call SupportDoc.ReplaceItemValue("solution", tmpString) |
| |
| LogIt( "Kommentar für den Benutzer holen ("+ SupportID +")") |
| tmpString=TicketDoc.GetItemValue("tx_usercomment") |
| LogIt( "Kommentar für den Benutzer schreiben ("+ SupportID +")") |
| Call SupportDoc.ReplaceItemValue("tx_usercomment", tmpString) |
| |
| LogIt( "Status holen ("+ SupportID +")") |
| tmpString=TicketDoc.GetItemValue("Status") |
| LogIt( "Status schreiben ("+ SupportID +")") |
| Call SupportDoc.ReplaceItemValue("Status", tmpString) |
| |
| LogIt( "Supporter holen ("+ SupportID +")") |
| tmpString=TicketDoc.GetItemValue("supporter") |
| LogIt( "Supporter schreiben ("+ SupportID +")") |
| Call SupportDoc.ReplaceItemValue("supporter",tmpString) |
| |
| LogIt( "Dok speichern ("+ SupportID +")") |
| Call SupportDoc.Save(True, True) |
| Goto EndeIf |
| End If |
| Wend |
| EndeIf: |
| LogIt( "Nächstes SupportDoc holen") |
| Set SupportDoc = SupportView.GetNextDocument(SupportDoc) |
| iCounterX = iCounterX +1 |
| Wend |
| |
| LogIt("Beenden des Agenten") |
| |
| ErrHandler: ' Error-handling routine |
| If (Err <> 0) Then |
| LogIt( "Fehler in Zeile " & Erl & " Fehler: " & Error$) |
| Print "Error " & Error$ & " at line number " &Erl |
| Exit Sub |
| End If |
| End Sub |
| |
| Sub LogIt(strText) |
| Dim session As New NotesSession |
| Dim db As NotesDatabase |
| Dim view As NotesView |
| Dim currentLog As NotesLog |
| Set db = session.CurrentDatabase |
| Set agent = session.CurrentAgent |
| Set currentLog = New NotesLog ( agent.Name + "-Agent in Datenbank " + db.Title + " auf " + db.Server ) |
| Call currentLog.OpenNotesLog( "Maria_Notes/Maria-Hilf GmbH", "agentlog.nsf" ) |
| currentLog.LogAction(strText) |
| Print agent.Name & " || " & strText |
| Call currentLog.Close |
| End Sub |
| |