/// <summary>
        /// Adds reply to the annotation, edits reply, creates child reply
        /// </summary>
        public static void AddAnnotationReply()
        {
            try
            {
                //ExStart:AddAnnotationReply
                // Create instance of annotator.
                AnnotationConfig cfg = CommonUtilities.GetConfiguration();

                AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);

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

                // Create document data object in storage
                var  document   = documentRepository.GetDocument("Document.pdf");
                long documentId = document != null ? document.Id : annotator.CreateDocument("Document.pdf");

                // Create annotation object
                AnnotationInfo pointAnnotation = new AnnotationInfo
                {
                    AnnotationPosition = new Point(852.0, 81.0),
                    Box          = new Rectangle(212f, 81f, 142f, 0.0f),
                    Type         = AnnotationType.Point,
                    PageNumber   = 0,
                    CreatorName  = "Anonym",
                    DocumentGuid = documentId
                };

                // Add annotation to storage
                var createPointAnnotationResult = annotator.CreateAnnotation(pointAnnotation);

                // Add simple reply to created annotation
                var addSimpleReplyResult = annotator.CreateAnnotationReply(createPointAnnotationResult.Id, "first question");

                // Edit created reply
                var editReplyResult = annotator.EditAnnotationReply(addSimpleReplyResult.ReplyGuid, "changed question");

                // Create child reply. This reply will be linked to previously created reply.
                var addChildReplyResult = annotator.CreateAnnotationReply(createPointAnnotationResult.Id, "answer", addSimpleReplyResult.ReplyGuid);

                // Delete annotation reply by guid
                var deleteReplyResult = annotator.DeleteAnnotationReply(addChildReplyResult.ReplyGuid);

                // Delete all replies from annotation
                annotator.DeleteAnnotationReplies(createPointAnnotationResult.Id);

                // List of replies after deleting all replies
                var listRepliesResultAfterDeleteAll = annotator.ListAnnotationReplies(createPointAnnotationResult.Id);
                //ExEnd:AddAnnotationReply
            }
            catch (System.Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Esempio n. 2
0
        public ActionResult Get(string guid)
        {
            Response.AddHeader("Content-Type", "application/json");
            AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();

            //String guid = request.getParameter("guid");

            DeleteReplyResult result = imageHandler.DeleteAnnotationReply(guid);

            return(Content(JsonConvert.SerializeObject(
                               result,
                               Formatting.Indented,
                               new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            }
                               ), "application/json"));
        }
Esempio n. 3
0
        /// <summary>
        /// Removes a reply from an annotation
        /// </summary>
        /// <param name="connectionId">Socket connection identifier to validate user permissions for</param>
        /// <param name="fileId">The document path to remove the reply from</param>
        /// <param name="annotationGuid">The annotation global unique identifier</param>
        /// <param name="replyGuid">The reply global unique identifier</param>
        /// <returns>An instance of an object containing information about the removed reply</returns>
        public DeleteReplyResult DeleteAnnotationReply(string connectionId, string fileId, string annotationGuid, string replyGuid)
        {
            var reviewer = _annotationBroadcaster.GetConnectionUser(connectionId);

            if (reviewer == null)
            {
                throw new AnnotatorException("There is no such reviewer.");
            }
            var user              = _userSvc.GetUserByGuid(reviewer.Value.UserGuid);
            var document          = GetDocument(fileId, user.Id);
            var collaboratorsInfo = _annotator.GetCollaborators(document.Id);

            var result = _annotator.DeleteAnnotationReply(replyGuid, document.Id, user.Id);

            _annotationBroadcaster.DeleteAnnotationReply(collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), connectionId, annotationGuid, replyGuid, _mapper.Map <AnnotationReplyInfo[]>(result.Replies));

            return(_mapper.Map <DeleteReplyResult>(result));
        }