Example #1
0
        /// <summary>
        /// Mời khách
        /// </summary>
        /// <param name="BookId">BookId</param>
        /// <param name="vehicle">Biển Số</param>
        /// <param name="result">Kết quả</param>
        /// <param name="msg">Thông báo</param>
        /// <param name="isContract">Xe hợp đồng</param>
        public static void SendACKInvite(Guid BookId, string vehicle, bool result, string msg, bool isContract)
        {
            if (isContract)
            {
                Task.Factory.StartNew(() =>
                {
                    return(WCFServicesAppXHD.SendText(CommonBL.ConvertSangBienSo(vehicle), msg, BookId));
                });
            }
            else
            {
                BackgroupActionServer(p =>
                {
                    var Content = new SendTextContext
                    {
                        BookId       = BookId,
                        VehiclePlate = CommonBL.ConvertSangBienSo(vehicle),
                        TextCommand  = msg,
                        Result       = result
                    };

                    p.SendACKInvite(Content);
                }, "Mời khách");
            }
        }
Example #2
0
        /// <summary>
        /// Gửi sms thông tin xe nhận
        /// </summary>
        /// <param name="receiveNumber"></param>
        /// <param name="carType"></param>
        /// <param name="privateCode"></param>
        /// <param name="phoneNumber"></param>
        /// <returns></returns>
        public static bool Vina_SendSms_VinaTaxi_ReceiveCarInfo(string receiveNumber, string carType, string privateCode, float custLat, float custLng, Guid bookID)
        {
            string driverPhone = "";

            if (CommonBL.DictDriver != null && CommonBL.DictDriver.ContainsKey(privateCode))
            {
                driverPhone = CommonBL.DictDriver[privateCode].DiDong;
            }
            string vehiclePlate = CommonBL.ConvertSangBienSo(privateCode).Trim();

            return(ServiceSMSVina.TryGet(t => t.SendSms_VinaTaxi_ReceiveCarInfo(ConvertPhoneNumber(receiveNumber), carType, privateCode, vehiclePlate, custLat, custLng, bookID)).Value);
        }
Example #3
0
        /// <summary>
        /// Gửi sms thông báo xe đón và có view car
        /// </summary>
        /// <param name="receiveNumber"></param>
        /// <param name="driverName"></param>
        /// <param name="phoneNumber"></param>
        /// <param name="privateCode"></param>
        /// <param name="vehiclePlate"></param>
        /// <returns></returns>
        public static bool Vina_SendSms_VinaTaxi_ViewCar(string receiveNumber, string privateCode, float custLat, float custLng, System.Guid bookID, float estimateTime)
        {
            string driverName  = "";
            string driverPhone = "";

            string vehiclePlate = CommonBL.ConvertSangBienSo(privateCode).Trim();

            if (CommonBL.DictDriver != null && CommonBL.DictDriver.ContainsKey(privateCode))
            {
                driverName  = UnicodeStrings.UnicodeFormat_V2(CommonBL.DictDriver[privateCode].TenNhanVien);
                driverPhone = CommonBL.DictDriver[privateCode].DiDong;
            }
            return(ServiceSMSVina.TryGet(t => t.SendSms_VinaTaxi_ViewCar(ConvertPhoneNumber(receiveNumber), driverName, driverPhone, privateCode, vehiclePlate, custLat, custLng, bookID, estimateTime)).Value);
        }
Example #4
0
 /// <summary>
 /// Gửi xe nhận cho app KH
 /// </summary>
 public static void SendOperatorDispatched(Guid bookId, string privateCode, bool isContract)
 {
     if (isContract)
     {
         Task.Factory.StartNew(() =>
         {
             return(WCFServicesAppXHD.SendOperatorDispatched(bookId, CommonBL.ConvertSangBienSo(privateCode)));
         });
     }
     else
     {
         BackgroupActionServer(p => p.SendOperatorDispatched(bookId, CommonBL.ConvertSangBienSo(privateCode)), "Gửi xe nhận cho app KH");
     }
 }
Example #5
0
 /// <summary>
 /// Gửi khách lên nhầm xe cho server
 /// </summary>
 public static void SendWrongCustomer(Guid bookId, string privateCode, bool isContract)
 {
     if (isContract)
     {
         Task.Factory.StartNew(() =>
         {
             return(WCFServicesAppXHD.SendWrongCustomer(bookId, CommonBL.ConvertSangBienSo(privateCode)));
         });
     }
     else
     {
         Task.Factory.StartNew(() =>
         {
             return(WCFServicesApp.SendWrongCustomer(bookId, CommonBL.ConvertSangBienSo(privateCode)));
         });
     }
 }
