Exemple #1
0
        public void VersionSampleObjects()
        {
            Console.WriteLine("Creating versions of sample data for VersionControlService samples.");
            ServiceFactory         serviceFactory = ServiceFactory.Instance;
            IVersionControlService versionSvc
                = serviceFactory.GetRemoteService <IVersionControlService>(serviceDemo.DemoServiceContext);

            ObjectIdentitySet objIdSet = new ObjectIdentitySet();

            ObjectIdentity docObjId = new ObjectIdentity();

            docObjId.RepositoryName = serviceDemo.DefaultRepository;
            docObjId.Value          = new ObjectPath(gifImageObjPath);
            ObjectIdentity doc1ObjId = new ObjectIdentity();

            doc1ObjId.RepositoryName = serviceDemo.DefaultRepository;
            doc1ObjId.Value          = new ObjectPath(gifImage1ObjPath);
            objIdSet.AddIdentity(docObjId);
            objIdSet.AddIdentity(doc1ObjId);

            OperationOptions operationOptions = new OperationOptions();
            ContentProfile   contentProfile
                = new ContentProfile(FormatFilter.ANY,
                                     null,
                                     PageFilter.ANY, -1,
                                     PageModifierFilter.ANY,
                                     null);

            operationOptions.ContentProfile = contentProfile;

            DataPackage checkinPackage = versionSvc.Checkout(objIdSet, operationOptions);

            Console.WriteLine("Checked out sample objects.");

            for (int i = 0; i <= 1; i++)
            {
                DataObject checkinObj = checkinPackage.DataObjects[i];
                checkinObj.Contents = null;
                FileContent newContent = new FileContent();
                newContent.LocalPath     = gifImageFilePath;
                newContent.RenditionType = RenditionType.PRIMARY;
                newContent.Format        = "gif";
                checkinObj.Contents.Add(newContent);
            }

            bool          retainLock = false;
            List <String> labels     = new List <String>();

            labels.Add("test_version");
            versionSvc.Checkin(checkinPackage, VersionStrategy.NEXT_MINOR, retainLock, labels, operationOptions);
            Console.WriteLine("Checked in sample object with label 'test_version'");
        }
Exemple #2
0
        public DataPackage Checkin(ObjectIdentity objIdentity, String newContentPath)
        {
            ObjectIdentitySet objIdSet = new ObjectIdentitySet();

            objIdSet.Identities.Add(objIdentity);

            OperationOptions operationOptions = new OperationOptions();
            ContentProfile   contentProfile   = new ContentProfile(FormatFilter.ANY, null,
                                                                   PageFilter.ANY,
                                                                   -1,
                                                                   PageModifierFilter.ANY, null);

            operationOptions.ContentProfile = contentProfile;

            DataPackage checkinPackage = versionControlService.Checkout(objIdSet, operationOptions);

            DataObject checkinObj = checkinPackage.DataObjects[0];

            checkinObj.Contents = null;
            FileContent newContent = new FileContent();

            newContent.LocalPath     = newContentPath;
            newContent.RenditionType = RenditionType.PRIMARY;
            newContent.Format        = "gif";
            checkinObj.Contents.Add(newContent);

            bool          retainLock = false;
            List <String> labels     = new List <String>();

            labels.Add("test_version");
            DataPackage resultDp;

            try
            {
                resultDp = versionControlService.Checkin(checkinPackage,
                                                         VersionStrategy.NEXT_MINOR,
                                                         retainLock,
                                                         labels,
                                                         operationOptions);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                throw new Exception(e.Message);
            }
            return(resultDp);
        }
Exemple #3
0
        /// <summary>
        /// Checkin di un documento in stato checkout
        /// </summary>
        /// <param name="checkOutStatus"></param>
        /// <param name="library"></param>
        /// <returns></returns>
        public bool CheckIn(DocsPaVO.CheckInOut.CheckOutStatus checkOutStatus, byte[] content, string checkInComments)
        {
            bool retValue = false;

            try
            {
                // Creazione di un nuovo DataObject che rappresenta il documento da sbloccare
                DataObject dataObject = new DataObject();
                dataObject.Type = ObjectTypes.DOCUMENTO;

                // Reperimento identity del documento da sbloccare
                if (DocsPaQueryHelper.isStampaRegistro(checkOutStatus.DocumentNumber))
                {
                    dataObject.Identity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(checkOutStatus.DocumentNumber);
                }
                else
                {
                    dataObject.Identity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(checkOutStatus.DocumentNumber);
                }

                List <Property> propertyList = new List <Property>();

                // Impostazione numero versione
                propertyList.Add(new NumberProperty(TypeDocumento.NUMERO_VERSIONE, DocsPaQueryHelper.getDocumentNextVersionId(checkOutStatus.IDDocument)));

                // Rimozione valore proprietà p3_locked_filepath
                propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_LOCAL_FILE_PATH, string.Empty));

                // Rimozione valore proprietà p3_locked_file_machinename
                propertyList.Add(new StringProperty(TypeDocumento.CHECKOUT_MACHINE_NAME, string.Empty));

                dataObject.Properties = new PropertySet();
                dataObject.Properties.Properties.AddRange(propertyList);

                // Temporaneo, inserimento contentuto file
                OperationOptions opts = new OperationOptions();

                CheckinProfile checkInProfile = new CheckinProfile();
                checkInProfile.MakeCurrent         = true;
                checkInProfile.DeleteLocalFileHint = true;

                opts.Profiles.Add(checkInProfile);

                // Creazione di un nuovo oggetto BinaryContent
                BinaryContent binaryContent = new BinaryContent();
                binaryContent.Value = content;

                string ext = System.IO.Path.GetExtension(checkOutStatus.DocumentLocation);
                if (ext.StartsWith("."))
                {
                    ext = ext.Substring(1);
                }
                string fileFormat = DfsHelper.getDctmFileFormat(this.GetServiceInstance <IQueryService>(false), ext);

                binaryContent.Format = fileFormat;

                dataObject.Contents.Add(binaryContent);

                DataPackage dataPackage = new DataPackage(dataObject);
                dataPackage.RepositoryName = DctmConfigurations.GetRepositoryName();

                IVersionControlService service = this.GetServiceInstance <IVersionControlService>(false);

                VersionStrategy strategy = VersionStrategy.IMPLIED;
                if (!DocsPaQueryHelper.isDocumentAcquisito(checkOutStatus.IDDocument))
                {
                    strategy = VersionStrategy.SAME_VERSION;
                }

                dataPackage = service.Checkin(dataPackage, strategy, false, null, opts);

                retValue = (dataPackage.DataObjects.Count > 0);

                if (retValue)
                {
                    logger.Debug(string.Format("Documentum.CheckIn: effettuato il checkin del documento con id {0} e docnumber {1}", checkOutStatus.IDDocument, checkOutStatus.DocumentNumber));
                }
            }
            catch (Exception ex)
            {
                retValue = false;

                logger.Debug("Errore in Documentum.CheckIn: " + ex.ToString());
            }

            return(retValue);
        }