2010-06-02 21 views
2

我有很多的Domino服務器上的數據庫,我需要找到的計數(版本8.5):的Lotus Domino 8.5的數據庫條目數

  • 每NSF總文檔數量
  • 的每個NSF的「所有文檔」視圖中的文檔數量

是否有任何獲取Domino Server 8.5的簡單方法來顯示它?

非常感謝 克里斯

回答

3

你能夠通過你的域服務器的一個域編目任務獲得的每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文件和數據庫文件的文件名,你要尋找的,所提供的計數您可以訪問到你的服務器上的所有數據庫的帳戶運行此。

0

我會在服務器上創建自己的「MyStats.nsf」數據庫。該數據庫將包含每n個小時觸發一次的LotusScript代理「UpdateAll」。

該代理程序基本上獲取數據庫路徑列表。爲每個路徑打開數據庫。 NotesDatabase.AllDocuments.Count爲您提供文檔的總數。打開視圖「($ All)」並檢索NotesView.AllEntries.Count nr。的文檔。爲「所有文件」。獲取這些信息並創建一個新的NotesDocument來保存數據庫名稱和檢索到的數字信息。最後但並非最不重要的是在MyStat中創建一個視圖來顯示結果。