Is there any way to access user activity properties programmatically?

I was asked to create some reports on the activities on a set of applications. I wonder if you can access the user activity properties on a database programmatic-ally?

activity

Advertisements

10 thoughts on “Is there any way to access user activity properties programmatically?

  1. Jan 2013-May-15 / 11:49 am

    Yes there is, In the past I found a Useractivity class that can access it and I’ve used it to collect the info from databases on the server. It is then easy to filter out access by admins and server and get the real user activity.
    If interested I can share the template

    • Patrick Kwinten 2013-May-16 / 8:56 am

      Hello Jan, it would be great if you are willing to share a template. This will probably save some start-up time.

  2. Peter Närlund 2013-May-15 / 6:08 pm

    Here is a modified version of the referenced class that I made working on w32 w64 and unix

    Option Public
    Option Explicit

    Type TIMEDATE_W32
    Innard1 As Long
    Innard2 As Long
    End Type

    Type DBACTIVITY_W32
    First As TIMEDATE_W32
    Last As TIMEDATE_W32
    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 TIMEDATE_W64
    Innard1 As Integer
    Innard2 As Integer
    End Type

    Type DBACTIVITY_W64
    First As TIMEDATE_W64
    Last As TIMEDATE_W64
    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

    ‘ Windows
    Declare Function W32_NSFDbOpen Lib “nnotes.dll” Alias “NSFDbOpen” ( Byval dbName As Lmbcs 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_W32, rethUserInfo As Long, retUserCount As Long) As Integer
    Declare Function W64_NSFDbGetUserActivity Lib “nnotes.dll” Alias “NSFDbGetUserActivity” ( Byval hDB As Long, Byval flags As Long, retDbActivity As DBActivity_W64, rethUserInfo As Long, retUserCount As Long) As Integer

    Declare Function W32_OSLockObject Lib “nnotes.dll” Alias “OSLockObject” ( Byval handle) As Long
    Declare Sub W32_OSUnlockObject Lib “nnotes.dll” Alias “OSUnlockObject” (Byval handle)
    Declare Sub W32_OSMemFree Lib “nnotes.dll” Alias “OSMemFree” (Byval handle)

    Declare Function W32_ConvertTIMEDATEPtrToText Lib “nnotes.dll” Alias “ConvertTIMEDATEToText” ( Byval IntlFormat As Long, Byval TextFormat As Long, Byval pActivityEntry As Long, Byval retTextBuffer As String, Byval TextBufferLength As Integer, retTextLength As Integer) As Integer
    Declare Sub W32_ConvertTIMEDATEToText Lib “nnotes.dll” Alias “ConvertTIMEDATEToText” ( Byval IntlFormat As Long, Byval TextFormat As Long, pActivityEntry As TIMEDATE_W32, Byval retTextBuffer As String, Byval TextBufferLength As Integer, retTextLength As Integer)
    Declare Sub W64_ConvertTIMEDATEToText Lib “nnotes.dll” Alias “ConvertTIMEDATEToText” ( Byval IntlFormat As Long, Byval TextFormat As Long, pActivityEntry As TIMEDATE_W64, Byval retTextBuffer As String, Byval TextBufferLength As Integer, retTextLength As Integer)

    Declare Sub W32_CopyMemory Lib “KERNEL32” Alias “RtlMoveMemory” ( hpvDest As Any, Byval hpvSource As Long, Byval cbCopy As Long)
    Declare Sub W32_CopyMemoryString Lib “KERNEL32” Alias “RtlMoveMemory” ( Byval hpvDest As Lmbcs String, Byval hpvSource As Long, Byval cbCopy As Long)

    ‘ Linux
    ‘ void * memcpy (void * dest, const void * src, size_t count);
    Declare Function TUX_NSFDbOpen Lib “libnotes.so” Alias “NSFDbOpen” ( Byval dbName As Lmbcs String, hDb As Long) As Integer
    Declare Function TUX_NSFDbClose Lib “libnotes.so” Alias “NSFDbClose” ( Byval hDb As Long) As Integer

    Declare Function TUX_NSFDbGetUserActivity Lib “libnotes.so” Alias “NSFDbGetUserActivity” ( Byval hDB As Long, Byval flags As Long, retDbActivity As DBActivity_W32, rethUserInfo As Long, retUserCount As Long) As Integer
    ‘Declare Function W64_NSFDbGetUserActivity Lib “nnotes.dll” Alias “NSFDbGetUserActivity” ( Byval hDB As Long, Byval flags As Long, retDbActivity As DBActivity_W64, rethUserInfo As Long, retUserCount As Long) As Integer

    Declare Function TUX_OSLockObject Lib “libnotes.so” Alias “OSLockObject” ( Byval handle) As Long
    Declare Sub TUX_OSUnlockObject Lib “libnotes.so” Alias “OSUnlockObject” (Byval handle)
    Declare Sub TUX_OSMemFree Lib “libnotes.so” Alias “OSMemFree” (Byval handle)

    Declare Function TUX_ConvertTIMEDATEPtrToText Lib “libnotes.so” Alias “ConvertTIMEDATEToText” ( Byval IntlFormat As Long, Byval TextFormat As Long, Byval pActivityEntry As Long, Byval retTextBuffer As String, Byval TextBufferLength As Integer, retTextLength As Integer) As Integer
    Declare Sub TUX_ConvertTIMEDATEToText Lib “libnotes.so” Alias “ConvertTIMEDATEToText” ( Byval IntlFormat As Long, Byval TextFormat As Long, pActivityEntry As TIMEDATE_W32, Byval retTextBuffer As String, Byval TextBufferLength As Integer, retTextLength As Integer)
    ‘Declare Sub W64_ConvertTIMEDATEToText Lib “libnotes.so” Alias “ConvertTIMEDATEToText” ( Byval IntlFormat As Long, Byval TextFormat As Long, pActivityEntry As TIMEDATE_W64, Byval retTextBuffer As String, Byval TextBufferLength As Integer, retTextLength As Integer)

    Declare Sub TUX_CopyMemory Lib “libc.so.6” Alias “memcpy” ( hpvDest As Any, Byval hpvSource As Long, Byval cbCopy As Long)
    Declare Sub TUX_CopyMemoryString Lib “libc.so.6” Alias “memcpy” ( Byval hpvDest As Lmbcs String, Byval hpvSource As Long, Byval cbCopy As Long)

    ‘————————————————-
    ‘ Public Class NotesUserActivityEntry
    ‘————————————————-
    Public Class NotesUserActivityEntry
    Public UserName As String
    Public Reads As Long
    Public Writes As Long
    Public Time As String
    End Class

    ‘————————————————-
    ‘ Public Class NotesUserActivity
    ‘————————————————-
    Public Class NotesUserActivity

    Private debug As Boolean
    Private hDb As Long
    Private rethUserInfo As Long
    Private retUserCount As Long
    Private prvdb As NotesDatabase
    Private flgHasActivity As Integer

    Public First As String
    Public Last As String
    Public Uses As Long

    Public Reads As Long
    Public Writes As Long
    Public PrevDayUses As Long
    Public PrevDayReads As Long
    Public PrevDayWrites As Long
    Public PrevWeekUses As Long
    Public PrevWeekReads As Long
    Public PrevWeekWrites As Long
    Public PrevMonthUses As Long
    Public PrevMonthReads As Long
    Public PrevMonthWrites As Long

    Sub Delete
    If Me.flgHasActivity Then Call OSMemFree(rethUserInfo)
    If hDb 0 Then Call NSFDbClose(hDb)
    End Sub

    Private Function initDb( inpNotesDatabase As NotesDatabase) As Boolean

    initDb = False

    Me.debug = False
    Me.flgHasActivity = False

    ‘Get a valid NotesDatabase to the specified database
    If inpNotesDatabase Is Nothing Then
    Error 14101, “NotesUserActivity: Database Object is invalid”
    Exit Function
    End If

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

    Dim session As New notessession()

    Dim sDatabase As String
    ‘If prvdb.Server = “” Then
    If session.CreateName(session.UserName).canonical = session.CreateName(inpNotesDatabase.Server).canonical Then
    sdatabase = prvdb.filepath
    Else
    sdatabase = prvdb.server + “!!” + prvdb.filepath
    End If

    Dim rc As Integer
    rc = NSFDbOpen(sDatabase,Me.hDb)

    If rc = 0 Then
    initDb= True
    Else
    ‘ get error string
    End If

    End Function

    Sub OSMemFree(rethUserInfo As Long)
    Call W32_OSMemFree( rethUserInfo )
    End Sub

    Sub NSFDbClose(hDb As Long)
    Call W32_NSFDbClose( hDb )
    End Sub

    Function NSFDbOpen(sDatabase As String, hDb As Long) As Integer
    NSFDbOpen = W32_NSFDbOpen( sDatabase,hDb )
    End Function

    ‘Function NSFDbGetUserActivity( Byval hDB As Long, Byval flags As Long, retDbActivity As DBActivity_W32, rethUserInfo As Long, retUserCount As Long) As Integer
    ‘ NSFDbGetUserActivity = W32_NSFDbGetUserActivity( hDb, flags, retDbActivity, rethUserInfo, retUserCount )
    ‘End Function

    Function OSLockObject( handle ) As Long
    OSLockObject = W32_OSLockObject( handle )
    End Function

    Function ConvertTIMEDATEPtrToText ( IntlFormat As Long, TextFormat As Long, pActivityEntry As Long, retTextBuffer As String, TextBufferLength As Integer, retTextLength As Integer) As Integer
    ConvertTIMEDATEPtrToText = W32_ConvertTIMEDATEPtrToText ( IntlFormat, TextFormat, pActivityEntry, retTextBuffer, TextBufferLength, retTextLength )
    End Function

    Sub CopyMemory( hpvDest As Long, hpvSource As Long, cbCopy As Long)
    Call W32_CopyMemory( hpvDest, hpvSource, cbCopy )
    End Sub

    Sub CopyMemoryString( hpvDest As String, hpvSource As Long, cbCopy As Long)
    Call W32_CopyMemoryString( hpvDest, hpvSource, cbCopy )
    End Sub

    Sub OSUnlockObject( handle )
    Call W32_OSUnlockObject( handle )
    End Sub

    Sub init (inpNotesDatabase As NotesDatabase)

    End Sub

    Public Function UserActivityCount As Long
    UserActivityCount = Me.retUserCount
    End Function

    Public Function HasUserActivity As Integer
    HasUserActivity = Me.flgHasActivity
    End Function

    Public Function Parent As NotesDatabase
    Set Parent = Me.prvdb
    End Function

    Public Function GetNthUserActivityEntry(inpEntry As Long) As NotesUserActivityEntry

    On Error Goto catch

    Dim lEntry As Long
    lEntry = inpEntry – 1

    If Not Me.flgHasActivity Then Error 14104, “NotesUserActivity: No activity available”
    If lEntry >= Me.retUserCount Or lEntry < 0 Then
    Error 14103, "NotesUserActivity: Subscript out of range."
    End If

    Dim puActivity As Long
    puActivity = OSLockObject(Me.rethUserInfo)

    Dim pActivityEntry As Long
    Dim sDate As String
    Dim nDate As Integer
    Dim reads As Long
    Dim writes As Long
    Dim nameOffset As Long
    Dim sName As String

    pActivityEntry = puActivity + lEntry *16

    sDate = Space(256)
    ConvertTIMEDATEPtrToText 0, 0, pActivityEntry, sDate, Len(sDate), nDate

    CopyMemory reads, pActivityEntry + 8 , 2
    CopyMemory writes, pActivityEntry + 10 , 2
    CopyMemory nameOffset, pActivityEntry + 12 , 4
    sName = Space(256)
    CopyMemoryString sName, puActivity + nameOffset, 256
    sName = Left(sName, Instr(sName, Chr(0)) – 1)

    If Me.debug Then Print Left$(sDate, nDate) & " " & sName & " read " & Cstr(reads) & ", wrote " & Cstr(writes)

    Dim nuae As New NotesUserActivityEntry
    With nuae
    .UserName = sName
    .Reads = reads
    .Writes = writes
    .Time = Left$(sDate, nDate)
    End With

    Call OSUnlockObject(rethUserInfo)

    Set GetNthUserActivityEntry = nuae

    Exit Function
    catch:
    Print "GetNthUserActivityEntry Error: " & Error & " Err: " & Err & " Erl: " & Erl
    Resume eos
    eos:
    End Function

    Private Sub printActivityDebug()
    If Me.debug Then
    Print "First " & Me.First
    Print "Last " & Me.Last
    Print "Uses " & Me.Uses
    Print "Reads " & Me.Reads
    Print "Writes " & Me.Writes
    Print "PrevDayUses " & Me.PrevDayUses
    Print "PrevDayReads " & Me.PrevDayReads
    Print "PrevDayWrites " & Me.PrevDayWrites
    Print "PrevWeekUses " & Me.PrevWeekUses
    Print "PrevWeekReads " & Me.PrevWeekReads
    Print "PrevWeekWrites " & Me.PrevWeekWrites
    Print "PrevMonthUses " & Me.PrevMonthUses
    Print "PrevMonthReads " & Me.PrevMonthReads
    Print "PrevMonthWrites " & Me.PrevMonthWrites
    End If
    End Sub

    End Class

    Class NotesUserActivity_W32 As NotesUserActivity

    Private pDbActivity As DBACTIVITY_W32

    Function NSFDbGetUserActivity( hDB As Long, flags As Long, retDbActivity As DBActivity_W32, rethUserInfo As Long, retUserCount As Long) As Integer
    Dim rc As Integer
    rc = W32_NSFDbGetUserActivity( hDb, flags, retDbActivity, rethUserInfo, retUserCount )
    If rc 0 Then
    ‘ display error code
    Else
    NSFDbGetUserActivity = rc
    End If

    End Function

    Sub init (inpNotesDatabase As NotesDatabase)

    If Not initDb( inpNotesDatabase) Then
    Exit Sub
    End If

    If NSFDbGetUserActivity(Me.hDb, &h0, Me.pDbActivity, Me.rethUserInfo, Me.retUserCount ) 0 Then Exit Sub
    Me.flgHasActivity = True

    Me.First = ConvertTIMEtoText(Me.pDbActivity.First)
    Me.Last = ConvertTIMEtoText(Me.pDbActivity.Last)
    Me.Uses = Me.pDbActivity.Uses
    Me.Reads = Me.pDbActivity.Reads
    Me.Writes = Me.pDbActivity.Writes
    Me.PrevDayUses = Me.pDbActivity.PrevDayUses
    Me.PrevDayReads = Me.pDbActivity.PrevDayReads
    Me.PrevDayWrites = Me.pDbActivity.PrevDayWrites
    Me.PrevWeekUses = Me.pDbActivity.PrevWeekUses
    Me.PrevWeekReads = Me.pDbActivity.PrevWeekReads
    Me.PrevWeekWrites = Me.pDbActivity.PrevWeekWrites
    Me.PrevMonthUses = Me.pDbActivity.PrevMonthUses
    Me.PrevMonthReads = Me.pDbActivity.PrevMonthReads
    Me.PrevMonthWrites = Me.pDbActivity.PrevMonthWrites

    Call printActivityDebug()
    End Sub

    Private Function ConvertTIMEtoText(TIMESTRUCT As TIMEDATE_W32) As String
    Dim spTime As String * 80
    Dim retLength As Integer

    spTime = Space(80)
    Call W32_ConvertTIMEDATEToText (&h0,&h0, TIMESTRUCT, spTime,80,retLength)
    ConvertTIMEtoText = Left(spTime,retLength)
    End Function
    End Class

    Class NotesUserActivity_W64 As NotesUserActivity

    Private pDbActivity As DBACTIVITY_W64

    Sub OSMemFree(rethUserInfo As Long)
    Call W32_OSMemFree( rethUserInfo )
    End Sub

    Sub NSFDbClose(hDb As Long)
    Call W32_NSFDbClose( hDb )
    End Sub

    Function NSFDbOpen(sDatabase As String, hDb As Long) As Integer
    NSFDbOpen = W32_NSFDbOpen( sDatabase,hDb )
    End Function

    Function NSFDbGetUserActivity( hDB As Long, flags As Long, retDbActivity As DBACTIVITY_W64, rethUserInfo As Long, retUserCount As Long) As Integer
    NSFDbGetUserActivity = W64_NSFDbGetUserActivity( hDb, flags, retDbActivity, rethUserInfo, retUserCount )
    End Function

    Function OSLockObject( handle ) As Long
    OSLockObject = W32_OSLockObject( handle )
    End Function

    Function ConvertTIMEDATEPtrToText ( IntlFormat As Long, TextFormat As Long, pActivityEntry As Long, retTextBuffer As String, TextBufferLength As Integer, retTextLength As Integer) As Integer
    ConvertTIMEDATEPtrToText = W32_ConvertTIMEDATEPtrToText ( IntlFormat, TextFormat, pActivityEntry, retTextBuffer, TextBufferLength, retTextLength )
    End Function

    Sub CopyMemory( hpvDest As Long, hpvSource As Long, cbCopy As Long)
    Call W32_CopyMemory( hpvDest, hpvSource, cbCopy )
    End Sub

    Sub CopyMemoryString( hpvDest As String, hpvSource As Long, cbCopy As Long)
    Call W32_CopyMemoryString( hpvDest, hpvSource, cbCopy )
    End Sub

    Sub OSUnlockObject( handle )
    Call W32_OSUnlockObject( handle )
    End Sub

    Sub init (inpNotesDatabase As NotesDatabase)

    If Not initDb( inpNotesDatabase) Then
    Exit Sub
    End If

    If NSFDbGetUserActivity(Me.hDb, &h0, Me.pDbActivity, Me.rethUserInfo, Me.retUserCount ) 0 Then Exit Sub
    Me.flgHasActivity = True

    Me.First = ConvertTIMEtoText(Me.pDbActivity.First)
    Me.Last = ConvertTIMEtoText(Me.pDbActivity.Last)
    Me.Uses = Me.pDbActivity.Uses
    Me.Reads = Me.pDbActivity.Reads
    Me.Writes = Me.pDbActivity.Writes
    Me.PrevDayUses = Me.pDbActivity.PrevDayUses
    Me.PrevDayReads = Me.pDbActivity.PrevDayReads
    Me.PrevDayWrites = Me.pDbActivity.PrevDayWrites
    Me.PrevWeekUses = Me.pDbActivity.PrevWeekUses
    Me.PrevWeekReads = Me.pDbActivity.PrevWeekReads
    Me.PrevWeekWrites = Me.pDbActivity.PrevWeekWrites
    Me.PrevMonthUses = Me.pDbActivity.PrevMonthUses
    Me.PrevMonthReads = Me.pDbActivity.PrevMonthReads
    Me.PrevMonthWrites = Me.pDbActivity.PrevMonthWrites

    Call printActivityDebug()
    End Sub

    Private Function ConvertTIMEtoText(TIMESTRUCT As TIMEDATE_W64) As String
    Dim spTime As String * 80
    Dim retLength As Integer

    spTime = Space(80)
    Call W64_ConvertTIMEDATEToText (&h0,&h0, TIMESTRUCT, spTime,80,retLength)
    ConvertTIMEtoText = Left(spTime,retLength)
    End Function
    End Class

    ‘ Linux impl
    Class NotesUserActivity_TUX As NotesUserActivity

    Private pDbActivity As DBACTIVITY_W32

    Sub OSMemFree(rethUserInfo As Long)
    Call TUX_OSMemFree( rethUserInfo )
    End Sub

    Sub NSFDbClose(hDb As Long)
    Call TUX_NSFDbClose( hDb )
    End Sub

    Function NSFDbOpen(sDatabase As String, hDb As Long) As Integer
    NSFDbOpen = TUX_NSFDbOpen( sDatabase,hDb )
    End Function

    Function NSFDbGetUserActivity( hDB As Long, flags As Long, retDbActivity As DBActivity_W32, rethUserInfo As Long, retUserCount As Long) As Integer
    NSFDbGetUserActivity = TUX_NSFDbGetUserActivity( hDb, flags, retDbActivity, rethUserInfo, retUserCount )
    End Function

    Function OSLockObject( handle ) As Long
    OSLockObject = TUX_OSLockObject( handle )
    End Function

    Function ConvertTIMEDATEPtrToText ( IntlFormat As Long, TextFormat As Long, pActivityEntry As Long, retTextBuffer As String, TextBufferLength As Integer, retTextLength As Integer) As Integer
    ConvertTIMEDATEPtrToText = TUX_ConvertTIMEDATEPtrToText ( IntlFormat, TextFormat, pActivityEntry, retTextBuffer, TextBufferLength, retTextLength )
    End Function

    Sub CopyMemory( hpvDest As Long, hpvSource As Long, cbCopy As Long)
    Call TUX_CopyMemory( hpvDest, hpvSource, cbCopy )
    End Sub

    Sub CopyMemoryString( hpvDest As String, hpvSource As Long, cbCopy As Long)
    Call TUX_CopyMemoryString( hpvDest, hpvSource, cbCopy )
    End Sub

    Sub OSUnlockObject( handle )
    Call TUX_OSUnlockObject( handle )
    End Sub

    Sub init (inpNotesDatabase As NotesDatabase)

    If Not initDb( inpNotesDatabase) Then
    Exit Sub
    End If

    If NSFDbGetUserActivity(Me.hDb, &h0, Me.pDbActivity, Me.rethUserInfo, Me.retUserCount ) 0 Then Exit Sub
    Me.flgHasActivity = True

    Me.First = ConvertTIMEtoText(Me.pDbActivity.First)
    Me.Last = ConvertTIMEtoText(Me.pDbActivity.Last)
    Me.Uses = Me.pDbActivity.Uses
    Me.Reads = Me.pDbActivity.Reads
    Me.Writes = Me.pDbActivity.Writes
    Me.PrevDayUses = Me.pDbActivity.PrevDayUses
    Me.PrevDayReads = Me.pDbActivity.PrevDayReads
    Me.PrevDayWrites = Me.pDbActivity.PrevDayWrites
    Me.PrevWeekUses = Me.pDbActivity.PrevWeekUses
    Me.PrevWeekReads = Me.pDbActivity.PrevWeekReads
    Me.PrevWeekWrites = Me.pDbActivity.PrevWeekWrites
    Me.PrevMonthUses = Me.pDbActivity.PrevMonthUses
    Me.PrevMonthReads = Me.pDbActivity.PrevMonthReads
    Me.PrevMonthWrites = Me.pDbActivity.PrevMonthWrites

    Call printActivityDebug()
    End Sub

    Private Function ConvertTIMEtoText(TIMESTRUCT As TIMEDATE_W32) As String
    Dim spTime As String * 80
    Dim retLength As Integer

    spTime = Space(80)
    Call TUX_ConvertTIMEDATEToText (&h0,&h0, TIMESTRUCT, spTime,80,retLength)
    ConvertTIMEtoText = Left(spTime,retLength)
    End Function
    End Class

    Class NotesUserActivityFactory

    Private session As NotesSession
    Private platform As String
    Private version As String
    Private build As Long

    Sub new
    Set session = New NotesSession
    platform = session.Platform
    version = Trim(session.NotesVersion)
    build = session.NotesBuildVersion
    End Sub

    Function getPlatformInfo() As String
    getPlatformInfo = “OS: ” & platform & ” NotesVersion: ” & version & ” NotesBuild: ” & build
    End Function

    Function getNotesUserActivity() As NotesUserActivity

    If Not isDatabaseUsageSupported() Then Exit Function

    Const PLATFORM_W32 = “Windows/32”
    Const PLATFORM_W64 = “Windows/64”
    Const PLATFORM_TUX = “UNIX”

    Const PLATFORM_AS400 = “OS/400”
    Const PLATFORM_AIX = “AIX”
    Const PLATFORM_SUN = “SOLARIS Sparc”

    If platform = PLATFORM_W32 Then
    Set getNotesUserActivity = New NotesUserActivity_W32()
    Exit Function

    Elseif platform = PLATFORM_W64 Then
    Set getNotesUserActivity = New NotesUserActivity_W64()
    Exit Function

    Elseif platform = PLATFORM_TUX Then
    Set getNotesUserActivity = New NotesUserActivity_TUX()
    Exit Function
    End If

    Set getNotesUserActivity = Nothing
    End Function

    Function isDatabaseUsageSupported() As Boolean
    isDatabaseUsageSupported = False

    Const PLATFORM_W32 = “Windows/32”
    Const PLATFORM_W64 = “Windows/64”
    Const PLATFORM_TUX = “UNIX”

    Const PLATFORM_AS400 = “OS/400”
    Const PLATFORM_AIX = “AIX”
    Const PLATFORM_SUN = “SOLARIS Sparc”

    ‘ Check for tested notes version – for each supported platform
    ‘ 199 – Notes 6.5.5
    ‘ 200 – Notes 6.5.6
    ‘ 256 – Notes 7.0
    ‘ 261 – Notes 7.0.1
    ‘ 265 – Notes 7.0.2
    ‘ 266 – Notes 7.0.3
    ‘ 307 – Notes 8.0
    ‘ 322 – Notes 8.0.1
    ‘ 323 – Notes 8.0.2, Notes 8.0.2 FP1 (Release 8.0.2FP1|January 12, 2009), Notes 8.0.2 FP2 (Release 8.0.2 FP2|June 23, 2009)
    ‘ 359 – Notes 8.5 (Release 8.5|December 05, 2008)
    ‘ 368 – Notes 8.5.1

    If platform = PLATFORM_W32 Then
    isDatabaseUsageSupported = True
    Exit Function

    Elseif platform = PLATFORM_W64 Then
    Select Case build
    Case 307, 322:
    isDatabaseUsageSupported = False
    Exit Function
    Case 323: ‘ Only FP2
    If Me.version = “Release 8.0.2 FP2|June 23, 2009” Then
    isDatabaseUsageSupported = True
    Exit Function
    Else
    isDatabaseUsageSupported = False
    Exit Function
    End If
    Case 359, 368:
    isDatabaseUsageSupported = True
    Exit Function

    End Select

    Elseif platform = PLATFORM_TUX Then
    Select Case build
    Case 0:
    isDatabaseUsageSupported = False
    Exit Function
    Case 359, 368, 379:
    isDatabaseUsageSupported = True
    Exit Function
    End Select
    End If

    End Function
    End Class

    • Susmita Yogeshwar Ghogale 2015-August-10 / 3:45 pm

      Is it possible to get ‘Adds’, ‘Updates’ and ‘Deletes’ separately than just ‘Writes’?

  3. Peter Närlund 2013-May-15 / 6:17 pm

    Use it like this:

    Sub Initialize

    Dim userActivityFactory As New NotesUserActivityFactory
    Dim ua As NotesUserActivity
    Dim uae As NotesUserActivityEntry
    Dim iCounter As Long

    Dim session As New NotesSession()
    Dim database As NotesDatabase
    Set database = session.currentDatabase()

    Set ua = userActivityFactory.getNotesUserActivity()
    Call ua.init(database)

    If ua.HasUserActivity Then

    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

    End If

    End Sub

  4. Ed Lee 2013-May-17 / 3:32 pm

    The NotesUserActivity class represents a summary of user activity for specified databases 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 check the HasUserActivity property to ensure that activity is available.

    http://www.agecom.com.au/useractivity

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s