async void cdDrive(object sender, System.EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(" Clicked send location Button");

            try
            {
                cdCallAPI mycallAPI = new cdCallAPI();
                Plugin.Geolocator.Abstractions.Position mypos = await mycallAPI.GetCurrentPosition();

                string cPosLat  = mypos.Latitude.ToString();
                string cPosLong = mypos.Longitude.ToString();

                String mailSubject = "Student " + plogaccount.FirstName + " " + plogaccount.LastName + " location details";
                String mailBody    = "Location of student " + plogaccount.FirstName + " " + plogaccount.LastName + " " + cPosLat + " " + cPosLong;

                var myresult = mycallAPI.cdSendEmail(mailSubject, plogaccount.Attr1, mailBody);

                System.Diagnostics.Debug.WriteLine(" Result is " + myresult.ToString());

                Status.Text = "Sent location " + cPosLat + " " + cPosLong + " to " + plogaccount.Attr1 + " Successfully";
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(" Result is " + ex);

                await DisplayAlert("Failed to get data. Please try later.", "Failed to get data. Please try later.", "OK");
            }
        }
示例#2
0
        private async void setCurrentLoc()
        {
            cdCallAPI getPosition = new cdCallAPI();

            if (getPosition != null)
            {
                Plugin.Geolocator.Abstractions.Position mypos = await getPosition.GetCurrentPosition();

                cPosLat   = Convert.ToDouble(mypos.Latitude.ToString());
                cPosLong  = Convert.ToDouble(mypos.Longitude.ToString());
                csPosLat  = mypos.Latitude.ToString();
                csPosLang = mypos.Longitude.ToString();
            }
        }