zoukankan      html  css  js  c++  java
  • documentum DFS下载指定的文件

    通过DFS 下载指定的文件

    下载文件要用 objectService服务的 Get 方法.

    先上实例代码

     1 public static DataObject GetContent(ObjectIdentity objIdentity)
     2         {
     3             try
     4             {
     5                 ObjectIdentitySet objectIdSet = new ObjectIdentitySet();
     6                 List<ObjectIdentity> objIdList = objectIdSet.Identities;
     7                 objIdList.Add(objIdentity);
     8 
     9                 //OperationOptions operationOptions = null;
    10                 OperationOptions operationoptions = new OperationOptions();
    11 
    12                 PropertyProfile propertyprofile = new PropertyProfile();
    13                 propertyprofile.FilterMode = (PropertyFilterMode.ALL_NON_SYSTEM);
    14 
    15                 ContentTransferProfile contenttransferprofile = new ContentTransferProfile();
    16                 contenttransferprofile.TransferMode = (ContentTransferMode.MTOM);
    17 
    18                 ContentProfile contentprofile = new ContentProfile();
    19                 contentprofile.FormatFilter = (FormatFilter.ANY);
    20                 contentprofile.PageFilter = (PageFilter.ANY);
    21                 contentprofile.PageModifierFilter = (PageModifierFilter.ANY);
    22 
    23                 operationoptions.Profiles.AddRange(new Emc.Documentum.FS.DataModel.Core.Profiles.Profile[] {
    24             contenttransferprofile, propertyprofile, contentprofile});
    25                 DataPackage dataPackage = objectService.Get(objectIdSet, operationoptions);
    26                 if (dataPackage.DataObjects.Count > 0)
    27                 {
    28                     return dataPackage.DataObjects[0];
    29                 }
    30             }
    31             catch (Exception e)
    32             {
    33                 //Console.WriteLine("Failed with exception " + e.Message);
    34             }
    35             finally
    36             {
    37                 //sampleContentManager.DeleteTestCabinet();
    38             }
    39             return null;
    40         }
    ObjectIdentity  对象 DFS 的解释是:

    An ObjectIdentity instance contains a repository name and a unique identifier
     that can take various forms, specified by Emc.Documentum.FS.DataModel.Core.ObjectIdentityType
     enum constants. When constructing a DataObject to pass to the create operation,
     or in any case when the DataObject represents a repository object that does
    not yet exist, the ObjectIdentity need only be populated with a repository
     name. If the ObjectIdentity does contain a unique identifier, it must represent
     an existing repository object.

    ObjectIdentityType 包含

    UNDEFINED = 0,
    //
    // Summary:
    // Object ID represents some proprietary mechanism (public URI structure is
    // not required) for combining object and repository identification. For example
    // in Documentum, ObjectId would be a string based identifier with position
    // encoded repository ID. This repository ID can be uniquely mapped to a repositoryName.
    // Object ID would normally require persistent object schema helpers to identify
    // repository name.
    OBJECT_ID = 1,
    //
    // Summary:
    // A set of properties that together (logical AND) compose the object identity.
    // Note that PropertyBasedIdentity also contains repositoryName necessary to
    // globally identify the object.
    OBJECT_KEY = 2,
    //
    // Summary:
    // Object Path is used to identify the object. Path object contains a string
    // based path expression, repository name as well as optional path type.
    OBJECT_PATH = 3,
    //
    // Summary:
    // Qualification object is used, containing qualification expression as well
    // as repository name. For example, Qualification object can contain a portion
    // of a DQL query without "select attr_list" clause. Constraint: If Qualification
    // is used as object identity it must be resolvable to a unique object.
    QUALIFICATION = 4,
    //
    // Summary:
    // An object id made up of more than one attribute. Works like a composite key.
    COMPOSITE_OBJECT_ID = 5,
    //
    // Summary:
    // Any URI structure compliant identity of the object. It must include/encode
    // repository identification and thus represent a complete global object reference
    // with PUBLIC structure. Example: "documentum:/dm_notes/12345"
    STRING_URI = 6

    因此 通过object_id 并下载到本地文件夹中 代码为 


     public static string GetContentById(string objectId, string localDirName)
            {
                ObjectId op = new ObjectId(objectId);
                ObjectIdentity objIdentity = new ObjectIdentity(op, DFSConfig.Repository);
                return GetContent(objIdentity, localDirName);   
            }
    

      通过 文件路径下载文件的代码为 

            public static string GetContentByPath(string path,string localDir) {
                ObjectPath op = new ObjectPath(path);
                ObjectIdentity objIdentity = new ObjectIdentity(op, DFSConfig.Repository);
                return GetContent(objIdentity, localDir);            
            }
    

      

    调用方法分别为:
      DFSCore.GetContentById("09030d41800001c3", "d:\\download");

    //System 为文件柜的名称(cabinet)
    //test 为文件夹名称
    DFSCore.GetContentByPath("/System/test", "d:\\download");



  • 相关阅读:
    Win7下IE 8内存保护可能导致ActiveX无法安装的问题及其解决方法
    为Windows Server 2000开发和部署ASP.NET 3.5的应用程序
    MOSS 2010:如何为列表设计Infopath表单用于编辑和显示
    Windows Live is designed for you, but maybe not for your browser
    Meet the new WSS SharePoint Foundation 2010
    MOSS 2010: Visual Studio 2010开发体验(3)——调试代码
    MOSS 2010:Visual Studio 2010开发体验(10)——列表开发之内容类型
    MOSS 2010:谁动了我的“共享服务”
    MOSS 2010:通过SharePoint Designer定制列表项的条件格式
    如何访问嵌套母版页中的控件
  • 原文地址:https://www.cnblogs.com/handk/p/2700002.html
Copyright © 2011-2022 走看看