Autor Thema: Benutzer Aktivität auslesen  (Gelesen 6204 mal)

Offline tfrenz

  • Aktives Mitglied
  • ***
  • Beiträge: 243
  • Geschlecht: Männlich
Benutzer Aktivität auslesen
« am: 23.05.08 - 12:22:06 »
Hallo,

gibt es eine Möglichkeit die Benutzeraktivität (unter DB-Eigenschaften, 2ter Reiter - Details) auszulesen?
Habe die Anforderung, wann eine DB das letzte mal von einem User benutzt worden ist.

Danke

Alles Unter Notes 6.5 Windows
Gruß
Thomas

Offline eknori

  • @Notes Preisträger
  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 11.730
  • Geschlecht: Männlich
Re: Benutzer Aktivität auslesen
« Antwort #1 am: 23.05.08 - 12:29:19 »
Warum nutzt du nicht die Activities und Activity Trends am Server?
Egal wie tief man die Messlatte für den menschlichen Verstand auch ansetzt: jeden Tag kommt jemand und marschiert erhobenen Hauptes drunter her!

Offline tfrenz

  • Aktives Mitglied
  • ***
  • Beiträge: 243
  • Geschlecht: Männlich
Re: Benutzer Aktivität auslesen
« Antwort #2 am: 23.05.08 - 12:34:33 »
Danke für die schnelle Antwort.
Werde mir das mal anschauen mit einem Kollegen.
Da aber ein bestimmter Agent die entsprechenden DB's schon durchforstet, möchte ich gerne noch die Aktivität auslesen und ausgeben.

Danke
Thomas
Gruß
Thomas

Offline eknori

  • @Notes Preisträger
  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 11.730
  • Geschlecht: Männlich
Re: Benutzer Aktivität auslesen
« Antwort #3 am: 23.05.08 - 13:29:58 »
Habe hier noch was ausgegraben:

Code
'User_ActivityClass: 
'Paste into the declarations section of your code
' NotesUserActivity class (R1.0)
' Written by: Daniel Alvers (daniel.alvers@au.pwcglobal.com)
' PricewaterhouseCoopers (Aust)
' February, 14 2000

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 = prvdb.server + "!!" + prvdb.filepath
		End If
		
'Open the target database
		rc = W32_NSFDbOpen(sDatabase,Me.hDb)
		If rc <> 0 Then
			Me.flgHasActivity = False
		End If
		
'Get the Summary User information
		rc = W32_NSFDbGetUserActivity(Me.hDb, &h0, Me.pDbActivity, Me.rethUserInfo, Me.retUserCount)
		If rc <> 0 Then
			Me.flgHasActivity = False
		End If 
		Me.flgHasActivity = True
	End Sub 
	
'Global Times
	Public Function First As String
		First = ConvertTIMEtoText(pDbActivity.First) 
	End Function
	Public Function Last As String
		Last = ConvertTIMEtoText(pDbActivity.Last) 
	End Function
	
'Total summary
	Public Function Uses As Long
		Uses = pDbActivity.Uses 
	End Function
	Public Function Reads As Long
		Reads = pDbActivity.Reads 
	End Function
	Public Function Writes As Long
		Writes = pDbActivity.Writes
	End Function
	
'Day summary
	Public Function PrevDayUses As Long
		PrevDayUses = pDbActivity.PrevDayUses 
	End Function
	Public Function PrevDayReads As Long
		PrevDayReads = pDbActivity.PrevDayReads 
	End Function
	Public Function PrevDayWrites As Long
		PrevDayWrites = pDbActivity.PrevDayReads
	End Function
	
'Week summary
	Public Function PrevWeekUses As Long
		PrevWeekUses = pDbActivity.PrevWeekUses 
	End Function
	Public Function PrevWeekReads As Long
		PrevWeekReads = pDbActivity.PrevWeekReads
	End Function
	Public Function PrevWeekWrites As Long
		PrevWeekWrites= pDbActivity.PrevWeekWrites
	End Function
	
