P
proteam
Всем привет. Стоит задача, сделать программное обновление шаблона. В интернете натолкнулся на такой вот
<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">код</div></div><div class="sp-body"><div class="sp-content">
Но лотус такая штука, в первый раз агент все хорошо обновил, во второй - тоже, запускаю в 3 раз: логируется что все успешно, но открываешь базу данных и видишь кривой дизайн, дубликаты некоторых элементов дизайна в общем небольшой хауз.
Может быть кто нибудь знает, как лучше и для лотуса безошибочно сделать программное обновление элементов дизайна БД?
<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">код</div></div><div class="sp-body"><div class="sp-content">
Код:
Function ReplaceDesign(SourceServer As String, SourcePath As String, TargetServer As String, TargetPath As String) As Boolean
On Error GoTo eh
Dim ui As Long
Dim Session As New NotesSession
'Dim workspace As New NotesUIWorkspace
Dim Sourcedb As New NotesDatabase(SourceServer,SourcePath)
Dim Targetdb As New NotesDatabase(TargetServer,TargetPath)
Call Logger.log(0, "Удаление элементов дизайна у текущей БД...")
'Delete elements from the Target Database
'Ignore Elements having "Prohibit design...." property or Master Template Defined
Dim TargetNoteCol As NotesNoteCollection
Set TargetNoteCol = Targetdb.CreateNoteCollection(True)
'Select All Design Elements
'Deselct Admin Notes
Call TargetNoteCol.SelectAllAdminNotes(False)
'Deselect Document Notes
Call targetNoteCol.SelectAllDataNotes(False)
'Deselect Icon Note
TargetNoteCol.SelectIcon = False
'Deselect Help-About and Help Using Notes which has different mechanism for checking "Prohibit design....."
TargetNoteCol.SelectHelpAbout = False
TargetNoteCol.SelectHelpIndex = False
TargetNoteCol.SelectHelpUsing = False
'Loop Thru All Design Notes and Check -- 'Ignore Elements having "Prohibit design...." property or Master Template Defined
Call TargetNoteCol.BuildCollection
Dim DesignDoc As NotesDocument
Dim ID As String
Dim NextID As String
Dim i As Long
ID = TargetNoteCol.GetFirstNoteId
For i = 1 To TargetNoteCol.Count
NextID = TargetNoteCol.GetNextNoteId(ID)
Set DesignDoc = TargetDB.GetDocumentByID(ID)
If (Not(DesignDoc.HasItem("$Class"))) And InStr(DesignDoc.~$Flags(0),"P") =0 Then
'Print "Removing " + DesignDoc.~$Title(0)
Call DesignDoc.RemovePermanently(True)
End If
nxtID:
ID= NextID
Next
'Check for Help About and Help Using
Dim IsHelpAbout As Boolean
Dim IsHelpUsing As Boolean
IsHelpAbout = False
IsHelpUsing = False
Call TargetNoteCol.SelectAllNotes(False)
Call TargetNoteCol.ClearCollection
TargetNoteCol.SelectHelpAbout = True
Call TargetNoteCol.BuildCollection
If TargetNoteCol.Count <> 0 Then
ID = TargetNoteCol.GetFirstNoteId
Set DesignDoc = TargetDB.GetDocumentByID(ID)
If InStr(DesignDoc.~$Flags(0),"R") <> 0 Then
'Print "Removing Help-About Document"
'Call DesignDoc.Remove(True)
Call DesignDoc.RemovePermanently(True)
IsHelpAbout = True
End If
End If
Call TargetNoteCol.SelectAllNotes(False)
Call TargetNoteCol.ClearCollection
TargetNoteCol.SelectHelpUsing = True
Call TargetNoteCol.BuildCollection
If TargetNoteCol.Count <> 0 Then
ID = TargetNoteCol.GetFirstNoteId
Set DesignDoc = TargetDB.GetDocumentByID(ID)
If InStr(DesignDoc.~$Flags(0),"R") <> 0 Then
'Print "Removing Help-Using Document"
'Call DesignDoc.Remove(True)
Call DesignDoc.RemovePermanently(True)
IsHelpUsing = True
End If
End If
'Set More Fields Options
Call TargetDb.SetOption(54,True)
Call Logger.log(0, "Копируем дизайн...")
'Copy All the Design Elements from SourceDB to Target DB except Help About and Help Using
Dim SourceNoteCol As NotesNoteCollection
Set SourceNoteCol = Sourcedb.CreateNoteCollection(True)
'Deselct Admin Notes
Call SourceNoteCol.SelectAllAdminNotes(False)
'Deselect Document Notes
Call SourceNoteCol.SelectAllDataNotes(False)
'Deselect Icon Note
SourceNoteCol.SelectIcon = False
'Deselect Help-About and Help Using Notes which has different mechanism for checking "Prohibit design....."
If IsHelpAbout = False Then
SourceNoteCol.SelectHelpAbout = False
End If
If IsHelpUsing = False Then
SourceNoteCol.SelectHelpUsing = False
End If
'Loop Thru All Design Notes and Check -- 'Ignore Elements having "Prohibit design...." property or Master Template Defined
Call SourceNoteCol.BuildCollection
ID = SourceNoteCol.GetFirstNoteId
For i = 1 To SourceNoteCol.Count
NextID = SourceNoteCol.GetNextNoteId(ID)
Set DesignDoc = SourceDB.GetDocumentByID(ID)
Call DesignDoc.CopyToDatabase(TargetDB)
'Print "Copying...." + DesignDoc.~$Title(0)
nxtID1:
ID= NextID
Next
'Add All the roles from Source DB to Target DB
Dim TargetACl As NotesACL
Dim SourceACL As NotesACL
Set TargetACL = TargetDb.ACL
Set SourceACL = SourceDB.ACL
Dim TargetRoles As Variant
Dim SourceRoles As Variant
TargetRoles = TargetACL.Roles
SourceRoles = SourceACL.Roles
If IsArray(SourceRoles) Then
Dim RolesToBeAdded As Variant
RolesToBeAdded = ArrayUnique((ArrayReplace(SourceRoles,TargetRoles,"")))
ForAll DummyRole In RolesToBeAdded
If FullTrim(DummyRole) <> "" Then
TargetACL.AddRole(StrLeft(StrRight(DummyRole,"["),"]"))
End If
End ForAll
TargetACL.Save
End If
ReplaceDesign = True
Call Sourcedb.Remove()
Delete Targetdb
ex:
Exit Function
eh:Call Logger.log(Err, CStr(Error)+" in "+Cstr(GetThreadInfo(1))+" on line "+Cstr(Erl))
Resume ex
End Function
Может быть кто нибудь знает, как лучше и для лотуса безошибочно сделать программное обновление элементов дизайна БД?