Example #1
0
        /// <summary>
        ///
        /// </summary>
        void Update()
        {
            TracerHelper.TraceEntry();
            if (_isUpdating == true)
            {
                return;
            }

            _isUpdating = true;

            List <NewsEvent> events = new List <NewsEvent>();

            WebRequest webRequest = WebRequest.Create(_xmlAddress);

            webRequest.Timeout = 5000;

            WebResponse response = webRequest.GetResponse();

            if (response.ContentLength > 0)
            {
                try
                {
                    XmlDocument document = new XmlDocument();
                    document.Load(response.GetResponseStream());

                    XmlNode weeklyEvents = document.ChildNodes[1];
                    foreach (XmlNode eventNode in weeklyEvents.ChildNodes)
                    {
                        events.Add(ParseEventXml(eventNode));
                    }
                }
                catch (Exception ex)
                {
                    SystemMonitor.Error("Failed to obtain XML stream [" + ex.Message + "].");
                }
            }

            lock (this)
            {
                _events.Clear();
                _events.AddRange(events);
            }

            UpdateVisibleEvents();

            ChartSeries.RaiseSeriesValuesUpdated(true);
            _isUpdating = false;
        }