Exemplo n.º 1
0
        private List <IFeature> GetFeatures(IFeatureClass featureClass, JsonFeatureServerEditRequest editRequest)
        {
            List <IFeature> features = new List <IFeature>();

            foreach (var jsonFeature in editRequest.Features)
            {
                features.Add(ToFeature(featureClass, jsonFeature));
            }

            return(features);
        }
Exemplo n.º 2
0
        private IFeatureClass GetFeatureClass(IServiceMap serviceMap, JsonFeatureServerEditRequest editRequest)
        {
            string filterQuery;

            var tableClasses = FindTableClass(serviceMap, editRequest.LayerId.ToString(), out filterQuery);

            if (tableClasses.Count > 1)
            {
                throw new Exception("FeatureService can't be used with aggregated feature classes");
            }
            if (tableClasses.Count == 0 || !(tableClasses[0] is IFeatureClass))
            {
                throw new Exception("FeatureService can only used with feature classes");
            }

            var featureClass = (IFeatureClass)tableClasses[0];

            return(featureClass);
        }
Exemplo n.º 3
0
        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
                            }
                        }
                    }
                }));
            }
        }