예제 #1
0
        public long bookTaxi_V2(TaxiOperation taxi)
        {
            int kq = 0;

            SqlParameter[] para = new SqlParameter[] {
                new SqlParameter("TenKhachHang", taxi.TenKhachHang),
                new SqlParameter("PhoneNumber", taxi.SoDienThoai),
                new SqlParameter("DiaChiDonKhach", taxi.DiaChiDon),
                new SqlParameter("LoaiXe", taxi.LoaiXe),
                new SqlParameter("SoLuong", taxi.SoLuongXe),
                new SqlParameter("DiaChiTraKhach", taxi.DiaChiTraKhach),
                new SqlParameter("GhiChuDienThoai", taxi.GhiChu),
                new SqlParameter("GioDon", taxi.GioDon),
                new SqlParameter("Email", taxi.Email),
                new SqlParameter("LenhDienThoai", taxi.LenhDienThoai),
                new SqlParameter("Line", taxi.Line),
                new SqlParameter("Source", taxi.Source),
                new SqlParameter("Lat", taxi.Lat),
                new SqlParameter("Lng", taxi.Lng),
                new SqlParameter("SenderId", taxi.SenderID),
                new SqlParameter("Ext1", taxi.Ext1),
                new SqlParameter("Ext2", taxi.Ext2),
                new SqlParameter("TickedId", SqlDbType.BigInt)
            };
            para[17].Direction = ParameterDirection.Output;

            if (taxi.brand == Brand.VinhPhuc)
            {
                myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString_VinhPhuc"];
            }
            else if (taxi.brand == Brand.HaNam)
            {
                myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString_HaNam"];
            }
            else if (taxi.brand == Brand.ThuaThienHue)
            {
                myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString_ThuaThienHue"];
            }
            else if (taxi.brand == Brand.QuangNinh)
            {
                myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString_QuangNinh"];
            }
            else
            {
                myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
            }
            DataSet dataset = SqlHelper.ExecuteDataset(myConnectionString, "SP_T_TaxiOperation_BookTaxi_V2", para);

            if (dataset != null && dataset.Tables != null && dataset.Tables.Count > 0)
            {
                DataTable dt = dataset.Tables[0];
                return((long)dt.Rows[0][0]);
            }
            return(0);
        }
