public CheckoutInfo CheckoutInfo(ObjectIdentity objIdentity) { ObjectIdentitySet objIdSet = new ObjectIdentitySet(); objIdSet.Identities.Add(objIdentity); List <CheckoutInfo> objList; OperationOptions operationOptions = null; versionControlService.Checkout(objIdSet, operationOptions); objList = versionControlService.GetCheckoutInfo(objIdSet); CheckoutInfo checkoutInfo = objList[0]; if (checkoutInfo.IsCheckedOut) { Console.WriteLine("Object " + checkoutInfo.Identity + " is checked out."); Console.WriteLine("Lock owner is " + checkoutInfo.UserName); } else { Console.WriteLine("Object " + checkoutInfo.Identity + " is not checked out."); } versionControlService.CancelCheckout(objIdSet); return(checkoutInfo); }
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'"); }
/// <summary> /// Checkout di un documento /// </summary> /// <param name="checkOutStatus">Metadati relativi allo stato del documento in checkout</param> /// <param name="user"></param> /// <param name="library"></param> /// <returns></returns> public bool CheckOut(string idDocument, string documentNumber, string documentLocation, string machineName, out CheckOutStatus checkOutStatus) { checkOutStatus = null; // Determina se il documento da bloccare è di tipo stampa registro bool isStampaRegistro = (DocsPaQueryHelper.isStampaRegistro(documentNumber)); bool retValue = this.SaveCheckOutDocumentProperties(string.Empty, documentNumber, documentLocation, machineName); try { if (retValue) { ObjectIdentity identity = null; // Reperimento identity del documento da bloccare if (isStampaRegistro) { identity = Dfs4DocsPa.getDocumentoStampaRegistroIdentityByDocNumber(documentNumber); } else { identity = Dfs4DocsPa.getDocumentoIdentityByDocNumber(documentNumber); } ObjectIdentitySet identitySet = new ObjectIdentitySet(); identitySet.Identities.Add(identity); OperationOptions opts = null; if (DocsPaQueryHelper.getCountAllegati(idDocument) > 0) { // Se il documento contiene allegati, è sicuramente un virtual document CheckoutProfile checkOutProfile = new CheckoutProfile(); // Ulteriore verifica se il documento è un allegato o un documento principale checkOutProfile.CheckoutOnlyVDMRoot = !DocsPaQueryHelper.isAllegatoProfilato(documentNumber); opts = new OperationOptions(); opts.CheckoutProfile = checkOutProfile; } IVersionControlService service = this.GetServiceInstance <IVersionControlService>(false); DataPackage dataPackage = service.Checkout(identitySet, opts); // Reperimento ObjectId della versione in checkout ObjectId objectId = (ObjectId)dataPackage.DataObjects[0].Identity.Value; checkOutStatus = this.GetCheckOutStatus(objectId.Id, idDocument, documentNumber); //if (DocsPaQueryHelper.getCountAllegati(idDocument) > 0) //{ // // Workaround per gli allegati // this.UndoCheckOutAllegati(documentNumber); //} retValue = true; logger.Debug(string.Format("Documentum.CheckOut: effettuato il checkout del documento con id {0} e docnumber {1}", idDocument, documentNumber)); } } catch (Exception ex) { retValue = false; logger.Debug("Errore in Documentum.CheckOut: " + ex.ToString()); } return(retValue); }