以编程方式将文档添加到 Hummingbird/OpenText eDocs 数据库

发布于 2024-11-25 10:31:35 字数 1587 浏览 1 评论 0原文

我正在使用(以前称为 Hummingbird Enterprise)OpenText eDocs 文档管理系统。

http:// /www.opentext.com/2/global/products/products-opentext-edocs-products/products-opentext-edocs-document-management.htm

我们仍在使用 Hummingbird 5.1.0.5。

我一直在查看该软件的 API 文档,但有些区域有点模糊。 到目前为止,我可以创建我的个人资料表单,填充一些值。

DOCSObjects.Application docApp = null;
DOCSObjects.IProfile profile = null;
Type fType = Type.GetTypeFromProgID("DOCSObjects.Application");
docApp = (DOCSObjects.Application)Activator.CreateInstance(fType);
try { profile = docApp.CurrentLibrary.CreateProfile("DEF_PROF"); }
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); }
if (profile != null)
{
    try
    {
        profile.Columns["DOCNAME"].Value = "New PDF Document";
        profile.Columns["APP_ID"].Value = "ACROBAT";
        profile.ShowProfile(1);
        // not sure how to set a document here
        profile.SetDocument(docApp.CurrentLibrary.Name, document);
        profile.Save(); // requires a short flag, but what?
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
    }
}
else
{
    MessageBox.Show("Profile is null");
}

我遇到的麻烦是如何使用配置文件保存文档。 我使用的是 C#,API 文档和智能感知只是要求文档的对象。 这是否意味着路径,或者我是否需要将 PDF 加载到某些特定的 DOCSObjects 类型中?

此外,API 文档在保存文档时引用常量,例如 OF_NORMAL。我假设这是 0,但是还有其他我应该知道的吗?文档中引用了许多未定义值的常量。 (所有示例均采用 C++/VB 语言)。

我知道有人使用这个软件的可能性不大,但我想尝试一下。 谢谢您并感谢任何帮助。

I am working with the the (formerly Hummingbird Enterprise) OpenText eDocs document management system.

http://www.opentext.com/2/global/products/products-opentext-edocs-products/products-opentext-edocs-document-management.htm

We are still using Hummingbird 5.1.0.5.

I have been reviewing the API docs for this software, but some areas are slightly vague.
So far, I can create my Profile form, populate some values.

DOCSObjects.Application docApp = null;
DOCSObjects.IProfile profile = null;
Type fType = Type.GetTypeFromProgID("DOCSObjects.Application");
docApp = (DOCSObjects.Application)Activator.CreateInstance(fType);
try { profile = docApp.CurrentLibrary.CreateProfile("DEF_PROF"); }
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); }
if (profile != null)
{
    try
    {
        profile.Columns["DOCNAME"].Value = "New PDF Document";
        profile.Columns["APP_ID"].Value = "ACROBAT";
        profile.ShowProfile(1);
        // not sure how to set a document here
        profile.SetDocument(docApp.CurrentLibrary.Name, document);
        profile.Save(); // requires a short flag, but what?
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
    }
}
else
{
    MessageBox.Show("Profile is null");
}

Where I am having trouble is how to save a document with the profile.
I am using C# and the API docs and intellisense simply ask for on object for the document.
Does that mean the path or do I need to load the PDF into some specific DOCSObjects type?

Also, the API docs references a Constant such as OF_NORMAL when saving the document. I assume this is 0, but are there others I should know about? There are many Constants referenced in the docs that have no values defined. (All examples are in C++/VB).

I know it's a long shot anyone is using this software, but thought I would give it a try.
Thank you and any assistance is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖上的星空 2024-12-02 10:31:35

我已经在 VB 中完成了它 - 使用我创建的 API 包装器。您应该使用 DM API 文件夹下的 PCDClient 而不是 DOCSObjects。

这里的代码可能不会立即为您工作,因为它是经过大量定制的,但是使用它,您可能会弄清楚。祝你好运!

