Exemplo n.º 1
0
        /// <summary>
        /// Moves the annotation marker to a new position
        /// </summary>
        /// <param name="connectionId">Socket connection identifier to validate user permissions for</param>
        /// <param name="fileId">The document path to move the annotation marker for</param>
        /// <param name="annotationGuid">The annotation global unique identifier</param>
        /// <param name="left">The X coordinate of the annotation</param>
        /// <param name="top">The Y coordinate of the annotation</param>
        /// <param name="pageNumber">The document page number to move the annotation to</param>
        /// <returns>An instance of an object containing the operation result and annotation metadata</returns>
        public MoveAnnotationResult MoveAnnotationMarker(string connectionId, string fileId, string annotationGuid, double left, double top, int?pageNumber)
        {
            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 annotation = _annotator.GetAnnotation(annotationGuid, document.Id, user.Id);
            var position   = new Point {
                X = left, Y = top
            };
            var result = _annotator.MoveAnnotationMarker(annotation.Id, new GroupDocs.Annotation.Domain.Point(position.X, position.Y), pageNumber, document.Id, user.Id);

            _annotationBroadcaster.MoveAnnotationMarker(collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(), connectionId, annotationGuid, position, pageNumber);

            return(_mapper.Map <MoveAnnotationResult>(result));
        }
Exemplo n.º 2
0
        public static AnnotationResults.CreateAnnotationResult CreateAnnotation(string connectionId, string userId, string privateKey,
                                                                                string fileId, byte type, string message, Rectangle rectangle, int pageNumber, Point annotationPosition, string svgPath,
                                                                                DrawingOptions drawingOptions, FontOptions font)
        {
            try
            {
                //_annotationSvc = UnityConfig.GetConfiguredContainer().Resolve<IAnnotationService>();

                var result = _annotationSvc.CreateAnnotation(connectionId, fileId, type, message, rectangle, pageNumber, annotationPosition, svgPath, drawingOptions, font);
                return(result);
            }
            catch (AnnotatorException e)
            {
                throw e;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new annotation for a document
        /// </summary>
        /// <param name="connectionId">Socket connection identifier to validate user permissions for</param>
        /// <param name="fileId">The document path to create the annotation for</param>
        /// <param name="type">The annotation type</param>
        /// <param name="message">The annotation text message</param>
        /// <param name="rectangle">The annotation bounds</param>
        /// <param name="pageNumber">The document page number to create the annotation at</param>
        /// <param name="annotationPosition">The annotation left-top position</param>
        /// <param name="svgPath">The annotation SVG path</param>
        /// <param name="options">The annotation drawing options (pen color, width etc.)</param>
        /// <param name="font">The annotation text font</param>
        /// <returns>An instance of an object containing information about a created annotation</returns>
        public CreateAnnotationResult CreateAnnotation(string connectionId, string fileId, byte type, string message,
                                                       Rectangle rectangle, int pageNumber, Point annotationPosition, string svgPath, DrawingOptions options, FontOptions font)
        {
            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 = _mapper.Map <GetCollaboratorsResult>(_annotator.GetCollaborators(document.Id));
            var caller            = collaboratorsInfo.Collaborators.FirstOrDefault(c => c.Guid == reviewer.Value.UserGuid);

            var annotation = new GroupDocs.Annotation.Domain.AnnotationInfo
            {
                Type               = (AnnotationType)type,
                Box                = new GroupDocs.Annotation.Domain.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height),
                PageNumber         = pageNumber,
                AnnotationPosition = new GroupDocs.Annotation.Domain.Point(annotationPosition.X, annotationPosition.Y),
                SvgPath            = svgPath,
                PenColor           = options != null ? options.PenColor : -984833,
                PenWidth           = options != null ? (byte?)options.PenWidth : 1,
                PenStyle           = options != null ? (byte?)options.DashStyle : (byte?)DashStyle.Solid,
                BackgroundColor    = options != null ? options.BrushColor : -984833,
                FontFamily         = !string.IsNullOrEmpty(font.Family) ? "Arial" : "Calibri",
                FontSize           = font.Size != null ? font.Size : 4,
            };

            if (!string.IsNullOrWhiteSpace(message))
            {
                annotation.Replies = new[] { new GroupDocs.Annotation.Domain.AnnotationReplyInfo {
                                                 Message = message
                                             } };
            }

            var result = _annotator.CreateAnnotation(annotation, document.Id, user.Id);

            _annotationBroadcaster.CreateAnnotation(
                collaboratorsInfo.Collaborators.Select(c => c.Guid).ToList(),
                connectionId,
                reviewer.Value.UserGuid,
                caller != null ? caller.PrimaryEmail : _authenticationSvc.AnonymousUserName,
                fileId,
                annotation.Type,
                result.Guid,
                (byte)result.Access,
                result.ReplyGuid,
                pageNumber,
                _mapper.Map <Rectangle>(rectangle),
                annotationPosition,
                svgPath,
                options,
                font);

            return(_mapper.Map <CreateAnnotationResult>(result));
        }
 public void MoveAnnotation(IList <string> collaboratorGuids, string connectionIdToExclude, string annotationGuid, int pageNumber, Point position)
 {
     Array.ForEach(
         _annotationsHub.GetConnectionIdsToCall(connectionIdToExclude, collaboratorGuids), x =>
         GetClient(x).moveAnnotationOnClient(connectionIdToExclude, annotationGuid, pageNumber, position));
 }