我是一名初学者编写程序员,并自己编写了一些基本代码。最近我制作了一个预定代理,它在视图中复制文档并将其移动到另一个数据库(归档数据库)。但是还有另一个需要完成的增强,它是使归档数据库的位置动态化。您可以在我的代码中看到服务器/路径和文件名是硬编码的:
%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 :(得分:3)
你已经拥有了一些你需要的逻辑。您需要获取包含具有归档DB位置的文档的视图,对吗?这将是这样做的:
Set viewArchiveInfo = db.Getview("View_With_Archive_Locations")
Set firstArchiveInfoDoc = viewArchiveInfo.GetFirstDocument()
serverName = firstArchiveInfoDoc.GetFirstItem("ArchiveServerName")(0)
archiveName = firstArchiveInfoDoc.GetFirstItem("ArchiveName")(0)
如果有三个包含存档数据库信息的不同文档,则可以获取下一个文档。
您还可以查看配置文件,以便以更易于访问的方式存储存档数据库信息。