public IActionResult EsriMap(string cmd, string ServiceName, string content) { if (cmd == "ping") { return(Result("gView MapServer Instance v" + gView.Framework.system.SystemVariables.gViewVersion.ToString(), "text/plain")); } if (cmd == "getversion") { return(Result(gView.Framework.system.SystemVariables.gViewVersion.ToString(), "text/plain")); } if (cmd == "capabilities") { content = @"<?xml version=""1.0"" encoding=""UTF-8""?><ARCXML version=""1.1""><REQUEST><GET_SERVICE_INFO fields=""true"" envelope=""true"" renderer=""true"" extensions=""true"" /></REQUEST></ARCXML>"; } var interpreter = InternetMapServer.GetInterpreter(typeof(ArcXMLRequest)); #region Request if (String.IsNullOrEmpty(content) && Request.Body.CanRead) { MemoryStream ms = new MemoryStream(); byte[] bodyData = new byte[1024]; int bytesRead; while ((bytesRead = Request.Body.Read(bodyData, 0, bodyData.Length)) > 0) { ms.Write(bodyData, 0, bytesRead); } content = Encoding.UTF8.GetString(ms.ToArray()); } ServiceRequest serviceRequest = new ServiceRequest(ServiceName, content); serviceRequest.OnlineResource = InternetMapServer.OnlineResource; #endregion #region Security Identity identity = Identity.FromFormattedString(String.Empty); identity.HashedPassword = String.Empty; serviceRequest.Identity = identity; #endregion #region Queue & Wait IServiceRequestContext context = new ServiceRequestContext( InternetMapServer.Instance, interpreter, serviceRequest); InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context); #endregion return(Result(serviceRequest.Response, "text/xml")); }
public IActionResult Legend(string folder, string id) { try { if (folder != DefaultFolder) { throw new Exception("Unknown folder: " + folder); } var interpreter = InternetMapServer.GetInterpreter(typeof(ArcGisServerInterperter)); #region Request ServiceRequest serviceRequest = new ServiceRequest(id, String.Empty) { OnlineResource = InternetMapServer.OnlineResource, Method = "legend" }; #endregion #region Security Identity identity = Identity.FromFormattedString(String.Empty); identity.HashedPassword = String.Empty; serviceRequest.Identity = identity; #endregion #region Queue & Wait IServiceRequestContext context = new ServiceRequestContext( InternetMapServer.Instance, interpreter, serviceRequest); InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context); #endregion return(Result(JsonConvert.DeserializeObject <LegendResponse>(serviceRequest.Response))); } catch (Exception ex) { return(Json(new JsonError() { error = new JsonError.Error() { code = 999, message = ex.Message } })); } }
public IActionResult OgcRequest(string id, string service = "") { try { IServiceRequestInterpreter interpreter = null; switch (service.ToLower().Split(',')[0]) { case "wms": interpreter = InternetMapServer.GetInterpreter(typeof(WMSRequest)); break; case "wfs": interpreter = InternetMapServer.GetInterpreter(typeof(WFSRequest)); break; case "wmts": interpreter = InternetMapServer.GetInterpreter(typeof(WMTSRequest)); break; default: throw new Exception("Missing or unknow service: " + service); } #region Request string requestString = Request.QueryString.ToString(); if (Request.Method.ToLower() == "post" && Request.Body.CanRead) { MemoryStream ms = new MemoryStream(); byte[] bodyData = new byte[1024]; int bytesRead; while ((bytesRead = Request.Body.Read(bodyData, 0, bodyData.Length)) > 0) { ms.Write(bodyData, 0, bytesRead); } string body = Encoding.UTF8.GetString(ms.ToArray()); if (!String.IsNullOrWhiteSpace(body)) { requestString = body; } } while (requestString.StartsWith("?")) { requestString = requestString.Substring(1); } ServiceRequest serviceRequest = new ServiceRequest(id, requestString); serviceRequest.OnlineResource = InternetMapServer.OnlineResource + "/ogc/" + id; #endregion #region Security Identity identity = Identity.FromFormattedString(String.Empty); identity.HashedPassword = String.Empty; serviceRequest.Identity = identity; #endregion IServiceRequestContext context = new ServiceRequestContext( InternetMapServer.Instance, interpreter, serviceRequest); InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context); return(Result(serviceRequest.Response, "text/xml")); } catch (Exception ex) { // ToDo: OgcXmlExcpetion return(Result(ex.Message, "text/plain")); } }
public IActionResult FeatureServerDeleteFeatures(string folder, string id, int layerId) { try { if (folder != DefaultFolder) { throw new Exception("Unknown folder: " + folder); } var interpreter = InternetMapServer.GetInterpreter(typeof(ArcGisServerInterperter)); #region Request JsonFeatureServerEditRequest editRequest = Deserialize <JsonFeatureServerEditRequest>( Request.HasFormContentType ? (IEnumerable <KeyValuePair <string, StringValues> >)Request.Form : (IEnumerable <KeyValuePair <string, StringValues> >)Request.Query); editRequest.LayerId = layerId; ServiceRequest serviceRequest = new ServiceRequest(id, JsonConvert.SerializeObject(editRequest)) { OnlineResource = InternetMapServer.OnlineResource, Method = "featureserver_deletefeatures" }; #endregion #region Security Identity identity = Identity.FromFormattedString(String.Empty); identity.HashedPassword = String.Empty; serviceRequest.Identity = identity; #endregion #region Queue & Wait IServiceRequestContext context = new ServiceRequestContext( InternetMapServer.Instance, interpreter, serviceRequest); InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context); #endregion return(Result(JsonConvert.DeserializeObject <JsonFeatureServerResponse>(serviceRequest.Response))); } catch (Exception ex) { return(Result(new JsonFeatureServerResponse() { DeleteResults = new JsonFeatureServerResponse.JsonResponse[] { new JsonFeatureServerResponse.JsonResponse() { Success = false, Error = new JsonFeatureServerResponse.JsonError() { Code = 999, Description = ex.Message } } } })); } }
public IActionResult Query(string folder, string id, int layerId) { try { if (folder != DefaultFolder) { throw new Exception("Unknown folder: " + folder); } var interpreter = InternetMapServer.GetInterpreter(typeof(ArcGisServerInterperter)); #region Request JsonQueryLayer queryLayer = Deserialize <JsonQueryLayer>( Request.HasFormContentType ? (IEnumerable <KeyValuePair <string, StringValues> >)Request.Form : (IEnumerable <KeyValuePair <string, StringValues> >)Request.Query); queryLayer.LayerId = layerId; ServiceRequest serviceRequest = new ServiceRequest(id, JsonConvert.SerializeObject(queryLayer)) { OnlineResource = InternetMapServer.OnlineResource, Method = "query" }; #endregion #region Security Identity identity = Identity.FromFormattedString(String.Empty); identity.HashedPassword = String.Empty; serviceRequest.Identity = identity; #endregion #region Queue & Wait IServiceRequestContext context = new ServiceRequestContext( InternetMapServer.Instance, interpreter, serviceRequest); InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context); #endregion if (serviceRequest.Succeeded) { if (queryLayer.ReturnCountOnly == true) { return(Result(JsonConvert.DeserializeObject <JsonFeatureCountResponse>(serviceRequest.Response))); } else { return(Result(JsonConvert.DeserializeObject <JsonFeatureResponse>(serviceRequest.Response))); } } else { return(Result(JsonConvert.DeserializeObject <JsonError>(serviceRequest.Response))); } } catch (Exception ex) { return(Json(new JsonError() { error = new JsonError.Error() { code = 999, message = ex.Message } })); } }
public IActionResult MapRequest(string guid, string id) { try { if (IfMatch()) { return(NotModified()); } //DateTime td = DateTime.Now; //Console.WriteLine("Start Map Request " + td.ToLongTimeString() + "." + td.Millisecond + " (" + name + ")"); //System.Threading.Thread.Sleep(10000); //string user, pwd; //var request = Request(out user, out pwd); #region Request string input = String.Empty; if (Request.Body.CanRead) { MemoryStream ms = new MemoryStream(); byte[] bodyData = new byte[1024]; int bytesRead; while ((bytesRead = Request.Body.Read(bodyData, 0, bodyData.Length)) > 0) { ms.Write(bodyData, 0, bytesRead); } input = Encoding.UTF8.GetString(ms.ToArray()); } if (String.IsNullOrEmpty(input)) { input = this.Request.QueryString.ToString(); } if (input.StartsWith("?")) { input = input.Substring(1); } ServiceRequest serviceRequest = new ServiceRequest(id, input); serviceRequest.OnlineResource = InternetMapServer.OnlineResource + "/MapRequest/" + guid + "/" + id; #endregion IServiceRequestInterpreter interpreter = InternetMapServer.GetInterpreter(new Guid(guid)); #region Security Identity identity = Identity.FromFormattedString(String.Empty); identity.HashedPassword = String.Empty; serviceRequest.Identity = identity; #endregion #region Queue & Wait IServiceRequestContext context = new ServiceRequestContext( InternetMapServer.Instance, interpreter, serviceRequest); InternetMapServer.ThreadQueue.AddQueuedThreadSync(interpreter.Request, context); #endregion string ret = serviceRequest.Response; return(Result(ret, "text/xml")); } catch (UnauthorizedAccessException) { return(WriteUnauthorized()); } }