Exemplo n.º 1
0
        // The thread procedure performs the task, such as
        // formatting and printing a document, and then invokes
        // the callback delegate with the number of lines printed.
        public void ThreadProc()
        {
            Ping      ping = new Ping();
            PingReply pingReply;

            pingReply = ping.Send(host, 500);

            if (pingReply != null && pingReply.Status == IPStatus.Success)
            {
                try
                {
                    var            FullUrl = $"http://{host}";
                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(FullUrl);
                    request.Timeout = 500;
                    request.Method  = "OPTIONS";
                    var _ = request.GetResponse();

                    var client = new ArdunoRest.ArdunoRestClient
                    {
                        BaseUrl = FullUrl
                    };

                    var id = client.Id();
                    callback(new Greenhouse
                    {
                        Greenhouse_ID    = id.Id ?? 99,
                        Greenhouse_Name  = id.Name,
                        Greenhouse_IP    = host,
                        Greenhouse_Image = "Images/GreenhouseDefault.png"
                    });
                }
                catch { }
            }
        }
Exemplo n.º 2
0
        // The thread procedure performs the task, such as
        // formatting and printing a document, and then invokes
        // the callback delegate with the number of lines printed.
        public void ThreadProc()
        {
            Ping      ping = new Ping();
            PingReply pingReply;
            string    imagesource = "/Images/DefaultGreenhouse.png";

            pingReply = ping.Send(host, 500);

            if (pingReply != null && pingReply.Status == IPStatus.Success)
            {
                try
                {
                    var            FullUrl = $"http://{host}";
                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(FullUrl);
                    request.Timeout = 500;
                    request.Method  = "OPTIONS";
                    var _ = request.GetResponse();

                    var client = new ArdunoRest.ArdunoRestClient
                    {
                        BaseUrl = FullUrl
                    };

                    var id = client.Id();
                    if (DatabaseManager.Instance.GetImageSource(Convert.ToInt32(id.Id)) != null)
                    {
                        imagesource = DatabaseManager.Instance.GetImageSource(Convert.ToInt32(id.Id)).Greenhouse_Image;
                    }

                    callback(new Greenhouse
                    {
                        Greenhouse_ID    = id.Id ?? 99,
                        Greenhouse_Name  = id.Name,
                        Greenhouse_IP    = host,
                        Greenhouse_Image = imagesource
                    });
                }
                catch { }
            }
        }