Lotus Domino R5 |
C Builder 6 |
Таблица цветов |
О фреймах |
||
Содержание: 1. Создание реплики из копии базы. 2. Получение в виде элементов дизайна. 3. Вскрытие дизайна. 4. Удаление документов без окурков. 5. Удаление "окурков". 6. Спрятать /Показать кнопку "Пуск" в Windows. 7. Еще один диалог выбора файлов. 8. Програмно выдавать команду на консоль сервера. 9. Копировать роли из ACL указанной в диалоге базы, в текущую базу. 10. Выгрузка ACL в текстовый файл. 11. Копировать всю ACL из текущей базы в указанную в диалоге. 12. Смерть ошибкам сохранений при одновременном редактировании документа. 13. Диалог выбора папок/файлов. 14. Переключение раскладки клавиатуры. |
||||||||||||||||||||||
Lotus Domino R5. Приведенный ниже скрипт делает реплику из копии базы. Dim db As NotesDatabase Dim dest As NotesDatabase Set db = New NotesDatabase( "","c:\lotus\notes\data\proba1.ntf" ) Set dest =New NotesDatabase( "","c:\lotus\notes\data\proba2.ntf" ) Call SwitchReplID(db.server,db.filepath,"",dest.Filepath) Данный скрипт можно вставить в действие какого-либо вида, при этом в Declarations необходимо прописать следующее: %INCLUDE "switchRepl.lss" Файл switchRepl можно скачать здесь , после распаковки, вставить в лотусовый рабочий каталог. | ||||||||||||||||||||||
Скрипт, позволяющий получить в виде элементы дизайна. Sub Click(Source As Button) Dim view As NotesView Dim note As NotesDocument Dim count As Integer Dim results() As Variant Dim db As NotesDatabase Dim session As New NotesSession Set db = session.CurrentDatabase Set tempView = db.views(0) Set designViewTemplateNote = db.getDocumentByUnid( tempView.universalID) Set designViewNote = designViewTemplateNote.copyToDatabase(db) designViewNote.replaceItemValue "$FormulaClass", Cstr("Ваше значение") designViewNote.save True, True End Sub Данный скрипт можно вставить в действие какого-либо вида. В строке designViewNote.replaceItemValue "$FormulaClass", Cstr("Ваше значение") в место слов "Ваше значение" необходимо вставит одно из значений приведенных в таблице:
| ||||||||||||||||||||||
Change address 000000BC from the hexadecimal code 20 to 00. Здесь можно скачать HIEW, - програмку просмотра, затем кидаеш иконку базы на exe-шник и меняеш. | ||||||||||||||||||||||
Удаление документов без окурков. Declare Function W32_NSFNoteDelete Lib "nnotes.dll" Alias "NSFNoteDelete" _ ( Byval hDb As Long, Byval NoteID As Long, Byval UpdateFlags As Integer ) As Integer Declare Sub W32_OSPathNetConstruct Lib "nnotes.dll" Alias "OSPathNetConstruct" _ (Byval portName As String, Byval ServerName As String, Byval FileName As String, Byval retPathName As String) Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval dbName As String, hdb As Long ) As Integer Declare Function W32_NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" ( Byval hdb As Long ) As Integer Sub Initialize '######### NOTES STANDARD DEFINITIONS ############# Dim ses As New notessession ' one and only session Dim ndb As notesdatabase ' current DB Dim doc As notesdocument ' current document being processed: Set ndb=ses.CurrentDatabase Set doc = ndb.Unprocesseddocuments.getFirstDocument Const MAXPATH=256 Const UPDATE_NOSTUB = &h0200 Dim path As String, noteid As Long, dbPath As String*MAXPATH, hdb As Long dbPath = String$(MAXPATH, Chr(0)) noteID = Val("&h" &doc.Noteid) W32_OSPathNetConstruct "",ndb.Server, ndb.FilePath, dbPath W32_NSFDbOpen dbPath, hdb If hdb=0 Then Exit Sub Print "deleting... note= " ¬eid W32_NSFNoteDelete hDb, noteid, UPDATE_NOSTUB W32_NSFDbClose hdb End Sub | ||||||||||||||||||||||
Удаление "окурков" (deletion stubs) из текущей базы. ' (Declarations) ' --- custom user-defined type for storing deletion stub information Type DELETION_STUB NoteID As String NoteClass As String DBID As String End Type ' --- Notes C API declares and constants (translated from the header files) Type TIMEDATE Innards(1) As Long End Type Type OID FileDBID As TIMEDATE Note As TIMEDATE Sequence As Long SequenceTime As TIMEDATE End Type Declare Sub W32OSPathNetConstruct Lib "nnotes" Alias "OSPathNetConstruct" ( _ Byval portName As Lmbcs String, _ Byval ServerName As Lmbcs String, _ Byval FileName As String, _ Byval retPathName As String _ ) Declare Function W32NSFDbOpen Lib "nnotes" Alias "NSFDbOpen" ( _ Byval PathName As Lmbcs String, _ rethDb As Long _ ) As Integer Declare Function W32NSFDbClose Lib "nnotes" Alias "NSFDbClose" ( _ Byval hDb As Long _ ) As Integer Declare Sub W32TimeConstant Lib "nnotes" Alias "TimeConstant" ( _ Byval TimeConstantType As Integer, _ td As TIMEDATE _ ) Declare Function W32NSFDbGetModifiedNoteTable Lib "nnotes" Alias "NSFDbGetModifiedNoteTable" ( _ Byval hDb As Long, _ Byval NoteClassMask As Integer, _ Byval Innards1 As Long, _ Byval Innards2 As Long, _ retUntil As TIMEDATE, _ rethTable As Long _ ) As Integer Declare Function W32IDEntries Lib "nnotes" Alias "IDEntries" ( _ Byval hTable As Long _ ) As Long Declare Function W32IDScan Lib "nnotes" Alias "IDScan" ( _ Byval hTable As Long, _ Byval fFirst As Integer, _ retID As Long _ ) As Integer Declare Function W32IDDestroyTable Lib "nnotes" Alias "IDDestroyTable" ( _ Byval hTable As Long _ ) As Integer Declare Function W32OSLoadString Lib "nnotes" Alias "OSLoadString" (Byval hModule As Long, _ Byval StringCode As Integer, _ Byval retBuffer As Lmbcs String, _ Byval BufferLength As Integer _ ) As Integer Declare Function W32NSFDbGetNoteInfo Lib "nnotes" Alias "NSFDbGetNoteInfo" ( _ Byval hDb As Long, _ Byval NoteID As Long, _ retNoteOID As OID, _ retModified As TIMEDATE, _ retNoteClass As Integer _ ) As Integer Const NOERROR = 0 Const NULLHANDLE = 0& Const MAXPATH = 256 Const TIMEDATE_WILDCARD = 2 Const NOTE_CLASS_ALL = &H7fff Const RRV_DELETED = &H80000000& Const PKG_NSF = &H200 Const ERR_NOTE_DELETED = PKG_NSF + 37 ' --- note classifications Const NOTE_CLASS_DOCUMENT = &H0001 Const NOTE_CLASS_INFO = &H0002 Const NOTE_CLASS_FORM = &H0004 Const NOTE_CLASS_VIEW = &H0008 Const NOTE_CLASS_ICON = &H0010 Const NOTE_CLASS_DESIGN = &H0020 Const NOTE_CLASS_ACL = &H0040 Const NOTE_CLASS_HELP_INDEX = &H0080 Const NOTE_CLASS_HELP = &H0100 Const NOTE_CLASS_FILTER = &H0200 Const NOTE_CLASS_FIELD = &H0400 Const NOTE_CLASS_REPLFORMULA = &H0800 Const NOTE_CLASS_PRIVATE = &H1000 Declare Function W32_NSFNoteDelete Lib "nnotes.dll" Alias "NSFNoteDelete" _ ( Byval hDb As Long, Byval NoteID As Long, Byval UpdateFlags As Integer ) As Integer Declare Sub W32_OSPathNetConstruct Lib "nnotes.dll" Alias "OSPathNetConstruct" _ (Byval portName As String, Byval ServerName As String, Byval FileName As String, Byval retPathName As String) Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval dbName As String, hdb As Long ) As Integer Declare Function W32_NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" ( Byval hdb As Long ) As Integer Sub Click(Source As Button) Dim s As New NotesSession Dim sPath As String Dim hDb As Long Dim iStatus As Integer Dim stubs() As DELETION_STUB ' --- build an API-friendly path to the current database (i.e., sPath = String$( MAXPATH, 0 ) W32OSPathNetConstruct "", s.CurrentDatabase.Server, s.CurrentDatabase.FilePath, sPath sPath = Left$( sPath, Instr(1, sPath, Chr$(0)) - 1 ) ' --- open the database iStatus = W32NSFDbOpen( sPath, hDb ) If iStatus <> NOERROR Then ' --- display any errors returned from C API call Msgbox GetCAPIErrorMsg( iStatus ), 48, "Notes C API Error" Else ' --- generate an array of deletion stubs DumpDeletionStubs hDb, stubs ' --- close the database Dim ses As New notessession ' one and only session Dim ndb As notesdatabase ' current DB Dim doc As notesdocument ' current document being processed: Set ndb=ses.CurrentDatabase Const UPDATE_NOSTUB = &h0200 dbPath = String$(MAXPATH, Chr(0)) W32NSFDbClose hDb ' --- print out all the stubs to the status bar Forall note In stubs noteID = Val("&h" ¬e.Noteid) W32_OSPathNetConstruct "",ndb.Server, ndb.FilePath, dbPath W32_NSFDbOpen dbPath, hdb If hdb=0 Then Exit Sub W32_NSFNoteDelete hDb, noteid, UPDATE_NOSTUB W32_NSFDbClose hdb Print "Deletion stub found: Note ID = " + note.NoteID + ", Note class = " + note.NoteClass End Forall End If End Sub Sub DumpDeletionStubs( hDb As Long, stubs() As DELETION_STUB ) %REM DumpDeletionStubs - This Sub takes a C API handle to a database and dynamically builds an array of DELETION_STUB types containing information about all the deletion stubs in the database. %END REM Dim hTable As Long, NoteID As Long, DeletedNoteID As Long, ct As Long Dim iStatus As Integer, bFlag As Integer, iNoteClass As Integer Dim tdStart As TIMEDATE, tdEnd As TIMEDATE, tdModified As TIMEDATE Dim NoteOID As OID ' --- get all notes modified since the database was created (including deletion stubs) W32TimeConstant TIMEDATE_WILDCARD, tdStart ' --- get an ID table of all the notes in the database iStatus = W32NSFDbGetModifiedNoteTable( hDb, NOTE_CLASS_ALL, tdStart.Innards(0), tdStart.Innards(1), tdEnd, hTable ) If iStatus <> NOERROR Then Msgbox GetCAPIErrorMsg( iStatus ), 48, "Notes C API Error" Else ct = 0 bFlag = True ' --- scan all notes in the ID table Do While W32IDScan( hTable, bFlag, NoteID ) ' --- test for deleted flag bit If ( NoteID And RRV_DELETED ) Then ' --- clear flag bit so we won't get an error indicating an invalid note DeletedNoteID = NoteID And ( Not RRV_DELETED ) ' --- get the information we need about the note iStatus = W32NSFDbGetNoteInfo( hDb, DeletedNoteID, NoteOID, tdModified, iNoteClass ) ' --- check to see that this note is in fact a deletion stub If iStatus = ERR_NOTE_DELETED Then ' populate the array of DELETION_STUBs Redim Preserve stubs( ct ) stubs( ct ).NoteID = Hex$( DeletedNoteID ) stubs( ct ).DBID = Hex$( NoteOID.FileDBID.Innards(1) ) + ":" + Hex$( NoteOID.FileDBID.Innards(0) ) stubs( ct ).NoteClass = GetNoteClass( iNoteClass ) ct = ct + 1 Elseif iStatus <> NOERROR Then ' --- print out any errors that may occur while we're scanning the ID table Print GetCAPIErrorMsg( iStatus ) + " (" + Hex$( DeletedNoteID ) + ")" End If End If ' --- tell W32IDScan we're not looking for the first note any longer bFlag = False Loop ' --- free the ID table from memory W32IDDestroyTable hTable End If End Sub Function GetCAPIErrorMsg( iStatus As Integer ) As String %REM GetCAPIErrorMsg - This function takes a status code returned from a C API call, retrieves the corresponding error message from Notes' internal string tables, and returns the string to the caller. %END REM Dim iLen As Integer Dim sBuffer As String ' --- initialize a buffer of adequate length to accept the error string sBuffer = String$( 256, 0 ) ' --- get the API error message from the internal Notes/Domino string tables iLen = W32OSLoadString( NULLHANDLE, iStatus, sBuffer, Len( sBuffer ) - 1 ) If iLen > 0 Then ' --- remove any trailing characters from the string and return it to the caller GetCAPIErrorMsg = Left$( sBuffer, Instr( 1, sBuffer, Chr$(0) ) - 1 ) Else ' --- couldn't locate the error message in the string tables GetCAPIErrorMsg = "Unknown error" End If End Function Function GetNoteClass( iNoteClass As Integer ) As String %REM GetNoteClass - This function takes a note type and returns a text string representing the note class type to the caller. %END REM Dim sNoteType As String Select Case iNoteClass Case NOTE_CLASS_DOCUMENT sNoteType = "Document" Case NOTE_CLASS_INFO sNoteType = "Help-about" Case NOTE_CLASS_FORM sNoteType = "Form" Case NOTE_CLASS_VIEW sNoteType = "View" Case NOTE_CLASS_ICON sNoteType = "Icon" Case NOTE_CLASS_DESIGN sNoteType = "Design collection" Case NOTE_CLASS_ACL sNoteType = "ACL" Case NOTE_CLASS_HELP_INDEX sNoteType = "Help index" Case NOTE_CLASS_HELP sNoteType = "Help-using" Case NOTE_CLASS_FILTER sNoteType = "Filter" Case NOTE_CLASS_FIELD sNoteType = "Field" Case NOTE_CLASS_REPLFORMULA sNoteType = "Replication formula" Case NOTE_CLASS_PRIVATE sNoteType = "Private design" Case Else sNoteType = "Unknown" End Select GetNoteClass = sNoteType End Function | ||||||||||||||||||||||
Спрятать/Показать кнопку "Пуск" в Windows Declare Function ShowWindow Lib "user32" (Byval hwnd As Long, Byval nCmdShow As Long) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" (Byval lpClassName As String, Byval lpWindowName As String) As Long Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (Byval hWnd1 As Long, Byval hWnd2 As Long, Byval lpsz1 As String, Byval lpsz2 As String) As Long Sub Command1_Click() 'спрятать кнопку "Пуск" OurParent& = FindWindow("Shell_TrayWnd", "") OurHandle& = FindWindowEx(OurParent&, 0, "Button", vbNullString) ShowWindow OurHandle&, 0 End Sub Sub Command2_Click() 'показать кнопку "Пуск" OurParent& = FindWindow("Shell_TrayWnd", "") OurHandle& = FindWindowEx(OurParent&, 0, "Button", vbNullString) ShowWindow OurHandle&, 5 End Sub | ||||||||||||||||||||||
Еще один диалог выбора файлов Declare Function NEMGetFileWin32 Lib "nnotesws" Alias "NEMGetFile" ( wUnk As Integer, Byval szFileName As Lmbcs String, Byval szFilter As Lmbcs String, Byval szTitle As Lmbcs String ) As Integer Sub Click(Source As Button) | ||||||||||||||||||||||
Програмно выдавать команду на консоль сервера Declare Sub OSMemFree Lib "nnotes.dll" (Byval hBuffer As Long) | ||||||||||||||||||||||
Копировать роли из ACL указанной в диалоге базы, в текущую базу. Dim session As New NotesSession | ||||||||||||||||||||||
Выгрузка ACL в текстовый файл. Dim session As New NotesSession | ||||||||||||||||||||||
Копировать всю ACL из текущей базы в указанную в диалоге.
Sub Initialize | ||||||||||||||||||||||
Смерть ошибкам сохранений при одновременном редактировании документа. Данный скрипт запрещает пользователю сохранить документ, если другой пользователь одновременно с первым редактировал документ и сохранил его. В принципе если доработать скрипт, то можно не запрещать сохранение, а объединять изменения двух одновременных редакций, без ошибок сохранений.
(Declaration) | ||||||||||||||||||||||
Диалог выбора папок/файлов. Еще один стандартный диалог выбора папок, файлов.
(Declaration) | ||||||||||||||||||||||
Переключение раскладки клавиатуры. Скрипт можно вставить как в кнопку, так и в событие формы или базы.
(Declaration) | ||||||||||||||||||||||