private async void AccepteerButton_Click(object sender, EventArgs e) { dataService.pushGeaccepteerdeKlanten(klant); 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/helpclient"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; string userString = "["; for (int i = 0; i < klant.Count; i++) { userString += "{\"useremail\":\"" + klant[0].Email + "\"," + "\"userLat\":\"" + klant[0].Latitude.ToString().Replace(',', '.') + "\"," + "\"userLong\":\"" + klant[0].Longitude.ToString().Replace(',', '.') + "\"}"; if (i != klant.Count - 1) { userString += ","; } } userString += "]"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = "{\"driveremail\":\"[email protected]\"," + "\"driverLat\":\"" + position.Latitude.ToString().Replace(',', '.') + "\"," + "\"driverLong\":\"" + position.Longitude.ToString().Replace(',', '.') + "\"," + "\"users\":" + userString + "}"; 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, "klant is toegevoegd", ToastLength.Long).Show(); var intent = new Intent(this, typeof(MapActivity)); StartActivity(intent); }
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); }
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(); }
private async void AccepteerButton_Click(object sender, EventArgs e) { geaccepteerdeKlanten = new List <Klant>(); for (int i = 0; i < serverKlanten.Count; i++) { if (klantenHelper[i] == true) { geaccepteerdeKlanten.Add(serverKlanten[i]); } } /* * voorbeeld hoe het naar de server moet * { * "driveremail": "*****@*****.**", * "driverLong": "4.0", * "driverLat": "51.0", * "users":[ * { * "useremail":"*****@*****.**", * "userLat":"51.11111", * "userLong":"4.11111" * }, * { * "useremail":"*****@*****.**", * "userLat":"51.22222", * "userLong":"4.22222" * }, * { * "useremail":"*****@*****.**", * "userLat":"51.333333", * "userLong":"4.33333" * }] * } */ if (geaccepteerdeKlanten.Count != 0) { dataService.pushGeaccepteerdeKlanten(geaccepteerdeKlanten); var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 50; var position = await locator.GetPositionAsync(timeoutMilliseconds : 20000); var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://35.165.103.236:80/helpclient"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; string userString = "["; for (int i = 0; i < geaccepteerdeKlanten.Count; i++) { userString += "{\"useremail\":\"" + geaccepteerdeKlanten[i].Email + "\"," + "\"userLat\":\"" + geaccepteerdeKlanten[i].Latitude.ToString().Replace(',', '.') + "\"," + "\"userLong\":\"" + geaccepteerdeKlanten[i].Longitude.ToString().Replace(',', '.') + "\"}"; if (i != geaccepteerdeKlanten.Count - 1) { userString += ","; } } userString += "]"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = "{\"driveremail\":\"[email protected]\"," + "\"driverLat\":\"" + position.Latitude.ToString().Replace(',', '.') + "\"," + "\"driverLong\":\"" + position.Longitude.ToString().Replace(',', '.') + "\"," + "\"users\":" + userString + "}"; 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); } else { Toast.MakeText(this, "gelieve klanten te selecteren", ToastLength.Long).Show(); } }