Lotus на практике. Экспорт ACL базы Lotus в Excel (Lotus script)

О чем этот текст?

Руководство любит слово матрица. И если ты не составлял матрицы доступа к базам Lotus, то возможно тебя ждет самая плохая неделя. Перебрать это всё вручную, про адский труд. К счастью у тебя есть мозг(можно поставить здесь восклицательный знак) и ты смог найти этот материал. Здесь представлен код, который позволяет повесить его на кнопку и выгрузить все ACL из базы. Туда попадут и пользователи и группы пользователей с назначенными на них ролями и правами. Считай две трети работы будет сделано и тебе останется только раздобыть блюдечко и голубую каёмочку.

Основная часть

Dim db As NotesDatabase
Dim acl As NotesACL
Dim entry As NotesACLEntry
Set session = New notessession
Set db=session.CurrentDatabase
Set acl = db.ACL
Set entry = acl.GetFirstEntry

Dim row As Double
Dim xl As Variant
Dim xlWbk As Variant

Set session = New notessession
Set db=session.CurrentDatabase

Set xl=CreateObject("Excel.Application")
Set xlWbk=xl.Workbooks.Add

xlWbk.ActiveSheet.Range("A2:H2").Select

'вывод в Excel

xlWbk.ActiveSheet.Cells(2, 1).RowHeight=30
xlWbk.ActiveSheet.Range("A2").HorizontalAlignment = -4108
xlWbk.ActiveSheet.Cells(2, 1)="ACL в Excel"
xlWbk.ActiveSheet.Range("A2:H2").Merge

numrow%=1
row=5

xlWbk.ActiveSheet.Cells(5, 1)="№ п/п"
xlWbk.ActiveSheet.Cells(5, 1).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 1).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 2)="Имя ACL"
xlWbk.ActiveSheet.Cells(5, 2).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 2).Font.Bold=True


xlWbk.ActiveSheet.Cells(5, 3)="User type"
xlWbk.ActiveSheet.Cells(5, 3).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 3).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 4)="Access"
xlWbk.ActiveSheet.Cells(5, 4).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 4).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 5)="Роли"
xlWbk.ActiveSheet.Cells(5, 5).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 5).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 6)="Create documents"
xlWbk.ActiveSheet.Cells(5, 6).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 6).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 7)="Delete documents"
xlWbk.ActiveSheet.Cells(5, 7).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 7).Font.Bold=True

xlWbk.ActiveSheet.Cells(5,8 )="Create private agents"
xlWbk.ActiveSheet.Cells(5, 8 ).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 8 ).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 9)="Create personal folders/views"
xlWbk.ActiveSheet.Cells(5, 9).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 9).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 10)="Create shared folders/views"
xlWbk.ActiveSheet.Cells(5, 10).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 10).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 11)="Create LotusScript/Java agents"
xlWbk.ActiveSheet.Cells(5, 11).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 11).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 12)="Read public documents"
xlWbk.ActiveSheet.Cells(5, 12).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 12).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 13)="Write public documents"
xlWbk.ActiveSheet.Cells(5, 13).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 13).Font.Bold=True

xlWbk.ActiveSheet.Cells(5, 14)="Replicate or copy documents"
xlWbk.ActiveSheet.Cells(5, 14).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(5, 14).Font.Bold=True

xlWbk.ActiveSheet.columns(2).ColumnWidth=15
xlWbk.ActiveSheet.Cells(row, 2).WrapText = True
xlWbk.ActiveSheet.columns(3).ColumnWidth=15
xlWbk.ActiveSheet.Cells(row, 3).WrapText = True
xlWbk.ActiveSheet.columns(4).ColumnWidth=15
xlWbk.ActiveSheet.Cells(row, 4).WrapText = True
xlWbk.ActiveSheet.columns(5).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 5).WrapText = True
xlWbk.ActiveSheet.columns(6).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 6).WrapText = True
xlWbk.ActiveSheet.columns(7).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 7).WrapText = True
xlWbk.ActiveSheet.columns(8 ).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 8 ).WrapText = True
xlWbk.ActiveSheet.columns(9).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 9).WrapText = True
xlWbk.ActiveSheet.columns(10).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 10).WrapText = True
xlWbk.ActiveSheet.columns(11).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 11).WrapText = True
xlWbk.ActiveSheet.columns(12).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 12).WrapText = True
xlWbk.ActiveSheet.columns(13).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 13).WrapText = True
xlWbk.ActiveSheet.columns(14).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 14).WrapText = True

xlWbk.ActiveSheet.Cells(row, 1).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 2).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 3).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 4).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 5).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 6).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 7).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 8 ).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 9).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 10).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 11).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 12).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 13).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 14).VerticalAlignment = -4160

row=row+1

While Not entry Is Nothing

xlWbk.ActiveSheet.Cells(row,1).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,2).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,3).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,4).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,5).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,6).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,7).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,8 ).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,9).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,10).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,11).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,12).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,13).Borders.LineStyle = 1
xlWbk.ActiveSheet.Cells(row,14).Borders.LineStyle = 1