Public Sub CreateProfile(ByRef Doc As Profile)

    Try
       'SET THE STATIC META DATA
        Doc.objDoc.SetProperty("TYPE_ID", "DOCS") ' DOCUMENT TYPE IS ALWAYS DOCS
        Doc.objDoc.SetProperty("TYPIST_ID", RDIMSAPI._UserID)
        Doc.objDoc.SetProperty("APP_ID", RDIMSData.GetApp(Doc.FileToImport)) ' FILE TO IMPORT

        'CREATE THE DOCUMENT
        Doc.objDoc.Create()
        If Doc.objDoc.ErrNumber <> 0 Then
            Throw New Exception(Doc.objDoc.ErrNumber & " - " & Doc.objDoc.ErrDescription)
        End If

        'RETRIEVE THE NEW DOCUMENT PROFILE
        Dim DocNumber As Integer = Doc.objDoc.GetReturnProperty("%OBJECT_IDENTIFIER")
        Dim VersionID As Integer = Doc.objDoc.GetReturnProperty("%VERSION_ID")

        'ADD THE DOCUMENT TO THE PROFILE
        Dim objPutDoc As New PCDClient.PCDPutDoc
        objPutDoc.SetDST(RDIMSAPI._sDST)
        objPutDoc.AddSearchCriteria("%TARGET_LIBRARY", RDIMSAPI._Library)
        objPutDoc.AddSearchCriteria("%DOCUMENT_NUMBER", DocNumber)
        objPutDoc.AddSearchCriteria("%VERSION_ID", VersionID)
        objPutDoc.Execute()
        If objPutDoc.ErrNumber <> 0 Then
            Throw New Exception(Doc.objDoc.ErrNumber & " - " & Doc.objDoc.ErrDescription)
        End If
        objPutDoc.NextRow()

        'UPLOAD THE DOCUMENT
        Dim objPutStream As PCDClient.PCDPutStream = objPutDoc.GetPropertyValue("%CONTENT")
        Dim fs As FileStream = System.IO.File.OpenRead(Doc.FileToImport)
        Dim fi As FileInfo = New System.IO.FileInfo(Doc.FileToImport)
        Dim br As BinaryReader = New BinaryReader(fs)
        Dim addDocBytes As Byte() = br.ReadBytes(CInt(fs.Length))
        br.Read(addDocBytes, 0, addDocBytes.Length)
        br.Close()
        Dim bytesWritten As Integer = 0
        objPutStream.Write(addDocBytes, addDocBytes.Length, bytesWritten)
        objPutStream.SetComplete()

        'UNLOCK THE DOCUMENT
        Dim objDoc As New PCDClient.PCDDocObject
        objDoc.SetDST(RDIMSAPI._sDST)
        objDoc.SetObjectType("0_RDIMSPROF_SYS")
        objDoc.SetProperty("%TARGET_LIBRARY", RDIMSAPI._Library)
        objDoc.SetProperty("%OBJECT_IDENTIFIER", DocNumber)
        objDoc.SetProperty("%VERSION_ID", VersionID)
        objDoc.SetProperty("%STATUS", "%UNLOCK")
        objDoc.Update()
        objDoc.Fetch()
        objDoc = Nothing
        If Doc.objDoc.ErrNumber <> 0 Then
            Throw New Exception(Doc.objDoc.ErrNumber & " - " & Doc.objDoc.ErrDescription)
        End If

        'RELEASE ALL OBJECTS AND RETURN DOCUMENT NUMBER
        objPutDoc = Nothing

    Catch ex As Exception
        'IF EXCEPTION, LOG ERROR AND DISPLAY MESSAGE
        Throw New Exception("(" & Me.GetType().FullName & "." & New StackTrace(0).GetFrame(0).GetMethod.Name & ") " & ex.Message)
        Exit Sub
    End Try

End Sub

I have done it in VB - using an API wrapper that I created. You should use the PCDClient under DM API folder instead of the DOCSObjects.

