Ejemplo n.º 1
0
        /// <summary>
        /// Loads and displayes the cached capabilities for the server.
        /// </summary>
        private bool LoadCachedCapabilities(WmsServer server)
        {
            var capabilities = WmsCapabilitiesCache.Load(server.Url);

            if (capabilities != null)
            {
                DisplayServerCapabilities(capabilities);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Displayes and cached the results of GetCapabilities request.
        /// </summary>
        private void ProcessWmsCapabilitiesResults(Task <Stream> task)
        {
            var server = SelectedServer;

            string msg = "WMS server GetCapabilities request failed: " + Environment.NewLine;

            try
            {
                using (var stream = task.Result)
                {
                    WmsCapabilities capabilities;

                    if (WmsCapabilitiesCache.Save(server.Url, stream))
                    {
                        // ConnectStream returned by WebResponse doesn't support seek operation,
                        // so we can't read it twice, therefore on successful saving to the disk
                        // we are rereading it from file
                        capabilities = WmsCapabilitiesCache.Load(server.Url);
                    }
                    else
                    {
                        capabilities = new WmsCapabilities(stream);
                    }

                    DisplayServerCapabilities(capabilities);
                }
            }
            catch (AggregateException ex)
            {
                MessageService.Current.Warn(msg + ex.InnerException.Message);
            }
            catch (Exception ex)
            {
                Logger.Current.Warn(msg + server.Name, ex);
            }
            finally
            {
                View.HideHourglass();
            }
        }