${iServer2_Query_ResultSet_Title}

${iServer2_Query_ResultSet_Description}

예제 #1
0
        /// <summary>${iServer2_ResultSet_method_FromJson_D}</summary>
        /// <returns>${iServer2_ResultSet_method_FromJson_return}</returns>
        /// <param name="jsonObject">${iServer2_ResultSet_method_FromJson_param_jsonObject}</param>
        public static ResultSet FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }

            ResultSet resultSet = new ResultSet();
            resultSet.TotalCount = (int)jsonObject["totalCount"];
            if (resultSet.TotalCount == 0)
            {
                return null;
            }//如果为0,认为结果为空?
            resultSet.CurrentCount = (int)jsonObject["currentCount"];
            resultSet.CustomResponse = (string)jsonObject["customResponse"];

            JsonArray recordSets = (JsonArray)jsonObject["recordSets"];
            if (recordSets != null && recordSets.Count > 0)
            {
                resultSet.RecordSets = new List<RecordSet>();
                for (int i = 0; i < recordSets.Count; i++)
                {
                    resultSet.RecordSets.Add(RecordSet.FromJson((JsonObject)recordSets[i]));
                }
            }
            return resultSet;
        }
 private void request_Completed(object sender, RequestEventArgs e)
 {
     JsonObject jsonObject = (JsonObject)JsonObject.Parse(e.Result);
     ResultSet result = ResultSet.FromJson(jsonObject);
     LastResult = result;
     QueryEventArgs args = new QueryEventArgs(result, e.Result, e.UserState);
     OnProcessCompleted(args);
 }
        // showResult 函数将查询结果在DataGrid控件和地图中显示
        private void ShowResult(ResultSet result)
        {
            // 显示或隐藏相关控件
            DataStackPanel.Visibility = Visibility.Visible;
            worldScroll.Visibility = Visibility.Collapsed;
            world.Visibility = Visibility.Collapsed;
            continentScroll.Visibility = Visibility.Collapsed;
            continent.Visibility = Visibility.Collapsed;
            capital.Visibility = Visibility.Collapsed;
            capitalScroll.Visibility = Visibility.Collapsed;

            //结果为空
            if (result == null)
            {
                MessageBox.Show("No Result!");
                return;
            }

            //遍历全部结果记录集
            foreach (RecordSet item in result.RecordSets)
            {
                //获取"Capital@world"图层上查询的结果并进行显示
                if (item.LayerName == PointLayerName)
                {
                    capitalScroll.Visibility = Visibility.Visible;
                    capital.Visibility = Visibility.Visible;
                    List<CapitalData> listCapital = new List<CapitalData>();

                    //将记录集中的每条记录转换成矢量要素,对其进行遍历,并将矢量要素在地图和DataGrid控件中显示
                    foreach (Feature feature in item.ToFeatureSet())
                    {
                        featuresLayer.Features.Add(feature);

                        listCapital.Add(new CapitalData
                        {
                            SmID = feature.Attributes["SmID"].ToString(),
                            SmX = feature.Attributes["SmX"].ToString(),
                            SmY = feature.Attributes["SmY"].ToString(),
                            Capital = feature.Attributes["Capital"].ToString(),
                            Country = feature.Attributes["Country"].ToString(),
                            Cap_Pop = feature.Attributes["Cap_Pop"].ToString()
                        });
                    }
                    capital.ItemsSource = listCapital;
                }

                //获取"Continent_Lable@world"图层上查询的结果并进行显示
                if (item.LayerName == LineLayerName)
                {
                    continentScroll.Visibility = Visibility.Visible;
                    continent.Visibility = Visibility.Visible;
                    List<ContinentData> listContinent = new List<ContinentData>();

                    //将记录集中的每条记录转换成矢量要素,对其进行遍历,并将矢量要素在地图和DataGrid控件中显示
                    foreach (Feature feature in item.ToFeatureSet())
                    {
                        featuresLayer.Features.Add(feature);

                        listContinent.Add(new ContinentData
                        {
                            SmID = feature.Attributes["SmID"].ToString(),
                            SmLength = feature.Attributes["SmLength"].ToString(),
                            CONTINENT = feature.Attributes["CONTINENT"].ToString(),
                            id = feature.Attributes["id"].ToString()

                        });
                    }
                    continent.ItemsSource = listContinent;
                }

                //获取"World@world"图层上查询的结果并进行显示
                if (item.LayerName == AreaLayerName)
                {
                    worldScroll.Visibility = Visibility.Visible;
                    world.Visibility = Visibility.Visible;
                    List<WorldData> listWorld = new List<WorldData>();

                    //将记录集中的每条记录转换成矢量要素,对其进行遍历,并将矢量要素在地图和DataGrid控件中显示
                    foreach (Feature feature in item.ToFeatureSet())
                    {
                        featuresLayer.Features.Add(feature);

                        listWorld.Add(new WorldData
                        {
                            SmID = feature.Attributes["SmID"].ToString(),
                            SmUserID = feature.Attributes["SmUserID"].ToString(),
                            SmArea = feature.Attributes["SmArea"].ToString(),
                            SmPerimeter = feature.Attributes["SmPerimeter"].ToString(),
                            COLOR_MAP = feature.Attributes["COLOR_MAP"].ToString(),
                            Country = feature.Attributes["Country"].ToString()
                        });
                    }
                    world.ItemsSource = listWorld;
                }
            }
        }
 /// <summary>${iServer2_QueryEventArgs_constructor_D}</summary>
 public QueryEventArgs(ResultSet resultSet, string originResult, object userToken)
     : base(userToken)
 {
     ResultSet = resultSet;
     OriginResult = originResult;
 }
        //showResult 函数将查询结果在DataGrid控件和地图中显示
        private void ShowResult(ResultSet result)
        {
            //显示或隐藏相关控件
            DataStackPanel.Visibility = Visibility.Visible;
            SchoolScroll.Visibility = Visibility.Collapsed;
            dgSchool.Visibility = Visibility.Collapsed;
            ResidentialScroll.Visibility = Visibility.Collapsed;
            dgResidential.Visibility = Visibility.Collapsed;
            dgRoad.Visibility = Visibility.Collapsed;
            RoadScroll.Visibility = Visibility.Collapsed;

            //结果为空
            if (result == null)
            {
                MessageBox.Show("No Result!");
                return;
            }

            //遍历全部结果记录集
            foreach (RecordSet item in result.RecordSets)
            {
                //获取“School@changchun”图层上查询的结果并进行显示
                if (item.LayerName == PointLayerName)
                {
                    SchoolScroll.Visibility = Visibility.Visible;
                    dgSchool.Visibility = Visibility.Visible;
                    List<SchoolData> listSchool = new List<SchoolData>();

                    //将记录集中的每条记录转换成矢量要素,对其进行遍历,并将矢量要素在地图和DataGrid控件中显示
                    foreach (Feature feature in item.ToFeatureSet())
                    {
                        featuresLayer.Features.Add(feature);

                        listSchool.Add(new SchoolData
                        {
                            SmID = feature.Attributes["SmID"].ToString(),
                            SmUserID = feature.Attributes["SmUserID"].ToString(),
                            name = feature.Attributes["name"].ToString(),
                            X = feature.Attributes["X"].ToString(),
                            Y = feature.Attributes["Y"].ToString(),
                            SmX = feature.Attributes["SmX"].ToString(),
                            SmY = feature.Attributes["SmY"].ToString()
                        });
                    }
                    dgSchool.ItemsSource = listSchool;
                }

                //获取"Railway@changchun"图层上查询的结果并进行显示
                if (item.LayerName == LineLayerName)
                {
                    RoadScroll.Visibility = Visibility.Visible;
                    dgRoad.Visibility = Visibility.Visible;
                    List<RoadData> listData = new List<RoadData>();

                    //将记录集中的每条记录转换成矢量要素,对其进行遍历,并将矢量要素在地图和DataGrid控件中显示
                    foreach (Feature feature in item.ToFeatureSet())
                    {
                        featuresLayer.Features.Add(feature);

                        listData.Add(new RoadData
                        {
                            SmID = feature.Attributes["SmID"].ToString(),
                            SmUserID = feature.Attributes["SmUserID"].ToString(),
                            Name = feature.Attributes["Name"].ToString(),
                            SmLength = feature.Attributes["SmLength"].ToString(),

                        });
                    }
                    dgRoad.ItemsSource = listData;
                }

                //获取"ResidentialArea@changchun"图层上查询的结果并进行显示
                if (item.LayerName == AreaLayerName)
                {
                    ResidentialScroll.Visibility = Visibility.Visible;
                    dgResidential.Visibility = Visibility.Visible;
                    List<ResidentialData> listResidential = new List<ResidentialData>();

                    //将记录集中的每条记录转换成矢量要素,对其进行遍历,并将矢量要素在地图和DataGrid控件中显示
                    foreach (Feature feature in item.ToFeatureSet())
                    {
                        featuresLayer.Features.Add(feature);

                        listResidential.Add(new ResidentialData
                        {
                            SmID = feature.Attributes["SmID"].ToString(),
                            SmUserID = feature.Attributes["SmUserID"].ToString(),
                            SmArea = feature.Attributes["SmArea"].ToString(),
                            SmPerimeter = feature.Attributes["SmPerimeter"].ToString(),
                            ClassID = feature.Attributes["ClassID"].ToString(),
                        });
                    }
                    dgResidential.ItemsSource = listResidential;
                }
            }
        }