无法将文档存档到lotus notes中的archive DB



有一个代理可以将文档归档到归档数据库,并将其从当前数据库中删除。但当我运行该代理时,一些文档会被归档,归档会停止,并出现错误"归档未决请求:4000:第33行:用户定义错误";

Option Public
'Use "LogError"  
Sub Initialize  
On Error Goto errorHandler

Dim s As New NotesSession   
Dim Odb As NotesDatabase
Dim Oview As NotesView
Dim Oview2 As NotesView
Dim archdb As NotesDatabase
Dim archdbpath As String        
Dim Ovc As NotesViewEntryCollection
Dim doc As NotesDocument    
Dim archview As NotesView


Set Odb = s.CurrentDatabase
archdbpath = "ArchivingArchive2_DunkMatMaint911.nsf"
Set archdb = s.GetDatabase("BRUSPLNA101", archdbpath, False)    

If Not(archdb.IsOpen()) Then
'Logaction "Could not locate Archive database "
Msgbox "Could not locate Archive database "
Exit Sub
End If  
'Set archview = archdb.GetView("vw_InArchivedDB")       
Set Oview = Odb.GetView("Archive Requests 1") '----Archiving View Name

Msgbox "Going In While Loop"
Set doc = Oview.GetFirstDocument()

While Not(doc Is Nothing)           
Call doc.CopyToDatabase(archdb) 
doc.Archived = "True"
Call doc.Save(True, False)      
Call Oview.Refresh      
Set doc = Oview.GetFirstDocument()
Wend    


Set Oview2 = Odb.GetView("Archive Requests 2")
Call Oview2.Refresh
Set Ovc = Oview2.AllEntries

Exit Sub    
errorHandler:
'LogAction("Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err) )
Msgbox "Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err)  
End Sub

幸运的是,您的代码有一个错误处理程序。。。所以我们确切地知道这个错误发生在哪一行:

Call doc.Save(True, False)  

这意味着:代码工作的文档无法保存。

不幸的是,错误数字4000是一个普通错误,可能意味着很多事情。我想,在您的情况下,文档已经增长到很大(一个字段中有32k个数据(,因此无法保存。

我会用这种方式更改代码,它会写一个关于无法存档的文档的日志,然后继续处理下一个文档,而不是崩溃。因此,您还需要更改逻辑,因为如果文档无法保存,它将永远不会从视图中消失:

Dim viwNav as NotesViewNavigator
Dim ve as NotesViewEntry
Set viwNav = Oview.CreateViewNavigator()
Oview.AutoUpdate = False
Set ve = viwNav.GetFirst()
While Not(ve Is Nothing)           
Set doc = ve.Document
On Error Goto errorHandlerDoc
Call doc.CopyToDatabase(archdb) 
doc.Archived = "True"
Call doc.Save(True, False)   
NextDoc:   
Set ve = viwNav.GetNext(ve)
Wend    
On Error Goto errorHandler
Set Oview2 = Odb.GetView("Archive Requests 2")
Call Oview2.Refresh
Set Ovc = Oview2.AllEntries
Exit Sub    
errorHandlerDoc:
Msgbox "Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err) + " for document " + doc.UniversalId
Resume NextDoc
errorHandler:
'LogAction("Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err) )
Msgbox "Archiving Pending Requests: " + Format$(Err) + " : Line " + Format$(Erl) + " : " + Error$(Err)  

最新更新