Exemple #1
0
        /// <summary>
        /// Returns an annotation document collaborator's metadata
        /// </summary>
        /// <param name="fileId">The document path to get collaborator for</param>
        /// <param name="userName">The collaborator name</param>
        /// <returns>An instance of an object containing the collaborator's details</returns>
        public ReviewerInfo GetDocumentCollaborator(string fileId, string userName)
        {
            var document = _documentSvc.GetDocument(fileId);

            return(_mapper.Map <ReviewerInfo>(_annotator.GetDocumentCollaborator(document.Id, userName)));
        }
        /// <summary>
        /// Gets document collaborator
        /// </summary>
        public static void GetCollaborator()
        {
            try
            {
                //ExStart:GetCollaborator
                // 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
                };

                // Get document collaborators.
                var getCollaboratorsResult = annotator.GetCollaborators(documentId);

                // Get document collaborator by email
                var getCollaboratorsResultByEmail = annotator.GetDocumentCollaborator(documentId, reviewerInfo.PrimaryEmail);

                // Get collaborator metadata
                var          user = userRepository.GetUserByEmail(reviewerInfo.PrimaryEmail);
                ReviewerInfo collaboratorMetadataResult = annotator.GetCollaboratorMetadata(user.Guid);
                //ExEnd:GetCollaborator
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }