Domino 9 und frühere Versionen > ND6: Entwicklung

!!HELP!! - BUG gefunden ?

<< < (4/4)

eknori:
... und in 1.0.9 werden Fehler in Agenten und LS Proceduren nicht nur in OpenLOG sondern auch in einer abgespeckten Version in !!HELP!! selbst geloggt.

eknori:
und um das jetzt konfigurierbar hinzubekommen, muss das ERRHANDLE in einem Agenten folgendermassen aussehen:

   
EXITPOINT:
   Exit Sub
ERRHANDLE:
   Dim TheError As String
   Dim TheProc As String
   'TheProc = Getthreadinfo(LSI_THREAD_PROC)
   TheError = Getthreadinfo(LSI_THREAD_PROC) & ": " &Trim$(Str$(Err)) & " on line " & Cstr(Erl) & ": " & Error$
   
   If UseOpenLog Then
      Call LogError
   Elseif LogScriptErrors Then
      Dim agent As NotesAgent
      Set agent = s.CurrentAgent
      TheProc = agent.Name
      Dim L As New LogProfile ( s.CurrentDatabase, TheProc,LOG_NORMAL, s.CurrentDatabase.Server)
      Call L.LogAction( TheError  ,LOG_NORMAL)
   End If
   'In all cases
   Print TheError
   If ResumeMethodNext Then
      Resume Next   
   Else
      Resume EXITPOINT
   End If

Im "INITIALIZE" Event der ScriptLib "lib.appl.functions" sieht das dann folgendermassen aus

Sub Initialize
   ' if configured, use OpenLog for error logging ( 25.05.2005, Ulrich Krause )
   On Error Goto ERRHANDLE
   
   If Ucase(GetConfigDocByKey ("OpenLogEnabled")) = "YES" Then
      UseOpenLog = True
   End If
   
   If Ucase(GetConfigDocByKey ("LogScriptErrors")) = "YES" Then
      LogScriptErrors = True
   End If
   
   If Ucase(GetConfigDocByKey ("ResumeMethod")) = "NEXT" Then
      ResumeMethodNext = True
   End If
   
EXITPOINT:
   Exit Sub
ERRHANDLE:
   UseOpenLog = False
   Resume EXITPOINT
End Sub

Dazu gibt es dann eben die entsprechenden Konfigurationsdokumente.

Damit das Ganze auch funktioniert, gibt es eine neue ScriptLib "lib.appl.log". Die Lib enthält eine Klasse:

'lib.appl.log:

Option Public

Const TASKLENGTH = 15
Const LOG_NONE = 00
Const LOG_ERROR = 01
Const LOG_NORMAL = 02
Const LOG_EXTENDED = 03
Const LOG_DEBUG = 99
Const NORMALLOG = 1
Const ERRORLOG = 2

Dim logview As NotesView
Dim logdc As NotesDocumentCollection

Public Class LOGProfile     
   
   Public LogLevel As Integer
   Public logdoc As NotesDocument
   Public logerrordoc As NotesDocument
   Public Subtask As String * TASKLENGTH ' used to display the task for all messages
   Public AgentName As String * TASKLENGTH
   Public Oldtask As String
   
   Sub New(db As NotesDatabase,scriptname As String,niveau As Integer,username As String)
      Dim special_item As NotesItem
      Dim agent As NotesAgent
      Dim serverdoc As NotesDocument
      Dim serverprofile As NotesDocument
      Dim onserver As String
      Dim currentservername As String
      Subtask = ""
      Me.loglevel = niveau
      Me.AgentName = scriptname ' truncated if to long
      Set logview = db.GetView("Log")
      If logview Is Nothing Then
         Error 1000,"View for logging not existing"
      End If
      Call logview.Refresh 'added to avoid that a new log is created but not seen by this routine
      Set logdc = logview.GetAllDocumentsByKey(Date$ & username & scriptname) ' changed 23/3/99 added

scriptname
      Select Case logdc.Count
      Case 0:
         Set logdoc = CreateNewLog(db,username, scriptname,NORMALLOG) ' changed 23/3/99 added

scriptname
         Call logview.Refresh
      Case 1:
         Set logdoc = logdc.GetFirstDocument
      Case Else: 'close them all off and create a new log
         For i = 1 To logdc.Count
            Set logdoc = logdc.GetNthDocument(i)
            logdoc.LogEnd = Format$(logdoc.LASTMODIFIED,"hh:mm:ss")
            Call logdoc.Save(True,True)
            Set logdoc = CreateNewLog(db,username, scriptname,NORMALLOG) ' changed 23/3/99

added scriptname
            Call logview.Refresh
         Next
      End Select
      Set logdc = logview.GetAllDocumentsByKey(Date$ & "ERROR" & username & scriptname) ' changed

