Exemple #1
0
        /// <summary>
        /// Removes the document collaborator
        /// </summary>
        /// <param name="fileId">The document path to remove the collaborator from</param>
        /// <param name="reviewerEmail">The email address of the collaborator</param>
        /// <returns>An instance of an object containing the operation result and collaborators details</returns>
        public SetCollaboratorsResult DeleteCollaborator(string fileId, string reviewerEmail)
        {
            var document = _documentSvc.GetDocument(fileId);
            var result   = _mapper.Map <SetCollaboratorsResult>(_annotator.DeleteCollaborator(document.Id, reviewerEmail));

            return(result);
        }
        /// <summary>
        /// Deletes document collaborator
        /// </summary>
        public static void DeleteCollaborator()
        {
            try
            {
                //ExStart:DeleteCollaborator
                // Create instance of annotator.
                AnnotationConfig cfg = CommonUtilities.GetConfiguration();

                //Create annotation handler
                AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);

                IUserDataHandler userRepository = annotator.GetUserDataHandler();

                IDocumentDataHandler documentRepository = annotator.GetDocumentDataHandler();
                if (!Directory.Exists(cfg.StoragePath))
                {
                    Directory.CreateDirectory(cfg.StoragePath);
                }

                // Create a user that will be an owner.
                // Get user from the storage
                var owner = userRepository.GetUserByEmail("*****@*****.**");

                // If user doesn’t exist in the storage then create it.
                if (owner == null)
                {
                    userRepository.Add(new User {
                        FirstName = "John", LastName = "Doe", Email = "*****@*****.**"
                    });
                    owner = userRepository.GetUserByEmail("*****@*****.**");
                }

                // Get document data object in the storage
                var document = documentRepository.GetDocument("Document.pdf");

                // If document already created or it hasn’t owner then delete document
                if (document != null && document.OwnerId != owner.Id)
                {
                    documentRepository.Remove(document);
                    document = null;
                }

                // Get document id if document already created or create new document
                long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf", DocumentType.Pdf, owner.Id);

                // Create reviewer.
                var reviewerInfo = new ReviewerInfo
                {
                    PrimaryEmail = "*****@*****.**", //user email, unique identifier
                    FirstName    = "Judy",
                    LastName     = "Doe",
                    AccessRights = AnnotationReviewerRights.All
                };

                // Delete collaborator
                var deleteCollaboratorResult = annotator.DeleteCollaborator(documentId, reviewerInfo.PrimaryEmail);
                //ExEnd:DeleteCollaborator
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }