1

Тема: Восстановление ошибочно удаленных документов

В базе "корзина" используется кнопка "Восстановить", для копирования документов в основную базу документооборота.

Sub Click(Source As Button)
    Dim ws As New NotesUIWorkspace
    Dim uiview As NotesUIView
    Dim dc1 As NotesDocumentCollection
    Dim session As New NotesSession
    Dim view As NotesView
    Dim db As NotesDatabase, strukdb As notesdatabase
    Dim dc As NotesDocumentCollection, strukdc As NotesDocumentCollection
    Dim curdoc As NotesDocument, docreg As NotesDocument, ftdoc As notesdocument,  strukdoc As NotesDocument
    Dim  nextftdoc As  NotesDocument
    Dim mes As String, mes2 As String, mes3 As String, who As String, server As String, user As String, shadow1 As String, shadow2 As String
    Dim flag As Boolean
    Dim picklist As Variant, sdate As Variant
    Dim item As NotesItem, item2 As NotesItem, item3 As NotesItem, item4 As NotesItem 
    Dim valueArray() As String
    Dim kom As String
    Dim kkey As String
    
    Dim workdb As NotesDatabase
    Dim newdoc As NotesDocument
    
    On Error Goto Errh
    
    Set uiview = ws.CurrentView
    Set dc1 = uiview.Documents
    
    Set db = session.CurrentDatabase
    server = db.Server
    user = session.CommonUserName
    
    server = db.Server
    Set workdb = New NotesDatabase( server, "...pdoc\documents.nsf" )
    
    If dc1.Count<1 Then
        Msgbox "Необходимо выбрать по крайней мере один документ !"
        Exit Sub
    End If
    
    Set curdoc = dc1.GetFirstDocument
    
    Set db = session.CurrentDatabase    
    
    While Not (curdoc Is Nothing)
        
        Set newdoc=workdb.CreateDocument        
        Call curdoc.CopyAllItems(newdoc,1)
        newdoc.UniversalID=curdoc.UniversalID
        newdoc.who="На регистрации"
        newdoc.whois="На регистрации"
        newdoc.archive=""
        Call newdoc.Save(True,False)
        
        Set nextdoc = dc1.GetNextDocument (curdoc)
        Set curdoc=nextdoc
        Set nextdoc=Nothing
        
    Wend
    Call uiview.DeselectAll
    Call uiview.View.Refresh()
    
    Messagebox "Документ(ы) восстановлен(ы) из корзины на регистрацию!"
    Exit Sub
errh:
    Msgbox Error & | in line | & Erl(), 64, |Lotus Notes (| & Lsi_info(2) & |)|
    Exit Sub    
End Sub

Поделиться