Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.

Commit 2d5b0ec

Browse files
New Release: GroupDocs.Annotation for .NET Modern Front-End v1.0.0
0 parents  commit 2d5b0ec

36 files changed

+2106
-0
lines changed

GroupDocs.Annotation for .NET.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GroupDocs.Annotation for .NET", "GroupDocs.Annotation for .NET\GroupDocs.Annotation for .NET.csproj", "{BA0EBBA7-72FE-459B-AB12-276B1D506A3F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{BA0EBBA7-72FE-459B-AB12-276B1D506A3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{BA0EBBA7-72FE-459B-AB12-276B1D506A3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{BA0EBBA7-72FE-459B-AB12-276B1D506A3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{BA0EBBA7-72FE-459B-AB12-276B1D506A3F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
388 KB
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
using System.Web.Routing;
7+
8+
namespace GroupDocs.Annotation_for.NET
9+
{
10+
public class RouteConfig
11+
{
12+
public static void RegisterRoutes(RouteCollection routes)
13+
{
14+
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15+
routes.MapMvcAttributeRoutes();
16+
routes.MapRoute(
17+
name: "Default",
18+
url: "{controller}/{action}/{id}",
19+
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20+
);
21+
}
22+
}
23+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web.Http;
5+
6+
namespace GroupDocs.Annotation_for.NET
7+
{
8+
public static class WebApiConfig
9+
{
10+
public static void Register(HttpConfiguration config)
11+
{
12+
// Web API configuration and services
13+
14+
// Web API routes
15+
config.MapHttpAttributeRoutes();
16+
17+
config.Routes.MapHttpRoute(
18+
name: "DefaultApi",
19+
routeTemplate: "api/{controller}/{id}",
20+
defaults: new { id = RouteParameter.Optional }
21+
);
22+
}
23+
}
24+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using GroupDocs.Annotation.Domain;
2+
using GroupDocs.Annotation.Domain.Results;
3+
using GroupDocs.Annotation.Handler;
4+
using GroupDocs.Annotation.Handler.Input;
5+
using GroupDocs.Annotation.Handler.Input.DataObjects;
6+
using GroupDocs.Annotation_for.NET.Models;
7+
using Newtonsoft.Json;
8+
using Newtonsoft.Json.Serialization;
9+
using System;
10+
using System.Collections.Generic;
11+
using System.Linq;
12+
using System.Web;
13+
using System.Web.Mvc;
14+
15+
namespace GroupDocs.Annotation_for.NET.Controllers
16+
{
17+
[RoutePrefix("annotation/add")]
18+
public class AddAnnotationController : Controller
19+
{
20+
// GET: AddAnnotation
21+
[Route("")]
22+
public ActionResult Post(string file)
23+
{
24+
Response.AddHeader("Content-Type", "application/json");
25+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
26+
IDocumentDataHandler documentDataHandler = imageHandler.GetDocumentDataHandler();
27+
28+
String filename = file;
29+
Document doc = documentDataHandler.GetDocument(filename);
30+
long documentId = doc != null ? doc.Id : imageHandler.CreateDocument(filename);
31+
32+
//StreamReader stream = new StreamReader(Request.InputStream);
33+
//string x = stream.ReadToEnd(); // added to view content of input stream
34+
35+
AnnotationInfo annotation = new AnnotationInfo(); //Request.InputStream as AnnotationInfo;
36+
annotation.DocumentGuid = documentId;
37+
CreateAnnotationResult result = imageHandler.CreateAnnotation(annotation);
38+
return Content(JsonConvert.SerializeObject(
39+
result,
40+
Formatting.Indented,
41+
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
42+
), "application/json");
43+
44+
}
45+
}
46+
}
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
using GroupDocs.Annotation.Domain;
2+
using GroupDocs.Annotation.Domain.Results;
3+
using GroupDocs.Annotation.Handler;
4+
using GroupDocs.Annotation.Handler.Input;
5+
using GroupDocs.Annotation.Handler.Input.DataObjects;
6+
using GroupDocs.Annotation_for.NET.Models;
7+
using Newtonsoft.Json;
8+
using Newtonsoft.Json.Serialization;
9+
using System;
10+
using System.Collections.Generic;
11+
using System.IO;
12+
using System.Linq;
13+
using System.Web;
14+
using System.Web.Mvc;
15+
16+
namespace GroupDocs.Annotation_for.NET.Controllers
17+
{
18+
[RoutePrefix("annotation")]
19+
public class AnnotationController : Controller
20+
{
21+
[HttpGet]
22+
[Route("")]
23+
public ActionResult Get(string guid)
24+
{
25+
Response.AddHeader("Content-Type", "application/json");
26+
27+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
28+
return Content(JsonConvert.SerializeObject(
29+
imageHandler.GetAnnotation(guid).Annotation,
30+
Formatting.Indented,
31+
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
32+
), "application/json");
33+
}
34+
[HttpDelete]
35+
public ActionResult Delete(string guid)
36+
{
37+
Response.AddHeader("Content-Type", "application/json");
38+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
39+
long annotationId = imageHandler.GetAnnotation(guid).Id;
40+
DeleteAnnotationResult result = imageHandler.DeleteAnnotation(annotationId);
41+
return Content(JsonConvert.SerializeObject(
42+
result,
43+
Formatting.Indented,
44+
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
45+
), "application/json");
46+
47+
48+
}
49+
[HttpPost]
50+
public ActionResult Post()
51+
{
52+
Response.AddHeader("Content-Type", "application/json");
53+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
54+
String guid = Request.Params["guid"];
55+
String section = Request.Params["guid"];
56+
AnnotationInfo annotationInfo = imageHandler.GetAnnotation(guid).Annotation;
57+
long annotationId = imageHandler.GetAnnotation(guid).Id;
58+
59+
switch (section)
60+
{
61+
case "fieldtext":
62+
var jsonString = String.Empty;
63+
using (var inputStream = new StreamReader(Request.InputStream))
64+
{
65+
jsonString = inputStream.ReadToEnd();
66+
}
67+
TextFieldInfo info = JsonConvert.DeserializeObject<TextFieldInfo>(jsonString);
68+
69+
SaveAnnotationTextResult result = imageHandler.SaveTextField(annotationId, info);
70+
return Content(JsonConvert.SerializeObject(
71+
result,
72+
Formatting.Indented,
73+
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
74+
), "application/json");
75+
case "position":
76+
var jsonStringPos = String.Empty;
77+
using (var inputStream = new StreamReader(Request.InputStream))
78+
{
79+
jsonStringPos = inputStream.ReadToEnd();
80+
}
81+
Point point = JsonConvert.DeserializeObject<Point>(jsonStringPos);
82+
83+
MoveAnnotationResult moveresult = imageHandler.MoveAnnotationMarker(annotationId, point, annotationInfo.PageNumber);
84+
return Content(JsonConvert.SerializeObject(
85+
moveresult,
86+
Formatting.Indented,
87+
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
88+
), "application/json");
89+
default:
90+
return Content(null);
91+
}
92+
}
93+
94+
95+
96+
public ActionResult Index(string guid)
97+
{
98+
return View();
99+
}
100+
// GET: Annotation
101+
public ActionResult List(string file)
102+
{
103+
Response.AddHeader("Content-Type", "application/json");
104+
AnnotationImageHandler handler = Utils.createAnnotationImageHandler();
105+
String filename = file;
106+
Document doc = Utils.findDocumentByName(filename);
107+
ListAnnotationsResult listResult = handler.GetAnnotations(doc.Id);
108+
109+
List<GetAnnotationResult> list = new List<GetAnnotationResult>();
110+
foreach (AnnotationInfo inf in listResult.Annotations)
111+
{
112+
list.Add(handler.GetAnnotation(inf.Guid));
113+
}
114+
return Content(JsonConvert.SerializeObject(
115+
list,
116+
Formatting.Indented,
117+
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
118+
), "application/json");
119+
120+
121+
//Response.Write(list);
122+
/*
123+
*
124+
* response.setHeader("Content-Type", "application/json");
125+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
126+
String filename = request.getParameter("file");
127+
128+
Document doc = Utils.findDocumentByName(filename);
129+
ListAnnotationsResult listResult = imageHandler.getAnnotations(doc.getId());
130+
131+
ArrayList<GetAnnotationResult> list = new ArrayList<>();
132+
for (AnnotationInfo inf : listResult.getAnnotations()) {
133+
list.add(imageHandler.getAnnotation(inf.getGuid()));
134+
}
135+
136+
new ObjectMapper().writeValue(response.getOutputStream(), list);*/
137+
138+
139+
return View();
140+
}
141+
public ActionResult Add2(string file)
142+
{
143+
Response.AddHeader("Content-Type", "application/json");
144+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
145+
IDocumentDataHandler documentDataHandler = imageHandler.GetDocumentDataHandler();
146+
147+
String filename = file;
148+
Document doc = documentDataHandler.GetDocument(filename);
149+
long documentId = doc != null ? doc.Id : imageHandler.CreateDocument(filename);
150+
151+
//StreamReader stream = new StreamReader(Request.InputStream);
152+
//string x = stream.ReadToEnd(); // added to view content of input stream
153+
154+
AnnotationInfo annotation = new AnnotationInfo(); //Request.InputStream as AnnotationInfo;
155+
annotation.DocumentGuid = documentId;
156+
CreateAnnotationResult result = imageHandler.CreateAnnotation(annotation);
157+
return Content(JsonConvert.SerializeObject(
158+
result,
159+
Formatting.Indented,
160+
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
161+
), "application/json");
162+
}
163+
}
164+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using GroupDocs.Annotation.Domain.Results;
2+
using GroupDocs.Annotation.Handler;
3+
using GroupDocs.Annotation_for.NET.Models;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Serialization;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using System.Web;
10+
using System.Web.Mvc;
11+
12+
namespace GroupDocs.Annotation_for.NET.Controllers
13+
{
14+
[RoutePrefix("annotation/delete")]
15+
public class DeleteAnnotationController : Controller
16+
{
17+
[Route("")]
18+
public ActionResult Get(string file)
19+
{
20+
21+
Response.AddHeader("Content-Type", "application/json");
22+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
23+
String filename = file;// request.getParameter("file");
24+
long annotationId = long.Parse(Request.Params["annotationId"]);
25+
26+
DeleteAnnotationResult result = imageHandler.DeleteAnnotation(annotationId);
27+
28+
return Content(JsonConvert.SerializeObject(
29+
result,
30+
Formatting.Indented,
31+
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
32+
), "application/json");
33+
}
34+
}
35+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using GroupDocs.Annotation.Domain.Containers;
2+
using GroupDocs.Annotation.Handler;
3+
using GroupDocs.Annotation_for.NET.Models;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Serialization;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.IO;
9+
using System.Linq;
10+
using System.Web;
11+
using System.Web.Mvc;
12+
13+
namespace GroupDocs.Annotation_for.NET.Controllers
14+
{
15+
[RoutePrefix("document/info")]
16+
public class DocumentInfoController : Controller
17+
{
18+
// GET: Document
19+
[Route("")]
20+
public ActionResult Get(string file)
21+
{
22+
AnnotationImageHandler handler = Utils.createAnnotationImageHandler();
23+
String filename = file;
24+
DocumentInfoContainer result = handler.GetDocumentInfo(filename);
25+
Response.AddHeader("Content-Type", "application/json");
26+
return Content(JsonConvert.SerializeObject(
27+
result,
28+
Formatting.Indented,
29+
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }
30+
), "application/json");
31+
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)