我有批处理vb.net作业,有/ for循环对象和创建字母,在代码中向数据库插入行,偶尔完成作业并挂起一些时间,当使用Visiual Basic 2008运行时,它好吧从不挂起,当它在Windows服务器上运行时,偶尔会挂起,请你能帮我找到导致它挂起的原因。
For i As Integer = 1 To myOverPmtContractInfos.Count
'For Each myOverpmtContractInfo In myOverPmtContractInfos
'Get all the contacts for the contract.
If Not myDBOverpmtContact.retrieveAllByBGContract((myOverPmtContractInfos(i).billingGrp), (myOverPmtContractInfos(i).contractNbr), myOverpmtContacts) Then
modErrorLog.WriteErrorLog(functionName & ": Error retrieving all contacts from Overpmt_Contacts for: " & myOverPmtContractInfos(i).billingGrp & " " & myOverPmtContractInfos(i).contractNbr)
createLetters = False
GoTo EndLetter
End If
'See if a second letter is due.
If isLetterNeeded((myOverPmtContractInfos(i).daysAged), iInterval2) Then
'Check to see if a second letter has already been processed.
If Not doesCorrespondenceExist(myOverPmtContractInfos(i), iInterval2Type) Then
' For j As Integer = 1 To myOverpmtContacts.Count
'For Each myOverpmtContact In myOverpmtContacts
'Populate a corrsepondence class object for the creation of the notice.
myOverpmtCorrespondence.billingGrp = myOverPmtContractInfos(i).billingGrp
myOverpmtCorrespondence.contractNbr = myOverPmtContractInfos(i).contractNbr
myOverpmtCorrespondence.corrNbr = myDBOverpmtCorrespondence.getNextNbr((myOverPmtContractInfos(i).billingGrp), (myOverPmtContractInfos(i).contractNbr))
myOverpmtCorrespondence.corrDate = todaysdate
myOverpmtCorrespondence.corrTypeId = iInterval2Type
myOverpmtCorrespondence.comments = ""
myOverpmtCorrespondence.postDate = todaysdate
myOverpmtCorrespondence.lastUpdated = todaysdate
If myOverpmtContacts.Count > 0 Then
modLetters.createCorrsepondence(myOverPmtContractInfos(i), myOverpmtContacts(1), myOverpmtCorrespondence)
iLetterCount = iLetterCount + 1
' insertCorrespondence(myOverpmtCorrespondence)
modErrorLog.WriteErrorLog(functionName & ": 2nd Letter created for: " & myOverpmtCorrespondence.billingGrp & " / " & myOverpmtCorrespondence.contractNbr & " / " & myOverpmtContacts(1).firstname)
End If
If myOverpmtContacts.Count > 1 Then
modLetters.createCorrsepondence(myOverPmtContractInfos(i), myOverpmtContacts(2), myOverpmtCorrespondence)
iLetterCount = iLetterCount + 1
modErrorLog.WriteErrorLog(functionName & ": 2nd Letter created for: " & myOverpmtCorrespondence.billingGrp & " / " & myOverpmtCorrespondence.contractNbr & " / " & myOverpmtContacts(2).firstname)
End If
If myOverpmtContacts.Count > 2 Then
modLetters.createCorrsepondence(myOverPmtContractInfos(i), myOverpmtContacts(3), myOverpmtCorrespondence)
iLetterCount = iLetterCount + 1
modErrorLog.WriteErrorLog(functionName & ": 2nd Letter created for: " & myOverpmtCorrespondence.billingGrp & " / " & myOverpmtCorrespondence.contractNbr & " / " & myOverpmtContacts(3).firstname)
End If
GoTo EndLetter
End If
End If
'See if a third letter is due.
If isLetterNeeded((myOverPmtContractInfos(i).daysAged), iInterval3) Then
'Check to see if a third letter has already been processed.
If Not doesCorrespondenceExist(myOverPmtContractInfos(i), iInterval3Type) Then
'For Each myOverpmtContact In myOverpmtContacts
' For k As Integer = 1 To myOverpmtContacts.Count
'Populate a corrsepondence class object for the creation of the notice.
myOverpmtCorrespondence.billingGrp = myOverPmtContractInfos(i).billingGrp
myOverpmtCorrespondence.contractNbr = myOverPmtContractInfos(i).contractNbr
myOverpmtCorrespondence.corrNbr = myDBOverpmtCorrespondence.getNextNbr((myOverPmtContractInfos(i).billingGrp), (myOverPmtContractInfos(i).contractNbr))
myOverpmtCorrespondence.corrDate = todaysdate
myOverpmtCorrespondence.corrTypeId = iInterval3Type
myOverpmtCorrespondence.comments = ""
myOverpmtCorrespondence.postDate = todaysdate
myOverpmtCorrespondence.lastUpdated = todaysdate
If myOverpmtContacts.Count > 0 Then
modLetters.createCorrsepondence(myOverPmtContractInfos(i), myOverpmtContacts(1), myOverpmtCorrespondence)
'modErrorLog.WriteErrorLog(functionName & ": Error creating 2nd Letter for: " & myOverpmtCorrespondence.billingGrp & " / " & myOverpmtCorrespondence.contractNbr)
iLetterCount = iLetterCount + 1
insertCorrespondence(myOverpmtCorrespondence)
modErrorLog.WriteErrorLog(functionName & ": Final Letter created for: " & myOverpmtCorrespondence.billingGrp & " / " & myOverpmtCorrespondence.contractNbr & " / " & myOverpmtContacts(1).firstname)
End If
If myOverpmtContacts.Count > 1 Then
modLetters.createCorrsepondence(myOverPmtContractInfos(i), myOverpmtContacts(2), myOverpmtCorrespondence)
'modErrorLog.WriteErrorLog(functionName & ": Error creating 2nd Letter for: " & myOverpmtCorrespondence.billingGrp & " / " & myOverpmtCorrespondence.contractNbr)
iLetterCount = iLetterCount + 1
modErrorLog.WriteErrorLog(functionName & ": Final Letter created for: " & myOverpmtCorrespondence.billingGrp & " / " & myOverpmtCorrespondence.contractNbr & " / " & myOverpmtContacts(2).firstname)
End If
If myOverpmtContacts.Count > 2 Then
modLetters.createCorrsepondence(myOverPmtContractInfos(i), myOverpmtContacts(3), myOverpmtCorrespondence)
'modErrorLog.WriteErrorLog(functionName & ": Error creating 2nd Letter for: " & myOverpmtCorrespondence.billingGrp & " / " & myOverpmtCorrespondence.contractNbr)
iLetterCount = iLetterCount + 1
modErrorLog.WriteErrorLog(functionName & ": Final Letter created for: " & myOverpmtCorrespondence.billingGrp & " / " & myOverpmtCorrespondence.contractNbr & " / " & myOverpmtContacts(3).firstname)
End If
End If
End If
EndLetter:
'Reset the contacts collect for the next contract.
'UPGRADE_NOTE: Object myOverpmtContacts may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
myOverpmtContacts = Nothing
myOverpmtContacts = New OverpmtContacts
Next i
createLetters = True
EndFunction:
modErrorLog.WriteErrorLog("Number of letters created: " & iLetterCount)
'UPGRADE_NOTE: Object myOverPmtContractInfos may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
myOverPmtContractInfos = Nothing
'UPGRADE_NOTE: Object myDBOverpmtContractInfo may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
myDBOverpmtContractInfo = Nothing
'UPGRADE_NOTE: Object myCodeTranslate may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
myCodeTranslate = Nothing
'UPGRADE_NOTE: Object myOverpmtContacts may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
myOverpmtContacts = Nothing
'UPGRADE_NOTE: Object myDBOverpmtContact may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
myDBOverpmtContact = Nothing
myOverpmtCorrespondence = New OverpmtCorrespondence
myDBOverpmtCorrespondence = New DBOverpmtCorrespondence
End Function
答案 0 :(得分:0)
如果某个应用程序有时会表现,但并非总是如此,那么它通常(但并不总是)由外部因素引起。
如果由外部因素引起:
如果您可以消除外部因素,请查看您的代码。
这些只是我能想到的一些事情,当零星的行为出现时,应该考虑这些事情。