This code here probably won't work right away for you because it is heavily customized, but play around with it and you can probably figure it out. Good Luck!

Public Sub CreateProfile(ByRef Doc As Profile)

    Try
       'SET THE STATIC META DATA
        Doc.objDoc.SetProperty("TYPE_ID", "DOCS") ' DOCUMENT TYPE IS ALWAYS DOCS
        Doc.objDoc.SetProperty("TYPIST_ID", RDIMSAPI._UserID)
        Doc.objDoc.SetProperty("APP_ID", RDIMSData.GetApp(Doc.FileToImport)) ' FILE TO IMPORT

        'CREATE THE DOCUMENT
        Doc.objDoc.Create()
        If Doc.objDoc.ErrNumber <> 0 Then
            Throw New Exception(Doc.objDoc.ErrNumber & " - " & Doc.objDoc.ErrDescription)
        End If

        'RETRIEVE THE NEW DOCUMENT PROFILE
        Dim DocNumber As Integer = Doc.objDoc.GetReturnProperty("%OBJECT_IDENTIFIER")
        Dim VersionID As Integer = Doc.objDoc.GetReturnProperty("%VERSION_ID")

        'ADD THE DOCUMENT TO THE PROFILE
        Dim objPutDoc As New PCDClient.PCDPutDoc
        objPutDoc.SetDST(RDIMSAPI._sDST)
        objPutDoc.AddSearchCriteria("%TARGET_LIBRARY", RDIMSAPI._Library)
        objPutDoc.AddSearchCriteria("%DOCUMENT_NUMBER", DocNumber)
        objPutDoc.AddSearchCriteria("%VERSION_ID", VersionID)
        objPutDoc.Execute()
        If objPutDoc.ErrNumber <> 0 Then
            Throw New Exception(Doc.objDoc.ErrNumber & " - " & Doc.objDoc.ErrDescription)
        End If
        objPutDoc.NextRow()

        'UPLOAD THE DOCUMENT
        Dim objPutStream As PCDClient.PCDPutStream = objPutDoc.GetPropertyValue("%CONTENT")
        Dim fs As FileStream = System.IO.File.OpenRead(Doc.FileToImport)
        Dim fi As FileInfo = New System.IO.FileInfo(Doc.FileToImport)
        Dim br As BinaryReader = New BinaryReader(fs)
        Dim addDocBytes As Byte() = br.ReadBytes(CInt(fs.Length))
        br.Read(addDocBytes, 0, addDocBytes.Length)
        br.Close()
        Dim bytesWritten As Integer = 0
        objPutStream.Write(addDocBytes, addDocBytes.Length, bytesWritten)
        objPutStream.SetComplete()

        'UNLOCK THE DOCUMENT
        Dim objDoc As New PCDClient.PCDDocObject
        objDoc.SetDST(RDIMSAPI._sDST)
        objDoc.SetObjectType("0_RDIMSPROF_SYS")
        objDoc.SetProperty("%TARGET_LIBRARY", RDIMSAPI._Library)
        objDoc.SetProperty("%OBJECT_IDENTIFIER", DocNumber)
        objDoc.SetProperty("%VERSION_ID", VersionID)
        objDoc.SetProperty("%STATUS", "%UNLOCK")
        objDoc.Update()
        objDoc.Fetch()
        objDoc = Nothing
        If Doc.objDoc.ErrNumber <> 0 Then
            Throw New Exception(Doc.objDoc.ErrNumber & " - " & Doc.objDoc.ErrDescription)
        End If

        'RELEASE ALL OBJECTS AND RETURN DOCUMENT NUMBER
        objPutDoc = Nothing

    Catch ex As Exception
        'IF EXCEPTION, LOG ERROR AND DISPLAY MESSAGE
        Throw New Exception("(" & Me.GetType().FullName & "." & New StackTrace(0).GetFrame(0).GetMethod.Name & ") " & ex.Message)
        Exit Sub
    End Try

