Search This Blog

Friday, January 11, 2013

How to get a number of deletion stubs in a Lotus Notes database

Hi guys

Recently I stuck with the task about programmatic way of getting a number of deletion stubs in a database.
I knew that there is a C NotesApi based way to do this but I had to resolve this task very fast what made me impossible to use this way.

I resolved it.
May be it looks ugly but it works so I am happy.

The idea is to run an agent on Domino server that sends a console command "show database" and then parse server response for getting number of deletion stubs.
This approach requires Domino server and will not work on local.


Here is my lotus script code (its possible that you need to fix string statements I used if you have Domino server with not English localization):


Function GetStubsNumber(targetDb As notesdatabase) As Long
On Error Goto errh

Dim s As New notessession
Dim response As String
Dim newLine As String
Dim cmd As String
Dim result As String

cmd = {show database "} & targetDb.Filepath & {"}

response = s.Sendconsolecommand(targetDb.server, cmd)

newLine = Strleft(Strright(response, "Deleted"), "Documents")

result = Strright(response, "Documents")
result = Strleft(result, newLine)

If Right(result, 1) = " " Then
Do
result = Left(result, Len(result)-1)
Loop While Right(result, 1) = " "
End If

result = Replace(Strrightback(result, "  "), " ", "")

If Isnumeric(result) Then
GetStubsNumber = Clng(result)
End If

basta:
Exit Function
errh:
Msgbox Lsi_info(12) & Lsi_info(2) & ": " & Error & " in line " & Erl
Resume basta
End Function

No comments:

Post a Comment