23/3/99 added scriptname
      Select Case logdc.Count
      Case 0:
         Set logerrordoc = CreateNewLog(db,username, scriptname,ERRORLOG) ' changed 23/3/99 added

scriptname
         Call logview.Refresh
      Case 1:
         Set logerrordoc = logdc.GetFirstDocument
      Case Else: 'close them all off and create a new log
         For i = 1 To logdc.Count
            Set logerrordoc = logdc.GetNthDocument(i)
            logerrordoc.LogEnd = Format$(logerrordoc.LASTMODIFIED,"hh:mm:ss")
            Call logerrordoc .Save(True,True)
            Set logerrordoc = CreateNewLog(db,username, scriptname,ERRORLOG) ' changed

23/3/99 added scriptname
            Call logview.Refresh
         Next
      End Select
   End Sub
   
   Sub LogAction(message As String,level As Integer)
      Dim item As NotesItem
      Dim db As NotesDatabase
      Dim size As Long
      If Me.LogLevel >= level Then
         If Me.LogLevel = LOG_DEBUG Then
            If level = LOG_DEBUG Then
               levelstr$ = " ( " & Trim(Str$(level)) & ") " & Subtask
            Else
               levelstr$ = " ( " & Trim(Str$(level)) & ") " & Subtask
            End If
         Else
            levelstr$ = ""
         End If
         Set item = logdoc.Getfirstitem("Log")
         If Not item Is Nothing Then 'check if the document does not get to large
            size = item.VALUELENGTH
         Else
            Set item = New NotesItem(logdoc,"Log","") ' if there is no logitem create a new

one and the size will then not be to large so we can presume 0
            size = 0
         End If
         If size + Len(message) > 32000 Then 'create a new logdoc if the old one becomes to large
            Set db = logdoc.ParentDatabase
            logdoc.LogEnd =  Now()
            Call logdoc.Save(True,True)
            Set logdoc = CreateNewLog(db,logdoc.LogUser(0),logdoc.Agentname(0),NORMALLOG) '

changed 23/3/99 added scriptname
            Set item = New NotesItem(logdoc,"Log","")
         End If
         If message = "" Then
            Call item.AppendToTextList("")
         Else
            Call item.AppendToTextList(  Now()  & "  : " & message )
         End If
         logdoc.LastAction = Date$ & " " & Time$   
         Call logdoc.ComputeWithForm(True,True)
         Call logdoc.Save(True,True)
      End If
   End Sub
   
   Sub LogError(errorcode As Integer,message As String,level As Integer)
      Dim item As NotesItem
      Dim db As NotesDatabase
      Dim size As Long
      If Me.LogLevel >= level Then
         If Me.LogLevel = LOG_DEBUG Then
            If level = LOG_DEBUG Then
               levelstr$ = " ( " & Trim(Str$(level)) & ") " & Subtask
            Else
               levelstr$ = " ( " & Trim(Str$(level)) & ") " & Subtask
            End If
         Else
            levelstr$ = ""
         End If
         
         Set item = logdoc.Getfirstitem("Log")
         If Not item Is Nothing Then 'check if the document does not get to large
            size = item.VALUELENGTH
         Else
            Set item = New NotesItem(logdoc,"Log","") ' if there is no logitem create a new

one and the size will then not be to large so we can presume 0
            size = 0
         End If
         If size + Len(message) > 32000 Then 'create a new logdoc if the old one becomes to large
            Set db = logdoc.ParentDatabase
            logdoc.LogEnd = Now()
            Call logdoc.Save(True,True)
            Set logdoc = CreateNewLog(db,logdoc.LogUser(0),logdoc.Agentname(0),NORMALLOG) '

