コード例 #1
0
ファイル: ArcIMSController.cs プロジェクト: jugstalt/gview5
        async public Task <IActionResult> EsriMap(string cmd, string ServiceName, string content)
        {
            return(await SecureMethodHandler(async (identity) =>
            {
                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 = _mapServerService.GetInterpreter(typeof(ArcXMLRequest));

                #region Request

                if (String.IsNullOrEmpty(content))
                {
                    content = await GetBody();
                }

                ServiceRequest serviceRequest = new ServiceRequest(ServiceName.ServiceName(), ServiceName.FolderName(), content)
                {
                    Identity = identity,
                    OnlineResource = _mapServerService.Options.OnlineResource,
                    OutputUrl = _mapServerService.Options.OutputUrl,
                };

                #endregion

                #region Queue & Wait

                IServiceRequestContext context = await ServiceRequestContext.TryCreate(
                    _mapServerService.Instance,
                    interpreter,
                    serviceRequest,
                    checkSecurity: ServiceName.ToLower() != "catalog");

                await _mapServerService.TaskQueue.AwaitRequest(interpreter.Request, context);

                #endregion

                return Result(serviceRequest.ResponseAsString, "text/xml");
            }));
        }
コード例 #2
0
        // https://localhost:44331/tilewmts/tor_tiles/compact/ul/31256/default/8/14099/16266.jpg
        async public Task <IActionResult> TileWmts(string name, string cachetype, string origin, string epsg, string style, string level, string row, string col, string folder = "")
        {
            if (IfMatch())
            {
                return(base.NotModified());
            }

            #region Security

            Identity identity = Identity.FromFormattedString(_loginMananger.GetAuthToken(this.Request).Username);

            #endregion

            var interpreter = _mapServiceMananger.GetInterpreter(typeof(WMTSRequest));

            #region Request

            string requestString = cachetype + "/" + origin + "/" + epsg + "/" + style + "/~" + level + "/" + row + "/" + col;

            ServiceRequest serviceRequest = new ServiceRequest(name, folder, requestString)
            {
                OnlineResource = _mapServiceMananger.Options.OnlineResource + "/ogc/" + name,
                OutputUrl      = _mapServiceMananger.Options.OutputUrl,
                Identity       = identity
            };

            #endregion

            IServiceRequestContext context = await ServiceRequestContext.TryCreate(
                _mapServiceMananger.Instance,
                interpreter,
                serviceRequest);

            //await interpreter.Request(context);
            await _mapServiceMananger.TaskQueue.AwaitRequest(interpreter.Request, context);

            var imageData = serviceRequest.Response as byte[];
            if (imageData != null)
            {
                if (serviceRequest.ResponseExpries.HasValue)
                {
                    base.AppendEtag(serviceRequest.ResponseExpries.Value);
                }

                return(Result(imageData, serviceRequest.ResponseContentType));
            }

            return(null);
        }
コード例 #3
0
        async public Task <IActionResult> MapRequest(string guid, string name, string folder)
        {
            try
            {
                if (IfMatch())
                {
                    return(NotModified());
                }

                #region Security

                Identity identity = Identity.FromFormattedString(_loginMananger.GetAuthToken(this.Request).Username);

                #endregion

                if (!String.IsNullOrWhiteSpace(folder))
                {
                    name = folder + "/" + name;
                }

                //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 = await GetBody();

                if (String.IsNullOrEmpty(input))
                {
                    input = this.Request.QueryString.ToString();
                }

                if (input.StartsWith("?"))
                {
                    input = input.Substring(1);
                }

                ServiceRequest serviceRequest = new ServiceRequest(name.ServiceName(), name.FolderName(), input)
                {
                    OnlineResource = _mapServiceManager.Options.OnlineResource + "/MapRequest/" + guid + "/" + name,
                    OutputUrl      = _mapServiceManager.Options.OutputUrl,
                    Identity       = identity
                };

                #endregion

                IServiceRequestInterpreter interpreter =
                    _mapServiceManager.GetInterpreter(new Guid(guid));

                #region Queue & Wait

                IServiceRequestContext context = await ServiceRequestContext.TryCreate(
                    _mapServiceManager.Instance,
                    interpreter,
                    serviceRequest);

                await _mapServiceManager.TaskQueue.AwaitRequest(interpreter.Request, context);

                #endregion

                string ret = serviceRequest.ResponseAsString;

                return(Result(ret, "text/xml"));
            }
            catch (MapServerException mse)
            {
                return(WriteError(mse.Message));
            }
            catch (UnauthorizedAccessException)
            {
                return(WriteUnauthorized());
            }
        }
コード例 #4
0
        async public Task <IActionResult> OgcRequest(string id, string service = "")
        {
            try
            {
                #region Security

                Identity identity = Identity.FromFormattedString(_loginMananger.GetAuthToken(this.Request).Username);

                #endregion

                IServiceRequestInterpreter interpreter = null;

                switch (service.ToLower().Split(',')[0])
                {
                case "wms":
                    interpreter = _mapServiceMananger.GetInterpreter(typeof(WMSRequest));
                    break;

                case "wfs":
                    interpreter = _mapServiceMananger.GetInterpreter(typeof(WFSRequest));
                    break;

                case "wmts":
                    interpreter = _mapServiceMananger.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)
                {
                    string body = await GetBody();

                    if (!String.IsNullOrWhiteSpace(body))
                    {
                        requestString = body;
                    }
                }

                while (requestString.StartsWith("?"))
                {
                    requestString = requestString.Substring(1);
                }

                ServiceRequest serviceRequest = new ServiceRequest(id.ServiceName(), id.FolderName(), requestString)
                {
                    OnlineResource = _mapServiceMananger.Options.OnlineResource + "/ogc/" + id,
                    OutputUrl      = _mapServiceMananger.Options.OutputUrl,
                    Identity       = identity
                };

                #endregion

                IServiceRequestContext context = await ServiceRequestContext.TryCreate(
                    _mapServiceMananger.Instance,
                    interpreter,
                    serviceRequest);


                await _mapServiceMananger.TaskQueue.AwaitRequest(interpreter.Request, context);

                var response = serviceRequest.Response;

                if (response is byte[])
                {
                    return(Result((byte[])response, serviceRequest.ResponseContentType));
                }

                return(Result(response?.ToString() ?? String.Empty, serviceRequest.ResponseContentType));
            }
            catch (Exception ex)
            {
                // ToDo: OgcXmlExcpetion
                return(Result(ex.Message, "text/plain"));
            }
        }