Lotus Domino 8.5 数据库条目计数

发布于 2024-09-03 11:43:38 字数 172 浏览 3 评论 0原文

我在 Domino 服务器(版本 8.5)上有多个数据库,我需要查找以下计数:

  • 每个 NSF 的文档总数
  • 每个 NSF 的“所有文档”视图中的文档数

有没有任何简单的方法让 Domino Server 8.5 显示这个?

非常感谢 克里斯

I have a number of databases on a Domino Server (version 8.5) which I need to find the counts of:

  • the number of documents in total per NSF
  • the number of documents in the "All Documents" view per NSF

Is there any simple way of getting Domino Server 8.5 to display this?

Many thanks
Chris

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海夕 2024-09-10 11:43:39

您可以通过在域的一台服务器上启用域目录任务来获取每个 NSF 的文档数量。这将创建一个域目录数据库 (catalog.nsf),其中包含域中所有数据库的信息。然后,您可以在该数据库中创建自定义视图,以按文档总数等组织数据库。

不幸的是,编目过程不会跟踪每个视图中有多少文档。此外,无法保证每个数据库都有“所有文档”视图。该视图是许多数据库设计模板(例如“邮件”或“讨论”)的一部分,但它实际上只是一个设计元素,而不是每个笔记数据库的基础。

您可以运行以下一些代码来在给定服务器上获取该信息。请注意,这段代码非常慢。

Sub CountDocuments()

'Handle database not open error
On Error Goto ProcessError
On Error 4060 Goto ProcessNotOpenError
On Error 4063 Goto ProcessNotOpenError
On Error 4185 Goto ProcessNotOpenError

'Constants
Const SERVERNAME = "SERVER/DOMAIN"
Const FILENAME = "C:\database_entry_counts.csv"

 'Initialize Objects
Dim s As New Notessession
Dim db As Notesdatabase
Dim dbDirectory As NotesDbDirectory
Dim docCollection As NotesDocumentCollection
Dim doc As NotesDocument
Dim strRow As String
Dim numDocs As Long, numAllDocs As Long
Dim viewAllDocs As NotesView
Dim vecAllDocs As NotesViewEntryCollection
Dim ve As NotesViewEntry
Dim docCount As Long

 'Get Database Directory
Set dbDirectory = s.GetDbDirectory(SERVERNAME)
Set db = dbDirectory.GetFirstDatabase(DATABASE)
flag = db.Open( "", "" )     
While flag = False  'Get next database if first can't be opened
    Set db = dbDirectory.GetNextDatabase
    flag = db.Open( "", "" )     
Wend

'Open output file   
Set stream = s.CreateStream
If Not stream.Open(FILENAME, "ASCII") Then
    Messagebox FILENAME,, "Open failed"
    Exit Sub
End If
If stream.Bytes <> 0 Then
    Messagebox FILENAME,, "File already exists and has content"
    Exit Sub
End If

'Output headers
Call stream.WriteText(|"Database Name","Total Documents","Count of All Documents"|, EOL_CRLF)


 'Main Loop
While Not (db Is Nothing)

    Print "Working on: " & db.Title

    docCount = 0
    strRow = ""

    'Get number of documents in database (easy)
    numDocs = db.AllDocuments.Count

    'Get number of documents in view (annoyingly difficult)
    Set viewAllDocs = db.GetView("($All)")
    If Not (viewAllDocs Is Nothing) Then
        Set vecAllDocs = viewAllDocs.AllEntries
        Set ve = vecAllDocs.GetFirstEntry
        While Not (ve Is Nothing)
            If ve.IsDocument Then docCount = docCount + 1           
            Set ve = vecAllDocs.GetNextEntry(ve)
        Wend
    Else
        docCount = 0
    End If

    'Output values to our comma delimited list
    strRow = |"| & db.Title & |","| & numDocs & |","| & docCount & |"|
    Call stream.WriteText(strRow, EOL_CRLF)

    'Get next database that can be opened
    Set db = dbDirectory.GetNextDatabase
    If Not (db Is Nothing) Then flag = db.Open( "", "" )
    While flag = False  
        Set db = dbDirectory.GetNextDatabase
        If Not (db Is Nothing) Then flag = db.Open( "", "" )     
    Wend

Wend

'Close file
Call stream.Close

Exit Sub

ProcessNotOpenError:

Resume Next

ProcessError:

Messagebox "Error " & Err() & ": " & Error()
If Not stream Is Nothing Then
    stream.Close
End If

Exit Sub

End Sub

这将输出一个 CSV 文件,其中包含数据库名称以及您要查找的计数,前提是您使用有权访问服务器上所有数据库的帐户运行此文件。