'Month summary
	Public Function PrevMonthUses As Long
		PrevMonthUses = pDbActivity.PrevMonthUses 
	End Function
	Public Function PrevMonthReads As Long
		PrevMonthReads = pDbActivity.PrevMonthReads 
	End Function
	Public Function PrevMonthWrites As Long
		PrevMonthWrites = pDbActivity.PrevMonthWrites
	End Function
	
	Public Function UserActivityCount As Long
		UserActivityCount = retUserCount
	End Function
	
	Public Function HasUserActivity As Integer
		HasUserActivity = Me.flgHasActivity
	End Function
	
	Public Function Parent As NotesDatabase
		Set Parent = prvdb
	End Function
	
	Public Function GetNthUserActivityEntry(inpEntry As Long) As NotesUserActivityEntry
		Dim puActivity As Long
		Dim lEntry As Long
		Dim puActivityEntry As DBACTIVITY_ENTRY
		Dim StructureOffset As Long
		Dim UsernameOffset As Long
		Dim spUsername As String * 256
		Dim sUsername As String
		Dim nuae As New NotesUserActivityEntry
		
		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
		
'Lock the structure get the required entry
		puActivity = W32_OSLockObject(Me.rethUserInfo)
		StructureOffset = puActivity + (Lenb(puActivityEntry) * lEntry)
		Call CopyMemory (puActivityEntry, StructureOffset, Len(puActivityEntry))
		
'Load the User name for the Activity Structure
		UsernameOffset = puActivity + puActivityEntry.UserNameOffset
		spUsername = Space(256)
		Call CopyMemoryString(spUsername, UsernameOffset,Lenb(spUsername))
		sUserName = Left(spUsername, Instr(spUsername, Chr(0)) - 1)
		
		With nuae
			.UserName = sUserName
			.Reads = puActivityEntry.Reads
			.Writes = puActivityEntry.Writes
			.Time = ConvertTIMEtoText(puActivityEntry.Time)
		End With
		
		Call OSUnlockObject(rethUserInfo)
		
		Set GetNthUserActivityEntry = nuae
		
	End Function
End Class
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
Sub Click(Source As Button)
	Dim Session As New NotesSession
	Dim db As NotesDatabase
	Dim ua As NotesUserActivity
	Dim uae As NotesUserActivityEntry
	Dim iCounter As Long
	Set db = Session.CurrentDatabase
	
	If Not db Is Nothing Then
		Set ua = New NotesUserActivity(db)
		If ua.HasUserActivity Then
			Msgbox ua.PrevMonthReads
			
		End If
	End If 
	
End Sub

« Letzte Änderung: 23.05.08 - 13:38:50 von eknori »
Egal wie tief man die Messlatte für den menschlichen Verstand auch ansetzt: jeden Tag kommt jemand und marschiert erhobenen Hauptes drunter her!

Offline WernerMo

  • @Notes Preisträger
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 3.050
  • Geschlecht: Männlich
Re: Benutzer Aktivität auslesen
« Antwort #4 am: 23.05.08 - 13:34:10 »
Hallo,

nur so als Frage am Rande:
"Was sagt der Betriebsrat zu solchen Aktionen/Funktionen"?

Gruß Werner
Gruß Werner
  o                                                  o   
 /@\  Nächster @Notes-Stammtisch  /@\  online Sept. 2020?
_/_\__________________________/_\_ Details folgen.

Offline eknori

  • @Notes Preisträger
  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 11.730
  • Geschlecht: Männlich
Re: Benutzer Aktivität auslesen
« Antwort #5 am: 23.05.08 - 13:39:57 »
Zitat
"Was sagt der Betriebsrat zu solchen Aktionen/Funktionen"?
Entweder gibt es keinen oder der kapiert eh nicht, worum es geht. Und viele Sachen werden heisser gekocht, als gegessen.
Egal wie tief man die Messlatte für den menschlichen Verstand auch ansetzt: jeden Tag kommt jemand und marschiert erhobenen Hauptes drunter her!

