Tip

Show (or mail) all relevant info about a database

To manage a database, you need all relevant information--preferably in one action. This agent shows (or mails) all relevant data.
'AdminDisplay version information:

Option Public
Option Declare
Dim session As notessession
Dim db As notesdatabase
Dim docVersion As notesdocument
Dim agt As NotesAgent
Dim acl As notesACL
Dim aclEntry As notesACLentry
Dim nn As notesname

Dim strMessage As String
Dim strPlatform
Dim strFile As String
Dim strVersion As String
Dim strAgents As String
Dim strACL As String
Dim strLevel As String
Dim varRoles As Variant
Dim strRoles As String

Dim strReplication As String
Sub Initialize
%REM
Created by Ronald Snijder
Last updated 20/2/2002 by Ronald Snijder

History:
Version 1.0
             Updated by: Ronald Snijder
             Date: 20/2/2002


Functionality:
This agent retrieves and shows all relevant data, needed for daily
administrative tasks
%END REM

      Set session = New notessession
      Set db = session.currentdatabase

      Call getPlatform
      Call getFile
      Call getAgents
      Call getACL
      Call getReplication

      Messagebox _
      strPlatform & Chr(10) & _
      strFile & Chr(10) & _
      strAgents & Chr(10)  & _
      strACL & Chr(10)  & _
      strReplication, _
      0 + 64, "Version information"
End Sub

Sub getFile
      Set nn = New notesname(db.server)
      strFile = "File information:" & Chr(10)
      strFile = strFile & "Title: " & db.Title & Chr(10)
      strFile = strFile & "Path: " & db.filepath & ", on server " & nn.abbreviated & Chr(10)
      strFile = strFile & "Template name: " & db.DesignTemplatename &
Chr(10)
End Sub

Sub getAgents
      strAgents = "Scheduled agents:" & Chr(10)
      Forall a In db.Agents
            If a.Servername <> "" Then
                  Set nn = New notesname(a.ServerName)
                  If a.Isenabled Then
                        strAgents = strAgents & "* " & a.Name & " (server: " & nn.Common &  ", owner: " & a.Commonowner &  _
                        ") is ENABLED." & Chr(10)
                  Else
                        strAgents = strAgents & "* " & a.Name & " (server: " & nn.Common  &  ", owner: " & a.Commonowner &  _
                        ") is DISABLED." & Chr(10)
                  End If
            End If
      End Forall
End Sub

Sub getPlatform
      strPlatform = "Current Notes version: " & Trim(session.Notesversion)
& " on " & session.Platform & Chr(10)
End Sub

Sub getACL
      Set acl = db.ACL
      Set aclentry = acl.getfirstentry
      strACL = "Database ACL: " & Chr(10)

      Do While Not aclentry Is Nothing
            strRoles = ""
            strLevel = ""

            Set nn = New Notesname(aclEntry.Name)

            Select Case aclEntry.Level
            Case ACLLEVEL_NOACCESS : strLevel = "No access"
            Case ACLLEVEL_DEPOSITOR : strLevel = "Depositor"
            Case ACLLEVEL_READER : strLevel = "Reader"
            Case ACLLEVEL_AUTHOR : strLevel = "Author"
            Case ACLLEVEL_EDITOR : strLevel = "Editor"
            Case ACLLEVEL_DESIGNER : strLevel = "Designer"
            Case ACLLEVEL_MANAGER : strLevel = "Manager"
            End Select

            varRoles = aclEntry.Roles
            If Not(Isempty(varRoles)) Then
                  Forall dbRole In varRoles
                        strRoles = strRoles & ", " & dbRole
                  End Forall
            End If
            strRoles = Right(strRoles, Len(strRoles)-2)

            strACL = strACL & "* " & nn.Abbreviated & " (Access: " & strLevel & ", Role(s): " & strRoles & ")" & Chr(10)

            Set ACLEntry = ACL.GetNextEntry(ACLEntry)
      Loop
End Sub


Sub getReplication
      Dim repInfo As Notesreplication
      Dim strPrio As String

      Set repInfo = db.Replicationinfo

      strReplication = "Replication:" & Chr(10)

      strReplication = strReplication & "Replication id: " & db.Replicaid & Chr(10)

      If repInfo.Disabled Then
            strReplication = strReplication & "Replication is DISABLED" & Chr(10)
      Else
            strReplication = strReplication & "Replication is ENABLED" & Chr(10)
      End If

      Select Case repInfo.Priority
      Case DB_REPLICATION_PRIORITY_LOW : strPrio = "Low"
      Case DB_REPLICATION_PRIORITY_MED : strPrio = "Medium"
      Case DB_REPLICATION_PRIORITY_HIGH: strPrio = "High"
      Case Else:
            strPrio = "No data available"
      End Select

      strReplication = strReplication & "Priority: " & strPrio
End Sub

****************************************

To place the info in a mail message, use this Initialize event instead.

****************************************
Sub Initialize
%REM
Created by Ronald Snijder
Last updated 20/2/2002 by Ronald Snijder

History:
Version 1.0
             Updated by: Ronald Snijder
             Date: 20/2/2002


Functionality:
This agent retrieves and shows all relevant data, needed for daily
administrative tasks,
and places it in a mail message
%END REM
      Dim ws As New notesuiworkspace
      Dim dbMail As notesdatabase
      Dim docProfile As notesdocument
      Dim docMemo As notesdocument
      Dim uiDoc As notesuidocument
      Dim strMailText As String

      Set session = New notessession
      Set db = session.currentdatabase

      Call getPlatform
      Call getFile
      Call getAgents
      Call getACL
      Call getReplication

      strMailtext = _
      strPlatform & Chr(10) & _
      strFile & Chr(10) & _
      strAgents & Chr(10)  & _
      strACL & Chr(10)  & _
      strReplication

      Set dbMail = New NotesDatabase("","")
      dbMail.OpenMail
      Set docProfile = dbMail.GetProfileDocument("CalendarProfile")

      Set docMemo = New NotesDocument(dbMail)
      docMemo.Form = "Memo"
      docMemo.Logo = docProfile.DefaultLogo(0)
      docMemo.Principal = docProfile.Owner(0)
      docMemo.Subject = "Version information concerning " & db.Title

      Set uidoc = ws.EditDocument(True,docMemo)
      Call uidoc.Fieldappendtext("Body", strMailtext)
End Sub

****************************************

This was first published in February 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.