private async void btn_CancelTrip_Tap(object sender, System.Windows.Input.GestureEventArgs e) { //Hiện màn hình Loading ShowLoadingGridScreen(); DriverStartTripObj cancelTrip = new DriverStartTripObj { uid = userId, //pw = pwmd5, tid = newTrip.tid, //status = "", //không truyền lên status lmd = tlmd //Cái này bây giờ không còn là của lmd Create trip nữa. mà của Accept Trip }; var input = string.Format("{{\"uid\":\"{0}\",\"tid\":\"{1}\",\"lmd\":\"{2}\"}}", cancelTrip.uid, cancelTrip.tid, cancelTrip.lmd); try { var output = await GetJsonFromPOSTMethod.GetJsonString(ConstantVariable.tNetDriverCancelTrip, input); if (output != null) { var cancelStatus = JsonConvert.DeserializeObject<BaseResponse>(output); if (cancelStatus.status.Equals(ConstantVariable.RESPONSECODE_SUCCESS)) //0000 { ///1. Update lmd ///2. Chuyển qua trạng thái ko hoạt động ///3. Xóa toàn bộ thông tin Trip và về màn hình home //1. Update lmd tlmd = (long)cancelStatus.lmd; //2. Chuyển qua trạng thái ko hoạt động UpdateDriverStatus(ConstantVariable.dStatusAvailable); //Để chuyển thành Not Available thì gửi lên "AC" ShowChangeStatusButton(); // <=========== Cần kích hoạt nút này lên để chuyển qua chế độ off //3. Xóa toàn bộ thông tin Trip và về màn hình home ResetAllData(); } else { Debug.WriteLine("Mã lỗi 5ew33 ở CancelTrip"); } } } catch (Exception) { MessageBox.Show("(Mã lỗi 313) " + ConstantVariable.errServerError); } }
private async void btn_StartTrip_Tap(object sender, System.Windows.Input.GestureEventArgs e) { ShowLoadingGridScreen(); var checkDistance = await GoogleAPIFunctions.GetDistance(currentLat, currentLng, newTrip.sLat, newTrip.sLng); if (checkDistance < 0.2) { //Hiển thị Loading grid ShowLoadingGridScreen(); RemoveMapRouteOnly(); //Kích hoạt lấy tọa độ điểm cuối isTrack = true; //Xóa đường đi hiện tại trên map RemoveMapRouteOnly(); //Và khai báo tọa độ điểm đầu của chuyến đi (Chính là địa điểm hiện tại) SetStartCoordinateOfTrip(currentLat, currentLng); DriverStartTripObj startTrip = new DriverStartTripObj { uid = userId, //pw = pwmd5, tid = newTrip.tid, //status = ConstantVariable.tripStatusPicked, //"PD" lmd = tlmd //Cái này bây giờ không còn là của lmd Create trip nữa. mà của Accept Trip }; //Gửi thông tin lên sv var input = string.Format("{{\"uid\":\"{0}\",\"tid\":\"{1}\",\"lmd\":\"{2}\"}}", startTrip.uid, startTrip.tid, startTrip.lmd); try { var output = await GetJsonFromPOSTMethod.GetJsonString(ConstantVariable.tNetDriverStartTrip, input); if (output != null) { var startStatus = JsonConvert.DeserializeObject<BaseResponse>(output); if (startStatus.status.Equals(ConstantVariable.RESPONSECODE_SUCCESS)) //0000 { //Nếu thành công thì ///1. Update lmd ///2 Hiện Button "chạm để thanh toán" ///3. Hiển thị giá, quãng đường, cập nhật sau 20s //1. Update lmd tlmd = (long)startStatus.lmd; //2. Tắt loading grid HideLoadingGridScreen(); //Vẽ một đường map từ vị trí hiện tại đến điểm đến (Nếu có) //Nếu khách hàng cung cấp địa chỉ đến thì mới chạy hàm này if (newTrip.eLat != 0 && newTrip.eLng != 0) { GetRouteOnMap(new GeoCoordinate(newTrip.sLat, newTrip.sLng), new GeoCoordinate(newTrip.eLat, newTrip.eLng)); } //Hiện button "Tap to pay" ShowStartTripScreen(); //Bật khóa để cho phép tracking route //Từ bây giờ bắt đầu vẽ map isTrackingRoute = true; //Bật hàm tính tiền isCalculateFare = true; isTrakingStated = true; //Gán điểm step đầu và cuối //Ngay khi ấn nút Start Trip thì sẽ gán điểm Đầu vào //Khi nào map di chuyển đc 5 lần sẽ gán điểm Cuối > Vẽ Map > rôi chueyenr điểm cuối thành điểm đầu fiveStepBeforeLat = currentLat; fiveStepBeforeLng = currentLng; //map_DriverMap.SetView(realCoordinate, 16, MapAnimationKind.Linear); } else { Debug.WriteLine("Mã lỗi 7hgtr4 ở StartTrip"); } } } catch (Exception) { HideLoadingGridScreen(); MessageBox.Show("(Mã lỗi 312) " + ConstantVariable.errServerError); } } else { HideLoadingGridScreen(); MessageBox.Show("Vui lòng đón khách trước khi bắt đầu chuyến đi!"); } }