0

有点远射,但我没有任何运气找到任何地方记录的答案。

我正在编写一个自定义工具,使用 eDOCS DM API 将文件批量上传到 eDOCS。该工具几乎可以按预期工作,我创建了一个文件和元数据属性的任务列表,它创建了所需的 eDOCS 配置文件并保存了文件。

将文件保存到 eDOCS 本质上是一个两步过程:

第 1 步 - 创建文档配置文件表单 这是通过创建具有键/值对的 DM API 对象来设置表单上的字段来完成的。其中一个字段将文档链接到具有默认扩展名的特定应用程序(例如 MS Word、Excel 等)。创建配置文件后,会在 eDOCS 文件存储库中生成一个空文件,该文件具有随机文件名和链接应用程序的默认扩展名。

第 2 步 - 将文档保存到存储库 这很简单,基本上将源文件读入字节数组并使用 eDOCS DM API 对象将流写入 eDOCS 文件存储库中保存的文件(在第 1 步中创建)。

我正在努力的是在创建表单时更改在 eDOCS 文件存储库中生成的文件的扩展名。我无法在官方文档中找到任何指针或在线任何答案(尽管几年前我发现有人在 Spiceworks 上问过这个问题(https://community.spiceworks.com/topic/196865- open-text-edocs-hummingbird-support-group?page=2#entry-5226944 ))。

因此,一个实际示例使用此工具将 rtf 文件保存到 eDOCS 并与 Microsoft Word 相关联,因为 Microsoft Word 的默认扩展名设置为 docx,该文件使用扩展名 docx 保存,并且当用户检索时 Word 无法解释该文件并抛出错误消息。

使用标准 eDOCS DM 扩展程序单独保存文件时,有一个“另存为”字段可用,可让您覆盖默认文件扩展名。

目前我能想到的解决此问题的唯一方法是在 eDOCS 数据库应用程序表中为我们遇到的每个文件扩展名创建一个条目,但是我希望有一种方法可以使用提供的 API 解决此问题。

任何建议将不胜感激,谢谢。

附加信息:所以我们在 APP_FILE_EXTNS 表中为每个应用程序定义了多个扩展,例如,我在下面包含了一些与 Microsoft Word 相关的行:

APPS_LINK   LANGUAGE    EXTENSION   FILE_FORMAT DESCRIPTION         NEW_DOC_ONLY    ORDER_NO    DISABLED
1435        EN      docx        NULL        Word Document (*.docx)      N       1       N
1435        EN      DOT     NULL        Word 97-2003 Template (*.dot)   N       13      N
1435        EN      doc     NULL        Word 97-2003 Document (*.doc)   N       2       N
1435        EN      rtf     6       Rich Text Format (*.rtf)    N       8       N

以下是创建配置文件的示例 API 调用(使用 Powershell):

$doc = New-Object -ComObject PCDClient.PCDDocObject.1
$doc.SetDST($global:dmDST)
$doc.SetObjectType($global:dmForm)
$doc.SetProperty("PD_FILEPT_NO", $edocsFilePart)
$doc.SetProperty("DOCNAME", $docname)
$doc.SetProperty("APP_ID", $appid)
$doc.SetProperty("AUTHOR_ID", $author
$doc.SetProperty("TYPIST_ID", $typist
$doc.SetProperty("TYPE_ID", "DEFAULT")
$doc.SetProperty("%TARGET_LIBRARY", $global:dmLibrary)
$doc.Create()

# use PCDClient.PCDPutDoc and PCDClient.PCDPutStream to save the file to the edocs file repo
# unlock the document

所以在上面的例子中,$appid 将与APPS 表中的APPLICATION 列相关(例如MS WORD、FOLDER、PDF 等)。当 $doc.Create() 被调用时,会发生以下情况:

  • 创建文档配置文件
  • edocs 文件 repo 上的空文件是通过 $doc.SetProperty("APP_ID", $appid) 创建的,扩展名设置为应用程序集的默认扩展名
  • COMPONENTS 表已更新以将空文件链接到文档配置文件

您是否知道是否有办法使用 DM API 将文件扩展名设置为与文档关联的应用程序的非默认扩展名之一?

我用几个不同的键尝试了 PCDClient.PCDDocObject.SetProperty() 都失败了:

  • 扩大
  • %扩大
  • 分机
  • %EXT
  • 小路
  • %小路
  • 文件扩展名
  • %文件扩展名
4

2 回答 2

0

我不确定这是否会有所帮助,但我在设置扩展名的下方找到了此代码。

            Function ahtCommonFileOpenSave( _
            Optional ByRef flags As Variant, _
            Optional ByVal InitialDir As Variant, _
            Optional ByVal Filter As Variant, _
            Optional ByVal FilterIndex As Variant, _
            Optional ByVal DefaultExt As Variant, _
            Optional ByVal FileName As Variant, _
            Optional ByVal DialogTitle As Variant, _
            Optional ByVal hwnd As Variant, _
            Optional ByVal OpenFile As Variant) As Variant

                ' This is the entry point you'll use to call the common
                ' file open/save dialog. The parameters are listed
                ' below, and all are optional.
                '
                ' In:
                ' Flags: one or more of the ahtOFN_* constants, OR'd together.
                ' InitialDir: the directory in which to first look
                ' Filter: a set of file filters, set up by calling
                ' AddFilterItem. See examples.
                ' FilterIndex: 1-based integer indicating which filter
                ' set to use, by default (1 if unspecified)
                ' DefaultExt: Extension to use if the user doesn't enter one.
                ' Only useful on file saves.
                ' FileName: Default value for the file name text box.
                ' DialogTitle: Title for the dialog.
                ' hWnd: parent window handle
                ' OpenFile: Boolean(True=Open File/False=Save As)
                ' Out:
                ' Return Value: Either Null or the selected filename

                Dim OFN As tagOPENFILENAME
                Dim strFilename As String
                Dim strFileTitle As String
                Dim fResult As Boolean

                ' Give the dialog a caption title.
                If IsMissing(InitialDir) Then InitialDir = CurDir
                If IsMissing(Filter) Then Filter = ""
                If IsMissing(FilterIndex) Then FilterIndex = 1
                If IsMissing(flags) Then flags = 0&
                If IsMissing(DefaultExt) Then DefaultExt = ""
                If IsMissing(FileName) Then FileName = ""
                If IsMissing(DialogTitle) Then DialogTitle = ""
                If IsMissing(OpenFile) Then OpenFile = True

                ' Allocate string space for the returned strings.
                strFilename = Left(FileName & String(256, 0), 256)
                strFileTitle = String(256, 0)

                ' Set up the data structure before you call the function
                With OFN
                    .lStructSize = Len(OFN)
                    .hwndOwner = hwnd
                    .strFilter = Filter
                    .nFilterIndex = FilterIndex
                    .strFile = strFilename
                    .nMaxFile = Len(strFilename)
                    .strFileTitle = strFileTitle
                    .nMaxFileTitle = Len(strFileTitle)
                    .strTitle = DialogTitle
                    .flags = flags
                    .strDefExt = DefaultExt
                    .strInitialDir = InitialDir
                    ' Didn't think most people would want to deal with
                    ' these options.
                    .hInstance = 0
                    .strCustomFilter = ""
                    .nMaxCustFilter = 0
                    .lpfnHook = 0
                    'New for NT 4.0
                    .strCustomFilter = String(255, 0)
                    .nMaxCustFilter = 255
                End With

                ' This will pass the desired data structure to the
                ' Windows API, which will in turn it uses to display
                ' the Open/Save As Dialog.

                If OpenFile Then

                    fResult = aht_apiGetOpenFileName(OFN)

                Else

                    fResult = aht_apiGetSaveFileName(OFN)

                End If

                ' The function call filled in the strFileTitle member
                ' of the structure. You'll have to write special code
                ' to retrieve that if you're interested.

                If fResult Then
                    ' You might care to check the Flags member of the
                    ' structure to get information about the chosen file.
                    ' In this example, if you bothered to pass in a
                    ' value for Flags, we'll fill it in with the outgoing
                    ' Flags value.
                    If Not IsMissing(flags) Then
                        flags = OFN.flags
                    End If

                    ahtCommonFileOpenSave = TrimNull(OFN.strFile)

                Else

                    ahtCommonFileOpenSave = vbNullString

                End If

            End Function
于 2018-07-18T02:22:28.080 回答
-1

简短的回答是您无法更改文件扩展名。

当您上传文件时,文件扩展名用于选择配置文件上的应用程序。在 DM531/DM10 中,每个应用程序都可以有一个默认扩展名(DOCX 或 DOC for word),然后您必须登录 Cyber​​Docs 才能添加其他文件扩展名。扩展被添加到表 APP_FILE_EXTNS 请注意,您不能添加行,因为 system_id 是由 eDOCS API 生成的。system_id 是使用序列表 SEQ_xxx 创建的。应用程序位于 APPS 表中。

因此,您必须让您的 eDOCS DM 管理员使用 Library Maintenance 或 DM Management Studio 工具(DM10 或 DM 16.x)添加所需的文件扩展名。

于 2017-09-22T17:42:14.767 回答