示例#1
0
        public bool checkAvailabilityWebRequest(_Default.Services service)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(service.URL);
                request.MaximumAutomaticRedirections = 10;
                request.MaximumResponseHeadersLength = 10;
                request.Credentials       = CredentialCache.DefaultCredentials;
                request.AllowAutoRedirect = false; // find out if this site is up and don't follow a redirector
                request.Method            = "HEAD";

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Console.WriteLine(response.ContentType);
                if (response == null || response.StatusCode != HttpStatusCode.OK)
                {
                    response.Close();
                    return(false);
                }
                // do something with response.Headers to find out information about the request
                response.Close();
                return(true);
            }
            catch (WebException wex)
            {
                //set flag if there was a timeout or some other issues
                return(false);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#2
0
        public void AddNewPoint(int timeStamp, Series ptSeries, _Default.Services service, int index)
        {
            double newVal = 0;

            if (ptSeries.Points.Count >= 0)
            {
                newVal = (rand.NextDouble());
            }

            ptSeries.Points.AddXY(0, index);
            ptSeries.Points.AddXY(timeStamp, index);

            Chart1.ChartAreas[0].AxisX.Maximum = timeStamp;
        }