public static void Run() { var apiInstance = new AnnotateApi(Constants.GetConfig()); try { var fileInfo = new FileInfo { FilePath = "one-page.docx" }; AnnotationInfo[] annotations = { new AnnotationInfo { AnnotationPosition = new Point{ X = 1, Y = 1 }, Box = new Rectangle{ X = 100, Y = 100, Width = 100, Height = 100 }, FontColor = 65535, FontSize = 12, Angle = 75, PageNumber = 0, Opacity = 0.7, Type = AnnotationInfo.TypeEnum.Watermark, Text = "This is watermark annotation", CreatorName = "Anonym A.", CreatedOn = DateTime.Now, Replies = new List <AnnotationReplyInfo> { new AnnotationReplyInfo { Comment = "First comment", RepliedOn = DateTime.Now }, new AnnotationReplyInfo { Comment = "Second comment", RepliedOn = DateTime.Now } } }, }; var options = new AnnotateOptions { FileInfo = fileInfo, Annotations = annotations.ToList(), OutputPath = "Output/output.docx" }; var link = apiInstance.Annotate(new AnnotateRequest(options)); Console.WriteLine("AddWatermarkAnnotation: Watermark Annotation added: " + link.Title); } catch (Exception e) { Console.WriteLine("Exception while calling AnnotateApi: " + e.Message); } }
public static void Run() { var apiInstance = new AnnotateApi(Constants.GetConfig()); try { var fileInfo = new FileInfo { FilePath = "one-page.docx" }; var options = new RemoveOptions(); options.FileInfo = fileInfo; options.AnnotationIds = new List <int?> { 1, 2, 3 }; options.OutputPath = "Output/output.docx"; var request = new RemoveAnnotationsRequest(options); var link = apiInstance.RemoveAnnotations(request); Console.WriteLine("DeleteAnnotations: Annotations deleted: " + link.Title); } catch (Exception e) { Console.WriteLine("Exception while calling AnnotateApi: " + e.Message); } }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new AnnotateApi(configuration); try { // Set request. var request = new GetExportRequest() { filePath = "Annotationdocs\\ten-pages.pdf", password = null, annotatedPages = true, annotationTypes = null, firstPage = 1, lastPage = 2 }; Stream response = apiInstance.GetExport(request); Console.WriteLine("Expected response type is Stream: Document Length: " + response.Length.ToString()); using (var fileStream = File.Create("D:\\Results-ten-pages.pdf")) { response.Seek(0, SeekOrigin.Begin); response.CopyTo(fileStream); } } catch (Exception e) { Console.WriteLine("Exception while calling Annotation AnnotateApi: " + e.Message); } }
public static void Run() { var apiInstance = new AnnotateApi(Constants.GetConfig()); try { var fileInfo = new FileInfo { FilePath = "one-page.docx" }; AnnotationInfo[] annotations = { new AnnotationInfo { AnnotationPosition = new Point{ X = 1, Y = 1 }, Box = new Rectangle{ X = 100, Y = 100, Width = 100, Height = 100 }, PageNumber = 0, BackgroundColor = 65535, PenColor = 65535, PenStyle = AnnotationInfo.PenStyleEnum.Solid, PenWidth = 3, Type = AnnotationInfo.TypeEnum.Area, Text = "This is area annotation", CreatorName = "Anonym A.", CreatedOn = DateTime.Now, Replies = new List <AnnotationReplyInfo> { new AnnotationReplyInfo { Comment = "First comment", RepliedOn = DateTime.Now }, new AnnotationReplyInfo { Comment = "Second comment", RepliedOn = DateTime.Now } } }, }; var options = new AnnotateOptions { FileInfo = fileInfo, Annotations = annotations.ToList() }; var stream = apiInstance.AnnotateDirect(new AnnotateDirectRequest(options)); Console.WriteLine("AddAnnotationDirect: Area Annotation added. Stream size: " + stream.Length); } catch (Exception e) { Console.WriteLine("Exception while calling AnnotateApi: " + e.Message); } }
public static void Run() { var apiInstance = new AnnotateApi(Constants.GetConfig()); try { var fileInfo = new FileInfo { FilePath = "one-page.docx" }; AnnotationInfo[] annotations = { new AnnotationInfo { Box = new Rectangle{ X = 250, Y = 35, Width = 102, Height = 12 }, PageNumber = 0, PenColor = 65535, PenStyle = AnnotationInfo.PenStyleEnum.Solid, PenWidth = 3, Opacity = 0.7, Type = AnnotationInfo.TypeEnum.Polyline, Text = "This is polyline annotation", CreatorName = "Anonym A.", CreatedOn = DateTime.Now, SvgPath = "M250.8280751173709,48.209295774647885l0.6986854460093896,0l0.6986854460093896,-1.3973708920187793l0.6986854460093896,0l0.6986854460093896,-1.3973708920187793l1.3973708920187793,-0.6986854460093896l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0l2.096056338028169,-1.3973708920187793l3.493427230046948,-1.3973708920187793l0.6986854460093896,-0.6986854460093896l1.3973708920187793,-1.3973708920187793l0.6986854460093896,0l1.3973708920187793,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0l0,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l0,-0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l2.096056338028169,-0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l1.3973708920187793,0l1.3973708920187793,0l2.096056338028169,0l5.589483568075117,0l1.3973708920187793,0l2.096056338028169,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l1.3973708920187793,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0l2.096056338028169,1.3973708920187793l0.6986854460093896,0l0.6986854460093896,0l0,0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0.6986854460093896l0,0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0.6986854460093896l1.3973708920187793,0.6986854460093896l3.493427230046948,0.6986854460093896l1.3973708920187793,0.6986854460093896l2.096056338028169,0.6986854460093896l1.3973708920187793,0.6986854460093896l1.3973708920187793,0l1.3973708920187793,0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l2.7947417840375586,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0", Replies = new List <AnnotationReplyInfo> { new AnnotationReplyInfo { Comment = "First comment", RepliedOn = DateTime.Now }, new AnnotationReplyInfo { Comment = "Second comment", RepliedOn = DateTime.Now } } }, }; var options = new AnnotateOptions { FileInfo = fileInfo, Annotations = annotations.ToList(), OutputPath = "Output/output.docx" }; var link = apiInstance.Annotate(new AnnotateRequest(options)); Console.WriteLine("AddPolylineAnnotation: Polyline Annotation added: " + link.Title); } catch (Exception e) { Console.WriteLine("Exception while calling AnnotateApi: " + e.Message); } }
public static void Run() { var apiInstance = new AnnotateApi(Constants.GetConfig()); try { var fileInfo = new FileInfo { FilePath = "one-page.docx" }; AnnotationInfo[] annotations = { new AnnotationInfo { Box = new Rectangle{ X = 100, Y = 100, Width = 200, Height = 100 }, PageNumber = 0, Type = AnnotationInfo.TypeEnum.Image, ImagePath = "JohnSmith.png", Text = "This is image annotation", CreatorName = "Anonym A.", CreatedOn = DateTime.Now, Replies = new List <AnnotationReplyInfo> { new AnnotationReplyInfo { Comment = "First comment", RepliedOn = DateTime.Now }, new AnnotationReplyInfo { Comment = "Second comment", RepliedOn = DateTime.Now } } }, }; var options = new AnnotateOptions { FileInfo = fileInfo, Annotations = annotations.ToList(), OutputPath = "Output/output.docx" }; var link = apiInstance.Annotate(new AnnotateRequest(options)); Console.WriteLine("AddImageAnnotation: Image Annotation added: " + link.Title); } catch (Exception e) { Console.WriteLine("Exception while calling AnnotateApi: " + e.Message); } }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new AnnotateApi(configuration); try { // Set request. var request = new PostAnnotationsRequest(); request.filePath = "Annotationdocs\\ten-pages.pdf"; AnnotationInfo[] annotations = { new AnnotationInfo { AnnotationPosition = new Point{ X = 1, Y = 1 }, Box = new Rectangle{ X = 100, Y = 100, Width = 100, Height = 100 }, PageNumber = 1, BackgroundColor = 65535, PenColor = 65535, PenStyle = 1, PenWidth = 3, Opacity = 0.7, Type = AnnotationInfo.TypeEnum.Area, Text = "This is area annotation", CreatorName = "Anonym A.", CreatedOn = DateTime.Now, Replies = new List <AnnotationReplyInfo> { new AnnotationReplyInfo { Message = "First comment", RepliedOn = DateTime.Now }, new AnnotationReplyInfo { Message = "Second comment", RepliedOn = DateTime.Now } } }, }; request.annotations = annotations.ToList(); apiInstance.PostAnnotations(request); Console.WriteLine("Expected response type is void: Area Annotation added."); } catch (Exception e) { Console.WriteLine("Exception while calling Annotation AnnotateApi: " + e.Message); } }
public void TestExtract(string filePath) { var fileInfo = new Model.FileInfo { FilePath = filePath }; var annotations = AnnotateApi.Extract(new ExtractRequest(fileInfo)); Assert.AreNotEqual(null, annotations); Assert.Greater(annotations.Count, 0); Assert.IsInstanceOf(typeof(AnnotationInfo), annotations[0]); }
public ActionResult Grade(int assignmentID, int authorTeamID, bool resubmission = false) { WebClient client = new WebClient(); Assignment assignment = db.Assignments.Find(assignmentID); AssignmentTeam at = GetAssignmentTeam(assignment, ActiveCourseUser); ReviewTeam reviewTeam = null; if (at != null) { reviewTeam = (from rt in assignment.ReviewTeams where rt.ReviewTeamID == at.TeamID && rt.AuthorTeamID == authorTeamID select rt).FirstOrDefault(); } //Send off to Annotate if we have exactly one deliverable and that deliverable is a PDF document if (assignment.Deliverables.Count == 1 && assignment.Deliverables[0].DeliverableType == DeliverableType.PDF) { AnnotateApi api = new AnnotateApi(ConfigurationManager.AppSettings["AnnotateUserName"], ConfigurationManager.AppSettings["AnnotateApiKey"]); AnnotateResult uploadResult = api.UploadDocument((int)assignment.ID, authorTeamID, resubmission); if (uploadResult.Result == ResultCode.OK) { AnnotateResult createResult = api.CreateAccount(CurrentUser); if (createResult.Result == ResultCode.OK) { //instructors get to see everyone, regardless of CR settings CriticalReviewSettings settings = new CriticalReviewSettings(); settings.AnonymizeComments = false; api.SetDocumentAnonymity(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate, settings); api.GiveAccessToDocument(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //log the user in to annotate string loginString = api.GetAnnotateLoginUrl(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //load the annotate url for the view ViewBag.AnnotateUrl = loginString; } } } else { return(RedirectToRoute(new { controller = "Home", action = "Index", area = "" })); } return(View("Review")); }
public void BeforeAllTests() { var config = new Configuration(_appSid, _appKey) { ApiBaseUrl = _apiBaseUrl }; InfoApi = new InfoApi(config); AnnotateApi = new AnnotateApi(config); PreviewApi = new PreviewApi(config); FileApi = new FileApi(config); FolderApi = new FolderApi(config); StorageApi = new StorageApi(config); UploadTestFiles(); }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new AnnotateApi(configuration); try { // Set request. var request = new PostAnnotationsRequest(); request.filePath = "Annotationdocs\\ten-pages.pdf"; AnnotationInfo[] annotations = { new AnnotationInfo { AnnotationPosition = new Point{ X = 1, Y = 1 }, FontColor = 65535, PageNumber = 1, Type = AnnotationInfo.TypeEnum.TextUnderline, Text = "This is text underline annotation", CreatorName = "Anonym A.", CreatedOn = DateTime.Now, Replies = new List <AnnotationReplyInfo> { new AnnotationReplyInfo { Message = "First comment", RepliedOn = DateTime.Now }, new AnnotationReplyInfo { Message = "Second comment", RepliedOn = DateTime.Now } } }, }; request.annotations = annotations.ToList(); apiInstance.PostAnnotations(request); Console.WriteLine("Expected response type is void: Text Underline Annotation added."); } catch (Exception e) { Console.WriteLine("Exception while calling Annotation AnnotateApi: " + e.Message); } }
public void TestRemoveAnnotations(string filePath) { var options = new RemoveOptions { FileInfo = new Model.FileInfo { FilePath = filePath }, AnnotationIds = new List <int?> { 1, 2, 3 }, OutputPath = $"{DefaultOutputPath}/{Path.GetFileName(filePath)}" }; var result = AnnotateApi.RemoveAnnotations(new RemoveAnnotationsRequest(options)); Assert.NotNull(result); Assert.IsNotEmpty(result.Href); }
public void TestAddAnnotationsManyPages(string filePath) { var fileInfo = new Model.FileInfo { FilePath = filePath }; var options = new AnnotateOptions { FileInfo = fileInfo, Annotations = GetAnnotationsManyPages(), OutputPath = $"{DefaultOutputPath}/{Path.GetFileName(filePath)}" }; var request = new AnnotateRequest(options); var result = AnnotateApi.Annotate(request); Assert.IsNotNull(result); Assert.IsNotEmpty(result.Href); }
public static void Run() { var apiInstance = new AnnotateApi(Constants.GetConfig()); try { var fileInfo = new FileInfo { FilePath = "input.docx" }; var response = apiInstance.Extract(new ExtractRequest(fileInfo)); Console.WriteLine("ExtractAnnotations: annotations count = " + response.Count); } catch (Exception e) { Console.WriteLine("Exception while calling AnnotateApi: " + e.Message); } }
public void TestAddDirect(string filePath, string annotationTypes = null, bool annotatedPages = false, int firstPage = -1, int lastPage = -1, string password = null) { var fileInfo = new Model.FileInfo { FilePath = filePath, Password = password }; var options = new AnnotateOptions { FileInfo = fileInfo, Annotations = GetAnnotations(), FirstPage = firstPage, LastPage = lastPage, OnlyAnnotatedPages = annotatedPages }; var request = new AnnotateDirectRequest(options); var result = AnnotateApi.AnnotateDirect(request); Assert.IsNotNull(result); Assert.IsInstanceOf(typeof(Stream), result); }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new AnnotateApi(configuration); try { // Set request. var request = new GetPdfRequest() { filePath = "Annotationdocs\\ten-pages.docx" }; var response = apiInstance.GetPdf(request); Console.WriteLine("Expected response type is Stream: Document Length: " + response.Length.ToString()); } catch (Exception e) { Console.WriteLine("Exception while calling Annotation AnnotateApi: " + e.Message); } }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new AnnotateApi(configuration); try { // Set request. var request = new DeleteAnnotationsRequest() { filePath = "Annotationdocs\\one-page.docx" }; apiInstance.DeleteAnnotations(request); Console.WriteLine("Expected response type is Void: Annotation deleted from document."); } catch (Exception e) { Console.WriteLine("Exception while calling Annotation AnnotateApi: " + e.Message); } }
public ActionResult GetAnnotateDocument(int assignmentID, int authorTeamID, string apiKey) { if (apiKey != ConfigurationManager.AppSettings["AnnotateApiKey"]) { return(RedirectToAction("Index", "Home")); } Assignment assignment = db.Assignments.Find(assignmentID); //add in some robustness. If we were passed in a critical review, //get the preceeding assignment. Otherwise, just use the current assignment. if (assignment.Type == AssignmentTypes.CriticalReview) { assignment = assignment.PreceedingAssignment; } AssignmentTeam assignmentTeam = (from at in db.AssignmentTeams where at.AssignmentID == assignment.ID && at.TeamID == authorTeamID select at ).FirstOrDefault(); string path = FileSystem.GetDeliverable( assignment.Course as Course, assignment.ID, assignmentTeam, assignment.Deliverables[0].ToString() ); string fileName = AnnotateApi.GetAnnotateDocumentName(assignment.ID, authorTeamID); return(new FileStreamResult(FileSystem.GetDocumentForRead(path), "application/octet-stream") { FileDownloadName = fileName }); }
public static void Run() { var apiInstance = new AnnotateApi(Constants.GetConfig()); try { var fileInfo = new FileInfo { FilePath = "one-page.docx" }; AnnotationInfo[] annotations = { new AnnotationInfo { Points = new List <Point> { new Point { X = 80, Y = 730 }, new Point{ X = 240, Y = 730 }, new Point{ X = 80, Y = 650 }, new Point{ X = 240, Y = 650 } }, FontColor = 65535, PageNumber = 0, Opacity = 0.7, Type = AnnotationInfo.TypeEnum.TextReplacement, Text = "This is text replacement annotation", TextToReplace = "replaced text", CreatorName = "Anonym A.", CreatedOn = DateTime.Now, Replies = new List <AnnotationReplyInfo> { new AnnotationReplyInfo { Comment = "First comment", RepliedOn = DateTime.Now }, new AnnotationReplyInfo { Comment = "Second comment", RepliedOn = DateTime.Now } } }, }; var options = new AnnotateOptions { FileInfo = fileInfo, Annotations = annotations.ToList(), OutputPath = "Output/output.docx" }; var link = apiInstance.Annotate(new AnnotateRequest(options)); Console.WriteLine("AddTextReplacementAnnotation: Text Replacement Annotation added: " + link.Title); } catch (Exception e) { Console.WriteLine("Exception while calling AnnotateApi: " + e.Message); } }
public static void Run() { var apiInstance = new AnnotateApi(Constants.GetConfig()); try { var fileInfo = new FileInfo { FilePath = "ten-pages.pdf" }; AnnotationInfo[] annotations = { new AnnotationInfo { AnnotationPosition = new Point{ X = 1, Y = 1 }, Box = new Rectangle{ X = 100, Y = 100, Width = 100, Height = 100 }, PageNumber = 1, BackgroundColor = 65535, PenColor = 65535, PenStyle = AnnotationInfo.PenStyleEnum.Solid, PenWidth = 3, Opacity = 0.7, Type = AnnotationInfo.TypeEnum.Area, Text = "This is area annotation", CreatorName = "Anonym A.", Replies = new List <AnnotationReplyInfo> { new AnnotationReplyInfo { Comment = "First comment", RepliedOn = DateTime.Now }, new AnnotationReplyInfo { Comment = "Second comment", RepliedOn = DateTime.Now } } }, new AnnotationInfo { AnnotationPosition = new Point{ X = 852, Y = 59.388262910798119 }, Box = new Rectangle{ X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, PageNumber = 2, PenColor = 1201033, PenStyle = 0, PenWidth = 1, Type = AnnotationInfo.TypeEnum.Area, CreatorName = "Anonym A." }, new AnnotationInfo { AnnotationPosition = new Point{ X = 852, Y = 59.388262910798119 }, Box = new Rectangle{ X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, PageNumber = 4, Type = AnnotationInfo.TypeEnum.Point, CreatorName = "Anonym A." }, new AnnotationInfo { AnnotationPosition = new Point{ X = 852, Y = 59.388262910798119 }, Box = new Rectangle{ X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, PageNumber = 5, PenColor = 1201033, PenStyle = 0, PenWidth = 1, Type = AnnotationInfo.TypeEnum.Arrow, CreatorName = "Anonym A." } }; var options = new AnnotateOptions { FileInfo = fileInfo, Annotations = annotations.ToList(), OutputPath = "Output/output.pdf" }; var link = apiInstance.Annotate(new AnnotateRequest(options)); Console.WriteLine("AddMultipleAnnotations: Multiple Annotation added: " + link.Title); } catch (Exception e) { Console.WriteLine("Exception while calling AnnotateApi: " + e.Message); } }
/// <summary> /// Loads a PDF for critical review /// </summary> /// <param name="assignmentID"></param> /// <param name="authorTeamID"></param> /// <returns></returns> public ActionResult Review(int assignmentID, int authorTeamID) { WebClient client = new WebClient(); Assignment CRassignment = db.Assignments.Find(assignmentID); AssignmentTeam at = GetAssignmentTeam(CRassignment, ActiveCourseUser); ReviewTeam reviewTeam = null; if (at != null) { reviewTeam = (from rt in CRassignment.ReviewTeams where rt.ReviewTeamID == at.TeamID && rt.AuthorTeamID == authorTeamID select rt).FirstOrDefault(); } bool canAccessReview = false; //Determine whether or not the current user can access the document if (CRassignment.Type == AssignmentTypes.CriticalReview) { //is the user a reviewer? if (reviewTeam != null) { canAccessReview = true; } //or, is the user an instructor? else if (ActiveCourseUser.AbstractRole.CanGrade) { canAccessReview = true; } //or, has the review been published and the current user is the author of the docment? else if (CRassignment.IsCriticalReviewPublished == true) { reviewTeam = (from rt in CRassignment.ReviewTeams where rt.AuthorTeamID == authorTeamID select rt ).FirstOrDefault(); if (reviewTeam != null) { TeamMember tm = reviewTeam.AuthorTeam.TeamMembers.Where(t => t.CourseUserID == ActiveCourseUser.ID).FirstOrDefault(); if (tm != null) { canAccessReview = true; } } } } if (canAccessReview) { //Send off to Annotate if we have exactly one deliverable and that deliverable is a PDF document if (CRassignment.PreceedingAssignment.Deliverables.Count == 1 && CRassignment.PreceedingAssignment.Deliverables[0].DeliverableType == DeliverableType.PDF) { AnnotateApi api = new AnnotateApi(ConfigurationManager.AppSettings["AnnotateUserName"], ConfigurationManager.AppSettings["AnnotateApiKey"]); AnnotateResult uploadResult = api.UploadDocument((int)CRassignment.PrecededingAssignmentID, authorTeamID); if (uploadResult.Result == ResultCode.OK) { AnnotateResult createResult = api.CreateAccount(CurrentUser); if (createResult.Result == ResultCode.OK) { //instructors get to see everyone, regardless of CR settings CriticalReviewSettings settings = CRassignment.CriticalReviewSettings; if (ActiveCourseUser.AbstractRoleID == (int)CourseRole.CourseRoles.Instructor) { settings.AnonymizeComments = false; } api.SetDocumentAnonymity(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate, settings); api.GiveAccessToDocument(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //log the user in to annotate string loginString = api.GetAnnotateLoginUrl(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //load the annotate url for the view ViewBag.AnnotateUrl = loginString; } } } else { return(RedirectToRoute(new { controller = "Home", action = "Index", area = "" })); } } return(View()); }
/// <summary> /// Loads a PDF for critical review /// </summary> /// <param name="assignmentID"></param> /// <param name="authorTeamID"></param> /// <returns></returns> public ActionResult ReviewGradedDocument(int assignmentID, int authorTeamID, int anonReview = 0) { WebClient client = new WebClient(); Assignment CRassignment = db.Assignments.Find(assignmentID); AssignmentTeam at = GetAssignmentTeam(CRassignment, ActiveCourseUser); bool canAccessReview = false; //Determine whether or not the current user can access the document //is the author of the docment? TeamMember tm = at.Team.TeamMembers.Where(tms => tms.CourseUserID == ActiveCourseUser.ID).FirstOrDefault(); if (tm != null) { canAccessReview = true; } if (canAccessReview) { //Send off to Annotate if we have exactly one deliverable and that deliverable is a PDF document if (true) { AnnotateApi api = new AnnotateApi(ConfigurationManager.AppSettings["AnnotateUserName"], ConfigurationManager.AppSettings["AnnotateApiKey"]); AnnotateResult uploadResult = api.UploadDocument((int)assignmentID, authorTeamID); if (uploadResult.Result == ResultCode.OK) { AnnotateResult createResult = api.CreateAccount(CurrentUser); if (createResult.Result == ResultCode.OK) { //instructors get to see everyone, regardless of CR settings CriticalReviewSettings settings = CRassignment.CriticalReviewSettings; if (ActiveCourseUser.AbstractRoleID == (int)CourseRole.CourseRoles.Instructor) { settings.AnonymizeComments = false; } if (settings == null) { settings = new CriticalReviewSettings(); settings.Assignment = CRassignment; } if (anonReview == 1) { settings.AnonymizeComments = true; } api.SetDocumentAnonymity(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate, settings); api.GiveAccessToDocument(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //log the user in to annotate string loginString = api.GetAnnotateLoginUrl(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //load the annotate url for the view ViewBag.AnnotateUrl = loginString; } } } else { return(RedirectToRoute(new { controller = "Home", action = "Index", area = "" })); } } return(View("Review")); }
public static void Run() { var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey); var apiInstance = new AnnotateApi(configuration); try { // Set request. var request = new PostAnnotationsRequest(); request.filePath = "Annotationdocs\\ten-pages.pdf"; AnnotationInfo[] annotations = { new AnnotationInfo { AnnotationPosition = new Point{ X = 852, Y = 59.388262910798119 }, Box = new Rectangle{ X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, PageNumber = 0, PenColor = 1201033, PenStyle = 0, PenWidth = 1, Type = AnnotationInfo.TypeEnum.Distance, CreatorName = "Anonym A.", CreatedOn = DateTime.Now }, new AnnotationInfo { AnnotationPosition = new Point{ X = 1, Y = 1 }, Box = new Rectangle{ X = 100, Y = 100, Width = 100, Height = 100 }, PageNumber = 1, BackgroundColor = 65535, PenColor = 65535, PenStyle = 1, PenWidth = 3, Opacity = 0.7, Type = AnnotationInfo.TypeEnum.Area, Text = "This is area annotation", CreatorName = "Anonym A.", Replies = new List <AnnotationReplyInfo> { new AnnotationReplyInfo { Message = "First comment", RepliedOn = DateTime.Now }, new AnnotationReplyInfo { Message = "Second comment", RepliedOn = DateTime.Now } } }, new AnnotationInfo { AnnotationPosition = new Point{ X = 852, Y = 59.388262910798119 }, Box = new Rectangle{ X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, PageNumber = 2, PenColor = 1201033, PenStyle = 0, PenWidth = 1, Type = AnnotationInfo.TypeEnum.Area, CreatorName = "Anonym A." }, new AnnotationInfo { AnnotationPosition = new Point{ X = 852, Y = 59.388262910798119 }, Box = new Rectangle{ X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, PageNumber = 4, Type = AnnotationInfo.TypeEnum.Point, CreatorName = "Anonym A." }, new AnnotationInfo { AnnotationPosition = new Point{ X = 852, Y = 59.388262910798119 }, Box = new Rectangle{ X = 375.89276123046875, Y = 59.388263702392578, Width = 88.7330551147461, Height = 37.7290153503418 }, PageNumber = 5, PenColor = 1201033, PenStyle = 0, PenWidth = 1, Type = AnnotationInfo.TypeEnum.Arrow, CreatorName = "Anonym A." } }; request.annotations = annotations.ToList(); apiInstance.PostAnnotations(request); Console.WriteLine("Expected response type is void: Multiple Annotations added."); } catch (Exception e) { Console.WriteLine("Exception while calling Annotation AnnotateApi: " + e.Message); } }