Offline tfrenz

  • Aktives Mitglied
  • ***
  • Beiträge: 243
  • Geschlecht: Männlich
Re: Benutzer Aktivität auslesen
« Antwort #6 am: 23.05.08 - 13:52:03 »
Hallo WernerMo,

das ganze ist für einen Kunden und von dem Betriebsrat abgesegnet.

Thomas
Gruß
Thomas

Offline To_B

  • Frischling
  • *
  • Beiträge: 7
  • Geschlecht: Männlich
Re: Benutzer Aktivität auslesen
« Antwort #7 am: 30.03.10 - 16:55:21 »
Der hier veröffentliche Code lief bei mir weder unter 6.5.4, noch unter 8.5.1.
Ich hab dann ein wenig dran rumgebastelt, bin aber nicht wirklich weiter gekommen.

Bei IBM (Quelle) habe ich dann den folgenden - recht frischen - Eintrag gefunden:

Zitat
Updated version of ClassUserActivity
Posted by Alex Elliott on 6.Mar.10 at 08:46 using a Web browser
Category: Domino DesignerRelease: 7.0.2Platform: Windows XP


We've completely reviewed the code in the NotesUser Activity class (CLASSUserActivity) application and released an update of it.

Improvements in 'release 2' 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.

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

Hope it helps!

Regards,

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

Ich kann nicht einschätzen, wie lange das online bleibt, daher noch die Script-Bibliothek "CLASSUserActivity" aus der Datenbank:
Code
Option Public
Option Declare


%INCLUDE "lsconst.lss"

%REM
CLASSUserActivity - updated by Alex Elliott of AGECOM (http://www.agecom.com.au)

This class is an update of the original CLASSUserActivity code available for download from the Lotus Sandbox:
http://www.lotus.com/ldd/sandbox.nsf/0/c12a2fd2142758b68525688d00708397?OpenDocument

Updates in this release March 2010
============================
* Fixes to API function declarations to ensure the correct datatypes are supplied for function arguments (to match expected
	compatible Lotus C-API data types).
		- retUserCount in W32_NSFDbGetUserActivity is now correctly defined as an Integer
		- handle in W32_OSLockObject is now defined as a Long.
		- handle in W32_OSUnlockObject is now defined as a Long
		- Return value for call to W32_OSMemFree is now retrieved.
		- handle in W32_OSMemFree is now defined as a Long.
		- hpvSource in CopyMemory is now defined as an Any.
		- hpvSource in CopyMemoryString is now defined as an Any.
		- Return value for call to W32_ConvertTIMEDATEToText is now retrieved.
* Reads object in NotesUserActivityEntry class is now defined as an Integer.
* Writes object in NotesUserActivityEntry class is now defined as an Integer.
* retUserCount object in NotesUserActivity class is now defined as an Integer.
* flgHasActivity object in NotesUserActivity class is now defined as a Boolean.
* If an error occurs in the GetNthUserActivityEntry function after the memory occupied by 'Me.rethUserInfo' is locked it is now
	unlocked when the error handler catches the error.
* Call to 'PrevDayWrites' now correctly returns the Writes.
* Error Handling now implemented throughout the code.

This updated script library may be used and modified by anyone provided the above information remains with the code.

%END REM

' Constants
Const MAXALPHATIMEDATE = 80
Const MAXUSERNAME = 256

' The API functions return errors as non-zero values hence zero is success
Const STATUS_SUCCESS = 0

' When working with the API, handles (always Long) are NULL or empty when they are equal to zero
Const NULLHANDLE = 0

' API Errors
Const ERR_NOEXIST = 259
Const ERR_NO_MODIFIED_NOTES = 572
Const ERR_SPECIAL_ID = 578
Const ERR_NOACCESS = 582
Const ERR_NOT_FOUND = 1028
Const ERR_ITEM_NOT_FOUND = 546

Type TIMEDATE
	Innards(1) 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 Integer) As Integer
