This agent was created to find duplicate folders in a Domino.doc application. It can be also be customized to find other duplicate design elements or duplicate folders. Once the final duplicates have been gathered. It is included in a notification e-mail to the database designer/project manager or appropriate person.
Option Public
Option Declare
Sub Initialize
Dim Session As New NotesSession
Dim DB As NotesDatabase
Dim View As NotesView
Dim dCount As Long ' count of dString
Dim tCount As Long ' count of tString
Dim cCount As Long ' count of cString
Dim ctoggle As Integer
Dim jCount As Long ' count of all cString that exist so far in compare loop
Dim tString List As String ' tString is a list of all the folders
Dim cString List As String ' cString is a list of the folders being compared
Dim dString List As String ' dString is a list of all the folders that are duplicates
Dim temp As String
Dim bodyCount As Long
' maildoc dims
Dim maildoc As NotesDocument
Dim Body As NotesRichTextItem
Set db = Session.CurrentDatabase
dCount = 0
tCount = 0
Forall v In db.Views
If v.IsFolder Then
tString(Str(tCount)) = v.Name
tCount = tCount + 1
End If
End Forall
If tCount = 0 Then
Exit Sub
End If
cCount=0
' Cycle through each value and see it it matches a value in cString.
' If so put it in dString, else add it to cString
Forall i In tString
' Cycle through all elements of tString list and compare to growing cString
' skipping first tstring(0) because nothing is in compare list yet
If cCount=0 Then
' Set first item of folder list to the compare list
temp = tString(Str(cCount))
cString(Str(cCount)) = temp
Goto Skip
End If
jCount = 0
Forall j In cString
' For each element of tString sycle through current list of cString
temp = tString(Str(cCount))
If cString(Str(jCount)) = temp Then
dString(Str(dCount)) = temp
dCount = dCount + 1
Goto Skip
Else
ctoggle = False
End If
jCount = jCount + 1
End Forall
If ctoggle= False Then
cString(Str(cCount )) = temp
End If
Skip:
cCount = cCount + 1
End Forall
If dCount=0 Then
Exit Sub
End If
' Mail document with list of dString
Set maildoc = New NotesDocument( db )
maildoc.Form = "Memo"
maildoc.Subject = "Duplicate Folder Alert - " & db.Title
Set Body = New NotesRichTextItem ( maildoc, "Body" )
Call Body.AppendText _
( "The following folders are all duplicates in this database. ")
Call Body.AddNewLine( 1 )
bodyCount=0
Do
Call Body.AppendText _
( dString(Str(bodyCount)) )
Call Body.AddNewLIne(1)
bodyCount = bodyCount + 1
Loop Until bodyCount >= dCount
' Call Body.AppendDocLink( db, db.Title ) Use doclink if had been Notes mail
Call Body.AddNewLIne(1)
Call Body.AppendText _
( db.server & " - " & db.filepath )
maildoc.From = "somefromname"
maildoc.Principal = "somefromname"
Call maildoc.Send( False, "sometoname" )
End Sub
previous page
|