开发者

How to retrieve the "Record activity" flag of Lotus Notes database?

How to retrieve the "Record activity" flag of Lotus Notes database?

I would开发者_如何学C like to retrieve the "Record activity" flag of Lotus Notes database, shown in the screenshot (see the checkbox in the bottom-left corner). How can I do that through API?


UPDATE: No way to do so via LotusScript alone, but perhaps you can get this information via the Lotus Notes C API.

The NSFDbGetUserActivity method will either return the user activity information (shown in that dialog) or it will return ERR_SPECIAL_ID if there is no summary information. This is not a precise way to determine whether the record activity flag is checked, but you could infer the state of the flag from the result of the method.

Of course, there's still the chance the flag is checked, but no activity has been recorded yet, or conversely the flag is not checked but activity was previously recorded in the database.

Another solution may be to programmatically perform an action that would normally get recorded in the User Activity. You could then check to see if that activity is in fact recorded, and you'd then know whether that flag was active or not. If you dedicate a special Notes user to run this code, it would be easier to pick out that user from the list of activities avoiding a false positive caused by some normal end-user activity.

The code below shows you how to get at the User Activity information via the C API, taken from example #3 on this tutorial page: http://www.triplewhitefox.com/tech-calling-c-api-from-lotusscript

(declarations)

'Structures used by Notes C API
Type TIMEDATE
   Innards(1) As Long 'DWORD
End Type

Const MAXALPHATIMEDATE = 80

Type DBACTIVITY
   First As TIMEDATE      'TIMEDATE /* Beginning of reporting period */
   Last As TIMEDATE        'TIMEDATE /* End of reporting period */
   Uses As Long            'DWORD /* # of uses in reporting period */
   Reads As Long           'DWORD /* # of reads in reporting period */
   Writes As Long          'DWORD /* # of writes in reporting period */
   PrevDayUses As Long     'DWORD /* # of uses in previous 24 hours */
   PrevDayReads As Long    'DWORD /* # of reads in previous 24 hours */
   PrevDayWrites As Long   'DWORD /* # of writes in previous 24 hours */
   PrevWeekUses As Long    'DWORD /* # of uses in previous week */
   PrevWeekReads As Long   'DWORD /* # of reads in previous week */
   PrevWeekWrites As Long  'DWORD /* # of writes in previous week */
   PrevMonthUses As Long   'DWORD /* # of uses in previous month */
   PrevMonthReads As Long  'DWORD /* # of reads in previous month */
   PrevMonthWrites As Long 'DWORD /* # of writes in previous month */
End Type

'STATUS LNPUBLIC NSFDbGetUserActivity(DBHANDLE hDB, DWORD Flags, DBACTIVITY far *retDbActivity, HANDLE far *rethUserInfo, WORD far *retUserCount);
Declare Function NSFDbGetUserActivity Lib "nnotes.dll" (Byval hDB As Long, Byval Flags As Long, retDbActivity As DBACTIVITY, rethUserInfo As Long, retUserCount As Integer) As Integer

'STATUS LNPUBLIC NSFDbClose( DBHANDLE hDB);
Declare Function NSFDbClose Lib "nnotes.dll" (Byval hDB As Long) As Integer

'STATUS LNPUBLIC NSFDbOpen(char far *PathName, DBHANDLE far *rethDB);
Declare Function NSFDbOpen Lib "nnotes.dll" (Byval filepath As String, DB As Long) As Integer

'STATUS LNPUBLIC ConvertTIMEDATEToText(const void far *IntlFormat, const TFMT far *TextFormat, const TIMEDATE far *InputTime, char far *retTextBuffer, WORD TextBufferLength, WORD far *retTextLength);
Declare Function ConvertTIMEDATEToText Lib "nnotes.dll" (Byval IntlFormat As Integer, Byval TextFormat As Integer, InputTime As TIMEDATE, Byval retTextBuffer As String, Byval TextBufferLength As Integer, retTextLength As Integer) As Integer

Initialize

Sub Initialize
   Dim ReturnCodel As Long
   Dim hDBl As Long
   Dim retDbActivity As DBACTIVITY
   Dim rethUserInfo As Long
   Dim retUserCount As Integer
   Dim Flags As Long

   Dim retTextBuffer As String
   Dim retTextLength As Integer
   Dim BufferSize As Integer

   Dim session As New NotesSession

   'Open the database
   ReturnCodel = NSFDbOpen(session.CurrentDatabase.FilePath, hDBl)
   If ReturnCodel <> 0 Then
      Error 9999, "An error occurred calling the API function " + _
         "NSFDbOpen." & Chr$(10) & "The return code was " & + _
         Trim$(Str$(ReturnCodel)) & "."
      Exit Sub
   End If

   Flags = 0
   ReturnCodel = NSFDbGetUserActivity(hDBl, Flags, retDbActivity, rethUserInfo, retUserCount)
   If ReturnCodel <> 0 Then
      Error 9999, "An error occurred calling the API function " + _          "NSFDbGetUserActivity." & Chr$(10) & "The return code was " & + _
         Trim$(Str$(ReturnCodel)) & "."
      Call NSFDbClose(hDBl)
      Exit Sub
   End If

   retTextBuffer = String$(MAXALPHATIMEDATE + 1,0)
   ReturnCodel = ConvertTIMEDATEToText(0, 0, retDBActivity.First, retTextBuffer, MAXALPHATIMEDATE, retTextLength)
   Print "First access = " + Left(retTextBuffer, retTextLength)

   retTextBuffer = String$(MAXALPHATIMEDATE + 1,0)
   ReturnCodel = ConvertTIMEDATEToText(0, 0, retDBActivity.Last, retTextBuffer, MAXALPHATIMEDATE, retTextLength)
   Print "Last access = " + Left(retTextBuffer, retTextLength)

   Print "Uses = " + Cstr(retDBActivity.Uses)
   Print "Reads = " + Cstr(retDBActivity.Reads)
   Print "Writes =" + Cstr(retDBActivity.Writes)

   'Close the database
   ReturnCodel = NSFDbClose(hDBl)
End Sub


There is a NotesUser Activity class (CLASSUserActivity) application freely available from AGECOM. They've completely reviewed and updated the class originally written by Daniel Alvers.

Improvements in Release 2x include:

  • Numerous fixes and enhancements to the original code.

  • Correction to data types and memory alignments when making calls to Lotus C-API code from LotusScript.

  • Implementation of error handling throughout the code.

  • Enhancement to sample agent for collection and displaying retrieved user activity information.

  • New options to scan user activity in all or selected databases.

  • New views to show reports of user activity information.

You can download the update from the AGECOM website at: http://www.agecom.com.au/useractivity

The application is a standard Lotus Notes application and can be run immediately from the Lotus Notes client.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