Exemple #1
0
        public List <BO.BuoiHoc.BuoiHoc> GetListBuoiHocByLopHoc(BO.GiangVien.LopHoc lh)
        {
            var collection = MongoDB <BO.BuoiHoc.BuoiHoc> .GetCollection(Config.BUOI_HOC_COLLECTION);

            List <BO.BuoiHoc.BuoiHoc> listBuoiHoc = collection.Find(x => lh.DSBuoiHoc.Contains(x._id)).ToList();

            return(listBuoiHoc);
        }
Exemple #2
0
        public void LuuLopHoc(BO.GiangVien.GiangVien gv, BO.GiangVien.LopHoc lh)
        {
            var collection = MongoDB <BO.GiangVien.GiangVien> .GetCollection(Config.GIANG_VIEN_COLLECTION);

            var filter = Builders <BO.GiangVien.GiangVien> .Filter.Eq(s => s.MaGv, gv.MaGv);

            var update = Builders <BO.GiangVien.GiangVien> .Update.Push <BO.GiangVien.LopHoc>(x => x.DSLopHoc, lh);


            collection.FindOneAndUpdate(filter, update);
        }
Exemple #3
0
        public List <BO.GiangVien.GiangVien> GetListOnLyGiangVien()
        {
            List <BO.GiangVien.GiangVien> dsGiangVien = new List <BO.GiangVien.GiangVien>();

            dsGiangVien = MongoDB <BO.GiangVien.GiangVien> .GetCollection(Config.GIANG_VIEN_COLLECTION)
                          .Find(x => true)
                          .Project <BO.GiangVien.GiangVien>("{ ho_gv:1, ten_gv:1, _id:1}")
                          .ToList();

            return(dsGiangVien);
        }
Exemple #4
0
        public BO.GiangVien.GiangVien LuuGiangVien(BO.GiangVien.GiangVien gv)
        {
            var collection = MongoDB <BO.GiangVien.GiangVien> .GetCollection(Config.GIANG_VIEN_COLLECTION);

            BO.GiangVien.GiangVien gvv = collection.Find(x => x.MaGv == gv.MaGv).SingleOrDefault();
            if (gvv == null)
            {
                collection.InsertOne(gv);
                return(gv);
            }
            return(gvv);
        }
        public DatabaseContext(DatabaseSettings settings)
        {
            MongoClient client = new MongoClient(settings.ConnectionString);

            MongoDB = client.GetDatabase(settings.DatabaseName);
            bool isActiveServer = MongoDB.RunCommandAsync((Command <BsonDocument>) "{ping:1}")
                                  .Wait(settings.ServerResponeWaitTime);

            if (!isActiveServer)
            {
                throw new Exception("Mongo server didnt respond: check if the server is running");
            }

            Predmet = MongoDB.GetCollection <PredmetModel>(settings.PredmetCollectionName);
            Rociste = MongoDB.GetCollection <RocisteModel>(settings.RocisteCollectionName);
        }
Exemple #6
0
        public void TaoBuoiHoc(BO.GiangVien.LopHoc lh, BO.GiangVien.GiangVien gv)
        {
            var configCollection = MongoDB <BO.ConfigSystem> .GetCollection(Config.CONFIG_COLLECTION);

            BO.ConfigSystem config = configCollection.Find(x => true).SingleOrDefault();

            DateTime ngayHoc                    = config.NgayBatDau;
            int      thuNgayNhapHoc             = Common.GetIntDayByDate(config.NgayBatDau);
            List <BO.BuoiHoc.BuoiHoc> dsBuoiHoc = new List <BO.BuoiHoc.BuoiHoc>();

            if (lh.Thu < thuNgayNhapHoc)
            {
                ngayHoc = ngayHoc.AddDays(7 - lh.Thu);
            }
            else
            {
                ngayHoc = ngayHoc.AddDays(lh.Thu - thuNgayNhapHoc);
            }

            for (int j = 0; j < config.SoBuoi; j++)
            {
                BO.BuoiHoc.BuoiHoc th = new BO.BuoiHoc.BuoiHoc()
                {
                    NgayHoc        = ngayHoc,
                    Phong          = lh.Phong,
                    SoTiet         = lh.SoTiet,
                    Thu            = lh.Thu,
                    TuanHoc        = j + 1,
                    TietBatDau     = lh.TietBd,
                    HoTenGiangVien = gv.HoTenGV,
                    MaGiangVien    = gv.MaGv,
                    TenMonHoc      = lh.TenMonHoc
                };

                lh.DSBuoiHoc.Add(th._id);
                ngayHoc = ngayHoc.AddDays(7);
                dsBuoiHoc.Add(th);
            }
            LuuDSBuoiHoc(dsBuoiHoc);
        }
