private async void BediendButton_Click(object sender, EventArgs e)
        {
            //data uit geaccepteerd
            dataService.klantBediend(klant[0]);

            var locator = CrossGeolocator.Current;

            locator.DesiredAccuracy = 50;

            var position = await locator.GetPositionAsync(timeoutMilliseconds : 10000);

            var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://35.165.103.236:80/doneclient");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = "{\"driveremail\":\"[email protected]\"," +
                              "\"driverLat\":\"" + position.Latitude.ToString().Replace(',', '.') + "\"," +
                              "\"driverLong\":\"" + position.Longitude.ToString().Replace(',', '.') + "\"," +
                              "\"useremail\":\"" + klant[0].Email + "\"}";


                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                routeDataService.pushRoute(result);
            }
            Toast.MakeText(this, klant[0].Username + " is behandeld", ToastLength.Long).Show();
            var intent = new Intent(this, typeof(MapActivity));

            StartActivity(intent);
        }
Пример #2
0
        private async void BehandelButton_Click(object sender, EventArgs e)
        {
            //data uit geaccepteerd
            List <Klant> klant = new List <Klant>();

            klant = klanten.Where(k => k.Email == geklikteKlant).ToList();
            dataService.klantBediend(klant[0]);

            /*
             * string mResult;
             * using (WebClient client = new WebClient())
             * {
             *
             *  //Uri uri = new Uri("http://35.165.103.236:80/clientlogin");
             *  string uri = "http://35.165.103.236:80/doneclient";
             *  NameValueCollection parameters = new NameValueCollection();
             * // parameters.Add("username", geaccepteerdeKlanten[klantId].Username);
             * // parameters.Add("userLong", Convert.ToString(geaccepteerdeKlanten[klantId].Longitude));
             * // parameters.Add("userLat", Convert.ToString(geaccepteerdeKlanten[klantId].Latitude));
             *  parameters.Add("email", klant[0].Email);
             *  byte[] response = client.UploadValues(uri, parameters);
             *  mResult = System.Text.Encoding.UTF8.GetString(response);
             * }*/

            var locator = CrossGeolocator.Current;

            locator.DesiredAccuracy = 50;

            var position = await locator.GetPositionAsync(timeoutMilliseconds : 10000);

            var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://35.165.103.236:80/doneclient");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = "{\"driveremail\":\"[email protected]\"," +
                              "\"driverLat\":\"" + position.Latitude.ToString().Replace(',', '.') + "\"," +
                              "\"driverLong\":\"" + position.Longitude.ToString().Replace(',', '.') + "\"," +
                              "\"useremail\":\"" + klant[0].Email + "\"}";


                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                routeDataService.pushRoute(result);
            }

            /*
             * dataService.pushGeaccepteerdeKlanten(geaccepteerdeKlanten);
             * Toast.MakeText(this, "klanten zijn toegevoegd", ToastLength.Long).Show();
             * var intent = new Intent(this, typeof(MapActivity));
             * StartActivity(intent);*/

            //data in handeld klanten
            Toast.MakeText(this, klant[0].Email, ToastLength.Long).Show();
        }