Lotus Domino (Lotusscript):文档的动态查找 - 视图
Lotus Domino (Lotusscript) : Dynamic lookup of document - View
我是lotusscripting的初级程序员,自己做了一些基本的代码。最近我做了一个预定的代理,它复制视图中的文档并将其移动到另一个数据库(存档数据库)。但是还有另一个需要做的改进,那就是使归档数据库的位置动态化。您可以在我的代码中看到 server/path&filename 是硬编码的:
%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
我当前的数据库中有一个视图包含存档数据库的位置,是的,有 3 个存档数据库所以我真的迷路了,对不起。我需要有关如何将这些文档 get/set 作为我的存档位置的帮助。谢谢!
您已经具备了一些您需要的逻辑。您需要获取包含具有存档数据库位置的文档的视图,对吗?这样做是这样的:
Set viewArchiveInfo = db.Getview("View_With_Archive_Locations")
Set firstArchiveInfoDoc = viewArchiveInfo.GetFirstDocument()
serverName = firstArchiveInfoDoc.GetFirstItem("ArchiveServerName")(0)
archiveName = firstArchiveInfoDoc.GetFirstItem("ArchiveName")(0)
如果有三个不同的文档包含存档数据库信息,您可以获得下一个文档。
您还可以查看配置文件文档,将其作为以 easier-to-access 方式存储存档数据库信息的一种方式。
我是lotusscripting的初级程序员,自己做了一些基本的代码。最近我做了一个预定的代理,它复制视图中的文档并将其移动到另一个数据库(存档数据库)。但是还有另一个需要做的改进,那就是使归档数据库的位置动态化。您可以在我的代码中看到 server/path&filename 是硬编码的:
%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
我当前的数据库中有一个视图包含存档数据库的位置,是的,有 3 个存档数据库所以我真的迷路了,对不起。我需要有关如何将这些文档 get/set 作为我的存档位置的帮助。谢谢!
您已经具备了一些您需要的逻辑。您需要获取包含具有存档数据库位置的文档的视图,对吗?这样做是这样的:
Set viewArchiveInfo = db.Getview("View_With_Archive_Locations")
Set firstArchiveInfoDoc = viewArchiveInfo.GetFirstDocument()
serverName = firstArchiveInfoDoc.GetFirstItem("ArchiveServerName")(0)
archiveName = firstArchiveInfoDoc.GetFirstItem("ArchiveName")(0)
如果有三个不同的文档包含存档数据库信息,您可以获得下一个文档。
您还可以查看配置文件文档,将其作为以 easier-to-access 方式存储存档数据库信息的一种方式。