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); } }
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); } } }
/// <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); } } }
public ServiceState GetModel(string iden) { using (MDbBase db = new MDbBase()) { return(db.GetCollection <ServiceState>().FindOne(x => x.iden == iden)); } }
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); } } }
public long GetCount() { using (MDbBase db = new MDbBase()) { return(db.GetCollection <MDbBase>().Count()); } }
public Log GetModel(string id) { using (MDbBase db = new MDbBase()) { return(db.GetCollection <Log>().FindOne(t => t.id == id)); } }
/// <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); } }
public void DeleteAll() { using (MDbBase db = new MDbBase()) { db.GetCollection <Log>().Remove(true); } }
public void Delete(string describe) { using (MDbBase db = new MDbBase()) { db.GetCollection <Log>().Remove(x => x.describe == describe); } }
public void insert(Log model) { using (MDbBase db = new MDbBase()) { model.id = MongoDB.Oid.NewOid().ToString(); db.GetCollection <Log>().Insert(model); } }
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(""); } }
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()); } }