xlWbk.ActiveSheet.Cells(row, 1).NumberFormat="@"
xlWbk.ActiveSheet.Cells(row, 2).NumberFormat="@"
xlWbk.ActiveSheet.Cells(row, 1)=numrow%
xlWbk.ActiveSheet.Cells(row, 2)=entry.Name
Select Case entry.UserType
Case 0 : xlWbk.ActiveSheet.Cells(row, 3)="Unspecified"
Case 1 : xlWbk.ActiveSheet.Cells(row, 3)="Person"
Case 2 : xlWbk.ActiveSheet.Cells(row, 3)="Server"
Case 3 : xlWbk.ActiveSheet.Cells(row, 3)="Mixed Group"
Case 4 : xlWbk.ActiveSheet.Cells(row, 3)="Person Group"
Case 5 : xlWbk.ActiveSheet.Cells(row, 3)="Server Group"
Case Else : xlWbk.ActiveSheet.Cells(row, 3)=""
End Select

Select Case entry.Level
Case 0 : xlWbk.ActiveSheet.Cells(row, 4)="No Access"
Case 1 : xlWbk.ActiveSheet.Cells(row, 4)="Depositor"
Case 2 : xlWbk.ActiveSheet.Cells(row, 4)="Reader"
Case 3 : xlWbk.ActiveSheet.Cells(row, 4)="Author"
Case 4 : xlWbk.ActiveSheet.Cells(row, 4)="Editor"
Case 5 : xlWbk.ActiveSheet.Cells(row, 4)="Designer"
Case 6 : xlWbk.ActiveSheet.Cells(row, 4)="Manager"
Case Else : xlWbk.ActiveSheet.Cells(row, 4)=""
End Select

xlWbk.ActiveSheet.Cells(row, 5)=Join(entry.Roles)

Select Case entry.CanCreateDocuments
Case False : xlWbk.ActiveSheet.Cells(row, 6)="'False"
Case True : xlWbk.ActiveSheet.Cells(row, 6)="'True"
End Select
Select Case entry.CanDeleteDocuments
Case False : xlWbk.ActiveSheet.Cells(row, 7)="'False"
Case True : xlWbk.ActiveSheet.Cells(row, 7)="'True"
End Select
Select Case entry.CanCreatePersonalAgent
Case False : xlWbk.ActiveSheet.Cells(row, 8 )="'False"
Case True : xlWbk.ActiveSheet.Cells(row, 8 )="'True"
End Select
Select Case entry.CanCreatePersonalFolder
Case False : xlWbk.ActiveSheet.Cells(row, 9)="'False"
Case True : xlWbk.ActiveSheet.Cells(row, 9)="'True"
End Select
Select Case entry.CanCreateSharedFolder
Case False : xlWbk.ActiveSheet.Cells(row, 10)="'False"
Case True : xlWbk.ActiveSheet.Cells(row, 10)="'True"
End Select
Select Case entry.CanCreateLSOrJavaAgent
Case False : xlWbk.ActiveSheet.Cells(row, 11)="'False"
Case True : xlWbk.ActiveSheet.Cells(row, 11)="'True"
End Select
Select Case entry.IsPublicReader
Case False : xlWbk.ActiveSheet.Cells(row, 12)="'False"
Case True : xlWbk.ActiveSheet.Cells(row, 12)="'True"
End Select
Select Case entry.IsPublicWriter
Case False : xlWbk.ActiveSheet.Cells(row, 13)="'False"
Case True : xlWbk.ActiveSheet.Cells(row, 13)="'True"
End Select
Select Case entry.CanReplicateOrCopyDocuments
Case False : xlWbk.ActiveSheet.Cells(row, 14)="'False"
Case True : xlWbk.ActiveSheet.Cells(row, 14)="'True"
End Select

numrow%=numrow%+1

xlWbk.ActiveSheet.Cells(row, 1).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 2).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 3).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 4).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 5).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 6).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 7).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 8 ).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 9).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 10).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 11).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 12).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 13).VerticalAlignment = -4160
xlWbk.ActiveSheet.Cells(row, 14).VerticalAlignment = -4160

xlWbk.ActiveSheet.columns(2).ColumnWidth=15
xlWbk.ActiveSheet.Cells(row, 2).WrapText = True
xlWbk.ActiveSheet.columns(3).ColumnWidth=15
xlWbk.ActiveSheet.Cells(row, 3).WrapText = True
xlWbk.ActiveSheet.columns(4).ColumnWidth=15
xlWbk.ActiveSheet.Cells(row, 4).WrapText = True
xlWbk.ActiveSheet.columns(5).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 5).WrapText = True
xlWbk.ActiveSheet.columns(6).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 6).WrapText = True
xlWbk.ActiveSheet.columns(7).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 7).WrapText = True
xlWbk.ActiveSheet.columns(8 ).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 8 ).WrapText = True
xlWbk.ActiveSheet.columns(9).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 9).WrapText = True
xlWbk.ActiveSheet.columns(10).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 10).WrapText = True
xlWbk.ActiveSheet.columns(11).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 11).WrapText = True
xlWbk.ActiveSheet.columns(12).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 12).WrapText = True
xlWbk.ActiveSheet.columns(13).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 13).WrapText = True
xlWbk.ActiveSheet.columns(14).ColumnWidth=20
xlWbk.ActiveSheet.Cells(row, 14).WrapText = True

row=row + 1
Print row
Set entry = acl.GetNextEntry(entry)
Wend

xl.Visible=True

Автор: Joe1000




Ссылки:

К содержанию

© Copyright 2004-2017 - CMS Made Simple
Сайт работает на CMS Made Simple version 1.4.1

© Все печеньки Break-people.ru принадлежат авторам проекта.

Яндекс цитирования Рейтинг@Mail.ru Яндекс.Метрика