예제 #1
0
        private void TimerProc(Object source, ElapsedEventArgs ea)
        {
            theTimer.Enabled = false;

            try
            {
                HttpWebRequest request = WebRequest.Create(theURL) as HttpWebRequest;
                request.Timeout = theRequestTimeout;
                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    if (response.StatusCode != HttpStatusCode.OK)
                    {
                        throw new Exception(String.Format(
                                                "Server error (HTTP {0}: {1}).",
                                                response.StatusCode,
                                                response.StatusDescription));
                    }
                    DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(ScoreboardResponse));
                    object             objResponse            = jsonSerializer.ReadObject(response.GetResponseStream());
                    ScoreboardResponse jsonResponse           = objResponse as ScoreboardResponse;

                    theDispatcher.BeginInvoke(DispatcherPriority.Send, theDelegate, jsonResponse);
                }
            }
            catch (Exception e)
            {
                Logger.Log("Error retrieving data: " + e.Message, EventLogEntryType.Error, Logger.Type.RetrieveFailure);
                theDispatcher.BeginInvoke(DispatcherPriority.Send, theDelegate, null);
            }

            theTimer.Enabled = true;
        }
예제 #2
0
        private void ScoreboardUpdate(ScoreboardResponse aResponse)
        {

            if ( aResponse != null && aResponse.Status == "OK" )
            {
                Home.Text = String.Format("{0}", aResponse.Home);
                Guest.Text = String.Format("{0}", aResponse.Guest);
            }
            else 
            {
                Home.Text = "-";
                Guest.Text = "-";
            }		
		}