Example #6
0
 /// <summary>
 /// Gửi kết quả hoàn thành của cuốc lên server
 /// </summary>
 /// <param name="cuocGoi">BookId</param>
 /// <param name="state">Trạng thái confirm</param>
 public static void SendConfirmDoneBook(CuocGoi cuocGoi, EnumConfirmDoneBook state)
 {
     if (cuocGoi.BookId != Guid.Empty)
     {
         if (cuocGoi.LoaiCuocKhach == LoaiCuocKhach.ChoKhachHopDong)
         {
             Task.Factory.StartNew(() =>
             {
                 return(WCFServicesAppXHD.SendConfirmDoneBook(cuocGoi.BookId, CommonBL.ConvertSangBienSo(cuocGoi.XeDon), (Taxi.Services.ServiceApp_XHD.ConfirmDoneBook)state));
             });
         }
         else
         {
             BackgroupActionServer(p => p.SendConfirmDoneBook(cuocGoi.BookId, CommonBL.ConvertSangBienSo(cuocGoi.XeDon), state), "Hoàn thành");
         }
     }
 }
        /// <summary>
        /// Gửi SMS khi có xe nhận
        /// </summary>
        public static bool SendSMS_ReceiveCarInfo(Guid bookId, string mobile, string privateCode, LoaiCuocKhach loaiCuoc, string privateCodeOld)
        {
            try
            {
                string driverName  = "";
                string driverPhone = "";
                if (CommonBL.DictDriver != null && CommonBL.DictDriver.ContainsKey(privateCode))
                {
                    driverName  = CommonBL.DictDriver[privateCode].TenNhanVien;
                    driverPhone = CommonBL.DictDriver[privateCode].DiDong;
                }
                TcpOPBookTripType tripType = TcpOPBookTripType.Normal;
                if (loaiCuoc == LoaiCuocKhach.ChoKhachDuongDai)
                {
                    tripType = TcpOPBookTripType.Long;
                }
                else if (loaiCuoc == LoaiCuocKhach.ChoKhachSanBay)
                {
                    tripType = TcpOPBookTripType.Airport;

                    #region BaSao : Xe nội thành chở khách đi sân bay mới nhắn tin
                    if (license.IsTaxiBaSao)
                    {
                        int soXe = 0;
                        if (int.TryParse(privateCode, out soXe)) //Nhiều xe cũng ko gửi sms
                        {
                            if (soXe >= 1000)                    //Xe sân bay của Ba Sao là xe lớn hơn 1000
                            {
                                return(true);
                            }
                        }
                    }
                    #endregion
                }
                return(Client.TryGet(p => p.SendSMS_ReceiveCarInfo(bookId, mobile, privateCode,
                                                                   CommonBL.ConvertSangBienSo(privateCode), driverName, driverPhone,
                                                                   tripType, privateCodeOld)).Value);
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("SendOperatorDispatched", ex);
                return(false);
            }
        }
