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");