public static List <DanhBaEx> GetAllKhachQuens_V2()
        {
            List <DanhBaEx> lstKhachQuen = new List <DanhBaEx>();
            DataTable       dt           = new DataTable();

            dt = new Data.DanhBaKhachQuen().GetAll();
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    DanhBaEx item = GetDanhBaEx_Row(dr);
                    if (item != null)
                    {
                        string[] arrDienThoai = item.PhoneNumber.Split(";".ToCharArray());
                        for (int i = 0; i < arrDienThoai.Length; i++)
                        {
                            item.PhoneNumber = arrDienThoai[i];
                            lstKhachQuen.Add(item);
                        }
                    }
                }
            }
            dt.Dispose();
            dt = null;

            return(lstKhachQuen);
        }
 private void KhoiTaoDanhBaOnMEM_CongTy_GetLast(DateTime LastUpdate)
 {
     try
     {
         List <DanhBaEx> listDBCongTy = new List <DanhBaEx>();
         listDBCongTy = DanhBaEx.GetDanhBaCONGTY_GetLast(LastUpdate);
         // thêm vào dic
         foreach (DanhBaEx dbcty in listDBCongTy)
         {
             // chưa tồn tài thì thêm vào ds
             if (!dicDanhBaCongTy.ContainsKey(dbcty.PhoneNumber))
             {
                 dicDanhBaCongTy.TryAdd(dbcty.PhoneNumber, dbcty);
             }
             else
             {
                 dicDanhBaCongTy[dbcty.PhoneNumber] = dbcty;
             }
             if (Global.IsDebug)
             {
                 LogError.WriteLogInfo("KhoiTaoDanhBaOnMEM_CongTy_GetLast:" + dbcty.PhoneNumber + "-" + dbcty.Address);
             }
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("KhoiTaoDanhBaOnMEM_CongTy_GetLast.", ex);
     }
 }
 public static DanhBaEx GetDanhBaEx_Row(DataRow dr)
 {
     try
     {
         DanhBaEx objKhachQuen = new DanhBaEx();
         objKhachQuen.MaDoiTac       = dr["MaKH"].ToString();
         objKhachQuen.PhoneNumber    = dr["Phones"].ToString();
         objKhachQuen.Name           = dr["Name"].ToString();
         objKhachQuen.Address        = dr["Address"].ToString();
         objKhachQuen.IsActive       = Convert.ToBoolean(dr["IsActive"]);
         objKhachQuen.GhiChuTiepNhan = dr["Notes"].ToString();
         int Type = dr["Type"] == DBNull.Value ? 0 : Convert.ToInt16(dr["Type"]);
         if (Type == 1)
         {
             objKhachQuen.KieuKHGoiDen = KieuKhachHangGoiDen.KhachHangVIP;
         }
         else if (Type == 2)
         {
             objKhachQuen.KieuKHGoiDen = KieuKhachHangGoiDen.KhachHangBinhThuong;
         }
         else if (Type == 3)
         {
             objKhachQuen.KieuKHGoiDen = KieuKhachHangGoiDen.KhachHangBinhThuong;
         }
         objKhachQuen.KieuDanhBa = KieuDanhBa.ThanThiet;
         objKhachQuen.GPS_KinhDo = dr["KinhDo"] == DBNull.Value ? 0 : (float)dr["KinhDo"];
         objKhachQuen.GPS_ViDo   = dr["ViDo"] == DBNull.Value ? 0 : (float)dr["ViDo"];
         return(objKhachQuen);
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("GetDanhBaEx_Row: ", ex);
         return(null);
     }
 }
 private void bwSync_LoadDanhBaKhachQuen_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         List <DanhBaEx> lstKhachVip = DanhBaKhachQuen.GetAllKhachQuens_V2();
         if (lstKhachVip != null && lstKhachVip.Count > 0)
         {
             DanhBaEx dicRet = new DanhBaEx();
             foreach (DanhBaEx item in lstKhachVip)
             {
                 if (dicKhachQuen.ContainsKey(dicRet.PhoneNumber))
                 {
                     continue;
                 }
                 dicKhachQuen.TryAdd(dicRet.PhoneNumber, dicRet);
                 if (Global.IsDebug)
                 {
                     LogError.WriteLogInfo("bwSync_LoadDanhBaKhachQuen_DoWork:" + dicRet.PhoneNumber + "-" + dicRet.Address);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("bwSync_LoadDanhBaKhachQuen_DoWork.", ex);
     }
 }
        /// <summary>
        /// Load danh bạ công ty, khách ảo
        /// </summary>
        private void KhoiTaoDanhBaOnMEM()
        {
            try
            {
                List <DanhBaEx> listDBMoiGioi = DanhBaEx.GetDanhBaMoiGioi();
                if (dicMoiGioi == null)
                {
                    dicMoiGioi = new ConcurrentDictionary <string, DanhBaEx>();
                }
                foreach (DanhBaEx dbex in listDBMoiGioi)
                {
                    if (!dicMoiGioi.ContainsKey(dbex.PhoneNumber))
                    {
                        dicMoiGioi.TryAdd(dbex.PhoneNumber, dbex);
                    }
                }

                List <DanhBaEx> listDBCongTy = new List <DanhBaEx>();
                listDBCongTy = DanhBaEx.GetDanhBaCongTy();
                foreach (DanhBaEx dbcty in listDBCongTy)
                {
                    if (!dicDanhBaCongTy.ContainsKey(dbcty.PhoneNumber))
                    {
                        dicDanhBaCongTy.TryAdd(dbcty.PhoneNumber, dbcty);
                    }
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("KhoiTaoDanhBaOnMEM: ", ex);
            }
        }
예제 #6
0
        /// <summary>
        /// hàm thực hiện lấy danh bạ công ty.
        /// </summary>
        public static List <DanhBaEx> GetDanhBaCongTy()
        {
            //Ds danh bạ mở rộng trả về
            List <DanhBaEx> listRet = new List <DanhBaEx>();

            try
            {
                List <DanhBaCongTy> listDanhBa = DanhBaCongTy.GetDanhSachDanhBaCongTy();
                foreach (DanhBaCongTy dbcty in listDanhBa)
                {
                    string   Name = dbcty.Name.Length > 0 ? "[" + dbcty.Name + "] " : "";
                    DanhBaEx dtx  = new DanhBaEx()
                    {
                        PhoneNumber  = dbcty.PhoneNumber,
                        Address      = Name + dbcty.Address,
                        KieuDanhBa   = KieuDanhBa.CongTy,
                        KieuKHGoiDen = KieuKhachHangGoiDen.KhachHangBinhThuong,
                        IsActive     = true
                    };
                    listRet.Add(dtx);
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("GetDanhBaCongTy: ", ex);
            }

            return(listRet);
        }
예제 #7
0
        /// <summary>
        /// Get danh bạ đối tác có sự thay đổi
        /// </summary>
        public static List <DanhBaEx> GetDanhBaMoiGioi_LastUpdate(DateTime LastUpdate)
        {
            List <DanhBaEx> listRet = new List <DanhBaEx>();

            try
            {
                DoiTac        dt     = new DoiTac();
                List <DoiTac> listDT = dt.GetCacDoiTacs_LastUpdate(LastUpdate);

                foreach (DoiTac doiTac in listDT)
                {
                    // tác số điện thoại
                    string[] arrDienThoai = doiTac.Phones.Split(";".ToCharArray());
                    for (int i = 0; i < arrDienThoai.Length; i++)
                    {
                        DanhBaEx dtx = new DanhBaEx(arrDienThoai[i], doiTac.Name + " - " + doiTac.Address, KieuDanhBa.MoiGioi, doiTac.MaDoiTac, doiTac.Vung, "", doiTac.IsActive, "", doiTac.KinhDo, doiTac.ViDo, "");
                        listRet.Add(dtx);
                    }
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("GetDanhBaMoiGioi_LastUpdate ", ex);
            }

            return(listRet);
        }
 private void KhoiTaoDanhBaOnMEM_DoiTac_GetLast(DateTime LastUpdate)
 {
     try
     {
         List <DanhBaEx> listDBMoiGioi = DanhBaEx.GetDanhBaMoiGioi_LastUpdate(LastUpdate);
         if (dicMoiGioi == null)
         {
             dicMoiGioi = new ConcurrentDictionary <string, DanhBaEx>();
         }
         foreach (DanhBaEx dbex in listDBMoiGioi)
         {
             DanhBaEx dbexOut = new DanhBaEx();
             if (!dicMoiGioi.ContainsKey(dbex.PhoneNumber))
             {
                 if (dbex.IsActive)
                 {
                     dicMoiGioi.TryAdd(dbex.PhoneNumber, dbex);
                 }
                 else
                 {
                     dicMoiGioi.TryRemove(dbex.PhoneNumber, out dbexOut);
                 }
             }
             else
             {
                 if (dbex.IsActive)
                 {
                     dicMoiGioi[dbex.PhoneNumber] = dbex;
                 }
             }
             if (Global.IsDebug)
             {
                 LogError.WriteLogInfo("KhoiTaoDanhBaOnMEM_DoiTac_GetLast:" + dbex.PhoneNumber + "-" + dbex.Address);
             }
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("KhoiTaoDanhBaOnMEM_DoiTac_GetLast.", ex);
     }
 }
예제 #9
0
        /// <summary>
        /// hàm thực hiện lấy danh bạ công ty.
        /// </summary>
        /// <returns></returns>
        public static List <DanhBaEx> GetDanhBaCONGTY_GetLast(DateTime LastUpdate)
        {
            List <DanhBaEx> listRet = new List <DanhBaEx>();

            try
            {
                List <DanhBaCongTy> listDanhBa = DanhBaCongTy.GetDanhBaCONGTY_GetLast(LastUpdate);
                foreach (DanhBaCongTy dbcty in listDanhBa)
                {
                    string   Name = dbcty.Name.Length > 0 ? "[" + dbcty.Name + "] " : "";
                    DanhBaEx dtx  = new DanhBaEx(dbcty.PhoneNumber, Name + dbcty.Address, KieuDanhBa.CongTy, string.Empty, 0, "", true);
                    listRet.Add(dtx);
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("GetDanhBaCONGTY_GetLast : ", ex);
            }

            return(listRet);
        }
예제 #10
0
        /// <summary>
        /// hàm thực hiện trả về ds anh ba môi giới
        /// </summary>
        public static List <DanhBaEx> GetDanhBaMoiGioi()
        {
            List <DanhBaEx> listRet = new List <DanhBaEx>();

            try
            {
                DoiTac        dt     = new DoiTac();
                List <DoiTac> listDT = dt.GetListOfDoiTacs(true);

                foreach (DoiTac doiTac in listDT)
                {
                    // tác số điện thoại
                    string[] arrDienThoai = doiTac.Phones.Split(";".ToCharArray());
                    for (int i = 0; i < arrDienThoai.Length; i++)
                    {
                        DanhBaEx dtx = new DanhBaEx()
                        {
                            PhoneNumber    = arrDienThoai[i],
                            Address        = doiTac.Name + " - " + doiTac.Address,
                            kieuDanhBa     = KieuDanhBa.MoiGioi,
                            MaDoiTac       = doiTac.MaDoiTac,
                            Vung           = doiTac.Vung,
                            IsActive       = doiTac.IsActive,
                            GhiChuTiepNhan = doiTac.Notes,
                            GPS_KinhDo     = doiTac.KinhDo,
                            GPS_ViDo       = doiTac.ViDo,
                            KieuKHGoiDen   = KieuKhachHangGoiDen.KhachHangMoiGioi
                        };
                        listRet.Add(dtx);
                    }
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("GetDanhBaMoiGioi ", ex);
            }
            return(listRet);
        }
        /// <summary>
        /// Load danh sách  cuộc gọi gần đây
        /// </summary>
        private void KhoiTaoCuocKhachOnlineLenMEM()
        {
            try
            {
                dicCuocOnline.Clear();
                DataTable dt = new Data.CuocGoi().GetCuocOnlines_v2();
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        DanhBaEx dicRet      = new DanhBaEx();
                        string   soDienThoai = dr["PhoneNumber"] == DBNull.Value ? string.Empty : dr["PhoneNumber"].ToString();
                        string   diaChi      = dr["DiaChiDonKhach"] == DBNull.Value ? string.Empty : dr["DiaChiDonKhach"].ToString();
                        if (soDienThoai != string.Empty && diaChi != string.Empty)
                        {
                            if (dicCuocOnline.ContainsKey(soDienThoai))
                            {
                                continue;
                            }

                            string   diaChiTra       = dr["DiaChiTraKhach"] == DBNull.Value ? string.Empty : dr["DiaChiTraKhach"].ToString();
                            int      vung            = dr["Vung"] == DBNull.Value ? 0 : int.Parse(dr["Vung"].ToString());
                            string   maDoiTac        = dr["MaDoiTac"] == DBNull.Value ? string.Empty : dr["MaDoiTac"].ToString();
                            string   loaiXe          = dr["LoaiXe"] == DBNull.Value ? string.Empty : dr["LoaiXe"].ToString();
                            float    kinhDo          = dr["GPS_KinhDo"] == DBNull.Value ? 0 : float.Parse(dr["GPS_KinhDo"].ToString());
                            float    viDo            = dr["GPS_ViDo"] == DBNull.Value ? 0 : float.Parse(dr["GPS_ViDo"].ToString());
                            string   lenhDienThoai   = dr["LenhDienThoai"] == DBNull.Value ? string.Empty : dr["LenhDienThoai"].ToString();
                            string   GhiChuDienThoai = dr["GhiChuDienThoai"] == DBNull.Value ? string.Empty : dr["GhiChuDienThoai"].ToString();
                            DateTime ThoiDiemGoi     = dr["ThoiDiemGoi"] == DBNull.Value ? DateTime.MinValue : DateTime.Parse(dr["ThoiDiemGoi"].ToString());
                            long     ID           = dr["ID"] == DBNull.Value ? 0 : long.Parse(dr["ID"].ToString());
                            int      SoLanGoi     = dr["SoLanGoi"] == DBNull.Value ? 0 : int.Parse(dr["SoLanGoi"].ToString());
                            int      KieuKHGoiDen = dr["KieuKhachHangGoiDen"] == DBNull.Value ? 0 : int.Parse(dr["KieuKhachHangGoiDen"].ToString());

                            dicRet.Address             = diaChi;
                            dicRet.PhoneNumber         = soDienThoai;
                            dicRet.Vung                = vung;
                            dicRet.MaDoiTac            = maDoiTac;
                            dicRet.LoaiXe              = loaiXe;
                            dicRet.Address_Destination = diaChiTra;
                            dicRet.GPS_KinhDo          = kinhDo;
                            dicRet.GPS_ViDo            = viDo;
                            dicRet.LenhTiepNhan        = lenhDienThoai;
                            dicRet.GhiChuTiepNhan      = GhiChuDienThoai;
                            dicRet.SoLanGoi            = SoLanGoi;
                            dicRet.IdCuocGoi           = ID;
                            dicRet.ThoiDiemGoi         = ThoiDiemGoi;
                            try
                            {
                                dicRet.KieuKHGoiDen = (KieuKhachHangGoiDen)KieuKHGoiDen;
                            }
                            catch
                            {
                                dicRet.KieuKHGoiDen = KieuKhachHangGoiDen.KhachHangBinhThuong;
                            }
                            dicCuocOnline.TryAdd(soDienThoai, dicRet);
                            if (Global.IsDebug)
                            {
                                LogError.WriteLogInfo("KhoiTaoCuocKhachOnlineLenMEM:" + soDienThoai + "-" + dicRet.Address);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("KhoiTaoCuocKhachOnlineLenMEM.", ex);
            }
        }
        public DanhBaEx GetGlobalContacsInfo(string phoneNumber)
        {
            DanhBaEx item = new DanhBaEx();

            try
            {
                if (Global.IsDebug)
                {
                    LogError.WriteLogInfo("GetGlobalContacsInfo:" + phoneNumber);
                }


                if (dicMoiGioi.ContainsKey(phoneNumber))
                {
                    item = dicMoiGioi[phoneNumber];
                    if (Global.IsDebug)
                    {
                        LogError.WriteLogInfo("dicMoiGioi:" + phoneNumber + "-" + item.Address);
                    }
                    return(item);
                }
                // lấy từ cuốc online
                //lock (dicCuocOnline)
                //{
                if (dicCuocOnline.ContainsKey(phoneNumber))
                {
                    item = dicCuocOnline[phoneNumber];
                    if (Global.IsDebug)
                    {
                        LogError.WriteLogInfo("dicCuocOnline:" + dicCuocOnline.Count.ToString() + "-" + dicCuocOnline[phoneNumber].PhoneNumber + "-" + item.PhoneNumber + "-" + " - " + phoneNumber + item.Address);
                    }
                    return(dicCuocOnline[phoneNumber]);
                }
                //}

                if (dicKhachQuen.ContainsKey(phoneNumber))
                {
                    item = dicKhachQuen[phoneNumber];
                    if (Global.IsDebug)
                    {
                        LogError.WriteLogInfo("dicKhachQuen:" + phoneNumber + "-" + item.Address);
                    }
                    return(item);
                }

                // lấy theo danh bạ
                if (dicDanhBaCongTy.ContainsKey(phoneNumber))
                {
                    item = dicDanhBaCongTy[phoneNumber];
                    if (Global.IsDebug)
                    {
                        LogError.WriteLogInfo("dicDanhBaCongTy:" + phoneNumber + "-" + item.Address);
                    }
                    return(item);
                }
                //if (soDienThoai.StartsWith("04"))
                //{
                //    //Nếu là số điện thoại bàn ở HN thì mới check trong danh mục Bưu Điện.
                //    if (dicDanhBa_BuuDien.ContainsKey(soDienThoai))
                //    {
                //        item = dicDanhBa_BuuDien[soDienThoai];
                //        diaChi = item.Address;
                //        if (item.Name != "")
                //            diaChi = string.Format("[{0}]{1}", item.Name, diaChi);

                //        kieuKhachHang = KieuKhachHangGoiDen.KhachHangBinhThuong;
                //    }
                //}
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("GetGlobalContacsInfo.", ex);
                return(item);
            }
            return(item);
        }