Declare Function W32_OSLockObject Lib "nnotes.dll" Alias "OSLockObject" ( Byval handle As Long) As Long
Declare Function W32_OSLoadString Lib "nnotes.dll" Alias "OSLoadString" (Byval handle As Long, Byval S As Integer, Byval B As String, Byval nB As Integer) As Integer
Declare Sub W32_OSUnlockObject Lib "nnotes.dll" Alias "OSUnlockObject" (Byval handle As Long)
Declare Function W32_OSMemFree Lib "nnotes.dll" Alias "OSMemFree" (Byval handle As Long) As Integer
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( hpvDest As Any, Byval hpvSource As Any, Byval cbCopy As Long)
Declare Sub CopyMemoryString Lib "kernel32" Alias "RtlMoveMemory" ( Byval hpvDest As String, Byval hpvSource As Any, Byval cbCopy As Long)
Declare Function W32_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) As Integer

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

Class NotesUserActivity
	Private hDb As Long
	Private pDbActivity As DBACTIVITY
	Private rethUserInfo As Long
	Private retUserCount As Integer
	Private prvdb As NotesDatabase
	Private flgHasActivity As Boolean
	
	Sub Delete
		Dim StatusResult As Integer
		
		' Error Handler
		On Error Goto Error_Handler
		
		If Me.flgHasActivity Then
			Call W32_OSMemFree(rethUserInfo)
		End If
		
		If hDb <> 0 Then
			StatusResult = W32_NSFDbClose(hDb)
			hDb = 0
			If StatusResult <> STATUS_SUCCESS Then
				' Database failed to close properly
				Call Output_Status_Error(StatusResult, "ClassUserActivity - NotesUserActivity Class (Delete)", "Call to NSFDbClose failed", Getthreadinfo(LSI_THREAD_LINE)-4)
			End If
		End If
		
		Exit Sub
		
Error_Handler:
		Call Output_Error("ClassUserActivity Script Library - NotesUserActivity (Delete)", Erl, True)
		Exit Sub
	End Sub
	
	Sub New (inpNotesDatabase As NotesDatabase)
		Dim sDatabase As String
		Dim StatusResult As Integer     
		
		' Error Handler
		On Error Goto Error_Handler
		
		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 = prvdb.server + "!!" + prvdb.filepath
		End If
		
          ' Open the target database
		StatusResult = W32_NSFDbOpen(sDatabase,Me.hDb)
		If StatusResult <> STATUS_SUCCESS Then
			' Database failed to open
			Call Output_Status_Error(StatusResult, "ClassUserActivity - NotesUserActivity Class (New)", "Call to NSFDbOpen failed", Getthreadinfo(LSI_THREAD_LINE)-3)
			Exit Sub
		End If
		
		' Get the Summary User information
		StatusResult = W32_NSFDbGetUserActivity(Me.hDb, &h0, Me.pDbActivity, Me.rethUserInfo, Me.retUserCount)
		If StatusResult <> STATUS_SUCCESS Then
			' Couldn't get handle to database user activity
			Call Output_Status_Error(StatusResult, "ClassUserActivity - NotesUserActivity Class (New)", "Call to NSFDbGetUserActivity failed", Getthreadinfo(LSI_THREAD_LINE)-3)
			Exit Sub
		End If
		
		If retUserCount > 0 Then
			' User activity was found
			Me.flgHasActivity = True
		End If
		
		Exit Sub
		
Error_Handler:
		Call Output_Error("ClassUserActivity Script Library - NotesUserActivity (New)", Erl, True)
		Exit Sub
	End Sub 
	
	' Global Times
	Public Function First As String
		
		' Error Handler
		On Error Goto Error_Handler
		
		First = ConvertTIMEtoText(pDbActivity.First)		
		Exit Function
		
