${REST_GetFeaturesByIDsParameters_Title}

${REST_GetFeaturesByIDsParameters_Description}

Inheritance: GetFeaturesParametersBase
コード例 #1
0
        private async void GetFeaturesByIDsBtn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(MyTextBox.Text) || string.IsNullOrWhiteSpace(MyTextBox.Text))
            {
                await MessageBox.Show("请输入查询条件");
                return;
            }
            //用逗号和空格分开的都行。
            string[] str = MyTextBox.Text.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (str.Length <= 0)
            {
                await MessageBox.Show("请输入查询条件");
                return;
            }
            List<int> ids = new List<int>();

            for (int i = 0; i < str.Length; i++)
            {
                int value = -1;
                if (Int32.TryParse(str[i], out value))
                {
                    ids.Add(value);
                }
                else
                {
                    await MessageBox.Show("ID必须为数字");
                    return;
                }
            }
            GetFeaturesByIDsParameters param = new GetFeaturesByIDsParameters
            {
                DatasetNames = new List<string> { "World:Capitals" },
                IDs = ids
            };
            //与服务器交互
            try
            {
                GetFeaturesByIDsService ser = new GetFeaturesByIDsService(url);
                var result = await ser.ProcessAsync(param);
                flayer.ClearFeatures();
                if (result != null)
                {
                    flayer.AddFeatureSet(result.Features);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        /// <summary>${REST_GetFeaturesByIDsService_method_ProcessAsync_D}</summary>
        /// <param name="parameters">${REST_GetFeaturesByIDsService_method_ProcessAsync_param_Parameters}</param>
        /// <param name="state">${REST_GetFeaturesByIDsService_method_ProcessAsync_param_state}</param>
        public async Task<GetFeaturesResult> ProcessAsync(GetFeaturesByIDsParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(ExceptionStrings.ArgumentIsNull);
            }
            if (string.IsNullOrEmpty(this.Url))
            {
                throw new InvalidOperationException(ExceptionStrings.InvalidUrl);
            }
            //base.Url += ".json?returnContent=true";
            base.Url += string.Format(".json?returnContent=true&debug=true&fromIndex={0}&toIndex={1}", parameters.FromIndex, parameters.ToIndex);

            var result = await base.SubmitRequest(base.Url, GetParameters(parameters), true);
            JsonObject jsonObject = JsonObject.Parse(result);
            return GetFeaturesResult.FromJson(jsonObject);
        }
コード例 #3
0
        private Dictionary<string, string> GetParameters(GetFeaturesByIDsParameters parameters)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            dictionary.Add("getFeatureMode", "\"ID\"");

            if (parameters.DatasetNames != null && parameters.DatasetNames.Count > 0)
            {
                string jsonDatasetNames = "[";
                List<string> list = new List<string>();
                for (int i = 0; i < parameters.DatasetNames.Count; i++)
                {
                    list.Add(string.Format("\"{0}\"", parameters.DatasetNames[i]));
                }
                jsonDatasetNames += string.Join(",", list.ToArray());
                jsonDatasetNames += "]";

                dictionary.Add("datasetNames", jsonDatasetNames);
            }
            if (parameters.IDs != null && parameters.IDs.Count > 0)
            {
                string jsonIDs = "[";
                List<string> list = new List<string>();
                for (int i = 0; i < parameters.IDs.Count; i++)
                {
                    list.Add(parameters.IDs[i].ToString());
                }
                jsonIDs += string.Join(",", list.ToArray());
                jsonIDs += "]";

                dictionary.Add("ids", jsonIDs);
            }

            if (parameters.Fields != null && parameters.Fields.Count > 0)
            {
                FilterParameter fp = new FilterParameter();
                fp.Fields = parameters.Fields;
                dictionary.Add("queryParameter", FilterParameter.ToJson(fp));
            }
            return dictionary;
        }