public static TripBookingsSendResult AddTrip(XeDiDuongDai objXeDiDuongDai)
        {
            try
            {
                TripBookingsSendResult rs = Service_Common.FastTaxi.TryGet(client => client.AddTrip(Parse(objXeDiDuongDai))).Value;
                if (rs.AddTripSuccess)
                {
                    ProcessFastTaxi.WriteLog("TaxiReturn_Process\\AddTrip", "Gửi thành công", "thành công");
                }
                else
                {
                    ProcessFastTaxi.WriteLog("TaxiReturn_Process\\AddTrip", "Gửi thất bại", "thất bại");
                }

                return(rs);
            }
            catch (Exception ex)
            {
                if (IsDebug)
                {
                    ProcessFastTaxi.WriteLog("TaxiReturn_Process\\AddTrip", ex.Message, "Lỗi");
                }
                return(null);
            }
        }
        public static void EditTrip(XeDiDuongDai objXeDiDuongDai)
        {
            Func <bool> func = () => Service_Common.FastTaxi.Try(client => client.UpdateTrip(Parse(objXeDiDuongDai)));

            queueTaxiReturnSend.Enqueue(new TaxiReturnSend()
            {
                func = func,
                Tree = "TaxiReturn_Process\\EditTrip"
            });
            RunProcess();
        }
 public static Trip Parse(XeDiDuongDai item)
 {
     try
     {
         //string BienSoXe = "";
         //if (ProcessFastTaxi.Vehicles_GPS.ContainsKey(item.FK_SoHieuXe))
         //{
         //    BienSoXe = ProcessFastTaxi.Vehicles_GPS[item.FK_SoHieuXe];
         //}
         return(new Trip()
         {
             AddressFrom = item.DiaDiemDi,
             AddressFromLat = item.Di_ViDo,
             AddressFromLng = item.Di_KinhDo,
             AddressTo = item.DiaDiemDen,
             AddressToLat = item.Den_ViDo,
             AddressToLng = item.Den_KinhDo,
             DriverName = item.TenLaiXe,
             DriverPhone = item.SoDienThoai,
             KmExpected = item.KmDuKien,
             MoneyExpected = (decimal)item.TienDuKien,
             TimeExpected = item.TGDuKien,
             Notes = item.GhiChu,
             PK_TripID = item.ID,
             TimeFrom = item.ThoiDiemDi.Value,
             TimeTo = item.ThoiDiemVe ?? item.TGDuKien,
             TripStatus = Trip.Status.DangDi,
             //TripType
             Vehicle_Lat = item.Xe_ViDo,
             Vehicle_Lng = item.Xe_KinhDo,
             VehiclePlate = item.BienSoXe,
             //XNCode
             //ExtensionData
             //FK_CompanyID
             //InputType
             //PrivateCode
             //Route
             //Route_Points
         });
     }
     catch (Exception ex)
     {
         if (IsDebug)
         {
             ProcessFastTaxi.WriteLog("TaxiReturn_Process\\Parse", ex.Message, "Lỗi");
         }
         return(null);
     }
 }