Error_Handler:
		Call Output_Error("ClassUserActivity Script Library - NotesUserActivity (First)", Erl, True)
		Exit Function
	End Function
	
	Public Function Last As String
		' Error Handler
		On Error Goto Error_Handler
		
		Last = ConvertTIMEtoText(pDbActivity.Last)     	
		Exit Function
		
Error_Handler:
		Call Output_Error("ClassUserActivity Script Library - NotesUserActivity (Last)", Erl, True)
		Exit Function
	End Function
	
	' Total summary
	Public Function Uses As Long
		Uses = pDbActivity.Uses  
	End Function
	
	Public Function Reads As Long
		Reads = pDbActivity.Reads          
	End Function
	
	Public Function Writes As Long
		Writes = pDbActivity.Writes
	End Function
	
	' Day summary
	Public Function PrevDayUses As Long
		PrevDayUses = pDbActivity.PrevDayUses     
	End Function
	
	Public Function PrevDayReads As Long
		PrevDayReads = pDbActivity.PrevDayReads     
	End Function
	
	Public Function PrevDayWrites As Long
		PrevDayWrites = pDbActivity.PrevDayWrites
	End Function
	
	' Week summary
	Public Function PrevWeekUses As Long
		PrevWeekUses = pDbActivity.PrevWeekUses          
	End Function
	
	Public Function PrevWeekReads As Long
		PrevWeekReads = pDbActivity.PrevWeekReads
	End Function
	
	Public Function PrevWeekWrites As Long
		PrevWeekWrites= pDbActivity.PrevWeekWrites
	End Function
	
	' Month summary
	Public Function PrevMonthUses As Long
		PrevMonthUses = pDbActivity.PrevMonthUses               
	End Function
	
	Public Function PrevMonthReads As Long
		PrevMonthReads = pDbActivity.PrevMonthReads     
	End Function
	
	Public Function PrevMonthWrites As Long
		PrevMonthWrites = pDbActivity.PrevMonthWrites
	End Function
	
	Public Function UserActivityCount As Integer
		UserActivityCount = retUserCount
	End Function
	
	Public Function HasUserActivity As Boolean
		HasUserActivity = Me.flgHasActivity
	End Function
	
	Public Function Parent As NotesDatabase
		Set Parent = prvdb
	End Function
	
	Public Function GetNthUserActivityEntry(inpEntry As Integer) As NotesUserActivityEntry
		Dim puActivity As Long
		Dim lEntry As Integer
		Dim puActivityEntry As DBACTIVITY_ENTRY
		Dim StructureOffset As Long
		Dim UsernameOffset As Long
		Dim spUsername As String * MAXUSERNAME
		Dim sUsername As String
		Dim nuae As New NotesUserActivityEntry
		
		' Error Handler
		On Error Goto Error_Handler
		
		lEntry = inpEntry - 1
		
		If Not Me.flgHasActivity Then
			Error 14104, "NotesUserActivity: No activity available"
		End If
		
		If lEntry > Me.retUserCount Or lEntry < 0 Then
			Error 14103, "NotesUserActivity: Subscript out of range."
		End If
		
		' Lock the structure get the required entry
		puActivity = W32_OSLockObject(Me.rethUserInfo)
		StructureOffset = puActivity + (Lenb(puActivityEntry) * lEntry)
		Call CopyMemory (puActivityEntry, StructureOffset, Len(puActivityEntry))
		
		' Load the User name for the Activity Structure
		UsernameOffset = puActivity + puActivityEntry.UserNameOffset
		spUsername = Space(MAXUSERNAME)
		Call CopyMemoryString(spUsername, UsernameOffset,Lenb(spUsername))
		sUserName = Left(spUsername, Instr(spUsername, Chr(0)) - 1)
		
		With nuae
			.UserName = sUserName
			.Reads = puActivityEntry.Reads
			.Writes = puActivityEntry.Writes
			.Time = ConvertTIMEtoText(puActivityEntry.Time)
		End With
		
		Call W32_OSUnlockObject(Me.rethUserInfo)
		puActivity = 0
		
		Set GetNthUserActivityEntry = nuae
		Exit Function
		
