Agent that Runs in Names.nsf and Sends Licensing Report

Author: Tripp W Black

Created: 08/02/2002 at 02:50 PM

 

Category:
Notes Developer Tips
Agents

This report is meant to be customized by the knowledgable admin. There is a user section where you can specify whether or not to run in detail mode which gives who has what kind of client with totals or just totals. The user section also includes a sento variable which can be lengthened/modified to include more people or groups to receive the report.

Code goes in initialization event. Recommended that this be run on schedule or kicked off with a button. (If kicked off with a button, it might be nice addition to have the button set whether or not to generate a long or short report.)

Sub Initialize
' this agent minds the values in the license view and emails them to the user in the sendto field's value
Dim s As New NotesSession
Dim db As NotesDatabase ' this database, names.nsf
Dim v As NotesView ' the license view
Dim doc As NotesDocument ' current entry document
Dim counttotal As Long ' total clients
Dim count0type As Long ' type 0 total
Dim count1type As Long ' type 1 total
Dim count2type As Long ' type 2 total
Dim count5type As Long ' type 5 total
Dim countothertype As Long ' other clients type
Dim countserver As Long ' servers count total
Dim aName As NotesName ' temporary holding variable
Dim sendtonames() As String ' list of recipients

Dim typedoc As String ' type of client or server
Dim longversion As Integer ' whether to run this agent in long mode with user detail or short mode of just totals

Dim mailDoc As NotesDocument ' memo being sent with license info
Dim Body As NotesRichTextItem ' body field

' ****************************** user customizable section ***********************
' toggle for long or short version of email
longversion = 1 ' change this line to 0 for just totals or 1 for details

' recipients list
Redim sendtonames(1)
sendtonames(0) = "Administrators"
sendtonames(1) = "Licensing"
' ****************************** end user customizable section ***********************

' initialize the counts
counttotal = 0
count0type = 0
count1type = 0
count2type = 0
count5type = 0
countothertype = 0
countserver = 0

' initialize the rest of the stuff
Set db = s.CurrentDatabase
Set v= db.GetView("Licenses")
Set doc=v.GetFirstDocument

' create mail doc and body header
Set mailDoc=db.CreateDocument
mailDoc.Form="Memo"
mailDoc.SaveMessageOnSend = False
mailDoc.From = "System Agent"
mailDoc.ReplyTo = "Administrator@mindwatering.com"
mailDoc.Principal = "Administrator@mindwatering.com"
mailDoc.Subject = "License information for Domino"
Set Body = New NotesRichTextItem( mailDoc , "Body" )
Call Body.AppendText("License information for domain on server: " & db.Server)
Call Body.AddNewLine(2)

' process all the docs in view
While Not (doc Is Nothing)
' use document values to add to counts
If doc.Type(0) = "Server" Then
If longversion=1 Then
typedoc = "Domino Server"
Set aName=New NotesName(doc.ServerName(0))
Call Body.AppendText("Server: " & aName.Abbreviated)
Call Body.AddNewLine(1)
End If
countserver=countserver+1
Else
' get type of person license
Select Case doc.ClientType(0)
Case "0"
If longversion=1 Then
typedoc = "Notes Client: "
Set aName=New NotesName(doc.FullName(0))
Call Body.AppendText(typedoc & aName.Abbreviated)
Call Body.AddNewLine(1)
End If
count0type=count0type+1
Case "1"
If longversion=1 Then
typedoc = "Notes Client - Mail: "
Set aName=New NotesName(doc.FullName(0))
Call Body.AppendText(typedoc & aName.Abbreviated)
Call Body.AddNewLine(1)
End If
count1type=count1type+1
Case "2"
If longversion=1 Then
typedoc = "Notes Client - Desktop: "
Set aName=New NotesName(doc.FullName(0))
Call Body.AppendText(typedoc & aName.Abbreviated)
Call Body.AddNewLine(1)
End If
count2type=count2type+1
Case "5"
If longversion=1 Then
typedoc = "Domino Client - iNotes/Domino CAL: "
Set aName=New NotesName(doc.FullName(0))
Call Body.AppendText(typedoc & aName.Abbreviated)
Call Body.AddNewLine(1)
End If
count5type=count5type+1
Case Else
If longversion=1 Then
typedoc = "Client - Other/Unknown: "
Set aName=New NotesName(doc.FullName(0))
Call Body.AppendText(typedoc & aName.Abbreviated)
Call Body.AddNewLine(1)
End If
countothertype=countothertype+1
End Select
End If
Set doc=v.GetNextDocument(doc)
Wend

' create tally text
Call Body.AppendText("Notes Clients: " & Cstr(count0type))
Call Body.AddNewLine(1)
Call Body.AppendText("Notes Clients - Mail: " & Cstr(count1type))
Call Body.AddNewLine(1)
Call Body.AppendText("Notes Clients - Desktop: " & Cstr(count2type))
Call Body.AddNewLine(1)
Call Body.AppendText("Domino Clients - iNotes/Domino CAL: " & Cstr(count5type))
Call Body.AddNewLine(1)
Call Body.AppendText("Other Clients - Unknown: " & Cstr(countothertype))
Call Body.AddNewLine(1)
Call Body.AppendText("___________________________________________")
Call Body.AddNewLine(1)
Call Body.AppendText(" Clients Total: " & Cstr(count0type + count1type + count2type + count5type + countothertype))
Call Body.AddNewLine(2)
Call Body.AppendText(" Servers Total: " & Cstr(countserver))

Call mailDoc.Send(False, sendtonames )

End Sub

previous page