Beispiel #1
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 CreateAnnotation(IList <string> collaboratorGuids,
                              string connectionIdToExclude,
                              string userGuid,
                              string userName,
                              string documentGuid,
                              AnnotationType annotationType,
                              string annotationGuid,
                              byte access,
                              string replyGuid,
                              int pageNumber,
                              Rectangle box,
                              Point?annotationPosition,
                              string svgPath,
                              DrawingOptions drawingOptions,
                              FontOptions font)
 {
     Array.ForEach(
         _annotationsHub.GetConnectionIdsToCall(connectionIdToExclude, collaboratorGuids), x =>
         GetClient(x).createAnnotationOnClient(connectionIdToExclude,
                                               new
     {
         userName,
         pageNumber,
         box,
         annotationPosition,
         documentGuid,
         annotationGuid,
         access,
         annotationType,
         replyGuid,
         userGuid,
         svgPath,
         serverTime     = GetJavascriptDateTime(DateTime.UtcNow),
         drawingOptions = (drawingOptions != null ? new { penColor = drawingOptions.PenColor, penWidth = drawingOptions.PenWidth, penStyle = drawingOptions.PenStyle, brushColor = drawingOptions.BrushColor } : null),
         font           = (font != null ? new { family = font.Family, size = font.Size } : null)
     }));
 }
Beispiel #3
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;
            }
        }