${iServer2_AddEntityParameters_Title}

${iServer2_AddEntityParameters_Description}

Inheritance: ParametersBase
        /// <summary>${iServer2_AddEntityService_method_ProcessAsync_D}</summary>
        /// <param name="parameters">${iServer2_AddEntityService_method_ProcessAsync_param_parameters}</param>
        /// <param name="state">${iServer2_AddEntityService_method_ProcessAsync_param_state}</param>
        public void ProcessAsync(AddEntityParameters parameters, object state)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(ExceptionStrings.ArgumentIsNull);
            }
            if (string.IsNullOrEmpty(base.Url))
            {
                throw new InvalidOperationException(ExceptionStrings.InvalidUrl);
            }

            if (!base.Url.EndsWith("/"))
            {
                base.Url += '/';
            }

            base.SubmitRequest(base.Url + "commonhandler?", GetParameters(parameters),
                new EventHandler<RequestEventArgs>(request_Completed), state, false);
        }
        //将地物添加到图层中
        private void polygon_DrawCompleted(object sender, DrawEventArgs e)
        {
            //将绘制的地物显示在FeaturesLayer中
            GeoRegion region = e.Geometry as GeoRegion;
            Feature f = new Feature();
            f.Geometry = region;
            f.Style = new PredefinedFillStyle() { Fill = new SolidColorBrush(Colors.Green) };
            drawLayer.Features.Add(f);

            //记录所绘制地物的点坐标
            Point2DCollection ps = new Point2DCollection();
            for (int i = 0; i < region.Parts.Count; i++)
            {
                for (int j = 0; j < region.Parts[i].Count; j++)
                {
                    ps.Add(new Point2D(region.Parts[i][j].X, region.Parts[i][j].Y));
                }
            }

            //将客户端地物转换成服务端几何类型
            ServerGeometry Addshape = new ServerGeometry
               {
               Feature = ServerFeatureType.Polygon,
               Point2Ds = ps
               };

            Entity entity = new Entity
            {
                Shape = Addshape
            };

            AddEntityParameters parameters = new AddEntityParameters
            {
                MapName = "Changchun",
                LayerName = "Vegetable@Changchun",
                Entity = entity
            };

            //与服务器交互
            AddEntityService editService = new AddEntityService("http://localhost:7080/demo");
            editService.ProcessAsync(parameters);
            editService.Failed += new EventHandler<ServiceFailedEventArgs>(Service_Failed);
            editService.ProcessCompleted += new EventHandler<EditEventArgs>(Service_ProcessCompleted);
        }
        private Dictionary<string, string> GetParameters(AddEntityParameters parameters)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            string method = "AddEntity";
            dictionary.Add("method", method);
            dictionary.Add("mapName", parameters.MapName);

            Dictionary<string, string> dict = new Dictionary<string, string>();
            dict.Add("mapName", parameters.MapName);
            dict.Add("layerName", parameters.LayerName);
            dict.Add("entities", Entity.ToJson(parameters.Entity));

            dict.Add("lockID", DateTime.Now.Ticks.ToString());
            dictionary.Add("params", Bridge.CreateParams(method, dict));

            return dictionary;
        }
 /// <overloads>${iServer2_AddEntityService_method_ProcessAsync_overloads_D}</overloads>
 /// <summary>${iServer2_AddEntityService_method_ProcessAsync_D}</summary>
 /// <param name="parameters">${iServer2_AddEntityService_method_ProcessAsync_param_parameters}</param>
 public void ProcessAsync(AddEntityParameters parameters)
 {
     ProcessAsync(parameters, null);
 }