2016-01-21 59 views
1

我是lotusscripting的初學程序員,並且自己創建了一些基本代碼。最近我製作了一個預定的代理程序,將文檔複製到視圖中並將其移動到另一個數據庫(檔案庫)。但是還有一個需要完成的改進,那就是使存檔數據庫的位置變爲動態。你可以在我的代碼中看到,服務器/路徑&文件名是硬編碼:Lotus Domino(Lotusscript):動態查找文檔 - 查看

%REM 
Agent Archive Kiosk Walk-In Test 
Created Dec 11, 2015 by Daryl 
Description: Comments for Agent 
%END REM 
Option Public 
Option Declare 

Sub Initialize 
Dim s As New NotesSession 
Dim db As NotesDatabase 
Dim dbArchive As NotesDatabase 
Dim view As NotesView 
Dim doc As NotesDocument 
Dim tmpDoc As NotesDocument 
Dim docArchive As NotesDocument 
Dim archiveDate As NotesDateTime 
Dim createDate As NotesDateTime 
Dim count As Integer 
Dim serverName As String 
Dim archiveName As String 

Set db = s.Currentdatabase 
Set archiveDate = New NotesDateTime("Today") 
Call archiveDate.Adjustday(-30) 

Set view = db.Getview("KWICompletedView") 
view.Autoupdate = False 

'Static declaration of database for archive 
serverName = "SBYGAD61/SBYISDEV" 
archiveName = "reso\var\test\resovara.nsf" 
Set dbArchive = New NotesDatabase(serverName, archiveName) 

If dbArchive Is Nothing Then 
    Print "Warning: unable to access archive database." 
Else 
    count = 0 
    Set doc = view.Getfirstdocument 
    While Not(doc Is nothing) 
     Set tmpDoc = view.Getnextdocument(doc) 
     Set createDate = New NotesDateTime("") 
     createDate.Localtime = doc.Created 

     If archiveDate.Timedifference(createDate) > 0 Then 
      Set docArchive = New NotesDocument(dbArchive)     
      Call doc.Copyallitems(docArchive, True) 
      Call docArchive.Save(True, True) 
      'Call doc.Remove(True) 
      count = count + 1 
     End If 

     Set doc = tmpDoc 
    Wend 
    Print "Complete: "+Cstr(count)+" document(s) archived." 
    End If 
End Sub 

有一個在我當前的數據庫視圖包含歸檔DBS的位置,是的,有3個存檔DBS所以我就真的失去了,我很抱歉。我需要幫助,我將如何將這些文檔實際獲取/設置爲我的歸檔位置。謝謝!

+0

只是一個建議:閱讀標準的Notes存檔功能。 –

回答

3

你有一些你需要的邏輯。您需要獲取包含具有歸檔數據庫位置的文檔的視圖,是否正確?這可以這樣做:

Set viewArchiveInfo = db.Getview("View_With_Archive_Locations") 
Set firstArchiveInfoDoc = viewArchiveInfo.GetFirstDocument() 
serverName = firstArchiveInfoDoc.GetFirstItem("ArchiveServerName")(0) 
archiveName = firstArchiveInfoDoc.GetFirstItem("ArchiveName")(0) 

如果有三個不同的文檔包含歸檔db信息,則可以獲取下一個文檔。

您還可以查看配置文件文件,以便以更容易訪問的方式存儲歸檔數據庫信息。

+0

謝謝Ken。我遵循你的解決方案,效果很好。 :) – Daryl