예제 #2
0
        //insert vao bang TaxiOperation
        public int bookTaxi(TaxiOperation taxi)
        {
            int kq = 0;

            SqlParameter[] para = new SqlParameter[] {
                new SqlParameter("TenKhachHang", taxi.TenKhachHang),
                new SqlParameter("PhoneNumber", taxi.SoDienThoai),
                new SqlParameter("DiaChiDonKhach", taxi.DiaChiDon),
                new SqlParameter("LoaiXe", taxi.LoaiXe),
                new SqlParameter("SoLuong", taxi.SoLuongXe),
                new SqlParameter("DiaChiTraKhach", taxi.DiaChiTraKhach),
                new SqlParameter("GhiChuDienThoai", taxi.GhiChu),
                new SqlParameter("GioDon", taxi.GioDon),
                new SqlParameter("Email", taxi.Email),
                new SqlParameter("LenhDienThoai", taxi.LenhDienThoai),
                new SqlParameter("Line", taxi.Line),
                new SqlParameter("Source", taxi.Source)
            };
            if (taxi.brand == Brand.VinhPhuc)
            {
                myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString_VinhPhuc"];
            }
            else if (taxi.brand == Brand.HaNam)
            {
                myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString_HaNam"];
            }
            else if (taxi.brand == Brand.ThuaThienHue)
            {
                myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString_ThuaThienHue"];
            }
            else
            {
                myConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
            }
            return(SqlHelper.ExecuteNonQuery(myConnectionString, "SP_T_TaxiOperation_BookTaxi", para));
        }
 public string BookingTaxi(string CustName, string Phone, string Addr, string VehType, int Qty, DateTime Time, string GhiChu, int brand, short src, string dmn)
 {
     try
     {
         if (CheckAuth(dmn))
         {
             //Vĩnh Phúc: 117.0.37.249
             //Taxi Thành Công: Hà Nam: 222.252.214.133
             //Taxi Thành Công: Huế:  117.2.0.48
             var taxi = new TaxiOperation()
             {
                 SoDienThoai = Phone,
                 DiaChiDon   = string.Format("[{0:HH:mm dd/MM}] {1}", Time, Addr)
             };
             //validate loại xe
             if (VehType.Length > 0)
             {
                 string[] arr = VehType.Split(';');
                 var      lx  = string.Empty;
                 foreach (string xe in arr)
                 {
                     if (xe.Length > 0)
                     {
                         lx += string.Format("{0}  chỗ;", xe);
                     }
                 }
                 taxi.LoaiXe = lx.Trim(';');
             }
             //check số lượng xe
             if (Qty == null || Qty == 0)
             {
                 Qty = 1;
             }
             else
             {
                 taxi.SoLuongXe = Qty;
             }
             taxi.GioDon        = Time;
             taxi.TenKhachHang  = CustName;
             taxi.LenhDienThoai = VehType;
             taxi.GhiChu        = GhiChu;
             taxi.brand         = (Brand)brand;
             taxi.Source        = src;
             string kq = "";
             try
             {
                 if (dao.bookTaxi(taxi) > 0)
                 {
                     kq = "1";
                 }
                 else
                 {
                     kq = "F";
                     LogError.WriteLogErrorForDebug("F : Không thành công");
                 }
             }
             catch (InvalidCastException ex)
             {
                 kq = "E2";
                 LogError.WriteLogError("E2 :", ex);
             }
             catch (SqlException ex)
             {
                 kq = "E1";
                 LogError.WriteLogError("E1 :", ex);
             }
             return(kq);
         }
         else
         {
             LogError.WriteLogErrorForDebug("E3 : Không đúng  thông tin truy cập");
             return("E3");
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("E4 : ", ex);
         return("E4");
     }
 }
        public string BookingTaxi_V2(string CustName, string Phone, string Addr, string VehType, int Qty, DateTime Time,
                                     string description, int brand, short src, string dmn, string lat, string lng, string senderID,
                                     string extension1 = "", string extension2 = "")
        {
            try
            {
                if (CheckAuth(dmn))
                {
                    //Vĩnh Phúc: 117.0.37.249
                    //Taxi Thành Công: Hà Nam: 222.252.214.133
                    //Taxi Thành Công: Huế:  117.2.0.48


                    float fLat = 0;
                    float fLng = 0;
                    float.TryParse(lat.Trim(), out fLat);
                    float.TryParse(lng.Trim(), out fLng);
                    if (fLat > 0 && fLng > 0)
                    {
                        string strlocation = string.Format("{0}, {1}", lat.Trim(), lng.Trim());

                        LogError.WriteLogErrorForDebug("strlocation : " + strlocation);

                        LogError.WriteLogErrorForDebug("Addr : " + Addr);
                        if (Addr.Contains("Location") || Addr.Contains("Pinned") || (Addr.Contains(lng.Trim()) && Addr.Contains(lng.Trim())))
                        {
                            try
                            {
                                using (ServicesOnlineClient geo = new ServicesOnlineClient())
                                {
                                    var auth = new AuthenticationHeader()
                                    {
                                        UserName = "******",
                                        PassWord = "******",
                                        Key      = "BAGIS_20160126"
                                    };
                                    string addressLocation = geo.GetAddressByGeo(auth, fLng, fLat);
                                    if (addressLocation != "" || addressLocation != "*")
                                    {
                                        //Addr = Addr.Replace(strlocation, "");
                                        Addr = addressLocation;
                                        LogError.WriteLogErrorForDebug("Addr new: " + Addr);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                LogError.WriteLogError("GEO ERR :", ex);
                            }
                        }
                    }
                    ////validate loại xe
                    //if (VehType.Length > 0)
                    //{
                    //    string[] arr = VehType.Split(';');
                    //    var lx = string.Empty;
                    //    foreach (string xe in arr)
                    //    {
                    //        if (xe.Length > 0)
                    //        {
                    //            lx += string.Format("{0}  chỗ;", xe);
                    //        }
                    //    }
                    //    taxi.LoaiXe = lx.Trim(';');
                    //}
                    var taxi = new TaxiOperation()
                    {
                        SoDienThoai = Phone,
                        DiaChiDon   = string.Format("[{0:HH:mm dd/MM}] {1}", Time, Addr)
                    };
                    taxi.LoaiXe = VehType;
                    //check số lượng xe
                    if (Qty == null || Qty == 0)
                    {
                        Qty = 1;
                    }
                    else
                    {
                        taxi.SoLuongXe = Qty;
                    }
                    taxi.GioDon       = Time;
                    taxi.TenKhachHang = CustName;
                    //taxi.LenhDienThoai = VehType;
                    taxi.GhiChu   = description;
                    taxi.brand    = (Brand)brand;
                    taxi.Source   = src;
                    taxi.Lat      = fLat;
                    taxi.Lng      = fLng;
                    taxi.SenderID = senderID;
                    taxi.Ext1     = extension1;
                    taxi.Ext2     = extension2;
                    string kq = "";
                    try
                    {
                        long id = dao.bookTaxi_V2(taxi);
                        if (id > 0)
                        {
                            kq = id.ToString();
                        }
                        else
                        {
                            kq = "F";
                            LogError.WriteLogErrorForDebug("F : Không thành công");
                        }
                    }
                    catch (InvalidCastException ex)
                    {
                        kq = "E2";
                        LogError.WriteLogError("E2 :", ex);
                    }
                    catch (SqlException ex)
                    {
                        kq = "E1";
                        LogError.WriteLogError("E1 :", ex);
                    }
                    return(kq);
                }
                else
                {
                    LogError.WriteLogErrorForDebug("E3 : Không đúng  thông tin truy cập");
                    return("E3");
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("E4 : ", ex);
                return("E4");
            }
        }