Exemplo n.º 1
0
 public long GetCount()
 {
     using (MDbBase db = new MDbBase())
     {
         return(db.GetCollection <MDbBase>().Count());
     }
 }
Exemplo n.º 2
0
 public ServiceState GetModel(string iden)
 {
     using (MDbBase db = new MDbBase())
     {
         return(db.GetCollection <ServiceState>().FindOne(x => x.iden == iden));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 判断是否存在
 /// </summary>
 /// <param name="describe"></param>
 /// <returns></returns>
 public bool Exist(string describe)
 {
     using (MDbBase db = new MDbBase())
     {
         return(db.GetCollection <Log>().Find(x => x.describe == describe).Documents.Count() > 0);
     }
 }
Exemplo n.º 4
0
 public Log GetModel(string id)
 {
     using (MDbBase db = new MDbBase())
     {
         return(db.GetCollection <Log>().FindOne(t => t.id == id));
     }
 }
Exemplo n.º 5
0
 public void DeleteAll()
 {
     using (MDbBase db = new MDbBase())
     {
         db.GetCollection <Log>().Remove(true);
     }
 }
Exemplo n.º 6
0
 public void Delete(string describe)
 {
     using (MDbBase db = new MDbBase())
     {
         db.GetCollection <Log>().Remove(x => x.describe == describe);
     }
 }
Exemplo n.º 7
0
 public void insert(Log model)
 {
     using (MDbBase db = new MDbBase())
     {
         model.id = MongoDB.Oid.NewOid().ToString();
         db.GetCollection <Log>().Insert(model);
     }
 }
Exemplo n.º 8
0
 public void Update(Log model)
 {
     using (MDbBase db = new MDbBase())
     {
         string id = db.GetCollection <Log>().Linq().Where(x => x.describe == model.describe).First().id;
         db.GetCollection <Log>().Update(model, x => x.id == id);
     }
 }
Exemplo n.º 9
0
 public string test()
 {
     using (MDbBase db = new MDbBase())
     {
         var dt = new BLL.DbBase().ExecuteTable("select top 10 * from yy_User");
         db.GetCollection <System.Data.DataTable>().Insert(dt);
         return("");
     }
 }
Exemplo n.º 10
0
 public bool GetLock()
 {
     using (MDbBase db = new MDbBase())
     {
         if (db.GetCollection <SynLock>().Count(x => x.id == "1") == 0)
         {
             return(false);
         }
         else
         {
             return(db.GetCollection <SynLock>().FindOne(x => x.id == "1").lck);
         }
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// 系统解锁
 /// </summary>
 public void UnLock()
 {
     using (MDbBase db = new MDbBase())
     {
         this.id  = "1";
         this.lck = false;
         if (db.GetCollection <SynLock>().Count(x => x.id == "1") == 0)
         {
             db.GetCollection <SynLock>().Insert(this);
         }
         else
         {
             db.GetCollection <SynLock>().Save(this);
         }
     }
 }
Exemplo n.º 12
0
 public void insert()
 {
     using (MDbBase db = new MDbBase())
     {
         if (db.GetCollection <ServiceState>().Linq().Where(x => x.iden == this.iden).Count() == 0)
         {
             UpdateTime = DateTime.Now;
             db.GetCollection <ServiceState>().Insert(this);
         }
         else
         {
             UpdateTime = DateTime.Now;
             db.GetCollection <ServiceState>().Update <ServiceState>(this, x => x.iden == iden);
         }
     }
 }
Exemplo n.º 13
0
        public List <Log> GetList(int PageSize, int PageIndex, out int recordCount, out int pageCount, bool order, string orderField, bool like, string whereField, string whereString, string type)
        {
            using (MDbBase db = new MDbBase())
            {
                var q = db.GetCollection <Log>().Linq();
                int typeint;
                if (int.TryParse(type, out typeint))
                {
                    q = q.Where(x => x.type == typeint);
                }
                if (!string.IsNullOrEmpty(username))
                {
                    q = q.Where(x => x.username == username);
                }

                if (!string.IsNullOrEmpty(whereString))
                {
                    if (like)
                    {
                        switch (whereField)
                        {
                        case "describe":
                        {
                            q = q.Where(x => x.describe == whereString);
                            break;
                        }

                        case "ip":
                        {
                            q = q.Where(x => x.ip == whereString);
                            break;
                        }

                        case "source":
                        {
                            q = q.Where(x => x.source == whereString);
                            break;
                        }
                        }
                    }
                    else
                    {
                        switch (whereField)
                        {
                        case "describe":
                        {
                            q = q.Where(x => x.describe.Contains(whereString));
                            break;
                        }

                        case "ip":
                        {
                            q = q.Where(x => x.ip.Contains(whereString));
                            break;
                        }

                        case "source":
                        {
                            q = q.Where(x => x.source.Contains(whereString));
                            break;
                        }
                        }
                    }
                }
                recordCount = q.Count();
                pageCount   = recordCount / PageSize;
                if ((recordCount % PageSize) != 0)
                {
                    pageCount++;
                }
                return(q.OrderByDescending(x => x.created).Skip(PageSize * (PageIndex - 1)).Take(PageSize).ToList());
            }
        }