changed 23/3/99 added scriptname
            Set item = New NotesItem(logdoc,"Log","")
         End If
         If message = "" Then
            Call item.AppendToTextList("")
         Else
            Call item.AppendToTextList(Now() & " " & Me.AgentName & " " & levelstr$ & " ***

Error *** :" & Str(errorcode) & " : " & message )
         End If
         logdoc.LastAction = Date$ & " " & Time$
         Call logdoc.Save(True,True)
         If level = LOG_ERROR Then ' error messages are logged seperate
            Set item = logerrordoc.Getfirstitem("Log")
            If Not item Is Nothing Then 'check if the document does not get to large
               size = item.VALUELENGTH
            Else
               Set item = New NotesItem(logerrordoc,"Log","") ' if there is no logitem

create a new one and the size will then not be to large so we can presume 0
               size = 0
            End If
            If size + Len(message) > 32000 Then 'create a new logdoc if the old one becomes

to large
               Set db = logerrordoc.ParentDatabase
               logerrordoc.LogEnd = Now()
               Call logerrordoc.Save(True,True)
               Set logerrordoc =

CreateNewLog(db,logdoc.LogUser(0),logdoc.Agentname(0),ERRORLOG)
               Set item = New NotesItem(logerrordoc,"Log","")
            End If
            If message = "" Then
               Call item.AppendToTextList("")
            Else
               Call item.AppendToTextList(Now() & " " & Me.AgentName & " " & levelstr$ &

" *** Error *** :" & Str(errorcode) & " : " & message )
            End If
            logdoc.LastAction = Date$ & " " & Time$
            Call logerrordoc.Save(True,True)
         End If
      End If
   End Sub
   
   Sub DefineTask(task As String)
      Subtask = task ' save TASKLENGTH characters
      Oldtask = Subtask & Oldtask
      Call Me.LogAction(">> " & Subtask,99)
   End Sub
   
   Sub ResetTask()
      Dim taskname As String * TASKLENGTH
      If Len(Oldtask) < TASKLENGTH Then
         Oldtask = ""
      Else
         Call Me.LogAction("<< " & Left(Oldtask,TASKLENGTH ),99)
         Oldtask = Right(Oldtask,Len(Oldtask) - TASKLENGTH )
      End If
      Subtask = Oldtask
   End Sub
End Class

Function CreateNewLog(LogDb As NotesDatabase,username As String, scriptname As String,logtype As Integer) As

NotesDocument ' changed 23/3/99 added scriptname
   Dim s As New NotesSession   
   Set logdoc = New NotesDocument(Logdb)
   logdoc.Form = "Log"
   logdoc.Type = logtype
   logdoc.AgentName = scriptname
   logdoc.LogUser = s.CurrentDatabase.Server
   logdoc.LogDate = Date$ & " " & Time$
   logdoc.LastAction = Date$ & " " & Time$
   Set notesItem = New NotesItem( logdoc, "author", username, AUTHORS)
   Set CreateNewLog = logdoc
End Function

Thomas Schulte:

--- Zitat von: eknori am 30.05.05 - 15:40:44 ---Thomas ist heute wieder aus dem Urlaub zurück; er arbeitet am Problem ...

--- Ende Zitat ---
Ich hab dran gearbeitet und festgestellt das ich einen schweren Denkfehler im Dispatcher drinhatte.  :'(

Im Initialize müssen ein paar Zeilen ausgetauscht werden:
Zum einen das hier:

' check if there is already an entry in the userdocumentlist
If Iselement(userdclist(strusername)) = True Then
userdclist(strusername) = userdclist(strusername) + "~" + founddoc.UniversalID
Else
userdclist(strusername) = founddoc.UniversalID
End If

Ersetzen durch das hier:

' check if there is already an entry in the userdocumentlist
If Iselement(userdclist(strusername)) = True Then
userdclist(strusername) = userdclist(strusername) + "~" + newdoc.universalid
Else
userdclist(strusername) = newdoc.UniversalID
End If

Und das hier:

Set currentnote = db.GetDocumentByUNID(Documentslist(i).UniversalID)

Ersetzen durch das hier:

Set currentnote = db.GetDocumentByUNID(Documentslist(i))

Jetzt schäm ich mich aber richtig. weil das hatte ich nämlich schon mal erledigt.  >:(

und danach sollte die Benachrichtigung auch mit der Version 1.08 inklusive der Doclinks und einem "vernünftigen" Text  im Mail funktionieren.

eknori:
Leider gibt es noch ein Problem wenn "MailIfNewMailResponseCheckNames" auf YES gesetzt wird.
Dann schickt der Dispatcher immer an den DEFAULT Supporter.

Ich habe den Fehler aber gefunden; hier der BugFix ( oder wie es im SAP heißt: bauen sie bitte diesen Hinweis ein )

Das Adressbuch wird sauber durchforstet und die Liste mit den Namen aufgebaut; offenbar vergleicht der Dispatcher dann aber den Namen in canonical Form.

Ich habe daher v nach StringCast in die canonical form umgewandelt ( in lib.appl.functions)


Function CanonicalNameString (strName As String) As String
   Set nn = New NotesName( strName )
   strPersonName = nn.Canonical
   
   CanonicalNameString = strPersonName
   
End Function


dann den Code im Dispatcher entsprechend angepasst


                     'get all the values of this item if it is a multivalue field
                  Set founditem = founddoc.GetFirstItem("supporter")
                  Forall v In founditem.Values
                     If Not(Trim(v)="") Then
                        strusername =  CanonicalNameString (Cstr(v))

und schon funzt es  ;D

Navigation

[0] Themen-Index

[*] Vorherige Sete

Zur normalen Ansicht wechseln