public void UnlockDocument(DocumentInfo docInfo) { var doc = new PCDDocObjectClass(); doc.SetDST(DocumentSecurityToken); doc.SetObjectType(ObjectFormDefaultProfile); doc.SetProperty(PropertyTargetLibrary, LibraryName); 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); } } }
/// <summary> /// </summary> public int Update() { int rtn; rtn = docObject.Update(); if (docObject.ErrNumber != 0) { logger.Debug("ritento update docObject"); System.Threading.Thread.Sleep(400); rtn = docObject.Update(); } return(rtn); // OLD: //return docObject.Update(); }
public void UpdateTrustees(int docNumber, TrusteeInfo[] trusteesToSet) { if(trusteesToSet == null) throw new ArgumentNullException("trusteesToSet"); if(trusteesToSet.Length == 0) throw new ArgumentException("trusteesToSet is empty"); var doc = new PCDDocObjectClass(); doc.SetDST(Dst); doc.SetObjectType(ObjectFormDefaultProfile); doc.SetProperty(PropertyTargetLibrary, Library); doc.SetProperty(PropertyObjectIdentifier, docNumber); int result = doc.FetchTrustees(); if(result != S_OK || doc.ErrNumber != 0) throw new DMApiException(string.Format("Cannot fetch trustees for document# {0}.", docNumber), doc.ErrNumber, doc.ErrDescription); // season greetings, DM API developers... var trustees = doc.GetTrustees(); if(doc.ErrNumber != 0) throw new DMApiException("GetTrustees failed.", doc.ErrNumber, doc.ErrDescription); int size = trustees.GetSize(); foreach(var t in trusteesToSet) { int idx = trustees.GetTrusteeIndex(t.Trustee, (int)t.TrusteeType); // funking DM API returns index equal GetSize() if trustee is not found if(idx == size) { if(t.AccessRights != AccessRights.NoAccess) trustees.AddTrustee(t.Trustee, (int)t.TrusteeType, (int)t.AccessRights); } else // update existing if(t.AccessRights == AccessRights.NoAccess) trustees.DeleteTrustee(idx); else trustees.SetTrusteeRights(idx, (int)t.AccessRights); } result = doc.SetTrustees(trustees); if(result != S_OK || doc.ErrNumber != 0) throw new DMApiException("SetTrustees failed.", doc.ErrNumber, doc.ErrDescription); result = doc.UpdateTrustees(); if(result != S_OK || doc.ErrNumber != 0) throw new DMApiException(string.Format("UpdateTrustees failed for document# {0}.", docNumber), doc.ErrNumber, doc.ErrDescription); result = doc.Update(); if(result != S_OK || doc.ErrNumber != 0) throw new DMApiException(string.Format("Cannot update document# {0}.", docNumber), doc.ErrNumber, doc.ErrDescription); }
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); }
public void UpdateTrustees(int docNumber, TrusteeInfo[] trusteesToSet) { if (trusteesToSet == null) { throw new ArgumentNullException("trusteesToSet"); } if (trusteesToSet.Length == 0) { throw new ArgumentException("trusteesToSet is empty"); } var doc = new PCDDocObjectClass(); doc.SetDST(DocumentSecurityToken); doc.SetObjectType(ObjectFormDefaultProfile); doc.SetProperty(PropertyTargetLibrary, LibraryName); doc.SetProperty(PropertyObjectIdentifier, docNumber); int result = doc.FetchTrustees(); if (result != S_OK || doc.ErrNumber != 0) { throw new DMApiException(string.Format("Cannot fetch trustees for document# {0}.", docNumber), doc.ErrNumber, doc.ErrDescription); } // season greetings, DM API developers... var trustees = doc.GetTrustees(); if (doc.ErrNumber != 0) { throw new DMApiException("GetTrustees failed.", doc.ErrNumber, doc.ErrDescription); } int size = trustees.GetSize(); foreach (var t in trusteesToSet) { int idx = trustees.GetTrusteeIndex(t.Trustee, (int)t.TrusteeType); // funking DM API returns index equal GetSize() if trustee is not found if (idx == size) { if (t.AccessRights != AccessRights.NoAccess) { trustees.AddTrustee(t.Trustee, (int)t.TrusteeType, (int)t.AccessRights); } } else // update existing if (t.AccessRights == AccessRights.NoAccess) { trustees.DeleteTrustee(idx); } else { trustees.SetTrusteeRights(idx, (int)t.AccessRights); } } result = doc.SetTrustees(trustees); if (result != S_OK || doc.ErrNumber != 0) { throw new DMApiException("SetTrustees failed.", doc.ErrNumber, doc.ErrDescription); } result = doc.UpdateTrustees(); if (result != S_OK || doc.ErrNumber != 0) { throw new DMApiException($"UpdateTrustees failed for document# {docNumber}.", doc.ErrNumber, doc.ErrDescription); } result = doc.Update(); if (result != S_OK || doc.ErrNumber != 0) { throw new DMApiException($"Cannot update document# {docNumber}.", doc.ErrNumber, doc.ErrDescription); } }