示例#1
0
        public DeleteAnnotationResult DeleteAnnotation(string annotationGuid)
        {
            Throw.IfNull <string>(annotationGuid, "annotationGuid");

            var template   = AnnotationApiUriTemplates.BuildUriTemplate(AnnotationApiUriTemplates.DeleteAnnotation);
            var parameters = new NameValueCollection()
            {
                { "userId", UserId },
                { "annotationId", annotationGuid }
            };

            var response = SubmitRequest <DeleteAnnotationResponse>(template, parameters, "DELETE", HttpContent.CreateEmpty());

            if (response.Code != ResponseCode.Ok)
            {
                throw new GroupdocsServiceException(response.ErrorMessage);
            }

            return(response.Result);
        }
示例#2
0
        public ListAnnotationsResult ListAnnotations(string documentGuid)
        {
            Throw.IfNull <string>(documentGuid, "documentGuid");

            var template   = AnnotationApiUriTemplates.BuildUriTemplate(AnnotationApiUriTemplates.ListAnnotations);
            var parameters = new NameValueCollection()
            {
                { "userId", UserId },
                { "fileId", documentGuid }
            };

            var response = SubmitRequest <ListAnnotationsResponse>(template, parameters);

            if (response.Code != ResponseCode.Ok)
            {
                throw new GroupdocsServiceException(response.ErrorMessage);
            }

            return(response.Result);
        }
示例#3
0
        public ListRepliesResult ListAnnotationReplies(string annotationGuid, DateTime?after = null)
        {
            Throw.IfNull <string>(annotationGuid, "annotationGuid");

            var template   = AnnotationApiUriTemplates.BuildUriTemplate(AnnotationApiUriTemplates.ListReplies);
            var parameters = new NameValueCollection()
            {
                { "userId", UserId },
                { "annotationId", annotationGuid },
                { "after", (after == null ? "0" : ((long)(after.Value.ToUniversalTime() - DateTimeConstants.Epoch).TotalMilliseconds).ToString()) }
            };

            var response = SubmitRequest <ListRepliesResponse>(template, parameters);

            if (response.Code != ResponseCode.Ok)
            {
                throw new GroupdocsServiceException(response.ErrorMessage);
            }

            return(response.Result);
        }
示例#4
0
        public MoveAnnotationResult MoveAnnotation(string annotationGuid, Point position)
        {
            Throw.IfNull <string>(annotationGuid, "annotationGuid");

            var template   = AnnotationApiUriTemplates.BuildUriTemplate(AnnotationApiUriTemplates.MoveAnnotation);
            var parameters = new NameValueCollection()
            {
                { "userId", UserId },
                { "annotationId", annotationGuid }
            };

            using (var content = HttpContentNetExtensions.CreateJsonNetDataContract <Point>(position))
            {
                var response = SubmitRequest <MoveAnnotationResponse>(template, parameters, "PUT", content);
                if (response.Code != ResponseCode.Ok)
                {
                    throw new GroupdocsServiceException(response.ErrorMessage);
                }

                return(response.Result);
            }
        }
示例#5
0
        public AddReplyResult AddAnnotationReply(string annotationGuid, string message)
        {
            Throw.IfNull <string>(annotationGuid, "annotationGuid");
            Throw.IfNull <string>(message, "message");

            var template   = AnnotationApiUriTemplates.BuildUriTemplate(AnnotationApiUriTemplates.CreateReply);
            var parameters = new NameValueCollection()
            {
                { "userId", UserId },
                { "annotationId", annotationGuid }
            };

            using (var content = HttpContentNetExtensions.CreateJsonNetDataContract <string>(message))
            {
                var response = SubmitRequest <AddReplyResponse>(template, parameters, "POST", content);
                if (response.Code != ResponseCode.Ok)
                {
                    throw new GroupdocsServiceException(response.ErrorMessage);
                }

                return(response.Result);
            }
        }
示例#6
0
        public SetCollaboratorsResult SetAnnotationCollaborators(string documentGuid, string[] collaborators)
        {
            Throw.IfNull <string>(documentGuid, "documentGuid");
            Throw.IfNull <string[]>(collaborators, "collaborators");

            var template   = AnnotationApiUriTemplates.BuildUriTemplate(AnnotationApiUriTemplates.SetCollaborators);
            var parameters = new NameValueCollection()
            {
                { "userId", UserId },
                { "fileId", documentGuid }
            };

            using (var content = HttpContentNetExtensions.CreateJsonNetDataContract <string[]>(collaborators))
            {
                var response = SubmitRequest <SetCollaboratorsResponse>(template, parameters, "PUT", content);
                if (response.Code != ResponseCode.Ok)
                {
                    throw new GroupdocsServiceException(response.ErrorMessage);
                }

                return(response.Result);
            }
        }
示例#7
0
        public CreateAnnotationResult CreateAnnotation(string documentGuid, AnnotationType type, Rectangle box,
                                                       Point?annotationPosition,
                                                       Range?textRange = null,
                                                       string svgPath  = null, string message = null)
        {
            Throw.IfNull <string>(documentGuid, "documentGuid");

            var template   = AnnotationApiUriTemplates.BuildUriTemplate(AnnotationApiUriTemplates.CreateAnnotation);
            var parameters = new NameValueCollection()
            {
                { "userId", UserId },
                { "fileId", documentGuid }
            };

            var annotation = new AnnotationInfo {
                Type = type, Box = box, AnnotationPosition = annotationPosition, TextRange = textRange, SvgPath = svgPath
            };

            if (!String.IsNullOrWhiteSpace(message))
            {
                annotation.Replies = new AnnotationReplyInfo[] { new AnnotationReplyInfo {
                                                                     Message = message ?? ""
                                                                 } };
            }

            using (var content = HttpContentNetExtensions.CreateJsonNetDataContract <AnnotationInfo>(annotation))
            {
                var response = SubmitRequest <CreateAnnotationResponse>(template, parameters, "POST", content);
                if (response.Code != ResponseCode.Ok)
                {
                    throw new GroupdocsServiceException(response.ErrorMessage);
                }

                return(response.Result);
            }
        }