Error_Handler:
		If puActivity <> 0 Then
			' Unlock
			Call W32_OSUnlockObject(Me.rethUserInfo)
		End If
		Call Output_Error("ClassUserActivity Script Library - NotesUserActivity (GetNthUserActivityEntry)", Erl, True)
		Exit Function
	End Function
End Class
Function ConvertTIMEtoText(TIMESTRUCT As TIMEDATE) As String
	Dim Session As New NotesSession
	Dim spTime As String * MAXALPHATIMEDATE
	Dim retLength As Integer
	Dim StatusResult As Integer
	
	' Error Handler
	On Error Goto Error_Handler
	
	spTime = Space(MAXALPHATIMEDATE)
	StatusResult = W32_ConvertTIMEDATEToText (&h0,&h0, TIMESTRUCT, spTime,MAXALPHATIMEDATE,retLength)
	If StatusResult <> STATUS_SUCCESS Then
		' Conversion failed
		Call Output_Status_Error(StatusResult, "ClassUserActivity - ConvertTIMEToText", "Call to ConvertTIMEDATEToText failed", Getthreadinfo(LSI_THREAD_LINE)-3)
	Else
		ConvertTIMEtoText = Left(spTime,retLength)
	End If
	
	Exit Function
	
Error_Handler:
	Call Output_Error("ClassUserActivity Script Library - ConvertTIMEToText", Erl, True)
	Exit Function	
End Function
Function Output_Status_Error(StatusError As Integer, FunctionName As Variant, Description As String, LineNumber As Variant) As Boolean
	Dim MaskedStatusError As Integer
	
	' Error Handler
	On Error Goto Error_Handler
	
	If StatusError = 0 Then
		' This is a null status code
		Exit Function
	End If
	
	MaskedStatusError = MaskedErrorStatus(StatusError)
	If MaskedStatusError = 0 Then
		' This is a null error code
		Exit Function
	End If
	
	' Errors that we will ignore
	If MaskedStatusError = ERR_NO_MODIFIED_NOTES Then
		Exit Function
	Elseif MaskedStatusError = ERR_SPECIAL_ID Then
		Exit Function
	Elseif MaskedStatusError = ERR_NOT_FOUND Then
		Exit Function
	End If
	
	Call Output_API_Error(Cstr(FunctionName), Description, Cint(LineNumber), MaskedStatusError)
	
	Output_Status_Error = True
	Exit Function
	
Error_Handler:
	Call Output_Error("ClassUserActivity Script Library - Output_Status_Error", Erl, True)
	Exit Function
End Function
Function MaskedErrorStatus(StatusError As Integer) As Integer
	' Error Handler
	On Error Goto Error_Handler
	
	MaskedErrorStatus = StatusError And &H3FFF
	Exit Function
	
Error_Handler:
	Call Output_Error("ClassUserActivity Script Library - MaskedErrorStatus", Erl, True)
	Exit Function
