/// <summary> /// 初始化(获取mongodb信息) /// </summary> public void Init() { this.treeView1.Nodes.Clear(); connectionString = this.textBox_MongoUrl.Text; service = new MongoService(new MongoConnectionString(connectionString)); //所有数据库 var listDatabase = service.client.ListDatabases().ToList(); foreach(BsonDocument dbDoc in listDatabase) { var dbName = dbDoc["name"].ToString(); TreeNode dbNode = new TreeNode(dbName, 0, 0); dbNode.Tag = "database"; var db = service.client.GetDatabase(dbName); //所有集合(可以理解为表) var listCollection = db.ListCollections().ToList(); foreach (BsonDocument collDoc in listCollection) { var collName = collDoc["name"].ToString(); TreeNode collNode = new TreeNode(collName,1,1); collNode.Tag = "collection"; dbNode.Nodes.Add(collNode); } this.treeView1.Nodes.Add(dbNode); } }
/// <summary> /// 测试 /// </summary> public void Test() { try { MongoService mongo = new MongoService("Mongodb"); Hashtable hs = new Hashtable(); //插入单条 ErrorLog log = new ErrorLog { Code = "2016001", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }; //mongo.Insert(log); //插入批量 List<ErrorLog> insertData = new List<ErrorLog>(); insertData.Add(new ErrorLog { Code = "2016002", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }); insertData.Add(new ErrorLog { Code = "2016003", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }); insertData.Add(new ErrorLog { Code = "2016004", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }); insertData.Add(new ErrorLog { Code = "2016005", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }); insertData.Add(new ErrorLog { Code = "2016006", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }); insertData.Add(new ErrorLog { Code = "2016007", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }); insertData.Add(new ErrorLog { Code = "2016008", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }); insertData.Add(new ErrorLog { Code = "2016009", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }); insertData.Add(new ErrorLog { Code = "2016010", CreateTime = DateTime.Now.ToString(), Module = "ErrorLog", RequestData = "", ResponseData = "" }); //mongo.Insert(insertData); //获取数据 List<ErrorLog> list1 = mongo.List<ErrorLog>(); //获取指定条件数据 hs.Clear(); hs.Add("Code", "2016009"); List<ErrorLog> list2 = mongo.List<ErrorLog>(hs); //分布获取数据 hs.Clear(); PagingList<ErrorLog> list3 = mongo.PageList<ErrorLog>(hs, 1, 8, "CreateTime", true); //删除数据 //mongo.Delete(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ReportClienteController() { _mongoService = new MongoService(); }
public void Update() { MongoService <DriftBottleAnalyzeRecord> .Update(this); }
private static KanColeGirlVoice GetRandVoiceInfo(string name) { var query = MongoService <KanColeGirlVoice> .Get(p => p.Name.Contains(name)); return(query.IsNullOrEmpty() ? null : query.RandElement()); }
public static long RecentCmdsCount(int hour) { var startTime = DateTime.Now.AddHours(-hour); return(MongoService <CmdRec> .Count(p => p.Time >= startTime)); }
public void Insert() { MongoService <CmdRec> .Insert(this); }
public void Delete() { MongoService <AliveStateCache> .Delete(this); }
public void Insert() { MongoService <SoldierGroup> .Insert(this); }
/// <summary> /// 移除一个群组信息 /// </summary> /// <param name="GroupNum"></param> public static void Delete(long GroupNum) { MongoService <GroupSettings> .DeleteMany(p => p.GroupNum == GroupNum); }
/// <summary> /// 获取指定的群组信息 /// </summary> /// <param name="GroupNum"></param> public GroupSettings this[long GroupNum] => MongoService <GroupSettings> .GetOnly(g => g.GroupNum == GroupNum);
public HomeController() { _mongoService = new MongoService(); }
public BreweryController() { this.mongoService = new MongoService(); }
public void Construct_Success() { MongoService repo = new MongoService(_mongoFixture.MongoClient, _mongoFixture.Logger, new Dictionary <string, HashSet <string> >()); Assert.True(true); }
public void Update() { MongoService <ArchCollection> .Update(this); }
public TicketController(IGraphClient graphClient, MongoService mongoService) { _neoContext = graphClient; _mongoService = mongoService; }
public void Update() { MongoService <BindAiRestrict> .Update(this); }
public void Update() { MongoService <GlobalVarRecord> .Update(this); }
public CountersController(MongoService mongoService) { this.mongoService = mongoService; }
public void Update() { MongoService <DailySellItemRareRecord> .Update(this); }
public void Insert() { MongoService <AliveStateCache> .Insert(this); }
public InlineUrlKey GetUrlInlineUrlKey(string botId) { return(_inlineUrlKeys.Find(x => x.Id == MongoService.TryCreateObjectId(botId)).FirstOrDefault()); }
public static IEnumerable <CmdRec> RecentCmds(int hour) { var startTime = DateTime.Now.AddHours(-hour); return(MongoService <CmdRec> .Get(p => p.Time >= startTime)); }
public bool RemoveInlineUrlKey(string id) { var deleteResult = _inlineUrlKeys.DeleteOne(x => x.Id == MongoService.TryCreateObjectId(id)); return(deleteResult.DeletedCount > 0); }
internal UsersBL() { _repository = new MongoService<User>(); //_repository = new UsersMongoService(); }
public void Starve() { State = SoldierState.Starving; MongoService <SoldierGroup> .Update(this); }
public void Update() { MongoService <ArchAsset> .Update(this); }
public void Feed() { State = SoldierState.Working; LastFeedTime = DateTime.Now; MongoService <SoldierGroup> .Update(this); }
public Handler(MongoService mongo, ILogger <Handler> logger) { _mongo = mongo; _logger = logger; }
public static List <SoldierGroup> Get(long QQNum) { return(MongoService <SoldierGroup> .Get(p => p.Owner == QQNum)); }
public void Setup() { _service = new MongoService(); }
public static IEnumerable <SoldierGroup> OverDateRebels(int overDays) { var overTime = DateTime.Now.AddDays(-overDays); return(MongoService <SoldierGroup> .Get(p => p.State == SoldierState.Rebel && p.CreateTime <= overTime)); }
public static List <SoldierGroup> StarvingGroups(long QQNum) { return(MongoService <SoldierGroup> .Get(p => p.Owner == QQNum && p.State == SoldierState.Starving).OrderBy(p => p.LastFeedTime).ToList()); }
public static int Pressure(string BindAi) { return((int)MongoService <RestrictRec> .Count(p => p.BindAi == BindAi)); }