I have attached script to be put for instance in a button and mailed to the Notes users after their Notes client have been upgraded to R6. When the users click on it, it will go through their local notes db’s and compact it to ODS 43.
The scripts works fine but when the local mail replica is still open (because the mail with the button is opened from the local mail replica) then the script will skip the compact of this db. But we need to compact this db also to make use of the new options in ODS43 like replication of unread marks.
Does anybody know another way of compacting these local db’s or know a way to close all open db’s first before launching the compact.
Thanks, Phuoc.
Hereby the code:
Dim dbcount As Long ’ number of databases encountered
Dim compacted_count% ’ how many were compacted
Dim amount_recovered As Double
Dim totalsize As Double ’ total size of all databases (not just those compacted)
Dim total_utilization As Double
Class Reporter
NormalTermination As Integer
Sub finish
NormalTermination = True
End Sub
Sub delete
Dim t$
If Not NormalTermination Then
t$ = |<< Process Terminated >>|
End If
Messagebox t$ & |Found | & dbcount & | Databases. These take = | & Format(totalsize, "0,0") & | Bytes. Compacted | & compacted_count & | Databases, reduced | & Format(amount_recovered, "0,0") & | Bytes.|
End Sub
End Class
Sub Click(Source As Button)
Dim dbs As notesdbdirectory, db As notesdatabase, cutoff As Double, tmp, delta As Long, ses As New notessession, thisdb As notesdatabase
Set thisdb = ses.currentdatabase
cutoff = 100
Set dbs = New notesdbdirectory("")
Set db = dbs.getfirstdatabase(DATABASE)
Dim report As New reporter
Do Until db Is Nothing
If db.filepath <> thisdb.filepath Or thisdb.server <> "" Then
db.open "", "" ' database must be open to read size and percent used.
If db.isopen Then
tmp = db.size
If db.percentused < cutoff Then
Print "Compacting " & db.title & " (" & db.filepath & ")"
delta = 0 ' in case there's an error when compacting
On Error Resume Next
delta = db.compact
On Error Goto 0
amount_recovered = amount_recovered + delta
compacted_count = compacted_count + 1
End If
totalsize = totalsize + tmp
total_utilization = total_utilization + db.percentused
dbcount = dbcount + 1
End If
End If
Set db = dbs.getnextdatabase()
Loop
report.finish
End Sub