public string createMap(string options) { try { GeoComWebClient request = new GeoComWebClient(); string url = String.Format("{0}/maps.json", EndpointURI); var result = request.Post(url, UserName, Password, "application/x-www-form-urlencoded", options); return result; } catch { return ""; } }
private void setCredentials(GeoComWebClient request) { if (!String.IsNullOrEmpty(UserName) && !String.IsNullOrEmpty(Password)) { string authInfo = UserName + ":" + Password; authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(UserName + ":" + Password)); request.Headers["Authorization"] = "Basic " + authInfo; } }
public AnalyticsResponse Union(int overlayid1, int overlayid2, MergeOptions merge) { AnalyticsResponse retval = null; try { GeoComWebClient request = new GeoComWebClient(); string mergestring = Enum.GetName(typeof(MergeOptions), merge); string url = String.Format(_unionTemplate, EndpointURI, overlayid1, overlayid2, mergestring); setCredentials(request); //validateFileType(files); string response = request.Post(url, UserName, Password, "application/json", ""); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(GeoIQ.Net.Data.AnalyticsResponse)); byte[] bytes = Encoding.ASCII.GetBytes(response); System.IO.MemoryStream stream = new System.IO.MemoryStream(bytes); stream.Position = 0; GeoIQ.Net.Data.AnalyticsResponse result = (GeoIQ.Net.Data.AnalyticsResponse)serializer.ReadObject(stream); retval = result; } catch (Exception ex) { this.LastError = ex; retval = null; } return retval; }
public void UploadFileAsync(string[] files) { GeoComWebClient request = new GeoComWebClient(); string url = String.Format("{0}/datasets.xml", EndpointURI); setCredentials(request); validateFileType(files); request.GeoComResponseReceived += new GeoComWebClient.GeoComAsyncReturn(UploadFilesDataResponse); request.UploadFilesAsync(url, files); }
public ResponseStatusEventArgs UploadFile(string[] files, string[] tags, string title) { ResponseStatusEventArgs args = new ResponseStatusEventArgs(); try { string parms = ""; string tags2 = ""; string title2 = ""; List<string> parmlist = new List<string>(); if (tags != null) { tags2 = "tags=" + String.Join("%20", tags); parmlist.Add(tags2); } if (title != null) { title2 = "name=" + title; parmlist.Add(title2); } if (parmlist.Count > 0) { parms = "?"; var tmp = String.Join("&", parmlist.ToArray()); parms += tmp; } GeoComWebClient request = new GeoComWebClient(); string url = String.Format("{0}/datasets.json" + parms, EndpointURI); setCredentials(request); validateFileType(files); ResponseEventArgs response = request.UploadFiles(url, files); args._result = response.Status; try { args._location = response.Location; } catch { } } catch (Exception ex) { args._error = ex; } return args; }
public ResponseStatusEventArgs UploadFile(string[] files, string[] tags) { ResponseStatusEventArgs args = new ResponseStatusEventArgs(); try { string parms = ""; if (tags != null) { parms = "?tags=" + String.Join("%20", tags); } GeoComWebClient request = new GeoComWebClient(); string url = String.Format("{0}/datasets.json" + parms, EndpointURI); setCredentials(request); validateFileType(files); ResponseEventArgs response = request.UploadFiles(url, files); args._result = response.Status; try { args._location = response.Location; } catch { } } catch (Exception ex) { args._error = ex; } return args; }
public ResponseStatusEventArgs UpdateTitle(string overlayUrl, string title) { ResponseStatusEventArgs args = new ResponseStatusEventArgs(); try { GeoComWebClient request = new GeoComWebClient(); string url = overlayUrl + "?title=" + title; setCredentials(request); //validateFileType(files); ResponseEventArgs response = request.Put(url, ""); args._result = response.Status; args._location = response.Location; } catch (Exception ex) { args._error = ex; } return args; }
public ResponseStatusEventArgs UpdateTitle(int overlayid, string title) { ResponseStatusEventArgs args = new ResponseStatusEventArgs(); try { GeoComWebClient request = new GeoComWebClient(); string url = String.Format("{0}/datasets/{1}.json?title={2}", EndpointURI, overlayid, title); setCredentials(request); //validateFileType(files); ResponseEventArgs response = request.Put(url, ""); args._result = response.Status; args._location = response.Location; } catch (Exception ex) { args._error = ex; } return args; }
public ResponseStatusEventArgs UpdateTags(int overlayid, List<string> taglist) { ResponseStatusEventArgs args = new ResponseStatusEventArgs(); try { GeoComWebClient request = new GeoComWebClient(); string url = String.Format("{0}/datasets/{1}.json?tags=", EndpointURI, overlayid); string tags = String.Join("%20", taglist.ToArray()); url += tags; setCredentials(request); //validateFileType(files); ResponseEventArgs response = request.Put(url, ""); args._result = response.Status; args._location = response.Location; } catch (Exception ex) { args._error = ex; } return args; }
//compiler directive to prevent synchronous method //from being made available if library is compiled for Silverlight public ResponseStatusEventArgs Delete(int overlayID) { ResponseStatusEventArgs args = new ResponseStatusEventArgs(); try { GeoComWebClient request = new GeoComWebClient(); string url = String.Format("{0}/datasets/{1}.json", EndpointURI, overlayID); setCredentials(request); //validateFileType(files); ResponseEventArgs response = request.Delete(url, UserName, Password, "application/json"); args._result = response.Status; //args._location = response.Location; } catch { } return args; }
public ResponseStatusEventArgs deleteMap(int mapid) { ResponseStatusEventArgs args = new ResponseStatusEventArgs(); try { GeoComWebClient request = new GeoComWebClient(); string url = String.Format("{0}/maps/{1}.json", EndpointURI, mapid); var result = request.Delete(url, UserName, Password, "application/json"); args._result = result.Status; } catch (Exception ex) { throw ex; } return args; }
public string getSession() { try { GeoComWebClient request = new GeoComWebClient(); string url = String.Format("{0}/sessions.json", EndpointURI); var result = request.GetCookie(url, this.UserName, this.Password); return result; } catch { return ""; } }