Example #1
1
        /// <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);
            }
        }
Example #2
0
 /// <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);
 }
Example #5
0
        private static KanColeGirlVoice GetRandVoiceInfo(string name)
        {
            var query = MongoService <KanColeGirlVoice> .Get(p => p.Name.Contains(name));

            return(query.IsNullOrEmpty() ? null : query.RandElement());
        }
Example #6
0
        public static long RecentCmdsCount(int hour)
        {
            var startTime = DateTime.Now.AddHours(-hour);

            return(MongoService <CmdRec> .Count(p => p.Time >= startTime));
        }
Example #7
0
 public void Insert()
 {
     MongoService <CmdRec> .Insert(this);
 }
Example #8
0
 public void Delete()
 {
     MongoService <AliveStateCache> .Delete(this);
 }
Example #9
0
 public void Insert()
 {
     MongoService <SoldierGroup> .Insert(this);
 }
Example #10
0
 /// <summary>
 /// 移除一个群组信息
 /// </summary>
 /// <param name="GroupNum"></param>
 public static void Delete(long GroupNum)
 {
     MongoService <GroupSettings> .DeleteMany(p => p.GroupNum == GroupNum);
 }
Example #11
0
 /// <summary>
 /// 获取指定的群组信息
 /// </summary>
 /// <param name="GroupNum"></param>
 public GroupSettings this[long GroupNum] => MongoService <GroupSettings> .GetOnly(g => g.GroupNum == GroupNum);
Example #12
0
 public HomeController()
 {
     _mongoService = new MongoService();
 }
Example #13
0
 public BreweryController()
 {
     this.mongoService = new MongoService();
 }
Example #14
0
        public void Construct_Success()
        {
            MongoService repo = new MongoService(_mongoFixture.MongoClient, _mongoFixture.Logger, new Dictionary <string, HashSet <string> >());

            Assert.True(true);
        }
Example #15
0
 public void Update()
 {
     MongoService <ArchCollection> .Update(this);
 }
Example #16
0
 public TicketController(IGraphClient graphClient,
                         MongoService mongoService)
 {
     _neoContext   = graphClient;
     _mongoService = mongoService;
 }
Example #17
0
 public void Update()
 {
     MongoService <BindAiRestrict> .Update(this);
 }
Example #18
0
 public void Update()
 {
     MongoService <GlobalVarRecord> .Update(this);
 }
Example #19
0
 public CountersController(MongoService mongoService)
 {
     this.mongoService = mongoService;
 }
 public void Update()
 {
     MongoService <DailySellItemRareRecord> .Update(this);
 }
Example #21
0
 public void Insert()
 {
     MongoService <AliveStateCache> .Insert(this);
 }
Example #22
0
 public InlineUrlKey GetUrlInlineUrlKey(string botId)
 {
     return(_inlineUrlKeys.Find(x => x.Id == MongoService.TryCreateObjectId(botId)).FirstOrDefault());
 }
Example #23
0
        public static IEnumerable <CmdRec> RecentCmds(int hour)
        {
            var startTime = DateTime.Now.AddHours(-hour);

            return(MongoService <CmdRec> .Get(p => p.Time >= startTime));
        }
Example #24
0
        public bool RemoveInlineUrlKey(string id)
        {
            var deleteResult = _inlineUrlKeys.DeleteOne(x => x.Id == MongoService.TryCreateObjectId(id));

            return(deleteResult.DeletedCount > 0);
        }
Example #25
0
 internal UsersBL()
 {
     _repository = new MongoService<User>();
     //_repository = new UsersMongoService();
 }
Example #26
0
 public void Starve()
 {
     State = SoldierState.Starving;
     MongoService <SoldierGroup> .Update(this);
 }
Example #27
0
 public void Update()
 {
     MongoService <ArchAsset> .Update(this);
 }
Example #28
0
 public void Feed()
 {
     State        = SoldierState.Working;
     LastFeedTime = DateTime.Now;
     MongoService <SoldierGroup> .Update(this);
 }
Example #29
0
 public Handler(MongoService mongo, ILogger <Handler> logger)
 {
     _mongo  = mongo;
     _logger = logger;
 }
Example #30
0
 public static List <SoldierGroup> Get(long QQNum)
 {
     return(MongoService <SoldierGroup> .Get(p => p.Owner == QQNum));
 }
Example #31
0
 public void Setup()
 {
     _service = new MongoService();
 }
Example #32
0
        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));
        }
Example #33
0
 public static List <SoldierGroup> StarvingGroups(long QQNum)
 {
     return(MongoService <SoldierGroup> .Get(p => p.Owner == QQNum && p.State == SoldierState.Starving).OrderBy(p => p.LastFeedTime).ToList());
 }
Example #34
0
 public static int Pressure(string BindAi)
 {
     return((int)MongoService <RestrictRec> .Count(p => p.BindAi == BindAi));
 }