示例#1
0
        private async void BletoothRM_clicked(object sender, EventArgs e)
        {
            activityIndicator.IsRunning = true;

            try
            {
                //await BletoothRM.ScaleTo(0.9, 1500, Easing.Linear);
                string LastDevices = Settings.LastUsedDevices;
                if (LastDevices == null || LastDevices == "")
                {
                    activityIndicator.IsRunning = false;
                    await DisplayAlert("Device number error", "Check the device number in 'Settings'", "Ok");

                    return;
                }
                try
                {
                    string          url      = "http://rehabmaker-001-site1.dtempurl.com";
                    HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(url);
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    if (response.StatusCode == HttpStatusCode.NotFound)
                    {
                        response.Close();
                        await DisplayAlert("Server is not aviable", "Check your Internet connection or wait for the server to recover", "Ok");

                        return;
                    }
                }
                catch (WebException)
                {
                    activityIndicator.IsRunning = false;
                    await DisplayAlert("Server is not aviable", "Check your Internet connection or wait for the server to recover", "Ok");

                    return;
                }

                //await BletoothRM.ScaleTo(1, 2000, Easing.Linear);
                string            json13  = GETApi("api/params/paraparams?id=" + LastDevices + "&simbol=1&ugo=ugo");
                AverageJsonParams JParams = Newtonsoft.Json.JsonConvert.DeserializeObject <AverageJsonParams>(json13);
                AvSpeed.Text = JParams.AverageSpeed.ToString();
                AvCal.Text   = JParams.TotalDistance.ToString();
                AvDis.Text   = JParams.TotalCalories.ToString();
                await stackLayout3.FadeTo(0, 1000);

                stackLayout3.IsVisible = false;
                await StartRM.FadeTo(1, 1000);

                DatePicker1.IsEnabled       = true;
                buttonViewDate.IsEnabled    = true;
                activityIndicator.IsRunning = false;
            }
            catch
            {
                await DisplayAlert("Device error", "An error has occurred", "Ok");

                activityIndicator.IsRunning = false;
            }
        }
示例#2
0
        private async void BletoothRM_clicked(object sender, EventArgs e)
        {
            activityIndicator.IsRunning = true;

            try
            {
                //await BletoothRM.ScaleTo(0.9, 1500, Easing.Linear);
                string LastDevices = Settings.LastUsedDevices;

                string Get = "";
                try
                {
                    Get = GETApi("api/web/ok/1");
                }
                catch
                {
                    label1.Text = "Server is not available. Check your Internet connection,";
                    activityIndicator.IsRunning = false;
                }
                if (Get == "\"Oks\"")
                {
                    //await BletoothRM.ScaleTo(1, 2000, Easing.Linear);
                    if (LastDevices == null)
                    {
                        activityIndicator.IsRunning = false;
                        await  DisplayAlert("Device error", "Check the device number in 'Settings'", "Ok");

                        return;
                    }
                    string            json13  = GETApi("api/params/paraparams?id=" + LastDevices + "&simbol=1&ugo=ugo");
                    AverageJsonParams JParams = JsonConvert.DeserializeObject <AverageJsonParams>(json13);
                    AvSpeed.Text = JParams.AverageSpeed.ToString();
                    AvCal.Text   = JParams.TotalDistance.ToString();
                    AvDis.Text   = JParams.TotalCalories.ToString();
                    await stackLayout3.FadeTo(0, 1000);

                    stackLayout3.IsVisible = false;
                    await StartRM.FadeTo(1, 1000);

                    DatePicker1.IsEnabled       = true;
                    activityIndicator.IsRunning = false;
                }
                else
                {
                    await DisplayAlert("Error", "Server is not available. Check your Internet connection", "Ok");
                }
                activityIndicator.IsRunning = false;
            }
            catch
            {
                await DisplayAlert("Device error", "Check the device number in 'Settings'", "Ok");

                activityIndicator.IsRunning = false;
            }
        }