You can get the number of documents per NSF by enabling the Domain Catalog task on one of your domain's servers. That will create a domain catalog database (catalog.nsf) with information on all the databases in the domain. You can then create a custom view in that database to organize the databases by total documents, etc.

Unfortunately the cataloging process doesn't track how many documents are in each view. Furthermore, there's no guarantee each database even has an All Documents view. That view is part of many database design templates like Mail or Discussions, but it is really just a design element and not something fundamental to every notes database.

Here is some code you can run to fetch that information for you on a given server. Note, this code is pretty slow.

Sub CountDocuments()

'Handle database not open error
On Error Goto ProcessError
On Error 4060 Goto ProcessNotOpenError
On Error 4063 Goto ProcessNotOpenError
On Error 4185 Goto ProcessNotOpenError

'Constants
Const SERVERNAME = "SERVER/DOMAIN"
Const FILENAME = "C:\database_entry_counts.csv"

 'Initialize Objects
Dim s As New Notessession
Dim db As Notesdatabase
Dim dbDirectory As NotesDbDirectory
Dim docCollection As NotesDocumentCollection
Dim doc As NotesDocument
Dim strRow As String
Dim numDocs As Long, numAllDocs As Long
Dim viewAllDocs As NotesView
Dim vecAllDocs As NotesViewEntryCollection
Dim ve As NotesViewEntry
Dim docCount As Long

 'Get Database Directory
Set dbDirectory = s.GetDbDirectory(SERVERNAME)
Set db = dbDirectory.GetFirstDatabase(DATABASE)
flag = db.Open( "", "" )     
While flag = False  'Get next database if first can't be opened
    Set db = dbDirectory.GetNextDatabase
    flag = db.Open( "", "" )     
Wend

'Open output file   
Set stream = s.CreateStream
If Not stream.Open(FILENAME, "ASCII") Then
    Messagebox FILENAME,, "Open failed"
    Exit Sub
End If
If stream.Bytes <> 0 Then
    Messagebox FILENAME,, "File already exists and has content"
    Exit Sub
End If

'Output headers
Call stream.WriteText(|"Database Name","Total Documents","Count of All Documents"|, EOL_CRLF)


 'Main Loop
While Not (db Is Nothing)

    Print "Working on: " & db.Title

    docCount = 0
    strRow = ""

    'Get number of documents in database (easy)
    numDocs = db.AllDocuments.Count

    'Get number of documents in view (annoyingly difficult)
    Set viewAllDocs = db.GetView("($All)")
    If Not (viewAllDocs Is Nothing) Then
        Set vecAllDocs = viewAllDocs.AllEntries
        Set ve = vecAllDocs.GetFirstEntry
        While Not (ve Is Nothing)
            If ve.IsDocument Then docCount = docCount + 1           
            Set ve = vecAllDocs.GetNextEntry(ve)
        Wend
    Else
        docCount = 0
    End If

    'Output values to our comma delimited list
    strRow = |"| & db.Title & |","| & numDocs & |","| & docCount & |"|
    Call stream.WriteText(strRow, EOL_CRLF)

    'Get next database that can be opened
    Set db = dbDirectory.GetNextDatabase
    If Not (db Is Nothing) Then flag = db.Open( "", "" )
    While flag = False  
        Set db = dbDirectory.GetNextDatabase
        If Not (db Is Nothing) Then flag = db.Open( "", "" )     
    Wend

Wend

'Close file
Call stream.Close

Exit Sub

ProcessNotOpenError:

Resume Next

ProcessError:

Messagebox "Error " & Err() & ": " & Error()
If Not stream Is Nothing Then
    stream.Close
End If

Exit Sub

End Sub

This will output a CSV file with the database name, and the counts you're looking for, provided you run this with an account that has access to all the databases on your server.

无需解释 2024-09-10 11:43:39

我将在服务器上创建自己的“MyStats.nsf”数据库。该数据库将包含每 n 小时触发一次的 LotusScript 代理“UpdateAll”。

代理基本上获取数据库路径列表。对于每个路径打开数据库。 NotesDatabase.AllDocuments.Count 为您提供文档总数。打开视图“($All)”并检索 NotesView.AllEntries.Count 的 nr。文档数量。对于“所有文档”。获取此信息并创建一个新的 NotesDocument 来保存数据库名称和检索到的号码信息。最后但并非最不重要的一点是在 MyStat 中创建一个视图来显示结果。

I would create my own "MyStats.nsf" database on the server. This db will contain an LotusScript Agent "UpdateAll" triggered each n hours.

The agent basically get a list of database paths. For each path open the database. The NotesDatabase.AllDocuments.Count gives you the total number of docs. Open the view "($All)" and retrive NotesView.AllEntries.Count the nr. of docs. for "All Documents". Take this information and create a new NotesDocument to save db name and the retrieved number info. Last but not least create a view in MyStat to display the result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文