End Sub
维持三分热 2024-12-02 10:31:35

我不知道你是否还在努力。但这是我的 C# 代码。它是一个更大模块的一部分,因此它不会立即工作。 profile 参数例如为“DEF_PROF”。

这也使用 PCDClientLib。我的理解是,这些是服务器端库,您应该只在服务器上使用。并且您应该使用已经用于客户端代码的库。

// All variable prepended with an underscore are class fields etc...
// DMImportException is a custom exception, nothing special really

/// <summary>
/// Import a file into the library previously logged in to.
/// </summary>
/// <param name="profile">The name of the used profile.</param>
/// <param name="profileNameValues">A dictionary of strings containing the profile values wich should be saved for the document.</param>
/// <param name="FileName">The path and filename of the file to import.</param>
public virtual void ImportFile(string profile, Dictionary<string, string> profileNameValues, string FileName)
{
    if (!_isLoggedIn)
    {
        throw new DMImportException("Trying to import a file while not logged in into DM.");
    }

    int totalbyteswritten;
    byte[] bdata;

    bdata = file.readallbytes(filename);

    pcddocobject objdoc = new pcddocobject();
    objdoc.setproperty("%target_library", _library);
    objdoc.setdst(_dst);
    objdoc.setobjecttype(profile);

    foreach(var profilenamevaluepair in profilenamevalues)
    {
        objdoc.setproperty(profilenamevaluepair.key, profilenamevaluepair.value);
    }

    objdoc.create();

    if (objdoc.errnumber != 0)
    {
        throw new dmimportexception("error while creating a new objdoc. check the inner error.", objdoc.errnumber, objdoc.errdescription);
    }

    _docnumber = objDoc.GetReturnProperty("%OBJECT_IDENTIFIER").ToString();
    _versionID = objDoc.GetReturnProperty("%VERSION_ID").ToString();

    PCDPutDoc objPutDoc = new PCDPutDoc();

    objPutDoc.SetDST(_dst);
    objPutDoc.AddSearchCriteria("%TARGET_LIBRARY", _library);
    objPutDoc.AddSearchCriteria("%DOCUMENT_NUMBER", _docNumber);
    objPutDoc.AddSearchCriteria("%VERSION_ID", _versionID);
    objPutDoc.Execute();

    if (objPutDoc.ErrNumber != 0)
    {
        throw new DMImportException("RecentEdit Failure on Execute: Error while trying to get a handle to the newly created doc. Check the inner error.", objPutDoc.ErrNumber, objPutDoc.ErrDescription);
    }

    objPutDoc.NextRow();

    PCDPutStream objPutStream = (PCDPutStream)objPutDoc.GetPropertyValue("%CONTENT");

    objPutStream.Write((object)bdata, (int)bdata.Length, out TotalBytesWritten);

    objPutStream.SetComplete();

    objPutStream = null;
    objDoc = null;

    objDoc = new PCDDocObject();
    objDoc.SetDST(_dst);
    objDoc.SetObjectType(profile);
    objDoc.SetProperty("%TARGET_LIBRARY", _library);
    objDoc.SetProperty("%OBJECT_IDENTIFIER", _docNumber);
    objDoc.SetProperty("%VERSION_ID", _versionID);
    objDoc.SetProperty("%STATUS", "%UNLOCK");
    objDoc.Update();

    if (objDoc.ErrNumber != 0)
    {
        throw new DMImportException("Error while trying to unlock the just imported file. Check the inner error.", objDoc.ErrNumber, objDoc.ErrDescription);
    }

    objPutDoc = null;
    objDoc = null;
    return;
}

PS 我建议您更新到更高版本的 eDocs(我们将于本周末从 5.1.0.5 升级到 5.2.1 ;-D)

--- 编辑 ---

,我认为您需要

Application.CurrentLibrary.CreateProfile("PROF_DEF").CreateVersionFromFile( /* filePath is one of the params */);