Example #8
0
 private void TimXe(string soHieuXe)
 {
     try
     {
         if (SearchType.EditValue.To <int>() == 1)
         {
             T_XeOnline XeOnline = new T_XeOnline();
             XeOnline = new SyncServiceOnlineClient().GetXeOnlineBySHX(soHieuXe);
             if (XeOnline == null)
             {
                 new MessageBox.MessageBoxBA().Show(string.Format("Không tồn tại xe {0} trên hệ thống", soHieuXe),
                                                    "Thông Báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
             }
             else
             {
                 if (XeOnline.TrangThaiKhac < 0)
                 {
                     new MessageBox.MessageBoxBA().Show(
                         string.Format("Xe {0} đã mất tín hiệu " + XeOnline.TrangThaiKhacText, soHieuXe),
                         "Thông Báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
                 }
                 else
                 {
                     //PointLatLng point = new PointLatLng(XeOnline.ViDo, XeOnline.KinhDo);
                     string strDiaChi = string.Format("[{0}]:{1}", soHieuXe,
                                                      Taxi.Services.Service_Common.GetAddressByGeoBA((float)XeOnline.ViDo,
                                                                                                     (float)XeOnline.KinhDo));
                     int trangThai = 0; //xe tắt máy
                     if ((XeOnline.TrangThai & 3) > 0)
                     {
                         trangThai = 2; //xe co khach
                     }
                     else if ((XeOnline.TrangThai & 8) == 0)
                     {
                         trangThai = 1; //xe bật máy.
                     }
                     MainMap.AddMarkerXeG5(trangThai, XeOnline.KinhDo, XeOnline.ViDo, strDiaChi);
                     MainMap.Position = new PointLatLng(XeOnline.ViDo, XeOnline.KinhDo);
                 }
             }
         }
         else
         {
             string bienso = CommonBL.ConvertSangBienSo(soHieuXe);
             if (string.IsNullOrEmpty(bienso))
             {
                 new MessageBox.MessageBoxBA().Show(string.Format("Không tồn tại xe {0} trên danh sách xe hệ thống", soHieuXe),
                                                    "Thông Báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
                 return;
             }
             var rs = Service_Common.ServiceG5.TryGet(p => p.GetVehicleOnlne(bienso));
             //if (Global.IsDebug)
             //    new MessageBox.MessageBox().Show(string.Format(bienso));
             if (rs.Success && rs.Value != null)
             {
                 string strDiaChi = string.Format("[{0}]:{1}", soHieuXe,
                                                  Service_Common.GetAddressByGeoBA((float)rs.Value.Lat, (float)rs.Value.Lng));
                 int trangThai = 0;                //xe tắt máy
                 if ((rs.Value.Status & 4096) > 0) //4096  sẵn sàng
                 {
                     trangThai = 1;                //xe sẵn sàng
                 }
                 else if ((rs.Value.Status & 8) == 0)
                 {
                     //     trangThai = 1; //xe bật máy.
                 }
                 //MainMap.MarkerCustomer
                 MainMap.AddMarkerXeG5(trangThai, (float)rs.Value.Lng, (float)rs.Value.Lat, strDiaChi);
                 MainMap.Position = new PointLatLng((float)rs.Value.Lat, (float)rs.Value.Lng);
             }
             else
             {
                 new MessageBox.MessageBoxBA().Show(string.Format("Không tìm thấy vị trí xe {0} trên hệ thống", soHieuXe),
                                                    "Thông Báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
             }
         }
     }
     catch
     (Exception ex)
     {
         new MessageBox.MessageBoxBA().Show("Lỗi, không tìm thấy xe", "Thông báo lỗi",
                                            Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
     }
 }
        public static bool SendInitTrip(CuocGoi objCuocGoi)
        {
            try
            {
                var tenKH = "";
                if (!string.IsNullOrEmpty(objCuocGoi.DiaChiGoi.Trim()))
                {
                    tenKH = string.Format("-[{0}]", objCuocGoi.DiaChiGoi.Trim());
                }
                LatLng currentLatLng = new LatLng {
                    Lat = (float)objCuocGoi.GPS_ViDo, Lng = (float)objCuocGoi.GPS_KinhDo
                };
                var from = new AddressInfo
                {
                    Address = string.Format("{0}{1}", objCuocGoi.DiaChiDonKhach, tenKH),
                    Name    = objCuocGoi.DiaChiDonKhach,
                    LatLng  = currentLatLng
                };
                var to = new AddressInfo
                {
                    Address = objCuocGoi.DiaChiTraKhach,
                    Name    = objCuocGoi.DiaChiTraKhach,
                    LatLng  = new LatLng {
                        Lat = (float)objCuocGoi.GPS_ViDo_Tra, Lng = (float)objCuocGoi.GPS_KinhDo_Tra
                    }
                };
                byte carType = 0;
                if (objCuocGoi.G5_CarType == "" || objCuocGoi.G5_CarType.Split(',').Length > 1)
                {
                    carType = 0;
                }
                else
                {
                    byte.TryParse(objCuocGoi.G5_CarType, out carType);
                }
                byte   customerType   = 0;
                var    vehicleOptions = new List <VehicleOption>();
                string xeDonChiDinh   = ""; // objCuocGoi.XeDenDiem != null && objCuocGoi.XeDenDiem != "" ? objCuocGoi.XeDenDiem : objCuocGoi.XeNhan;
                string xeDieuChiDinh  = ""; // objCuocGoi.TrangThaiCuocGoi == TrangThaiCuocGoiTaxi.DieuLaiAppLaiXe ? string.Empty : xeDonChiDinh;
                if (Config_Common.App_SendRadioTrip && objCuocGoi.XeDenDiem.IndexOf(".") <= 0)
                {
                    xeDonChiDinh  = objCuocGoi.XeDenDiem != null && objCuocGoi.XeDenDiem != "" ? objCuocGoi.XeDenDiem : objCuocGoi.XeNhan;
                    xeDieuChiDinh = objCuocGoi.TrangThaiCuocGoi == TrangThaiCuocGoiTaxi.DieuLaiAppLaiXe ? string.Empty : xeDonChiDinh;
                }
                if (!string.IsNullOrEmpty(xeDieuChiDinh))
                {
                    var lst = xeDieuChiDinh.Split('.');
                    foreach (var s in lst)
                    {
                        vehicleOptions.Add(new VehicleOption
                        {
                            Distance = 0,                            //Khoảng cách
                            Vehicle  = CommonBL.ConvertSangBienSo(s) // Chuyển đổi thành biển số
                        });
                    }
                }
                string[] arrVehicleDeny = null;
                if (!string.IsNullOrEmpty(objCuocGoi.XeNhan))
                {
                    arrVehicleDeny = new string[] { objCuocGoi.XeNhan };
                }
                else if (!string.IsNullOrEmpty(objCuocGoi.XeDungDiem))
                {
                    arrVehicleDeny = new string[] { objCuocGoi.XeDungDiem };
                }
                Direction chieu = Direction.One;
                if (objCuocGoi.Long_ChieuID == 2)
                {
                    chieu = Direction.Two;
                }
                int GiaPhuTroi_Km  = 0;
                int GiaPhuTroi_Gio = 0;
                int LoaiXeID       = 0;
                int.TryParse(objCuocGoi.Long_LoaiXeID, out LoaiXeID);
                if (CommonBL.ListDanhMucVuotGio != null)
                {
                    Data.BanCo.Entity.TuyenThueBao.VuotGioQuyDinh temp = CommonBL.ListDanhMucVuotGio.Find(a => a.FK_LoaiXeID == LoaiXeID);
                    if (temp != null)
                    {
                        if (chieu == Direction.Two)
                        {
                            int.TryParse(temp.GiaDinhMucVuot1KmHaiChieu.ToString(), out GiaPhuTroi_Km);
                            int.TryParse(temp.GiaDinhMucVuot1GioHaiChieu.ToString(), out GiaPhuTroi_Gio);
                        }
                        else
                        {
                            int.TryParse(temp.GiaDinhMucVuot1KmMotChieu.ToString(), out GiaPhuTroi_Km);
                        }
                    }
                }
                BookTripType tripType = BookTripType.Normal;
                if (objCuocGoi.LoaiCuocKhach == LoaiCuocKhach.ChoKhachDuongDai)
                {
                    tripType = BookTripType.Long;
                }
                if (objCuocGoi.BookId == Guid.Empty)//Chưa khởi tạo thì khởi tạo
                {
                    objCuocGoi.BookId = Guid.NewGuid();
                    CuocGoi.G5_DIENTHOAI_UpdateBookIdByIdCuocGoi(objCuocGoi.BookId, objCuocGoi.IDCuocGoi, Enum_G5_Type.DieuApp, objCuocGoi.LenhDienThoai);
                    LogError.WriteLogInfo(string.Format("G5_DIENTHOAI_UpdateBookIdByIdCuocGoi:{0}-{1}-{2} Taxi", objCuocGoi.IDCuocGoi, objCuocGoi.CuocGoiLaiIDs, objCuocGoi.BookId));
                }

                string comment   = objCuocGoi.GhiChuDienThoai;
                string ghichu    = "";
                string showphone = "0";
                if (Config_Common.AppLX_CMDID_ShowPhoneNumber > 0)
                {
                    //{"p":1, "c":"ghi chu"}
                    if (objCuocGoi.GhiChuDienThoai != null && objCuocGoi.GhiChuDienThoai != "")
                    {
                        ghichu = objCuocGoi.GhiChuDienThoai;
                    }
                    if ((objCuocGoi.ShowPhoneAppDriver != null && objCuocGoi.ShowPhoneAppDriver) || objCuocGoi.LenhDienThoai.Contains(CommandCode.LENH_SHOWPHONENUMBER))
                    {
                        showphone = "1";
                    }

                    comment = "{" + string.Format("\"p\":{0}, \"c\":\"{1}\"", showphone, ghichu) + "}";
                }
                //temp.GiaDinhMucVuot1GioHaiChieu
                return(Client.TryGet(p => p.SendInitTrip(
                                         objCuocGoi.BookId,
                                         from,
                                         to,
                                         comment,
                                         (byte)objCuocGoi.SoLuong,
                                         carType,
                                         customerType,
                                         objCuocGoi.PhoneNumber,
                                         vehicleOptions.ToArray(),
                                         currentLatLng,
                                         arrVehicleDeny,
                                         tripType,
                                         objCuocGoi.Money_Contract > 0 ? objCuocGoi.Money_Contract : objCuocGoi.Long_GiaTien,
                                         objCuocGoi.Long_Km,
                                         chieu,
                                         GiaPhuTroi_Km,
                                         GiaPhuTroi_Gio)).Value);
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("App SendInitTrip", ex);
                return(false);
            }
        }
 /// <summary>
 /// Gửi sms khi xe đến điểm gặp khách trong điều xe đường dài! (VD: Ba Sao)
 /// </summary>
 public static bool SendSMS_ReceiveCatchedUser(Guid bookId, string mobile, string privateCode, int money, LoaiCuocKhach loaiCuoc, int giaPhuTroi, int quangduong, TcpOPDirection dir,
                                               string param6 = "", string param7 = "", string param8 = "", string param9 = "", string param10 = "")
 {
     try
     {
         string driverName = "";
         if (CommonBL.DictDriver != null && CommonBL.DictDriver.ContainsKey(privateCode))
         {
             driverName = UnicodeStrings.UnicodeFormat_V2(CommonBL.DictDriver[privateCode].TenNhanVien);
         }
         TcpOPBookTripType tripType = TcpOPBookTripType.Normal;
         if (loaiCuoc == LoaiCuocKhach.ChoKhachDuongDai)
         {
             tripType = TcpOPBookTripType.Long;
         }
         else if (loaiCuoc == LoaiCuocKhach.ChoKhachSanBay)
         {
             tripType = TcpOPBookTripType.Airport;
             #region BaSao : Xe nội thành chở khách đi sân bay mới nhắn tin
             if (license.IsTaxiBaSao)
             {
                 int soXe = 0;
                 if (int.TryParse(privateCode, out soXe)) //Nhiều xe cũng ko gửi sms
                 {
                     if (soXe >= 1000)                    //Xe sân bay của Ba Sao là xe lớn hơn 1000
                     {
                         return(true);
                     }
                 }
             }
             #endregion
         }
         if (Config_Common.SMS_CuocDuongDai_LaiXe)
         {
             return(Client.TryGet(p => p.SendSMS_ReceiveCatchedUser_V2(bookId, mobile, privateCode, driverName, CommonBL.ConvertSangBienSo(privateCode), money, tripType, giaPhuTroi, quangduong, dir, param6, param7, param8, param9, param10)).Value);
         }
         else
         {
             return(Client.TryGet(p => p.SendSMS_ReceiveCatchedUser(bookId, mobile, privateCode, money, tripType, giaPhuTroi, quangduong, dir, param6, param7, param8, param9, param10)).Value);
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("SendSMS_ReceiveCatchedUser", ex);
         return(false);
     }
 }
Example #11
0
        /// <summary>
        /// Gửi lệnh cho lái xe bằng biển số.
        /// </summary>
        /// <param name="privateCode">Số hiệu xe</param>
        /// <param name="Text">Lệnh gửi lái xe</param>
        /// <param name="BookId">BookId</param>
        /// <param name="idCuocGoi">ID Cuộc gọi</param>
        /// <param name="userId">nhân viên gửi Lệnh</param>
        /// <param name="cmdId">Mã Lệnh</param>
        /// <param name="result">Driver Command gửi lên từ lái xe, tới điều hành là gửi ACKDriver Command
        /// Để xác nhận lệnh từ lái xe đã tới điều hành.
        /// Vì thế để biết ĐH xử lý thế nào thì gửi OperatorCmd result là true: false
        /// Ví dụ: lái xe xin số, điều hành gửi về result:false => ko được, true: có được xem số</param>
        public static void SendText(string privateCode, string Text, Guid BookId, long idCuocGoi, string userId, bool isContract, int cmdId = 0, bool result = true)
        {
            try
            {
                //LogError.WriteLogInfo(string.Format("SendText:{0}" , Text));
                var Content = new SendTextContext
                {
                    VehiclePlate = CommonBL.ConvertSangBienSo(privateCode),
                    TextCommand  = Text,
                    CmdId        = cmdId,
                    BookId       = BookId,
                    Result       = result
                };
                if (Content.VehiclePlate != "")
                {
                    //Nếu là xe Car thì gửi cho bên Car
                    if (CommonBL.DictDriver.ContainsKey(privateCode))
                    {
                        if (CommonBL.DictDriver[privateCode].SystemType == Enum_SystemType.Car)
                        {
                            isContract = true;
                        }
                    }
                    Task.Factory.StartNew(() =>
                    {
                        if (isContract)
                        {
                            if (Content.CmdId == 0)
                            {
                                return(WCFServicesAppXHD.SendText(Content.VehiclePlate, Content.TextCommand, Content.BookId));
                            }
                            else
                            {
                                return(WCFServicesAppXHD.SendOperatorCmd(Content.VehiclePlate, Content.BookId, Content.CmdId, Content.TextCommand, Content.Result));
                            }
                        }
                        else
                        {
                            if (Content.CmdId == 0)
                            {
                                return(WCFServicesApp.SendText(Content.VehiclePlate, Content.TextCommand, Content.BookId));
                            }
                            else
                            {
                                return(WCFServicesApp.SendOperatorCmd(Content.VehiclePlate, Content.BookId, Content.CmdId, Content.TextCommand, Content.Result));
                            }
                        }
                    }).ContinueWith(x =>
                    {
                        if (x.Result == false)
                        {
                            if (MessageBox.Show("Lỗi gửi lệnh cho lái xe, Vui lòng gửi lại", "Thông báo",
                                                MessageBoxButtons.RetryCancel,
                                                MessageBoxIcon.Warning,
                                                MessageBoxDefaultButton.Button1) == DialogResult.Retry)
                            {
                                SendText(privateCode, Text, BookId, idCuocGoi, userId, isContract, cmdId, Content.Result);
                            }
                        }
                    });

                    var history = new T_TaxiOperation_SendCommand()
                    {
                        BookId      = Content.BookId,
                        CommandID   = Content.CmdId,
                        CommandText = Content.TextCommand,
                        CreatedBy   = userId,
                        IdCuocGoi   = idCuocGoi,
                        PrivateCode = privateCode,
                        Result      = false
                    };
                    history.Insert();
                }
            }
            catch (Exception ex)
            {
                if (MessageBox.Show("Lỗi gửi lệnh cho lái xe, Vui lòng gửi lại", "Thông báo", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.Retry)
                {
                    SendText(privateCode, Text, BookId, idCuocGoi, userId, isContract, cmdId = 0, result);
                }
                LogError.WriteLogError("SendText:", ex);
            }
        }
        private void TimXe(string soHieuXe)
        {
            try
            {
                if (SearchType.EditValue.To <int>() == 1)
                {
                    T_XeOnline XeOnline = new T_XeOnline();
                    XeOnline = WCFService_Common.GetXeOnlineBySHX(soHieuXe);
                    if (XeOnline == null)
                    {
                        new MessageBox.MessageBoxBA().Show(string.Format("Không tồn tại xe {0} trên hệ thống", soHieuXe),
                                                           "Thông Báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
                    }
                    else
                    {
                        if (XeOnline.ThoiDiemChenDuLieu <= DateTime.Now.AddMinutes(-150))
                        {
                            new MessageBox.MessageBoxBA().Show(string.Format("Xe {0} đã mất tín hiệu GPS.{1}", soHieuXe, XeOnline.TGGPS.ToString("dd/MM/yyyy HH:mm:ss")),
                                                               "Thông Báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
                        }
                        else
                        {
                            string strDiaChi = string.Format("[{0}]:{1}", soHieuXe, Service_Common.GetAddressByGeoBA(XeOnline.ViDo, XeOnline.KinhDo));
                            int    trangThai = 0; //xe tắt máy
                            if ((XeOnline.TrangThai & 3) > 0)
                            {
                                trangThai = 2; //xe co khach
                            }
                            else if ((XeOnline.TrangThai & 8) == 0)
                            {
                                trangThai = 1; //xe bật máy.
                            }

                            MainMap.addMarkerXeDeCu3(trangThai, XeOnline.KinhDo, XeOnline.ViDo, strDiaChi);
                            MainMap.Position = new PointLatLng(XeOnline.ViDo, XeOnline.KinhDo);
                        }
                    }
                }
                else
                {
                    string bienso = CommonBL.ConvertSangBienSo(soHieuXe);
                    if (string.IsNullOrEmpty(bienso))
                    {
                        new MessageBox.MessageBoxBA().Show(string.Format("Không tồn tại xe {0} trên danh sách xe hệ thống", soHieuXe),
                                                           "Thông Báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
                        return;
                    }
                    var rs = WCFServicesApp.Client.TryGet(p => p.GetVehicleOnlne(bienso));
                    //if (Global.IsDebug)
                    //    new MessageBox.MessageBox().Show(string.Format(bienso));
                    if (rs.Success && rs.Value != null)
                    {
                        string strDiaChi = string.Format("[{0}]:{1}", soHieuXe,
                                                         Service_Common.GetAddressByGeoBA((float)rs.Value.Lat, (float)rs.Value.Lng));
                        int trangThai = 0;                //xe tắt máy
                        if ((rs.Value.Status & 4096) > 0) //4096  sẵn sàng
                        {
                            trangThai = 1;                //xe sẵn sàng
                        }
                        else if ((rs.Value.Status & 8) == 0)
                        {
                            //     trangThai = 1; //xe bật máy.
                        }

                        MainMap.AddMarkerXeG5(trangThai, (float)rs.Value.Lng, (float)rs.Value.Lat, strDiaChi);
                        MainMap.Position = new PointLatLng((float)rs.Value.Lat, (float)rs.Value.Lng);
                    }
                    else
                    {
                        new MessageBox.MessageBoxBA().Show(string.Format("Không tìm thấy vị trí xe {0} trên hệ thống", soHieuXe),
                                                           "Thông Báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                new MessageBox.MessageBoxBA().Show("Lỗi, không tìm thấy xe", "Thông báo lỗi",
                                                   Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
                LogError.WriteLogError("TImXe", ex);
            }
        }
        private void txtInputGrid_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                g_CloseForm = true;
                MessageBox.MessageBoxBA msgBox = new MessageBox.MessageBoxBA();
                string s = StringTools.TrimSpace(txtInputGrid.Text);


                #region KENH
                if (g_KieuNhap == KieuNhapTrenGridTongDai.NhapChuyenKenh)
                {
                    if (s.Length <= 0)
                    {
                        this.DialogResult = DialogResult.Cancel;
                        return;
                    }
                    g_Return = s;
                    int kenhVung;
                    try
                    {
                        kenhVung = Convert.ToInt32(s);
                        if (!CheckVungNamTrongVungCauHinh(kenhVung))
                        {
                            kenhVung = -1;
                        }
                    }
                    catch
                    {
                        kenhVung = 0;
                    }
                    if (kenhVung <= 0)
                    {
                        msgBox.Show(this, "Vùng phải lớn hơn 0 và nằm trong vùng được cấp phép.", "Thông báo", MessageBox.MessageBoxButtonsBA.OK, MessageBox.MessageBoxIconBA.Question);
                        this.DialogResult = DialogResult.Cancel;
                        g_CloseForm       = false;
                        return;
                    }
                    g_CuocGoi.Vung          = kenhVung;
                    g_CuocGoi.TrangThaiLenh = TrangThaiLenhTaxi.TongGuiSangMoiKhach;
                    if (CuocGoi.TONGDAI_UpdateChuyenVung(g_CuocGoi.IDCuocGoi, ThongTinDangNhap.USER_ID, g_CuocGoi.Vung, ""))
                    {
                        this.DialogResult = DialogResult.OK;
                        g_CloseForm       = true;
                    }
                }
                #endregion KENH

                #region XENHAN
                else if (g_KieuNhap == KieuNhapTrenGridTongDai.NhapXeNhan)
                {
                    // Check xe nhận
                    string xeNhan = StringTools.ConvertToChuoiXeNhanChuan(s);
                    g_Return = xeNhan;
                    if (Config_Common.CanhBaoKhiNhapXe == 0 && !ValidateXeNhan(xeNhan, g_CuocGoi.XeDon))
                    {
                        g_CloseForm       = false;
                        this.DialogResult = DialogResult.Cancel;
                        return;
                    }
                    if (Config_Common.TDV_VALIDATE_XENHAN_APP)
                    {
                        string xeNhanMoi = StringTools.GetXeNhanMoi(g_CuocGoi.XeNhan, xeNhan);
                        List <T_TaxiOperation> lstItem = T_TaxiOperation.Inst.GetList_XeDangNhanApp(g_CuocGoi.IDCuocGoi, xeNhanMoi);
                        if (lstItem != null && lstItem.Count > 0)
                        {
                            T_TaxiOperation item         = lstItem[0];
                            frmConfirmXeDon confirmXeDon = new frmConfirmXeDon(KieuCanhBaoKhiNhapThongTin.TrungXeNhanApp, item.MessageAlert, item.Id);
                            {
                                confirmXeDon.ShowDialog();
                                if (confirmXeDon.DialogResult == DialogResult.OK && confirmXeDon.Result == 1)
                                {
                                    this.DialogResult = DialogResult.OK;
                                }
                                else
                                {
                                    g_CloseForm       = false;
                                    this.DialogResult = DialogResult.Cancel;
                                    return;
                                }
                            }
                        }
                    }
                    else if (Config_Common.TDV_XENHAN_RADIO_TO_APP)
                    {
                        string xeNhanMoi = StringTools.GetXeNhanMoi(g_CuocGoi.XeNhan, xeNhan);
                        if (CommonBL.DictApp_Current != null && CommonBL.DictApp_Current.Count > 0)
                        {
                            if (CommonBL.DictApp_Current.ContainsKey(xeNhanMoi))
                            {
                                string info = string.Format("Cuốc khách gối : {0} - {1}", g_CuocGoi.PhoneNumber, g_CuocGoi.DiaChiDonKhach);
                                Taxi.Services.WCFServicesApp.SendText(CommonBL.ConvertSangBienSo(xeNhanMoi), info, CommonBL.DictApp_Current[xeNhanMoi]);
                                g_CuocGoi.LenhTongDai = "Đã gửi cuốc gối cho lx";
                            }
                        }
                    }
                }
                #endregion XENHAN

                #region Xe MK
                else if (g_KieuNhap == KieuNhapTrenGridTongDai.NhapXeMK)
                {
                    // Check xe nhận
                    string xeNhan = StringTools.ConvertToChuoiXeNhanChuan(s);
                    g_Return = xeNhan;
                    if (Config_Common.CanhBaoKhiNhapXe == 0 && !ValidateXeMK(xeNhan, g_CuocGoi.XeNhan))
                    {
                        g_CloseForm       = false;
                        this.DialogResult = DialogResult.Cancel;
                        return;
                    }
                }
                #endregion XENHAN

                #region XEDON
                else if (s.Length > 0 && g_KieuNhap == KieuNhapTrenGridTongDai.NhapXeDon)
                {
                    // Kiểm tra xe đó có nằm trong xe nhận
                    string xeDon = StringTools.ConvertToChuoiXeNhanChuan(s);
                    g_Return = xeDon;

                    if (!string.IsNullOrEmpty(xeDon))
                    {
                        if (xeDon == "000")
                        {
                            xeDon       = "000";
                            g_IsKetThuc = true;
                        }
                        else
                        {
                            G_XeDonLength = xeDon.Split('.').Length;
                            if (Config_Common.CanhBaoKhiNhapXe == 0 && !KiemTraXeNhan(xeDon) && (!StringTools.KiemTraTrungLapXeChay(xeDon)))
                            {
                                msgBox.Show(this, "Vui lòng nhập chính xác xe đón.Báo quản trị bổ sung xe nếu thiếu", "Thông báo", MessageBox.MessageBoxButtonsBA.OK, MessageBox.MessageBoxIconBA.Question);
                                g_CloseForm       = false;
                                this.DialogResult = DialogResult.Cancel;
                                return;
                            }
                            string KenhVung_Trung;
                            string xeDangCoKhach = new CuocGoi().TONGDAI_UPDATE_XEDON_CHECKVALID(xeDon, g_CuocGoi.ThoiDiemGoi, out KenhVung_Trung);
                            if (xeDangCoKhach != "")
                            {
                                string message = String.Format("Xe {0} đã đón khách ở vùng {1} khoảng 5 phút gần đây", xeDangCoKhach, KenhVung_Trung);
                                using (frmConfirmXeDon confirmXeDon = new frmConfirmXeDon(KieuCanhBaoKhiNhapThongTin.TrungXeDon, message, g_CuocGoi.IDCuocGoi))
                                {
                                    confirmXeDon.ShowDialog();
                                    if (confirmXeDon.DialogResult == DialogResult.OK)
                                    {
                                        if (confirmXeDon.Result == 1)
                                        {
                                            if (!new Data.CuocGoi().TONGDAI_UPDATE_XACNHAN(g_CuocGoi.IDCuocGoi, message, confirmXeDon.Result, ThongTinDangNhap.USER_ID, KieuCanhBaoKhiNhapThongTin.TrungXeDon))
                                            {
                                                new MessageBox.MessageBoxBA().Show("Cập nhật lỗi", "Thông báo", MessageBox.MessageBoxButtonsBA.OK, MessageBox.MessageBoxIconBA.Error);
                                                return;
                                            }
                                            g_IsKetThuc = true;
                                        }
                                        else
                                        {
                                            g_IsKetThuc = false;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        g_IsKetThuc = false;
                                        return;
                                    }
                                }
                            }
                            if (Config_Common.CanhBaoKhiNhapXe == 0 && G_XeDonLength < g_CuocGoi.SoLuong)
                            {
                                const string message = "Chưa đủ xe số lượng xe yêu cầu";
                                using (frmConfirmXeDon confirmXeDon = new frmConfirmXeDon(KieuCanhBaoKhiNhapThongTin.ChuaDuSoLuongXeDon, message, g_CuocGoi.IDCuocGoi))
                                {
                                    confirmXeDon.ShowDialog();
                                    if (confirmXeDon.DialogResult == DialogResult.OK)
                                    {
                                        if (confirmXeDon.Result == 2)
                                        {
                                            if (!new Data.CuocGoi().TONGDAI_UPDATE_XACNHAN(g_CuocGoi.IDCuocGoi, message, confirmXeDon.Result, ThongTinDangNhap.USER_ID, KieuCanhBaoKhiNhapThongTin.ChuaDuSoLuongXeDon))
                                            {
                                                new MessageBox.MessageBoxBA().Show("Cập nhật lỗi", "Thông báo", MessageBox.MessageBoxButtonsBA.OK, MessageBox.MessageBoxIconBA.Error);
                                                return;
                                            }
                                            g_IsKetThuc = true;
                                        }
                                        else
                                        {
                                            g_IsKetThuc = false;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        g_IsKetThuc = false;
                                        return;
                                    }
                                }
                            }
                            else if (Config_Common.CanhBaoKhiNhapXe == 0 && G_XeDonLength > g_CuocGoi.SoLuong)
                            {
                                new MessageBox.MessageBoxBA().Show("Xe đón vượt số lượng yêu cầu. Vui lòng kiểm tra lại");
                                g_IsKetThuc = false;
                                return;
                            }
                            else
                            {
                                g_IsKetThuc = true;
                            }
                            string XeNhan = g_CuocGoi.XeNhan;
                            if (Config_Common.CanhBaoKhiNhapXe == 0 && Config_Common.TongDai_HienThiCanhBao_XeDonTrungXeNhan > 0 && !StringTools.KiemTraXeDonThuocXeNhan(xeDon, XeNhan))
                            {
                                string message = string.Format("Xe {0} đón nhưng không thuộc Xe Nhận", xeDon);
                                using (frmConfirmXeDon confirmXeDon = new frmConfirmXeDon(KieuCanhBaoKhiNhapThongTin.XeDonKhongThuocXeNhan, message, xeDon))
                                {
                                    confirmXeDon.ShowDialog();
                                    if (confirmXeDon.DialogResult == DialogResult.OK)
                                    {
                                        xeDon = confirmXeDon.XeDonResult;
                                        if (!new Data.CuocGoi().TONGDAI_UPDATE_XACNHAN(g_CuocGoi.IDCuocGoi, message, confirmXeDon.Result, ThongTinDangNhap.USER_ID, KieuCanhBaoKhiNhapThongTin.XeDonKhongThuocXeNhan))
                                        {
                                            new MessageBox.MessageBoxBA().Show("Cập nhật lỗi", "Thông báo", MessageBox.MessageBoxButtonsBA.OK, MessageBox.MessageBoxIconBA.Error);
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        g_IsKetThuc = false;
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    g_Return = xeDon;
                }
                #endregion

                #region XENHANDENDIEM
                else if (g_KieuNhap == KieuNhapTrenGridTongDai.NhapXeNhanDenDiem)
                {
                    // Check xe nhận
                    string xeNhanDenDiem = StringTools.ConvertToChuoiXeNhanChuan(s);
                    g_Return = s;
                    if (Config_Common.CanhBaoKhiNhapXe == 0 && !ValidateXeNhan(xeNhanDenDiem, g_CuocGoi.XeDon))
                    {
                        return;
                    }
                }
                #endregion XENHAN

                #region GHI CHU
                if (g_KieuNhap == KieuNhapTrenGridTongDai.NhapGhiChuTongDai)
                {
                    if (s.Length <= 0 && s.Equals(g_CuocGoi.GhiChuTongDai))
                    {
                        this.DialogResult = DialogResult.Cancel;
                        return;
                    }
                    g_Return = s;
                    g_CuocGoi.GhiChuTongDai = g_Return;
                    g_CuocGoi.TrangThaiLenh = TrangThaiLenhTaxi.TongGuiSangMoiKhach;
                    if (CuocGoi.TONGDAI_UpdateGhiChuTongDai(g_CuocGoi.IDCuocGoi, g_CuocGoi.GhiChuTongDai))
                    {
                        this.DialogResult = DialogResult.OK;
                        g_CloseForm       = true;
                    }
                }
                #endregion GHI CHU

                #region Tìm kiếm Xe
                if (g_KieuNhap == KieuNhapTrenGridTongDai.TimKiemXe)
                {
                    g_Return          = s;
                    this.DialogResult = DialogResult.OK;
                    g_CloseForm       = true;
                }
                #endregion

                #region Nhập địa chỉ trả
                if (g_KieuNhap == KieuNhapTrenGridTongDai.NhapDiaChiTra)
                {
                    g_Return          = s;
                    this.DialogResult = DialogResult.OK;
                    g_CloseForm       = true;
                }
                #endregion

                #region Số phút báo khách chờ
                else if (g_KieuNhap == KieuNhapTrenGridTongDai.NhapPhutKhachCho)
                {
                    g_Return          = s;
                    this.DialogResult = DialogResult.OK;
                    g_CloseForm       = true;
                }
                #endregion

                else if (s.Length > 0 && g_KieuNhap == KieuNhapTrenGridTongDai.NhapXeDungDiem)
                {
                    string xeDungDiem = StringTools.ConvertToChuoiXeNhanChuan(s);
                    g_Return = xeDungDiem;
                }
                g_CloseForm       = true;
                this.DialogResult = DialogResult.OK;

                this.Close();
            }
        }