Esempio n. 1
0
 void validateCredentials_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
 {
     ResponseStatusEventArgs args = new ResponseStatusEventArgs();
     if (e.Error == null)
     {
         args._result = "Credentials validate.";
     }
     else
     {
         args._error = e.Error;
     }
     if (this.AsyncValidateCredentialsComplete != null)
     {
         AsyncValidateCredentialsComplete(args);
     }
 }
Esempio n. 2
0
        public ResponseStatusEventArgs ValidateUser()
        {
            ResponseStatusEventArgs args = new ResponseStatusEventArgs();
            try
            {
                WebClient request = new WebClient();

                string url = String.Format("{0}/#", EndpointURI);
                setCredentials(request);
                string result = request.DownloadString(url);

                args._result = "valid";
            }
            catch (Exception ex)
            {
                args._error = ex;
            }
            return args;
        }
Esempio n. 3
0
 private void UploadFilesDataResponse(object webClient, ResponseEventArgs e)
 {
     ResponseStatusEventArgs args = new ResponseStatusEventArgs();
     if (e.Error == null)
     {
         args._result = e.Status;
         args._location = e.Location;
     }
     else
     {
         args._error = e.Error;
     }
     if (this.AsyncUploadFileComplete != null)
         AsyncUploadFileComplete(args);
 }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
        //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;
        }
Esempio n. 10
0
 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;
 }