'---------------------------------------------------------------------------------------------------------
' Class collect - получения дока в котором хранится инфа для бэкапа
'и обработка его классом ArcdATABASE
'---------------------------------------------------------------------------------------------------------
Class collect
Public doc As NotesDocument
Private ArcDB As ArcDATABASE
Sub new
Dim s As New NotesSession
Dim view As NotesView
Dim Press As Pressing
Set db=s.CurrentDatabase
Set view = db.GetView("MainV")
Set doc = view.GetFirstDocument
While Not(doc Is Nothing)
Set ArcDB = New ArcDATABASE(doc)
Set doc = view.GetNextDocument(doc)
Wend
End Sub
End Class
'---------------------------------------------------------------------------------------------------------
' Class ArcdATABASE - архивирование БД
'
'---------------------------------------------------------------------------------------------------------
Class ArcDATABASE
Public dbCopy As NotesDatabase
Public resultbase As String
Private archiveDb As NotesDatabase
Private ItemBase As NotesItem
Private ItemPath As NotesItem
Private ItemServ As NotesItem
Sub new (doc As NotesDocument)
Call Me.init(doc)
Call CreatDir
Call arc
End Sub
Sub init(doc As NotesDocument)
Dim s As New NotesSession
Set ItemBase = doc.GetFirstItem("BaseNames")
Set ItemPath = doc.GetFirstItem("Path")
Set ItemServ = doc.GetFirstItem("Serv")
Set dbCopy = s.GetDatabase(itemserv.Text,Itembase.Text)
End Sub
Sub CreatDir
Chdir (itempath.text)
a$ = Str(Date-1)
ZZZ = (Strrightback(a$,".20")+Strleft(Strright(a$,"."),".")+Strleft(a$,"."))
pathnames = ItemPath.Text + "\*.*"
dirs = Dir(pathnames,16)
Do While dirs <> ""
If ZZZ = dirs Then
Goto gogogo
End If
dirs = Dir()
Loop
Mkdir ZZZ
gogogo:
End Sub
Sub arc
Dim doccoll As NotesDocumentCollection
Dim docarc As NotesDocument
a$ = Str(Date-1)
ZZZ = (Strrightback(a$,".20")+Strleft(Strright(a$,"."),".")+Strleft(a$,"."))
resultbase = ItemPath.Text + "\" +ZZZ+"\"+ Strleft(dbcopy.FileName,".")+ZZZ+Strleft(itemserv.Text,"/")
Set archiveDb = dbCopy.CreateCopy("",resultbase+".nsf")
Set doccoll = dbCopy.AllDocuments
Set docArc = doccoll.GetFirstDocument
i=0
While Not docArc Is Nothing
i=i+1
Print i
Call docArc.CopyToDatabase(archiveDb)
Set docArc = doccoll.GetNextDocument(docarc)
Wend
End Sub
End Class
'---------------------------------------------------------------------------------------------------------
' Class Pressing - сжатие скопированной бд архиватором
'
'---------------------------------------------------------------------------------------------------------
Class Pressing
Public baseDoc As NotesDocument
Sub new
Dim s As New NotesSession
Dim view As NotesView
Dim ItemBase As NotesItem
Dim ItemPath As NotesItem
Dim ItemServ As NotesItem
Dim dbCopy As NotesDatabase
Set db=s.CurrentDatabase
Set view = db.GetView("MainV")
Set baseDoc = view.GetFirstDocument
While Not(baseDoc Is Nothing)
Set ItemBase = baseDoc.GetFirstItem("BaseNames")
Set ItemPath = baseDoc.GetFirstItem("Path")
Set ItemServ = baseDoc.GetFirstItem("Serv")
Set dbCopy = s.GetDatabase(itemserv.Text,Itembase.Text)
a$ = Str(Date-1)
ZZZ = (Strrightback(a$,".20")+Strleft(Strright(a$,"."),".")+Strleft(a$,"."))
resultbas = ItemPath.Text + "\" +ZZZ+"\"+ Strleft(dbcopy.FileName,".")+ZZZ+Strleft(itemserv.Text,"/")
result = Shell("C:\rar.exe "+"m[f] -ep "+resultbas+" "+resultbas+".nsf", 6)
Set baseDoc = view.GetNextDocument(baseDoc)
Wend
End Sub
End Class