• Курсы Академии Кодебай, стартующие в мае - июне, от команды The Codeby

    1. Цифровая криминалистика и реагирование на инциденты
    2. ОС Linux (DFIR) Старт: 16 мая
    3. Анализ фишинговых атак Старт: 16 мая Устройства для тестирования на проникновение Старт: 16 мая

    Скидки до 10%

    Полный список ближайших курсов ...

Как программно создать File Resource в дизайне базы данных?

  • Автор темы fedotxxl
  • Дата начала
F

fedotxxl

Всем привет
Есть элемент базы данных - File Resource. Туда можно добавлять файлы произвольного содержания. Как это можно сделать программно?
 
F

fedotxxl

Пока решил проблему сл. образом:
Для создания использую dxl:
Код:
Function createEmptyMercurialProperties(db As NotesDatabase) As FileResource

Dim ns As New NotesSession
Dim nd As NotesDocument

Dim importer As NotesDXLImporter
Dim dxl As String

Set db = ns.CurrentDatabase
Set nd = db.CreateDocument

dxl = {<?xml version='1.0'?>
<fileresource name='MercurialProperties.xml' xmlns='http://www.lotus.com/dxl'
version='8.0' maintenanceversion='2.0' replicaid='} + db.ReplicaID + {' publicaccess='false'
designerversion='8'>
<noteinfo noteid='8ca' unid='} + nd.UniversalID + {' sequence='3'>
<created><datetime dst='true'>20100916T121213,33+04</datetime></created>
<modified><datetime dst='true'>20100916T121253,86+04</datetime></modified>
<revised><datetime dst='true'>20100916T121253,85+04</datetime></revised>
<lastaccessed><datetime dst='true'>20100916T121253,85+04</datetime></lastaccessed>
<addedtofile><datetime dst='true'>20100916T121213,35+04</datetime></addedtofile></noteinfo>
<updatedby><name>} + ns.UserName + {</name></updatedby><filedata
>
SABlAGwAbABvACAAVwBvAHIAbABkAA==
</filedata></fileresource>

}

Set importer = ns.CreateDXLImporter
importer.DesignImportOption = DXLIMPORTOPTION_CREATE
Call importer.Import(dxl, db)

Set createEmptyMercurialProperties = FindFileResource(db, "file", "MercurialProperties.xml")
End Function
Для изменения содержимого - класс FileResource из LotusScript Gold Collection
Код:
Set db = session.CurrentDatabase
Set fr = findMercurialProperties(db)

Dim stream As NotesStream
Set stream = session.Createstream

Call stream.WriteText("Here is another content")
Call fr.UpdateFileData(stream)
Call fr.save
Call stream.close
Код:
Function findMercurialProperties(db As NotesDatabase) As FileResource
Dim fr As FileResource

Set fr = FindFileResource(db, "file", "MercurialProperties.xml")
If fr Is Nothing Then Set fr = createEmptyMercurialProperties(db)

Set findMercurialProperties = fr
End Function
 
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!