Manage Learn to apply best practices and optimize your operations.

Notesuseractivity Class

NotesUserActivity class

Represents a summary of user activity for a specified database.
Containment
Contains: NotesUserActivityEntry
Properties
UserActivityCount As Long
HasUserActivity As Integer
Parent As NotesDatabase

Methods
First as String
Last As String
Uses As Long
Reads As Long
Writes As Long
PrevDayUses As Long
PrevDayReads As Long
PrevDayWrites As Long
PrevWeekUses As Long
PrevWeekReads As Long
PrevWeekWrites As Long
PrevMonthUses As Long
PrevMonthReads As Long
PrevMonthWrites As Long
GetNthUserActivityEntry(EntryNumber As Long) As NotesUserActivityEntry

Access & New
The NotesUserActivity class represents a summary of user activity for a
specified database as well as providing access to individual user activity
entries. User activity for the specified database must be enabled for this
function to work. After creating a new instance of the NotesUserActivity
object for a database you should interegate the HasUserActivity property to
ensure that activity is available.

Installation
Copy and paste the CLASSNotesUserActivity library from this database to your
source database.

In the Options section of your code include the line:

Use "CLASSNotesUserActivity"

Syntax
Dim variableName As New NotesUserActivity( notesDatabase)
or
Set notesUserActivityEntry = New NotesUserActivity( notesDatabase)

NotesUserActivityEntry class

Represents an User Activity Entry for a specified database.
Containment
Contain by: NotesUserActivity
Properties
UserName As String
Reads As Long
Writes As Long
Time As String

Methods
None

Example

Dim db As New NotesDatabase("","")
Dim ua As NotesUserActivity
Dim uae As NotesUserActivityEntry
Dim iCounter As Long

Call db.OpenMail
If Not db Is Nothing Then
Set ua = New NotesUserActivity(db)
If ua.HasUserActivity Then
Print "First: " + ua.First
Print "Last: " + ua.Last
Print "Uses: " + Cstr(ua.Uses)
Print "Uses Day: " + Cstr(ua.PrevDayUses)
Print "Uses Week: " + Cstr(ua.PrevWeekUses)
Print "Uses Month: " + Cstr(ua.PrevMonthUses)

For iCounter = 1 To ua.UserActivityCount
Set uae = ua.GetNthUserActivityEntry(iCounter)
Print "(" + Cstr(iCounter) + ") " + uae.Time + " " +
uae.UserName + " " + "Reads:" + Cstr(uae.Reads) + " Writes:" + Cstr(uae.Writes)
Next iCounter
End If
End If
'
' NotesUserActivity class (R1.0)
' Written by: Daniel Alvers (daniel.alvers@au.pwcglobal.com)
' PricewaterhouseCoopers (Aust)
' February, 14 2000
'
' This code is provided as is and no warranty, express or implied, exists
' as to its fitness for use for any purpose.
' You are free to use and distributed the code as long as credit is retained
' and this header is not removed
'

'Paste as a function into your code
Function ConvertTIMEtoText(TIMESTRUCT As TIMEDATE) As String

Dim spTime As String * MAXALPHATIMEDATE
Dim retLength As Integer

spTime = Space(MAXALPHATIMEDATE)
Call ConvertTIMEDATEToText (&h0,&h0, TIMESTRUCT,
spTime,MAXALPHATIMEDATE,retLength)
ConvertTIMEtoText = Left(spTime,retLength)
End Function

'Paste into the declarations section of your code

Const MAXALPHATIMEDATE = 80

Type TIMEDATE
Innard1 As Long
Innard2 As Long
End Type

Type DBACTIVITY
First As TIMEDATE
Last As TIMEDATE
Uses As Long
Reads As Long
Writes As Long
PrevDayUses As Long
PrevDayReads As Long
PrevDayWrites As Long
PrevWeekUses As Long
PrevWeekReads As Long
PrevWeekWrites As Long
PrevMonthUses As Long
PrevMonthReads As Long
PrevMonthWrites As Long
End Type

Type DBACTIVITY_ENTRY
Time As TIMEDATE
Reads As Integer
Writes As Integer
UserNameOffset As Long
End Type

Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval
dbName As String, hDb As Long) As Integer
Declare Function W32_NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" ( Byval hDb
As Long) As Integer
Declare Function W32_NSFDbGetUserActivity Lib "nnotes.dll" Alias
"NSFDbGetUserActivity" ( Byval hDB As Long, Byval flags As Long, retDbActivity
As DBActivity, rethUserInfo As Long, retUserCount As Long) As Integer
Declare Function W32_OSLockObject Lib "nnotes.dll" Alias "OSLockObject" ( Byval
handle) As Long
Declare Sub OSUnlockObject Lib "NNOTES.DLL" Alias "OSUnlockObject" (Byval
handle)
Declare Sub W32_OSMemFree Lib "NNOTES.DLL" Alias "OSMemFree" (Byval handle)
Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" ( hpvDest As Any,
Byval hpvSource As Long, Byval cbCopy As Long)
Declare Sub CopyMemoryString Lib "KERNEL32" Alias "RtlMoveMemory" ( Byval
hpvDest As String, Byval hpvSource As Long, Byval cbCopy As Long)
Declare Sub ConvertTIMEDATEToText Lib "NNOTES.DLL" Alias
"ConvertTIMEDATEToText" (Byval IntlFormat As Long,Byval TextFormat As Long,
actTIMEDATE As TIMEDATE, Byval retTextBuffer As String,Byval TextBufferLength
As Integer,retTextLength As Integer)

Class NotesUserActivityEntry
Public UserName As String
Public Reads As Long
Public Writes As Long
Public Time As String
End Class

Class NotesUserActivity

Private hDb As Long
Private pDbActivity As DBACTIVITY
Private rethUserInfo As Long
Private retUserCount As Long
Private prvdb As NotesDatabase
Private flgHasActivity As Integer

Sub Delete
If Me.flgHasActivity Then Call W32_OSMemFree(rethUserInfo)
If hDb <> 0 Then Call W32_NSFDbClose(hDb)
End Sub

Sub New (inpNotesDatabase As NotesDatabase)

Dim sDatabase As String
Dim rc As Integer

Me.flgHasActivity = False

'Get a valid NotesDatabase to the specified database
If inpNotesDatabase Is Nothing Then
Error 14101, "NotesUserActivity: Database Object is invalid"
Exit Sub
End If

Set prvdb = New NotesDatabase(inpNotesDatabase.Server,
inpNotesDatabase.FilePath)

If prvdb.Server = "" Then
sdatabase = prvdb.filepath
Else
sdatabase

Dig Deeper on Domino Resources - Part 7

SearchWindowsServer

Search400

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury

SearchDataCenter

SearchContentManagement

Close