End Function
Function Output_Error(FunctionName As String, ErrorLine As Integer, ContinueOnError As Integer)
	' Output the error that has occurred
	Dim ErrorString As String
	Dim ErrorSession As New NotesSession
	Dim NewLine As String
	
	' Format the error for printing and outputting to the error log
	NewLine = "   "
	ErrorString = "The following error has occurred:" & NewLine
	ErrorString = ErrorString & "Function - " & FunctionName & NewLine
	ErrorString = ErrorString & "Line - " & Trim(Cstr(ErrorLine)) & NewLine
	ErrorString = ErrorString & "Error - " & Trim(Cstr(Err)) & NewLine
	ErrorString = ErrorString & "Details - " & Error$
	
	If ErrorSession.IsOnServer Then
		' This is being called from a scheduled agent.  Output error details to the Notes log and exit
		Print ErrorString
		If ContinueOnError Then
			' ContinueOnError is true.  Return execution to the calling function
			Exit Function
		Else
			' ContinueOnError is false.  Abort execution
			End
		End If
	End If
	
	' This is being called from an agent being manually run.  Error details will be displayed in a message box
	' Format the error for printing and outputting to the error log
	NewLine = Chr(13)
	ErrorString = "The following error has occurred:" & NewLine
	ErrorString = ErrorString & "Function - " & FunctionName & NewLine
	ErrorString = ErrorString & "Line - " & Trim(Cstr(ErrorLine)) & NewLine
	ErrorString = ErrorString & "Error - " & Trim(Cstr(Err)) & NewLine
	ErrorString = ErrorString & "Details - " & Error$ & NewLine & NewLine
	ErrorString = ErrorString & "Would you like to continue processing?"
	
	If Messagebox(ErrorString, MB_YESNO + MB_ICONSTOP, "Processing Error") = IDNO Then
		' The no button was clicked
		End
	End If
End Function
Sub Output_API_Error(FunctionName As String, Description As String, ErrorLine As Integer, APIErrorCode As Integer)
	' Output the the description for the passed API error code
	Dim ThisSession As New NotesSession
	Dim ErrorDescr As String
	Dim ErrorString As String
	Dim NewLine As String
	
	If APIErrorCode = 0 Then
		' Invalid error code
		Exit Sub
	End If
	
	If ThisSession.Platform = "Windows/32" Then
		ErrorDescr = String$(1024, " ")
		Call W32_OSLoadString(0, APIErrorCode And &H3FFF, ErrorDescr, 1024)
		If Instr(1, ErrorDescr, Chr$(0)) > 0 Then
			ErrorDescr = Strleft(ErrorDescr, Chr$(0))
		End If
		If Trim(ErrorDescr) = "" Or ErrorDescr = "No error" Then
			ErrorDescr = "Unknown error (&H" & Hex$(Cint(APIErrorCode)) & ")"
		End If
	Else
		ErrorDescr = "Unknown error (&H" & Hex$(Cint(APIErrorCode)) & ")"
	End If
	
	If Trim(Description) <> "" Then
		ErrorDescr = Description & ": " & ErrorDescr
	End If
	
	If ThisSession.IsOnServer Then
		' Session is running on server (scheduled / background agent). Print the error then continue processing
		' Format the error for printing
		NewLine = ", "
		ErrorString = "The following API error has occurred: "
		ErrorString = ErrorString & "Function - " & FunctionName & NewLine
		ErrorString = ErrorString & "Line - " & Trim(Cstr(ErrorLine)) & NewLine
		ErrorString = ErrorString & "Error - " & Trim(Cstr(APIErrorCode)) & NewLine
		ErrorString = ErrorString & "Details - " & ErrorDescr
		Print ErrorString
	Else
		NewLine = Chr(13)
		ErrorString = "The following API error has occurred:" & NewLine
		ErrorString = ErrorString & "Function - " & FunctionName & NewLine
		ErrorString = ErrorString & "Line - " & Trim(Cstr(ErrorLine)) & NewLine
		ErrorString = ErrorString & "Error - " & Trim(Cstr(APIErrorCode)) & NewLine
		ErrorString = ErrorString & "Details - " & ErrorDescr & NewLine & NewLine
		ErrorString = ErrorString & "Would you like to continue processing?"
		
		If Messagebox(ErrorString, MB_YESNO + MB_ICONSTOP, "Processing Error") = IDNO Then
			' The no button was clicked
			End
		End If
	End If
End Sub
MfG
Tobi

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz