示例#1
0
        /// <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)
            });
        }
示例#2
0
        /// <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) };
        }