Lotus Notes中的无限循环

石膏

运行代理时,出现无限循环错误。该代理将获取文档的值。值之一是请求日期,另一个是响应日期。如果这两者之间的差值不是3,则我需要选择该文档并将其邮寄给一个人。请帮我解决该问题。

Sub Initialize

    On Error GoTo ErrorOut  

    Dim sess As NotesSession
    Dim db As NotesDatabase
    Dim vwSearchRequests As NotesView
    Dim reqNumColl As NotesDocumentCollection
    Dim doc, searchDoc, reqNumDoc As NotesDocument
    Dim body As NotesMIMEEntity
    Dim header As NotesMIMEHeader
    Dim stream As NotesStream
    Dim reqPanelRes As Variant
    Dim reqNum,  totalNoRes, reqNumCount, total As Integer
    Dim reqDate, reqDate1, reqDate2, firstresponse, reqSerLine, reqSerArea, reqIntType, response As String



    Dim MailsendTime As New NotesDateTime("")
    Dim CurDate As New NotesDateTime("")
    Dim diff As Long
    Dim diff1 As Long


    Set sess = New NotesSession
    Set db = sess.CurrentDatabase
    Set vwSearchRequests = db.GetView("RequestDocConsolidated")
    Set searchDoc = vwSearchRequests.GetFirstDocument


    MsgBox "hello"
    Set stream = sess.CreateStream
    'sess.ConvertMIME = False ' Do not convert MIME to rich text
    Set doc = db.CreateDocument
    doc.Form = "Memo"
    Set body = doc.CreateMIMEEntity
    Set header = body.CreateHeader("Subject")
    Call header.SetHeaderVal("myHire - Consolidated Report")
    Set header = body.CreateHeader("To")
    Call header.SetHeaderVal("Ashutosh Das/India/IBM@IBMIN")
    Call stream.writetext(|<HTML>|)
    Call stream.writetext(|<head>|)
    Call stream.writetext(|<style>|)
    Call stream.writetext(|table.gridtable{border-width: 1px; border-color: #666666; border-collapse: collapse; width: 95%;}|)
    Call stream.writetext(|table.gridtable th{font-family: verdana,arial,sans-serif; font-size: 11px; color: #FFFFFF; border-width: 1px; padding: 4px; border-style: solid; border-color: #666666; background-color: #09092a;}|)
    Call stream.writetext(|table.gridtable td{font-family: verdana,arial,sans-serif; font-size: 11px; color: #000000; border-width: 1px; padding: 4px; border-style: solid; border-color: #666666; background-color: #ffffff;}|)
    Call stream.writetext(|</style>|)
    Call stream.writetext(|</head>|)
    Call stream.writetext(|<body bgcolor="white">|)
    'Call stream.writetext(|<img src="\myHire_Header.jpg" alt="myHire">|)
    Call stream.writetext(|<font style="font-family: verdana,arial,sans-serif; font-size: 13px; color: #333333;"><br><br>Report to show list of second line escalations gone out SL vise<br><br></font>|)
    Call stream.writetext(|<table class="gridtable">|)
    Call stream.writetext(|<tr>|)
    Call stream.writetext(|<th>Service Line</th><th>Service Area</th><th>Date of Notification</th><th>Panel Name</th><th>Tech/PDM</th><th>Panel Manager</th><th>Date Escalation mail was sent</th><th>Manager response to first escalation</th><th>Date second escalation mail was sent</th><th>Manager response to second escalation</th>|)
    Call stream.writetext(|</tr>|)

    While Not searchDoc Is Nothing

        reqNum = searchDoc.PS_RequestNo(0)

        reqSerLine = searchDoc.PS_Service_Line(0)
        reqSerArea = searchDoc.PS_Service_Area(0)
        reqDate = CStr(Format(searchDoc.RequestSendDate(0),"dd/mm/yyyy hh:mm:ss"))
        PanelId = searchDoc.PANELID(0)
        PanelType = searchDoc.Panel_Type(0)
        PeM_ID = searchDoc.PeM_NotesID(0)
        PanelResponsedate = searchDoc.PanelResponsedate(0) 
        total = 0   

        MsgBox "Hi1"
        Set reqNumColl = vwSearchRequests.GetAllDocumentsByKey(searchDoc.PS_RequestNo(0))
        Set reqNumDoc = reqNumColl.GetFirstDocument
        reqNumCount = reqNumColl.Count

        For i = 1 To reqNumCount
            If Not reqNumDoc.GetFirstItem("PanelResponse") Is Nothing Then
                reqPanelRes = reqNumDoc.GetItemValue("PanelResponse") 

                Set MailsendTime = New NotesDateTime(searchDoc.REQUESTDATE(0))
                Set CurDate = New NotesDateTime(Today)
                diff = CurDate.TimeDifference(MailsendTime)  
                diff1 = CurDate.TimeDifference(searchDoc.PanelResponsedate(0))  
                NoDays = Int(diff/86400)
                NoDays1 = Int(diff1/86400)

                MsgBox "Hi2"
                If CStr(reqPanelRes(0)) = "Accepted" Then
                    response = "Yes"
                End If

                If CStr(reqPanelRes(0)) = "Rejected" Then
                    response = "Yes"
                End If

                If CStr(reqPanelRes(0)) = "OOO" Then
                    response = "Yes"
                End If
            Else
                response = "No"
            End If
            total = total + 1

            reqDate1 = CStr(searchDoc.RequestSendDate(0)+ 2 )
            reqDate2 = CStr(searchDoc.RequestSendDate(0)+ 3 )
            Set reqNumDoc = reqNumColl.GetNextDocument(reqNumDoc)

            MsgBox "Hi3"
            If total = reqNumCount Then
                Call stream.writetext(|<tr>|)
                Call stream.writetext(|<td>| & reqSerLine & |</td><td>| & reqSerArea & |</td><td>| & reqdate & |</td><td>| & PanelId & |</td><td>| & PanelType & |</td><td>| & PeM_ID & |</td><td align=right>| & reqDate1 & |</td><td align=right>| & firstresponse & |</td><td align=right>| & reqdate2 & |</td><td align=right>| & CStr(response) & |</td>|)
                Call stream.writetext(|</tr>|)
            End If

            Set searchDoc = vwSearchRequests.GetNextDocument(searchDoc)
        Next        
    Wend

    MsgBox "Hi4"
    Call stream.writetext(|</table>|)
    user$ = sess.CommonUserName 'if scheduled agent this returns the name of the server
    'Below uses the ampersand (&) to concatenate user$
    Call stream.writetext(|<br>|)
    Call stream.writetext(|<font style="font-family: verdana,arial,sans-serif; font-size: 13px; color: #333333;">Thank you.<br><br>Regards,<br><br><b>myHire Team</b>.</font>|)
    Call stream.writetext(|</body>|)
    Call stream.writetext(|</html>|)
    Call body.SetContentFromText(stream, "text/HTML;charset=UTF-8", ENC_IDENTITY_7BIT)
    Call doc.Send(False)
    sess.ConvertMIME = True ' Restore conversion - very important

    Exit Sub

ErrorOut:
    Print "Error ocurred - Agent: agMailSendDailyReport; Error Line: " & Erl & "; Error: " & Error & "."
    Exit Sub
End Sub
纳特·赫尔曼(Knut Herrmann)

您的代码行

   Set searchDoc = vwSearchRequests.GetNextDocument(searchDoc)

应该代码行之后Next

否则,变量reqNumCount至少适用于一个文档,0并且searchDoc永远保持不变。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章