Example #1
0
        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);
        }
Example #2
0
        /*private void CreateNewVersion(string dst, int docNumber, string userID) {
            var docObject = new PCDDocObjectClass();
            docObject.SetDST(dst);
            docObject.SetObjectType("ENG_DRAW_P");//set profile form name
            docObject.SetProperty("%TARGET_LIBRARY", dApp.CurrentLibrary.Name);//database
            docObject.SetProperty("%OBJECT_IDENTIFIER", docNumber);
            docObject.SetProperty("%VERSION_DIRECTIVE", "%PCD_NEW_VERSION");
            docObject.SetProperty("%VERSION_TYPIST", userID);
            int result = docObject.Update();

            if(result != S_OK || docObject.ErrNumber != 0)
                throw new DMApiException(string.Format("PCDDocObjectClass.Update failed with error {0}: {1}", docObject.ErrNumber, docObject.ErrDescription));
            //versionID = docObject.GetReturnProperty("%VERSION_ID").ToString();
        }*/
        public PCDPutStream GetPcdPutStream(DocumentInfo doc)
        {
            // TODO Check if checked-out / locked
            var pcdPutDoc = new PCDPutDocClass();
            pcdPutDoc.SetDST(Dst);//log into DM - set security token
            pcdPutDoc.AddSearchCriteria(PropertyTargetLibrary, Library);
            pcdPutDoc.AddSearchCriteria("%DOCUMENT_NUMBER", doc.DocNumber);
            pcdPutDoc.AddSearchCriteria(PropertyVersionID, doc.VersionID);
            int result = pcdPutDoc.Execute();
            if(result != S_OK || pcdPutDoc.ErrNumber != 0)
                throw new DMApiException("PCDPutDocClass.Execute has failed.", pcdPutDoc.ErrNumber, pcdPutDoc.ErrDescription);

            // TODO check result count
            pcdPutDoc.NextRow();
            return (PCDPutStream)pcdPutDoc.GetPropertyValue("%CONTENT");
        }
Example #3
0
        public void UnlockDocument(DocumentInfo docInfo)
        {
            var doc = new PCDDocObjectClass();
            doc.SetDST(Dst);
            doc.SetObjectType(ObjectFormDefaultProfile);
            doc.SetProperty(PropertyTargetLibrary, Library);
            doc.SetProperty(PropertyObjectIdentifier, docInfo.DocNumber);
            if(docInfo.VersionID > 0)
                doc.SetProperty(PropertyVersionID, docInfo.VersionID);
            doc.SetProperty("%STATUS", "%UNLOCK");

            int result = doc.Update();
            if(result != S_OK || doc.ErrNumber != 0)
                if(doc.ErrNumber == DMApiEmptyDocumentFileException.EmptyFileDMErrorCode)
                    throw new DMApiEmptyDocumentFileException(string.Format("An attempt to check-in an empty document (document# {0})", docInfo.DocNumber), doc.ErrNumber, doc.ErrDescription);
                else
                    throw new DMApiException(string.Format("Cannot unlock document# {0}", docInfo.DocNumber), doc.ErrNumber, doc.ErrDescription);
        }
Example #4
0
        public void TestCreateFolder_LinkToFolder_DeleteFolder()
        {
            DMLogin.ServerName = DMTestEnvironment.Server;
            DMLogin.Password = TestHelperSecure.MyPassword;
            string newDocName = Guid.NewGuid().ToString();
            string dst = DMLogin.Dst;

            ProfileInfo profile = new ProfileInfo() { FormName = "STANDARD_P" };
            profile.Properties = new Dictionary<string, string>() {
                    { "DOCNAME", newDocName },
                    { "APP_ID", "FOLDER" },
                    { "AUTHOR_ID", "JDOE" },
                    { "TYPIST_ID", "NKHORIN" }
                };

            DMDocument doc = new DMDocument() { Dst = dst, Library = DMLogin.Library };

            // create
            var docInfo = doc.CreateProfile(profile);
            Assert.IsNotNull(docInfo);
            Assert.IsTrue(docInfo.DocNumber > 0);
            Assert.IsTrue(docInfo.VersionID > 0);

            try {
                // no need to unlock a folder

                // link to an existing folder (we looked up its DOCNUMBER and VERSIONID)
                var parent = new DocumentInfo { DocNumber = 12070617, VersionID = 12681993 };
                doc.AddLink(docInfo.DocNumber, parent);
            }
            finally {
                // clear links and delete
                doc.DeleteProfile(docInfo.DocNumber, true);
            }
        }