如何检索Lotus Notes数据库的“Record activity”标志?

时间:2011-10-07 10:10:40

标签: lotus-notes

"Record activity" flag of Lotus Notes database

我想检索Lotus Notes数据库的“Record activity”标志,如屏幕截图所示(请参阅左下角的复选框)。我怎么能通过API做到这一点?

2 个答案:

答案 0 :(得分:5)

<强>更新 单靠LotusScript无法实现,但也许您可以通过Lotus Notes C API获取此信息。

NSFDbGetUserActivity方法将返回用户活动信息(显示在该对话框中),如果没有摘要信息,它将返回ERR_SPECIAL_ID。这不是确定是否检查记录活动标志的精确方法,但您可以从方法的结果推断标志的状态。

当然,仍然有可能检查标志 ,但尚未记录任何活动,或者相反,标志未被检查但活动先前已记录在数据库。

另一种解决方案可能是以编程方式执行通常会记录在用户活动中的操作。然后,您可以检查是否实际记录了该活动,然后您就可以知道该标志是否处于活动状态。如果您使用特殊的Notes用户来运行此代码,则可以更轻松地从活动列表中选择该用户,从而避免由于某些正常的最终用户活动而导致的误报。

下面的代码向您展示了如何通过C API获取用户活动信息,该API来自本教程页面上的示例#3:http://www.triplewhitefox.com/tech-calling-c-api-from-lotusscript

(适用声明)

'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

<强>初始化

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

答案 1 :(得分:0)

AGECOM免费提供NotesUser Activity类(CLASSUserActivity)应用程序。他们完全审查并更新了Daniel Alvers最初编写的课程。

Release 2x的改进包括:

  • 对原始代码进行了大量修复和增强。

  • 从LotusScript调用Lotus C-API代码时对数据类型和内存对齐的更正。

  • 在整个代码中实施错误处理。

  • 增强样本代理以收集和显示检索到的用户活动信息。

  • 扫描所有或所选数据库中的用户活动的新选项。

  • 显示用户活动信息报告的新视图。

您可以从AGECOM网站下载更新: http://www.agecom.com.au/useractivity

该应用程序是标准的Lotus Notes应用程序,可以立即从Lotus Notes客户端运行。