string uri = @"http://kytcmaps.******.*****.****/ArcGIS/rest/services/MeasuredRoute/MapServer/exts/KYTCGISREST/InCorpBounds"; string url = uri + string.Format("?X={0}&Y={1}&f=pjson", C.X.ToString(), C.Y.ToString()); HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(url); request1.Timeout = 60000; request1.Method = "GET"; string jsonString = string.Empty; using (HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse()) { Stream responseStream1 = response1.GetResponseStream(); using (StreamReader reader1 = new StreamReader(responseStream1)) { jsonString = reader1.ReadToEnd(); reader1.Close(); } } CityInfo CI = JsonConvert.DeserializeObject<CityInfo>(jsonString);
using (System.Net.WebClient client = new System.Net.WebClient()) { client.Headers["Content-type"] = "application/x-www-form-urlencoded"; client.Encoding = System.Text.Encoding.UTF8; var collection = new System.Collections.Specialized.NameValueCollection { {"f", "json"}, {"Token", System.Configuration.ConfigurationManager.AppSettings["TOKEN"]}, {"features", featureParam} }; byte[] response = client.UploadValues(reqUrl, "POST", collection); MemoryStream stream = new MemoryStream(response); StreamReader reader = new StreamReader(stream); string aRespStr = reader.ReadToEnd(); JavaScriptSerializer jss = new JavaScriptSerializer(); AddResults addResults = jss.Deserialize<AddResults>(aRespStr); if (addResults == null) { GenericError error = jss.Deserialize<GenericError>(aRespStr); return false; } return addResults.addResults.All(addResult=> addResult.success); } public class Result { public int objectId { get; set; } public object globalId { get; set; } public bool success { get; set; } public Error error { get; set; } } public class AddResults { public List<Result> addResults { get; set; } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.