如果您确实需要 使用 DM Ext 执行此操作。 API 代替 DM API

I don't know if you're still trying. But here's my C# code for this. It's part of a larger module, so it won't work immediately. The profile parameter would be for example "DEF_PROF".

This also uses the PCDClientLib. My understanding is that these are serverside libraries, wich you should use only on the server. And that you should use the lib you've already used for clientside code.

// All variable prepended with an underscore are class fields etc...
// DMImportException is a custom exception, nothing special really

/// <summary>
/// Import a file into the library previously logged in to.
/// </summary>
/// <param name="profile">The name of the used profile.</param>
/// <param name="profileNameValues">A dictionary of strings containing the profile values wich should be saved for the document.</param>
/// <param name="FileName">The path and filename of the file to import.</param>
public virtual void ImportFile(string profile, Dictionary<string, string> profileNameValues, string FileName)
{
    if (!_isLoggedIn)
    {
        throw new DMImportException("Trying to import a file while not logged in into DM.");
    }

    int totalbyteswritten;
    byte[] bdata;

    bdata = file.readallbytes(filename);

    pcddocobject objdoc = new pcddocobject();
    objdoc.setproperty("%target_library", _library);
    objdoc.setdst(_dst);
    objdoc.setobjecttype(profile);

    foreach(var profilenamevaluepair in profilenamevalues)
    {
        objdoc.setproperty(profilenamevaluepair.key, profilenamevaluepair.value);
    }

    objdoc.create();

    if (objdoc.errnumber != 0)
    {
        throw new dmimportexception("error while creating a new objdoc. check the inner error.", objdoc.errnumber, objdoc.errdescription);
    }

    _docnumber = objDoc.GetReturnProperty("%OBJECT_IDENTIFIER").ToString();
    _versionID = objDoc.GetReturnProperty("%VERSION_ID").ToString();

    PCDPutDoc objPutDoc = new PCDPutDoc();

    objPutDoc.SetDST(_dst);
    objPutDoc.AddSearchCriteria("%TARGET_LIBRARY", _library);
    objPutDoc.AddSearchCriteria("%DOCUMENT_NUMBER", _docNumber);
    objPutDoc.AddSearchCriteria("%VERSION_ID", _versionID);
    objPutDoc.Execute();

    if (objPutDoc.ErrNumber != 0)
    {
        throw new DMImportException("RecentEdit Failure on Execute: Error while trying to get a handle to the newly created doc. Check the inner error.", objPutDoc.ErrNumber, objPutDoc.ErrDescription);
    }

    objPutDoc.NextRow();

    PCDPutStream objPutStream = (PCDPutStream)objPutDoc.GetPropertyValue("%CONTENT");

    objPutStream.Write((object)bdata, (int)bdata.Length, out TotalBytesWritten);

    objPutStream.SetComplete();

    objPutStream = null;
    objDoc = null;

    objDoc = new PCDDocObject();
    objDoc.SetDST(_dst);
    objDoc.SetObjectType(profile);
    objDoc.SetProperty("%TARGET_LIBRARY", _library);
    objDoc.SetProperty("%OBJECT_IDENTIFIER", _docNumber);
    objDoc.SetProperty("%VERSION_ID", _versionID);
    objDoc.SetProperty("%STATUS", "%UNLOCK");
    objDoc.Update();

    if (objDoc.ErrNumber != 0)
    {
        throw new DMImportException("Error while trying to unlock the just imported file. Check the inner error.", objDoc.ErrNumber, objDoc.ErrDescription);
    }

    objPutDoc = null;
    objDoc = null;
    return;
}

P.S. I'd recommend you update to a later version of eDocs (we're upgrading from 5.1.0.5 to 5.2.1 end of this week ;-D)

--- EDIT ---

I think you need

Application.CurrentLibrary.CreateProfile("PROF_DEF").CreateVersionFromFile( /* filePath is one of the params */);

if you really need to do this with the DM Ext. API instead of the DM API

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文