Example #1
0
        public Test()
        {
            InitializeComponent();
            SHARED.Global.USE_APP_CONFIG = true;

            //for (int i = 0; i < 100; i++)
            //{
            //    NhanVienPT obj = new NhanVienPT();
            //    obj.hoten = "Hoten " + i;
            //    obj.mota = "Mo ta " + i;
            //    obj.sodienthoai = "SĐT " + i;
            //    obj.add();
            //}
            //DBInstance.commit();

            var re = NhanVienPTSF.search("123.4");
        }
Example #2
0
        public static List <DoSearch> DoSearch(string request)
        {
            int     limit    = 100;
            Boolean isMobile = MobileDetect.fBrowserIsMobile();

            if (isMobile)
            {
                limit = 3;
            }

            List <DoSearch> Searchs = new List <DoSearch>();

            try
            {
                List <CoSoSF> ListCoSoSF = CoSoSF.search(request).Take(limit).ToList();
                foreach (CoSoSF _CoSoSF in ListCoSoSF)
                {
                    if (_CoSoSF.match_field.FirstOrDefault().Equals("ten"))
                    {
                        Searchs.Add(new DoSearch(_CoSoSF.obj.id, _CoSoSF.obj.ten, "TENCOSO"));
                    }
                    else
                    {
                        Searchs.Add(new DoSearch(_CoSoSF.obj.id, _CoSoSF.obj.subId, "MACOSO"));
                    }
                }

                List <DayySF> ListDayySF = DayySF.search(request).Take(limit).ToList();
                foreach (DayySF _DayySF in ListDayySF)
                {
                    if (_DayySF.match_field.FirstOrDefault().Equals("ten"))
                    {
                        Searchs.Add(new DoSearch(_DayySF.obj.id, string.Format("{0} ({1})", _DayySF.obj.ten, _DayySF.obj.coso != null ? _DayySF.obj.coso.ten : "[Cơ sở]"), "TENDAY"));
                    }
                    else
                    {
                        Searchs.Add(new DoSearch(_DayySF.obj.id, string.Format("{0} ({1})", _DayySF.obj.subId, _DayySF.obj.coso != null ? _DayySF.obj.coso.ten : "[Cơ sở]"), "MADAY"));
                    }
                }

                List <TangSF> ListTangSF = TangSF.search(request).Take(limit).ToList();
                foreach (TangSF _TangSF in ListTangSF)
                {
                    if (_TangSF.match_field.FirstOrDefault().Equals("ten"))
                    {
                        Searchs.Add(new DoSearch(_TangSF.obj.id, string.Format("{0} ({1} - {2})", _TangSF.obj.ten, _TangSF.obj.day != null ? _TangSF.obj.day.coso != null ? _TangSF.obj.day.coso.ten : "[Cơ sở]" : "[Cơ sở]", _TangSF.obj.day != null ? _TangSF.obj.day.ten : "[Dãy]"), "TENTANG"));
                    }
                    else
                    {
                        Searchs.Add(new DoSearch(_TangSF.obj.id, string.Format("{0} ({1} - {2})", _TangSF.obj.subId, _TangSF.obj.day != null ? _TangSF.obj.day.coso != null ? _TangSF.obj.day.coso.ten : "[Cơ sở]" : "[Cơ sở]", _TangSF.obj.day != null ? _TangSF.obj.day.ten : "[Dãy]"), "MATANG"));
                    }
                }

                List <PhongSF> ListPhongSF = PhongSF.search(request).Take(limit).ToList();
                foreach (PhongSF _PhongSF in ListPhongSF)
                {
                    string strViTri = Libraries.StringHelper.StringViTriPhong(_PhongSF.obj);
                    if (_PhongSF.match_field.FirstOrDefault().Equals("ten"))
                    {
                        Searchs.Add(new DoSearch(_PhongSF.obj.id, string.Format("{0}{1}", _PhongSF.obj.ten, !Object.Equals(strViTri, "") ? " " + strViTri : ""), "TENPHONG"));
                    }
                    else
                    {
                        Searchs.Add(new DoSearch(_PhongSF.obj.id, string.Format("{0}{1}", _PhongSF.obj.subId, !Object.Equals(strViTri, "") ? " " + strViTri : ""), "MAPHONG"));
                    }
                }

                List <ThietBiSF> ListThietBiSF = ThietBiSF.search(request).Take(limit).ToList();
                foreach (ThietBiSF _ThietBiSF in ListThietBiSF)
                {
                    if (_ThietBiSF.match_field.FirstOrDefault().Equals("ten"))
                    {
                        Searchs.Add(new DoSearch(_ThietBiSF.obj.id, _ThietBiSF.obj.ten, "TENTHIETBI"));
                    }
                    else
                    {
                        Searchs.Add(new DoSearch(_ThietBiSF.obj.id, _ThietBiSF.obj.subId, "MATHIETBI"));
                    }
                }

                List <LoaiThietBiSF> ListLoaiThietBiSF = LoaiThietBiSF.search(request).Take(limit).ToList();
                foreach (LoaiThietBiSF _LoaiThietBiSF in ListLoaiThietBiSF)
                {
                    if (_LoaiThietBiSF.match_field.FirstOrDefault().Equals("ten"))
                    {
                        Searchs.Add(new DoSearch(_LoaiThietBiSF.obj.id, _LoaiThietBiSF.obj.ten, "TENLOAITHIETBI"));
                    }
                    else
                    {
                        Searchs.Add(new DoSearch(_LoaiThietBiSF.obj.id, _LoaiThietBiSF.obj.subId, "MALOAITHIETBI"));
                    }
                }

                List <NhanVienPTSF> ListNhanVienPTSF = NhanVienPTSF.search(request).Take(limit).ToList();
                foreach (NhanVienPTSF _NhanVienPTSF in ListNhanVienPTSF)
                {
                    if (_NhanVienPTSF.match_field.FirstOrDefault().Equals("hoten"))
                    {
                        Searchs.Add(new DoSearch(_NhanVienPTSF.obj.id, _NhanVienPTSF.obj.hoten, "TENNHANVIENPT"));
                    }
                    else if (_NhanVienPTSF.match_field.FirstOrDefault().Equals("sodienthoai"))
                    {
                        Searchs.Add(new DoSearch(_NhanVienPTSF.obj.id, _NhanVienPTSF.obj.sodienthoai, "SDTNHANVIENPT"));
                    }
                    else
                    {
                        Searchs.Add(new DoSearch(_NhanVienPTSF.obj.id, _NhanVienPTSF.obj.subId, "MANHANVIENPT"));
                    }
                }

                List <SuCoPhongSF> ListSuCoPhongSF = SuCoPhongSF.search(request).Take(limit).ToList();
                foreach (SuCoPhongSF _SuCoPhongSF in ListSuCoPhongSF)
                {
                    if (_SuCoPhongSF.match_field.FirstOrDefault().Equals("ten"))
                    {
                        Searchs.Add(new DoSearch(_SuCoPhongSF.obj.id, _SuCoPhongSF.obj.ten, "TENSUCO"));
                    }
                    else
                    {
                        Searchs.Add(new DoSearch(_SuCoPhongSF.obj.id, _SuCoPhongSF.obj.mota, "MOTASUCO"));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            return(Searchs);
        }