Beispiel #4
0
        private bool DieuKienTimKiem(XeDiDuongDai xddd)
        {
            bool rs = false;

            if (inputLookUp_Province1.EditValue != null && inputLookUp_Province1.EditValue.To <int>() > 0)
            {
                rs = (xddd.FK_TinhThanhDenID == inputLookUp_Province1.EditValue.To <int>());
            }
            else
            {
                rs = true;
            }
            if (txtSoXe.EditValue != null && txtSoXe.EditValue.To <string>().Trim() != "")
            {
                rs = rs && (xddd.FK_SoHieuXe == txtSoXe.EditValue.To <string>());
            }
            else
            {
                rs = rs && true;
            }
            return(rs);
        }
        public static void AddTripProcess(XeDiDuongDai objXeDiDuongDai)
        {
            Func <bool> func = () =>
            {
                try
                {
                    Service_Common.FastTaxi.Try(client => client.AddTrip(Parse(objXeDiDuongDai)));
                    return(true);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            };

            queueTaxiReturnSend.Enqueue(new TaxiReturnSend()
            {
                func = func,
                Tree = "TaxiReturn_Process\\AddTripProcess"
            });
            RunProcess();
        }
Beispiel #6
0
 private bool DieuKienXoa(XeDiDuongDai p)
 {
     return(p.IsKetThuc || p.isDelete);
 }
Beispiel #7
0
        private void kếtThúcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var _model = gridView_Bookings.GetFocusedRow <Booking>();

            if (_model == null)
            {
                return;
            }
            int G_XNCode = ThongTinCauHinh.CompanyID;

            #region Trường hợp 1:Khách hàng hủy
            if (_model.OpCommand == m_HuyDieu)
            {
                //Bạn có muốn xóa cuốc khách chiều về này không ?
                //    if (new MessageBox.MessageBox().Show("Khách hàng hủy cuốc chiều về ?", "Thông báo", MessageBoxButtons.YesNo).ToLower() == "yes".ToLower())
                {
                    try
                    {
                        //cập nhật trạng thái của xe đường dài.
                        var xddd = new XeDiDuongDai();
                        xddd.UpdateStatus(_model.FK_TaxiReturn, Enum_XeBaoDiDuongDai_TrangThai.ChoGhepKhach, ThongTinDangNhap.USER_ID);
                        _model.UpdateStatus(_model.PK_BooID, Enum_Bookings_OpStatus.KhachHangHuy, m_HuyDieu, ThongTinDangNhap.USER_ID);

                        if (_model.FK_TaxiReturn > 0)
                        {
                            TaxiReturn_Process.TripUpdateStatus(_model.FK_TaxiReturn, G_XNCode, Services.FastTaxi_OperationService.Trip.Status.DangDi);
                        }
                        //  this.Close();
                    }
                    catch (Exception ex)
                    {
                        new Log().WriteLog(ThongTinDangNhap.USER_ID, "ctrlListBook\\kếtThúcToolStripMenuItem_Click", DateTime.Now, ex.Message);
                        //  ShowMessageFail("[KH hủy] Quá trình lưu xảy ra bị lỗi");
                    }
                }
                return;
            }
            #endregion

            #region Từ chối
            if (_model.FK_TaxiReturn == 0)
            {
                new MessageBox.MessageBoxBA().Show("Cuốc khách chưa gián xe.\nvui lòng chọn trạng thái từ chối");
                return;
            }
            #endregion

            #region Trường hợp 2:Đã ghép.
            else
            {
                #region Mobile đã gặp xe
                if (_model.OpCommand == m_DaGapXe)
                {
                    try
                    {
                        string rs       = string.Empty;
                        var    themTrip = new XeDiDuongDai();
                        var    address  = new AutoCompleteAddress();
                        address.Bind();

                        #region Khởi tạo trip mới và chưa lưu
                        themTrip.ID = _model.FK_TaxiReturn;
                        try
                        {
                            //Thiếu : Thêm ID cha vào để quan hệ
                            if (themTrip.GetByKey())
                            {
                                themTrip.ParentID      = _model.FK_TaxiReturn;
                                themTrip.ID            = 0;
                                themTrip.LoTrinh       = string.Empty;
                                themTrip.LoTrinh_Diem  = string.Empty;
                                themTrip.KmDuKien      = 0;
                                themTrip.TrangThai     = (int)Enum_XeBaoDiDuongDai_TrangThai.ChoGhepKhach;
                                themTrip.CreatedDate   = TaxiReturn_Process.timerServer;
                                themTrip.CreatedByUser = ThongTinDangNhap.USER_ID;
                                themTrip.UpdatedDate   = null;
                                themTrip.UpdatedByUser = string.Empty;
                                // thời điểm bắt đầu của lái xe.
                                themTrip.ThoiDiemDi = themTrip.TGDuKien;
                                //_modelDetail.B
                                themTrip.DiaDiemDen = _model.ToAdress;
                                //address.Text = themTrip.DiaDiemDen;
                                //address.ReSearch();
                                themTrip.FK_QuanHuyenDenID = address.HuyenId;
                                themTrip.FK_TinhThanhDenID = address.TinhId;
                                themTrip.Den_ViDo          = _model.ToLat;
                                themTrip.Den_KinhDo        = _model.ToLng;


                                //lấy tọa độ của xe.
                                var _xeOnline = WCFService_Common.GetXeOnlineBySHX(themTrip.FK_SoHieuXe);
                                themTrip.Xe_KinhDo = _xeOnline.KinhDo;
                                themTrip.Xe_ViDo   = _xeOnline.ViDo;

                                // Lộ trình này là lộ trình của điểm DC
                                var lotrinh = TaxiReturn_Process.LayLoTrinh(themTrip.Di_ViDo, themTrip.Di_KinhDo, themTrip.Den_ViDo, themTrip.Den_KinhDo);
                                themTrip.LoTrinh      = lotrinh.LoTrinh_DiaChi;
                                themTrip.LoTrinh_Diem = lotrinh.LoTrinh_ToaDo;
                                themTrip.KmDuKien     = (int)lotrinh.Distance;

                                //Tính thời gian đi của book.
                                int SoPhutDiQuangDuongBC = TaxiReturn_Process.TinhThoiGianDiHetQuangDuong(_model.BC_Route_Distance);
                                themTrip.TGDuKien   = themTrip.TGDuKien.AddMinutes(SoPhutDiQuangDuongBC); // là thời điểm đến điểm C.
                                themTrip.ThoiDiemVe = themTrip.TGDuKien;
                                Xe objXe1 = new Xe().GetChiTietXe(themTrip.FK_SoHieuXe);
                                if (objXe1 != null)
                                {
                                    themTrip.BienSoXe = objXe1.BienKiemSoat;
                                    TinhTienTheoKm objTinhTien = new TinhTienTheoKm(objXe1.LoaiXeID, themTrip.KmDuKien);
                                    themTrip.TienDuKien = objTinhTien.TongTien1Chieu;
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                        #endregion

                        if (themTrip.KmDuKien >= g_KmDuKien)
                        {
                            rs = new MessageBox.MessageBoxBA().Show("Xe này có muốn đón cuốc chiều về khác không ?", "Thông báo", MessageBoxButtons.YesNo);
                        }

                        if (rs == "Yes")
                        {
                            themTrip.Insert();
                        }
                        themTrip.UpdateStatusV2(_model.FK_TaxiReturn, Enum_XeBaoDiDuongDai_TrangThai.None, ThongTinDangNhap.USER_ID, true, Enum_Bookings_OpStatus.MobileKetThuc, _model.PK_BooID);

                        #region Send server
                        try
                        {
                            TaxiReturn_Process.TripUpdateStatus(_model.FK_TaxiReturn, G_XNCode, Services.FastTaxi_OperationService.Trip.Status.KetThuc);
                            if (rs == "Yes" && themTrip.ID > 0)
                            {
                                var rsBoot = TaxiReturn_Process.ReplaceTrip(themTrip.ParentID, themTrip);
                                themTrip.UpdateIsAddedStaxi(themTrip.ID, ThongTinDangNhap.USER_ID, rsBoot);
                            }
                        }
                        catch (Exception ex)
                        {
                            new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message);
                        }

                        //chỉ cần Kết thúc cái Book chưa có hàm gửi lên server
                        try
                        {
                            //  if (!G_DoNotSendToServer)
                            TaxiReturn_Process.FinishVehicleReturn(_model.ClientKey);
                        }
                        catch (Exception ex)
                        {
                            new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message);
                        }

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Cập nhật dữ liệu lỗi:" + ex.Message);
                    }
                }
                #endregion

                #region Mobile chưa gặp xe
                else
                {
                    try
                    {
                        #region Điều hành kết thúc
                        string rs       = string.Empty;
                        var    themTrip = new XeDiDuongDai();
                        var    address  = new AutoCompleteAddress();
                        address.Bind();

                        #region Khởi tạo trip mới và chưa lưu
                        themTrip.ID = _model.FK_TaxiReturn;
                        try
                        {
                            //Thiếu : Thêm ID cha vào để quan hệ
                            if (themTrip.GetByKey())
                            {
                                themTrip.ParentID      = _model.FK_TaxiReturn;
                                themTrip.ID            = 0;
                                themTrip.LoTrinh       = string.Empty;
                                themTrip.LoTrinh_Diem  = string.Empty;
                                themTrip.KmDuKien      = 0;
                                themTrip.TrangThai     = (int)Enum_XeBaoDiDuongDai_TrangThai.ChoGhepKhach;
                                themTrip.CreatedDate   = TaxiReturn_Process.timerServer;
                                themTrip.CreatedByUser = ThongTinDangNhap.USER_ID;
                                themTrip.UpdatedDate   = null;
                                themTrip.UpdatedByUser = string.Empty;
                                // thời điểm bắt đầu của lái xe.
                                themTrip.ThoiDiemDi = themTrip.TGDuKien;
                                //_modelDetail.B
                                themTrip.DiaDiemDen = _model.ToAdress;
                                //address.Text = themTrip.DiaDiemDen;
                                //address.ReSearch();
                                themTrip.FK_QuanHuyenDenID = address.HuyenId;
                                themTrip.FK_TinhThanhDenID = address.TinhId;
                                themTrip.Den_ViDo          = _model.ToLat;
                                themTrip.Den_KinhDo        = _model.ToLng;


                                //lấy tọa độ của xe.
                                var _xeOnline = WCFService_Common.GetXeOnlineBySHX(themTrip.FK_SoHieuXe);
                                themTrip.Xe_KinhDo = _xeOnline.KinhDo;
                                themTrip.Xe_ViDo   = _xeOnline.ViDo;

                                // Lộ trình này là lộ trình của điểm DC
                                var lotrinh = TaxiReturn_Process.LayLoTrinh(themTrip.Di_ViDo, themTrip.Di_KinhDo, themTrip.Den_ViDo, themTrip.Den_KinhDo);
                                themTrip.LoTrinh      = lotrinh.LoTrinh_DiaChi;
                                themTrip.LoTrinh_Diem = lotrinh.LoTrinh_ToaDo;
                                themTrip.KmDuKien     = (int)lotrinh.Distance;

                                //Tính thời gian đi của book.
                                int SoPhutDiQuangDuongBC = TaxiReturn_Process.TinhThoiGianDiHetQuangDuong(_model.BC_Route_Distance);
                                themTrip.TGDuKien   = themTrip.TGDuKien.AddMinutes(SoPhutDiQuangDuongBC); // là thời điểm đến điểm C.
                                themTrip.ThoiDiemVe = themTrip.TGDuKien;
                                Xe objXe1 = new Xe().GetChiTietXe(themTrip.FK_SoHieuXe);
                                if (objXe1 != null)
                                {
                                    themTrip.BienSoXe = objXe1.BienKiemSoat;
                                    TinhTienTheoKm objTinhTien = new TinhTienTheoKm(objXe1.LoaiXeID, themTrip.KmDuKien);
                                    themTrip.TienDuKien = objTinhTien.TongTien1Chieu;
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                        #endregion

                        if (themTrip.KmDuKien >= g_KmDuKien)
                        {
                            rs = new MessageBox.MessageBoxBA().Show("Xe này có muốn đón cuốc chiều về khác không ?", "Thông báo", MessageBoxButtons.YesNo);
                        }


                        #region nếu chọn đón cuốc chiều về khác thì Thêm mới Trip
                        if (rs == "Yes")
                        {
                            themTrip.Insert();
                        }
                        themTrip.UpdateStatusV2(_model.FK_TaxiReturn, Enum_XeBaoDiDuongDai_TrangThai.None, ThongTinDangNhap.USER_ID, true, Enum_Bookings_OpStatus.KetThuc, _model.PK_BooID);
                        #endregion

                        #region Send server
                        try
                        {
                            TaxiReturn_Process.TripUpdateStatus(_model.FK_TaxiReturn, G_XNCode, Services.FastTaxi_OperationService.Trip.Status.KetThuc);
                            if (rs == "Yes" && themTrip.ID > 0)
                            {
                                var rsBoot = TaxiReturn_Process.ReplaceTrip(themTrip.ParentID, themTrip);
                                themTrip.UpdateIsAddedStaxi(themTrip.ID, ThongTinDangNhap.USER_ID, rsBoot);
                            }
                        }
                        catch (Exception ex)
                        {
                            new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message);
                        }

                        //chỉ cần Kết thúc cái Book chưa có hàm gửi lên server
                        try
                        {
                            //if (!G_DoNotSendToServer)
                            TaxiReturn_Process.FinishVehicleReturn(_model.ClientKey);
                        }
                        catch (Exception ex)
                        {
                            new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message);
                        }

                        #endregion
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        new Log().WriteLog(ThongTinDangNhap.USER_ID, "Kết thúc trên lưới Book", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message);
                        new MessageBox.MessageBoxBA().Show("Quá trình xử lý sảy ra lỗi vui lòng liên hệ với quản trị");
                    }
                }
                #endregion
            }
            #endregion
        }
Beispiel #8
0
 public frmUpdateTrip(XeDiDuongDai model)
 {
     _model = model;
     InitializeComponent();
 }
 public static bool ReplaceTrip(long tripIDOld, XeDiDuongDai objXeDiDuongDai)
 {
     return(Service_Common.FastTaxi.Try(client => client.ReplaceTrip(tripIDOld, Parse(objXeDiDuongDai))));
 }