How to parse the user activity of a Lotus Notes database

本文介绍如何使用LotusScript解析LotusNotes数据库中的用户活动记录,包括获取历史记录的数量及具体活动详情,并提供了具体的代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

How to parse the user activity of a Lotus Notes database

Is it possible to parse the user activity of a Lotus Notes database? I want to remove automatic access to the Lotus Notes database (by agents or servers), using LotusScript.

VIEW MEMBER FEEDBACK TO THIS ASK THE EXPERT Q&A.

Absolutely. First you will need to visit http://www-10.lotus.com/ldd/sandbox.nsf and search for "UserActivity". Download the "NotesUserActivity Class" file. This is a sample Lotus Notes database containing a script library called "CLASSUserActivity."

When you look at this library, you will see only one subroutine. That's because in Lotus Notes, classes are defined in the "Declarations" section, so this library is basically one giant declaration (thus explaining why no one uses OOP or classes in LotusScript!).

I'm going to give you the LotusScript code you need to use this beastie, thus you'll have to find something else to spend the next two weeks figuring out.

I'll warn you -- pulling the usage history from each Lotus Notes database is fairly time consuming. In this code, lifted directly from my production application inventory crawler, Names2exclude lists the Lotus Domino servers, developers and administrators to ignore.

The usage counters here are declared globally, because the routine must be called once on each Lotus Domino server where a replica of the Lotus Notes database resides. Since each replica copy of a database has its own independent history, in this way the usage from all Lotus Domino server replica copies can be aggregate.

Const Names2exclude=
"CORPAGENTSIGNER~APPS001~CREGG S HARDWICK"

Dim WeekUses As Long,
WeekReads As Long,WeekWrites As Long
Dim MonthUses As 
Long,MonthReads As Long,MonthWrites As Long
Dim totaluses As Long,totalreads 
As Long,totalwrites As Long

Sub GetUserActivity(db As NotesDatabase)
 
Dim ua As New NotesUserActivity(db)

Dim uae As notesuseractivityentry

If ua.HasUserActivity Then
weekUses=ua.PrevWeekUses
weekReads=ua.PrevWeekReads
weekWrites=ua.PrevWeekWrites
monthUses=ua.PrevmonthUses
monthReads=ua.PrevmonthReads
monthWrites=ua.PrevmonthWrites
totalUses=ua.Uses
totalReads=ua.Reads
totalWrites=ua.Writes

Dim ActivityEntries As Long
ActivityEntries=ua.UserActivityCount

If ActivityEntries>0 Then
Print "        -- Reading "+
Format(ActivityEntries,"###,##0")+_
" history records..."
End If 
 
