private static string CleanObjectIds(IEnumerable <int> objectIds) { return(objectIds == null ? "" : Compatibility.UrlEncode(string.Join(",", objectIds))); }
private static T GetResponse <T>(string url, string data, ICredentials credentials, Token token, string gdbVersion) where T : Response { var parameters = new Dictionary <string, object> { { "token", token }, { "gdbVersion", gdbVersion }, { "f", "json" } }; var queryString = string.Join("&", parameters.Where(p => p.Value != null).Select(p => $"{p.Key}={Compatibility.UrlEncode(p.Value.ToString())}")); var isPost = data != null; var url2 = isPost ? url : url + "?" + queryString; var requestText = isPost ? data + "&" + queryString : ""; string responseText = null; try { var requestModifier = credentials == null ? (Action <HttpWebRequest>)null : r => r.Credentials = credentials; responseText = isPost ? Http.Post(url2, requestText, requestModifier) : Http.Get(url2, requestModifier); var response = responseText.Deserialize <T>(); var errorMessage = "ArcGIS Server returned an error response."; if (response.error != null) { throw new InvalidOperationException(errorMessage); } var resultSet = response as EditResultSet; if (resultSet != null && new[] { resultSet.addResults, resultSet.updateResults, resultSet.deleteResults }.Any(results => results == null || results.Any(r => !r.success))) { throw new InvalidOperationException(errorMessage); } return(response); } catch (Exception ex) { throw new RestException(url2, requestText, responseText, $"An error occurred while processing a request against '{url2}'.", ex); } }
private static string CleanWhereClause(string whereClause) { return(Compatibility.UrlEncode(string.IsNullOrWhiteSpace(whereClause) ? "1=1" : whereClause)); }
static Service() { Compatibility.EnableTls12(); }