Exemple #7
0
 public void LuuConfigSystem(BO.ConfigSystem config)
 {
     MongoDB <BO.ConfigSystem> .GetCollection(Config.CONFIG_COLLECTION).InsertOne(config);
 }
Exemple #8
0
        public void LuuDSBuoiHoc(List <BO.BuoiHoc.BuoiHoc> dsBuoiHoc)
        {
            var collection = MongoDB <BO.BuoiHoc.BuoiHoc> .GetCollection(Config.BUOI_HOC_COLLECTION);

            collection.InsertMany(dsBuoiHoc);
        }
Exemple #9
0
 public BO.GiangVien.GiangVien GetGiangVienDSLopHoc(string id)
 {
     return(MongoDB <BO.GiangVien.GiangVien> .GetCollection(Config.GIANG_VIEN_COLLECTION).Find(x => x.MaGv == id).Project <BO.GiangVien.GiangVien>(@"{""danh_sach_lop_hoc.danh_sach_buoi_hoc"":0}").SingleOrDefault());
 }
Exemple #10
0
 public BO.GiangVien.GiangVien GetGiangVien(string id)
 {
     return(MongoDB <BO.GiangVien.GiangVien> .GetCollection(Config.GIANG_VIEN_COLLECTION).Find(x => x.MaGv == id).SingleOrDefault());
 }
Exemple #11
0
 public List <BO.GiangVien.GiangVien> GetGiangVienByName(string ten)
 {
     return(MongoDB <BO.GiangVien.GiangVien> .GetCollection(Config.GIANG_VIEN_COLLECTION).Find(@"{ ""ten_gv"": /" + ten.Trim() + "/i}").Project <BO.GiangVien.GiangVien>("{ ho_gv:1, ten_gv:1, _id:1}")
            .ToList());;
 }
Exemple #12
0
        private void MakeJs(TreeNode treeNode, MongoDB.Driver.MongoDatabase mongoDatabase,bool bRefresh)
        {
            //throw new NotImplementedException();
            if (bRefresh) treeNode.Nodes.Clear();
            if (treeNode.Nodes.Count <= 0)
            {
                Log("db."+mongoDatabase.Name+".system.js.find()");
                foreach (MongoDB.Bson.BsonDocument bd in mongoDatabase.GetCollection(Data.Data.sysStore).FindAll())
                {
                    Data.JSStore js =new Data.JSStore();
                    foreach (MongoDB.Bson.BsonElement be in bd.Elements)
                    {
                        if (be.Name == "_id")
                            js.Name = be.Value.ToString();
                        else
                            js.Value = be.Value.ToString();//.Substring(19, be.Value.ToString().Length - 20);
                    }

                    Data.MTag mt = new Data.MTag(Data.Data.DbCludes.jsstore);
                    mt.tag = js;
                    TreeNode tn = new TreeNode(js.Name);
                    tn.ImageIndex = (int)Data.Data.DbCludes.jsstore;
                    tn.SelectedImageIndex = (int)Data.Data.DbCludes.jsstore;
                    tn.Tag = mt;
                    treeNode.Nodes.Add(tn);
                }
                treeNode.ExpandAll();
            }
        }
Exemple #13
0
 private void MakeCollections(TreeNode treeNode, MongoDB.Driver.MongoDatabase mongoDatabase,bool bRefresh)
 {
     //throw new NotImplementedException();
     if (bRefresh) treeNode.Nodes.Clear();
     if (treeNode.Nodes.Count <= 0)
     {
         foreach (string s in mongoDatabase.GetCollectionNames())
         {
             if (s.IndexOf("system") == 0) // system belong to Db,not Collections!
                 continue;
             TreeNode tn = new TreeNode(s);
             tn.ImageIndex = (int)Data.Data.DbCludes.table;
             tn.SelectedImageIndex = (int)Data.Data.DbCludes.table;
             Data.MTag mt = new Data.MTag(Data.Data.DbCludes.table);
             mt.tag = mongoDatabase.GetCollection(s);
             tn.Tag = mt;
             AddIndexes(tn);
             treeNode.Nodes.Add(tn);
         }
         treeNode.ExpandAll();
     }
 }