Exemplo n.º 1
0
        private void KMLWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                HttpWebRequest req;
                req           = (HttpWebRequest)WebRequest.Create(AppConfig.MapServerURL);
                req.Method    = WebRequestMethods.Http.Get;
                req.KeepAlive = true;
                req.Accept    = accept;
                req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                HttpWebResponse webResponse    = (HttpWebResponse)req.GetResponse();
                Stream          responseStream = webResponse.GetResponseStream();
                StreamReader    streamReader   = new StreamReader(responseStream);
                string          s = streamReader.ReadToEnd();
                streamReader.Close();
                responseStream.Close();
                features = FeatureCollection.FromString(s);

                this.RunOnUiThread(delegate
                {
                    errorView.Visibility = ViewStates.Invisible;
                });
            }
            catch (Exception ex)
            {
                this.RunOnUiThread(delegate
                {
                    errorView.Visibility = ViewStates.Visible;
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Issues GET to map server to get list of features.
        /// </summary>
        private void KML_DoWork()
        {
            try
            {
                string urlToUse = _watchTowerSettings.MapServerUrl;

                HttpWebRequest req;
                req           = (HttpWebRequest)WebRequest.Create(urlToUse);
                req.Method    = WebRequestMethods.Http.Get;
                req.KeepAlive = true;
                req.Accept    = accept;
                req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                HttpWebResponse webResponse    = (HttpWebResponse)req.GetResponse();
                Stream          responseStream = webResponse.GetResponseStream();
                StreamReader    streamReader   = new StreamReader(responseStream);
                string          s = streamReader.ReadToEnd();
                streamReader.Close();
                responseStream.Close();
                features = FeatureCollection.FromString(s);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());

                // Error reading features.  Clear out collection so we're not showing stale data
                features = null;
            }
        }