| Sub Initialize |
| '********************************************************************************************************************************* |
| 'This agent edit the reservations if an cost object or a city in db "Kostenträgerverwaltung" was changed. |
| '********************************************************************************************************************************* |
| On Error Goto ErrHandle |
| '********************************************************************************************************************************* |
| Set s = New NotesSession |
| Set db = s.CurrentDatabase |
| |
| 'get tmp doc to continue logging with real user name |
| If General_GetModificationDoc = False Then |
| Call CreateLogEntry(db.title,s.CommonUserName,"Agent: AllocateChanges","Initialize",_ |
| "General_GetModificationDoc = false - beende Agenten") |
| Exit Sub |
| End If |
| |
| 'verify form of changed doc |
| strForm = Cstr(docMod.ChangedForm(0)) |
| 'get ID |
| strCostObject = Cstr(docMod.ID(0)) |
| |
| 'start allocating for the changed doc |
| If strForm = "CostObject" Then |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","Initialize",_ |
| "geänderte Maske: " & strForm) |
| |
| Call CostObject_EditAll |
| |
| Elseif strForm = "City" Then |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","Initialize",_ |
| "geänderte Maske: " & strForm) |
| |
| Call City_EditAll() |
| |
| Else |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","Initialize",_ |
| "geänderte Maske nicht gültig - Maske: " & strForm) |
| End If |
| |
| Leave: |
| Exit Sub |
| |
| ErrHandle: |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","Initialize",_ |
| "Error" & Str(Err) & ": " & Error$ & " in Zeile " & Erl) |
| Resume Leave |
| End Sub |
| |
| |
| |
| Function General_GetModificationDoc As Boolean |
| '********************************************************************************************************************************* |
| 'get the temporary doc in db . Save the form of changed doc global and continue logging with the name of the user, which have |
| 'created the tmp doc. |
| '********************************************************************************************************************************* |
| On Error Goto ErrHandle |
| '********************************************************************************************************************************* |
| 'get tmpModification doc |
| Set agent = s.CurrentAgent |
| Set SourceDocDB = s.GetDatabase("Baghira","Zeiterfassung\Kostenträgerverwaltung.nsf") |
| Set docMod = SourceDocDB.GetDocumentByID(agent.ParameterDocID) |
| |
| If docMod Is Nothing Then |
| 'log with the name of the server on which this agent run |
| Call CreateLogEntry(db.title,s.CommonUserName,"Agent: ReservationsEdit","General_GetModificationDoc",_ |
| "Das temporäre Änderungsdokument konnte nicht gefunden werden") |
| 'RETURN |
| General_GetModificationDoc = False |
| Else |
| 'get username for logging |
| strUser = Cstr(docMod.EditingUser(0)) |
| |
| 'log with the name of the user, which have edited the doc |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","General_GetModificationDoc",_ |
| "Agent: " & agent.Name & " wurde gestartet") |
| End If |
| |
| 'RETURN |
| General_GetModificationDoc = True |
| |
| Leave: |
| Exit Function |
| |
| ErrHandle: |
| Call CreateLogEntry(db.title,s.CommonUserName,"Agent: ReservationsEdit","General_GetModificationDoc",_ |
| "Error" & Str(Err) & ": " & Error$ & " in Zeile " & Erl) |
| 'RETURN |
| General_GetModificationDoc = False |
| Resume Leave |
| End Function |
| |
| |
| |
| |
| |
| Function City_EditAll() |
| '********************************************************************************************************************************************** |
| 'This function gets the changed city in the DB Stammdatenverwaltung, search for all reservations with this city |
| 'edit them an send an info mail to the author of the reservation. |
| '********************************************************************************************************************************************** |
| On Error Goto ErrHandle |
| '********************************************************************************************************************************************** |
| Dim doccol As NotesDocumentCollection 'all reservations which must be edited |
| Dim resdoc As NotesDocument 'Reservation doc |
| '********************************************************************************************************************************************** |
| 'search for all reservations with the city |
| If Not (docMod Is Nothing) Then |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","City_EditAll",_ |
| "geänderter Ort gefunden: - " & docMod.CityOLD(0)) |
| |
| Dim view As NotesView |
| Set view = db.GetView("lkpCities") |
| |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","City_EditAll",_ |
| "suche nach Reservierungen mit Ort: " & docMod.CityOLD(0)) |
| |
| Set doccol = view.GetAllDocumentsByKey(docMod.CityOLD(0),True) |
| |
| If doccol.Count = 0 Then |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","City_EditAll",_ |
| "Es wurden keine zu ändernden Reservierungen mit Ort: " & docMod.CityOLD(0) & " gefunden") |
| Exit Function |
| End If |
| |
| 'get first reservation |
| Set resdoc = doccol.GetFirstDocument |
| |
| 'run over all reservations |
| While Not (resdoc Is Nothing) |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","City_EditAll",_ |
| "es wurden " & doccol.Count & " Reservierungen gefunden") |
| |
| 'read out old data |
| strCostObject = resdoc.ReservationOrderNumber(0) |
| strCityOLD = resdoc.ReservationCity(0) |
| strDistanceOLD = Cstr(resdoc.ReservationKilometer(0)) |
| |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","City_EditAll",_ |
| "Alter Ort: " & strCityOLD) |
| |
| 'change the data |
| resdoc.ReservationCity = docMod.CityNEW(0) |
| Call resdoc.Save(True,False) |
| |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","City_EditAll",_ |
| "Ort bei Reservierung " & resdoc.NoteID & " wurde geändert") |
| |
| 'Informate the author of the reservation |
| Call Memo_Variables(resdoc) |
| Call Memo_Initialize(resdoc) |
| |
| 'get next reservation |
| Set resdoc = doccol.GetNextDocument(resdoc) |
| Wend |
| |
| End If |
| |
| 'delete modification doc after allocating |
| Call General_DeleteModificationDoc |
| |
| Leave: |
| Exit Function |
| |
| ErrHandle: |
| Call CreateLogEntry(db.title,strUser,"Agent: ReservationsEdit","City_EditAll",_ |
| "Error" & Str(Err) & ": " & Error$ & " in Zeile " & Erl) |
| 'delete modification doc after error |
| Call General_DeleteModificationDoc |
| Resume Leave |
| End Function |
| |