Esempio n. 1
0
        private byte[] GetFeaturesOperHandler(NameValueCollection boundVariables,
                                              JsonObject operationInput,
                                              string outputFormat,
                                              string requestProperties,
                                              out string responseProperties)
        {
            responseProperties = null;

            JsonObject joConn;
            bool       found = operationInput.TryGetJsonObject("connectionString", out joConn);

            if (!found || joConn == null)
            {
                throw new ArgumentNullException("connectionString");
            }

            JsonObject joFC;

            found = operationInput.TryGetJsonObject("featureClass", out joFC);
            if (!found || joFC == null)
            {
                throw new ArgumentNullException("featureClass");
            }

            JsonObject joFilter;

            found = operationInput.TryGetJsonObject("filterWhere", out joFilter);
            if (!found || joFilter == null)
            {
                throw new ArgumentNullException("filterWhere");
            }

            JsonObject result = new JsonObject();

            ConnectionJSObject   connJsObj = ParamsParser.ParseConn(joConn);
            FeatureClassJSObject fcObj     = ParamsParser.ParseFeatrureClass(joFC);
            FilterWhereJSObject  filterObj = ParamsParser.ParseFilterWhere(joFilter);

            List <FeatureObject> features;
            string         outMsg = string.Empty;
            FeaturesHelper helper = new FeaturesHelper();

            features = helper.GetFeatures(connJsObj, fcObj, filterObj, out outMsg);
            List <JsonObject> featureList = new List <JsonObject>();

            foreach (FeatureObject fo in features)
            {
                JsonObject jo = new JsonObject();
                jo.AddArray("attributes", fo.attributes.ToArray());
                jo.AddJsonObject("geometry", Conversion.ToJsonObject(fo.geometry));
                featureList.Add(jo);
            }
            result.AddArray("features", featureList.ToArray());
            result.AddString("outMsg", outMsg);

            return(Encoding.UTF8.GetBytes(result.ToJson()));
        }
Esempio n. 2
0
        private byte[] DeleteFeaturesOperHandler(NameValueCollection boundVariables,
                                                 JsonObject operationInput,
                                                 string outputFormat,
                                                 string requestProperties,
                                                 out string responseProperties)
        {
            responseProperties = null;

            JsonObject joConn;
            bool       found = operationInput.TryGetJsonObject("connectionString", out joConn);

            if (!found || joConn == null)
            {
                throw new ArgumentNullException("connectionString can not parse to jsonobject");
            }

            JsonObject joFC;

            found = operationInput.TryGetJsonObject("featureClass", out joFC);
            if (!found || joFC == null)
            {
                throw new ArgumentNullException("featureClass can not parse to jsonobject");
            }

            JsonObject joFilter;

            found = operationInput.TryGetJsonObject("filterWhere", out joFilter);
            if (!found || joFilter == null)
            {
                throw new ArgumentNullException("filterWhere can not parse to jsonobject");
            }

            JsonObject result = new JsonObject();

            ConnectionJSObject   connJsObj = ParamsParser.ParseConn(joConn);
            FeatureClassJSObject fcObj     = ParamsParser.ParseFeatrureClass(joFC);
            FilterWhereJSObject  filterObj = ParamsParser.ParseFilterWhere(joFilter);

            bool           isok   = false;
            int            count  = 0;
            string         outMsg = string.Empty;
            FeaturesHelper helper = new FeaturesHelper();

            isok = helper.DeleteFeatures(connJsObj, fcObj, filterObj, out count, out outMsg);
            result.AddBoolean("isSucess", isok);
            result.AddLong("recordCount", count);
            result.AddString("outMsg", outMsg);

            return(Encoding.UTF8.GetBytes(result.ToJson()));
        }