public void AddLink(int docNumber, DocumentInfo folder) { if (folder == null) { throw new ArgumentNullException("folder"); } var doc = new PCDDocObjectClass(); doc.SetDST(DocumentSecurityToken); doc.SetObjectType(ObjectContentItem); doc.SetProperty(PropertyTargetLibrary, LibraryName); doc.SetProperty(PropertyParentFolder, folder.DocNumber.ToString()); doc.SetProperty(PropertyParentFolderVer, folder.VersionID.ToString()); doc.SetProperty(PropertyDocNumber, docNumber.ToString()); doc.SetProperty(PropertyParentFolderLib, LibraryName); // we save to one library only //doc.SetProperty("DISPLAYNAME", docName); doc.SetProperty("VERSION_TYPE", "R"); int result = doc.Create(); if (result != S_OK || doc.ErrNumber != 0) { throw new DMApiException(string.Format("Cannot link document# {0} to folder {1}", docNumber, folder.DocNumber), doc.ErrNumber, doc.ErrDescription); } }
/// <summary> /// Creates a document profile /// </summary> /// <param name="profileInfo"></param> /// <returns>Returns the document number and the version of newly created profile.</returns> public DocumentInfo CreateProfile(ProfileInfo profileInfo) { if (profileInfo == null) { throw new ArgumentNullException("profileInfo"); } if (profileInfo.Properties == null) { throw new ArgumentNullException("profileInfo.Properties"); } var doc = new PCDDocObjectClass(); doc.SetDST(DocumentSecurityToken); doc.SetObjectType(profileInfo.FormName); doc.SetProperty(PropertyTargetLibrary, LibraryName); foreach (var pair in profileInfo.Properties) { doc.SetProperty(pair.Key, pair.Value); } if (profileInfo.Trustees != null) { foreach (TrusteeInfo t in profileInfo.Trustees) { doc.SetTrustee(t.Trustee, (int)t.TrusteeType, (int)t.AccessRights); } } int result = doc.Create(); if (result != S_OK || doc.ErrNumber != 0) { throw new DMApiException("Cannot create profile.", doc.ErrNumber, doc.ErrDescription); } object docNum = doc.GetReturnProperty(PropertyObjectIdentifier); object verID = doc.GetReturnProperty(PropertyVersionID); return(new DocumentInfo { DocNumber = Convert.ToInt32(docNum), VersionID = Convert.ToInt32(verID) }); }
public void AddLink(int docNumber, DocumentInfo folder) { if(folder == null) throw new ArgumentNullException("folder"); var doc = new PCDDocObjectClass(); doc.SetDST(Dst); doc.SetObjectType(ObjectContentItem); doc.SetProperty(PropertyTargetLibrary, Library); doc.SetProperty(PropertyParentFolder, folder.DocNumber.ToString()); doc.SetProperty(PropertyParentFolderVer, folder.VersionID.ToString()); doc.SetProperty(PropertyDocNumber, docNumber.ToString()); doc.SetProperty(PropertyParentFolderLib, Library); // we save to one library only //doc.SetProperty("DISPLAYNAME", docName); doc.SetProperty("VERSION_TYPE", "R"); int result = doc.Create(); if(result != S_OK || doc.ErrNumber != 0) throw new DMApiException(string.Format("Cannot link document# {0} to folder {1}", docNumber, folder.DocNumber), doc.ErrNumber, doc.ErrDescription); }
/// <summary> /// Creates a document profile /// </summary> /// <param name="profileInfo"></param> /// <returns>Returns the document number and the version of newly created profile.</returns> public DocumentInfo CreateProfile(ProfileInfo profileInfo) { if(profileInfo == null) throw new ArgumentNullException("profileInfo"); if(profileInfo.Properties == null) throw new ArgumentNullException("profileInfo.Properties"); var doc = new PCDDocObjectClass(); doc.SetDST(Dst); doc.SetObjectType(profileInfo.FormName); doc.SetProperty(PropertyTargetLibrary, Library); foreach (var pair in profileInfo.Properties) doc.SetProperty(pair.Key, pair.Value); if(profileInfo.Trustees != null) foreach(TrusteeInfo t in profileInfo.Trustees) doc.SetTrustee(t.Trustee, (int)t.TrusteeType, (int)t.AccessRights); int result = doc.Create(); if(result != S_OK || doc.ErrNumber != 0) throw new DMApiException("Cannot create profile.", doc.ErrNumber, doc.ErrDescription); object docNum = doc.GetReturnProperty(PropertyObjectIdentifier); object verID = doc.GetReturnProperty(PropertyVersionID); return new DocumentInfo { DocNumber = Convert.ToInt32(docNum), VersionID = Convert.ToInt32(verID) }; }