Dim index As Variant,result As Variant
Dim AIndex As Long
For AIndex = 1 To ActivityEntries
Set uae = ua.GetNthUserActivityEntry(AIndex)
result=Evaluate
({@Name([Abbreviate];"}+_
uae.UserName+{"):@Name([cn];"}+_
uae.UserName+{")})
If Instr(names2exclude,Ucase(result(1)))=0 Then
index=Arraygetindex(UserList,result(0))
If Isnull(index) Then
If users<=maxusers Then  
Redim Preserve UserList(Users) As String
Redim Preserve readsList(Users) As Long
Redim Preserve writesList(Users) As Long
Redim Preserve sessionList(Users) As Long
Redim Preserve timeList(Users) As String
UserList(Users)=result(0)
timelist(users)=uae.time
sessionList(Users)=1
readsList(Users)=uae.reads
writeslist(users)=uae.writes
Users=Users+1
End If
Else
sessionList(Index)=sessionList(Index)+1
readsList(Index)=readsList(Index)+uae.reads
writeslist(Index)=writeslist(Index)+uae.writes
End If
End If
Next AIndex
  
End If
End Sub

MEMBER FEEDBACK TO THIS ASK THE EXPERT Q&A:

I still have a problem with this code. When I try to save the agent I get the following error: "Reference occurs before declaration:UserList"

Allow me to point out that the variable is only declared three lines later.

If Instr(names2exclude,Ucase(result(1)))=0 Then
index=Arraygetindex(UserList,result(0))
If Isnull(index) Then
If users<=maxusers Then  
Redim Preserve UserList(Users) As String
Redim Preserve readsList(Users) As Long
Redim Preserve writesList(Users) As Long
Redim Preserve sessionList(Users) As Long
Redim Preserve timeList(Users) As String
UserList(Users)=result(0)
timelist(users)=uae.time
sessionList(Users)=1
readsList(Users)=uae.reads
writeslist(users)=uae.writes
Users=Users+1
End If
Else
sessionList(Index)=sessionList(Index)+1
readsList(Index)=readsList(Index)+uae.reads
writeslist(Index)=writeslist(Index)+uae.writes
End If
End If
Next AIndex

—Wannes R.

******************************************

My apologies, I left out part of the Global Declarations section needed to support the GetUserActivity subroutine. Of course if -- in my production application, I had taken the time to compartmentalize this code in its own script library, then such a mistake would have been much harder to make!

To fix it, add the following to the Declarations section of your agent:

Dim users As Long
Dim UserList() As String
Dim readsList() As Long
Dim writesList() As Long
Dim timelist() As String
Dim sessionList() As Long

Once more, the agent or script library should be set up as follows:

In the Options section:

'Option Public
Use "CLASSUserActivity"
Const Names2exclude=
"CORPAGENTSIGNER~APPS001
~CREGG S HARDWICK"
The Declarations section:
Dim totaluses As Long,totalreads 
Dim WeekUses As Long,
WeekReads As Long,WeekWrites As Long
Dim MonthUses As Long, 
MonthReads As Long, MonthWrites As Long , 
totalwrites As Long
Dim users As Long
Dim UserList() As String
Dim readsList() As Long
Dim writesList() As Long
Dim timelist() As String
Dim sessionList() As Long

The initialize event for a test 
agent that will call it:
Sub Initialize
Dim db As New notesdatabase("","")
Call db.OpenByReplicaID
(YOURSERVER,YOURDBREPLICAID)
Call GetUserActivity(db)
' Access the global variables 
above to get results…
End Sub
The subroutine that does the work:
Sub GetUserActivity(db As NotesDatabase)
            
Dim ua As New NotesUserActivity(db)
            
Dim uae As notesuseractivityentry
            
If ua.HasUserActivity Then
weekUses=ua.PrevWeekUses
weekReads=ua.PrevWeekReads
weekWrites=ua.PrevWeekWrites
monthUses=ua.PrevmonthUses
monthReads=ua.PrevmonthReads
monthWrites=ua.PrevmonthWrites
totalUses=ua.Uses
totalReads=ua.Reads
totalWrites=ua.Writes
                        
Dim ActivityEntries As Long
ActivityEntries=ua.UserActivityCount
                        
If ActivityEntries>0 Then
Print "        
-- Reading "+Format(ActivityEntries,"###,##0")
+" history records..."
End If 
                        
Dim index As Variant,result As Variant
Dim AIndex As Long
For AIndex = 1 To ActivityEntries
Set uae = ua.GetNthUserActivityEntry(AIndex)
result=Evaluate({@Name([Abbreviate];"}
+uae.UserName+{"):@Name([cn];"}
+uae.UserName+{")})
If Instr(names2exclude,Ucase(result(1)))=0 Then
index=Arraygetindex(UserList,result(0))
If Isnull(index) Then
 If users<=maxusers Then  
Redim Preserve UserList(Users) As String
Redim Preserve readsList(Users) As Long
Redim Preserve writesList(Users) As Long
Redim Preserve sessionList(Users) As Long
Redim Preserve timeList(Users) As String
UserList(Users)=result(0)
timelist(users)=uae.time
sessionList(Users)=1
readsList(Users)=uae.reads
writeslist(users)=uae.writes
Users=Users+1
End If
Else
sessionList(Index)=sessionList(Index)+1
readsList(Index)=readsList(Index)+uae.reads
writeslist(Index)=writeslist(Index)+uae.writes
End If
End If
                        Next AIndex
                        
            End If
End Sub

Cregg Hardwick, LotusScript expert

Do you have comments on this Ask the Expert Q&A? Let us know.

内容概要:《2024年印尼税收袖珍指南》由普华永道发布,涵盖了印尼税收体系的关键方面。主要内容包括企业所得税、个人所得税、预提税、国际税收协定、增值税、奢侈品销售税、碳税、关税与消费税、税收优惠、地方税、印花税、税务会计、税务稽查与评估、强制执行征税、税务纠纷与处理等。企业所得税税率一般为22%,特定条件可享受优惠。个人所得税采用超额累进税率,最高达35%。预提税涵盖多种收入类型,如工资、利息、股息等。国际税收协定帮助避免双重征税,提供优惠税率。增值税标准税率为11%,部分商品和服务免征。税收优惠包括免税期、加计扣除等,尤其针对特定行业和地区。地方税种类繁多,如土地与建筑物税、机动车税等。税务稽查与评估确保纳税人合规,税务纠纷可通过异议、申诉、诉讼等方式解决。 适用人群:企业财务人员、税务顾问、跨国公司税务部门、个人纳税人等。 使用场景及目标:①帮助企业理解和遵守印尼税法,优化税务规划;②协助个人纳税人正确申报各类税项;③为税务顾问提供最新税收政策信息,提升专业服务水平;④为跨国公司处理跨境税务问题提供指导。 阅读建议:此指南内容详尽,建议读者根据自身需求重点阅读相关章节,结合实际案例深入理解各项规定,并关注最新政策动态,确保税务处理合法合规。
### 回答1: "malformed database url, failed to parse the main url sections"的意思是数据库的URL格式错误,无法解析主URL部分。这通常意味着在配置数据库连接时输入的URL存在错误或不完整,导致程序无法正确地连接到数据库。要解决这个问题,需要检查输入的URL是否正确,确保包含必需的信息(例如用户名、密码、主机地址等),并且遵循正确的格式。 ### 回答2: “malformed database url,failed to parse the main url sections” 是指数据库连接的URL格式不正确,在解析主要URL部分时出现了错误而无法连接到数据库。 这个错误通常发生在应用程序或网站尝试连接到数据库时,因为URL格式有误而导致连接被拒绝。通常来说,这个错误是由程序员编写URL时出现的拼写错误、语法错误或格式错误造成的。 解决这个问题的方法是检查URL是否正确,包括确认URL的拼写、语法和格式是否正确。可以尝试使用不同的数据库管理工具进行测试,以确定是否可以成功连接到数据库。如果确认URL正确,则可能需要检查数据库是否已启动,并检查其它相关连接参数是否正确。 在编写程序时,应该采用一系列最佳实践,如使用常量代表URL、避免手写URL、使用标准URL格式,并进行输入验证和错误处理,以确保编写的程序没有这种错误。 ### 回答3: 在使用数据库进行数据处理时,可能会出现“malformed database url,failed to parse the main url sections”的错误。其中,“malformed database url”指的是数据库的URL地址出现了错误,“failed to parse the main url sections”则表示无法识别主URL的部分。 这种错误通常是由于URL地址中出现了不合法的字符或格式不正确所引起的。为了解决这个问题,可以从以下几个方面入手: 1. 检查URL地址是否正确 首先需要检查URL的完整性、正确性以及合法性。确保URL中的所有字符均符合标准,没有任何的拼写错误或格式错误。也可以尝试手动输入正确的URL地址,以避免因复制黏贴导致的问题。 2. 检查数据库连接信息是否正确 其次,需要检查数据库连接信息是否正确。数据库连接信息包括数据库的类型、地址、用户名、密码等,需要确保这些信息全部正确无误,才能进行正常的连接。 3. 检查数据库是否正常 还可检查数据库本身是否正常。如果数据库存在故障或不稳定的情况,就会出现连接不上的情况。可以通过检查数据库的日志文件来确认是否存在问题。 总的来说,“malformed database url,failed to parse the main url sections”这个错误是由URL地址不正确或不合法导致的,解决方法包括检查URL地址本身、数据库连接信息以及数据库本身是否正常。只有在这些方面都没有问题的情况下,才能建立正确的数据库连接,进行数据的处理和管理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值