-
Notifications
You must be signed in to change notification settings - Fork 305
Expand file tree
/
Copy pathAdminServices.cs
More file actions
61 lines (59 loc) · 2.62 KB
/
AdminServices.cs
File metadata and controls
61 lines (59 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using System.Web.Script.Serialization;
using System.Reflection;
namespace SharpMapServer
{
public class AdminServices : IHttpHandler, IRequiresSessionState
{
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
string operation = context.Request.QueryString["operation"];
switch (operation)
{
case "status":
context.Response.ContentType = "application/json";
context.Response.Write(new JavaScriptSerializer().Serialize(new
{
Status = "OK",
Version = Assembly.GetExecutingAssembly().GetName().Name + " Version: " + Assembly.GetExecutingAssembly().GetName().Version.ToString(),
}));
break;
case "getwmslayers":
context.Response.ContentType = "application/json";
var res = new { layers = WMSServer.m_Map.Layers.Select(x => new { Name = x.LayerName }).ToArray() };
context.Response.Write(new JavaScriptSerializer().Serialize(new
{
Status = "OK",
layers = res.layers
}));
break;
case "generalsettings":
context.Response.ContentType = "application/json";
context.Response.Write(new JavaScriptSerializer().Serialize(new
{
Status = "OK",
Title = WMSServer.m_Capabilities.Title,
Abstract = WMSServer.m_Capabilities.Abstract,
AccessConstraints = WMSServer.m_Capabilities.AccessConstraints,
ContactInformation = WMSServer.m_Capabilities.ContactInformation,
Fees = WMSServer.m_Capabilities.Fees,
KeyWords = string.Join(",",WMSServer.m_Capabilities.Keywords),
OnlineResource = WMSServer.m_Capabilities.OnlineResource,
}));
break;
default:
context.Response.ContentType = "application/json";
context.Response.Write(new JavaScriptSerializer().Serialize(new { Status = "Err", Text = "Unknown operation" }));
break;
}
}
}
}