/// <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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates a reply text
        /// </summary>
        /// <param name="connectionId">Socket connection identifier to validate user permissions for</param>
        /// <param name="fileId">The document path to update the reply text for</param>
        /// <param name="annotationGuid">The annotation global unique identifier</param>
        /// <param name="replyGuid">The reply global unique identifier</param>
        /// <param name="message">The text message to update</param>
        /// <returns>An instance of an object containing the operation result</returns>
        public EditReplyResult EditAnnotationReply(string connectionId, string fileId, string annotationGuid, string replyGuid, string message)
        {
            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.EditAnnotationReply(replyGuid, message, document.Id, user.Id);

            _annotationBroadcaster.EditAnnotationReply(collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), connectionId, annotationGuid, replyGuid, message);

            return(_mapper.Map <EditReplyResult>(result));
        }
Exemplo n.º 3
0
        public ActionResult Post(string guid)
        {
            Response.AddHeader("Content-Type", "application/json");
            AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
            //String guid = request.getParameter("guid");
            String section = Request.Params["section"];

            switch (section)
            {
            case "message":
                AnnotationReplyInfo info   = JsonConvert.DeserializeObject(new StreamReader(Request.InputStream).ReadToEnd()) as AnnotationReplyInfo;;
                EditReplyResult     result = imageHandler.EditAnnotationReply(guid, info.Message);
                return(Content(JsonConvert.SerializeObject(
                                   result,
                                   Formatting.Indented,
                                   new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                }
                                   ), "application/json"));

            default:
                return(new HttpNotFoundResult("Not found"));
            }
        }