コード例 #1
0
 public OrdersController(
     ILogger <OrdersController> logger,
     MongoDbService service)
 {
     _logger  = logger;
     _service = service;
 }
コード例 #2
0
        public async Task <JsonResult> Get()
        {
            var dbService  = new MongoDbService("dev-challenge", "Titles", "mongodb://*****:*****@ds043348.mongolab.com:43348/dev-challenge");
            var allContent = await dbService.GetContent();

            return(Json(allContent));
        }
コード例 #3
0
ファイル: RssService.cs プロジェクト: ppaarrkk/web-crawler
        public RssService(MongoDbService mongoDbService)
        {
            _mongoDbRss = new MongoDbUtil <Rss>(mongoDbService.Database);

            _mongoDbRss.Collection.Indexes.CreateOne(new CreateIndexModel <Rss>(
                                                         Builders <Rss> .IndexKeys.Ascending(x => x.Url)));
        }
コード例 #4
0
        public async Task <JsonResult> Get()
        {
            var mongoDbService = new MongoDbService("mongodb://*****:*****@ds149754.mlab.com:49754/chatter", "chatter", "users");
            var users          = await mongoDbService.GetAllUsers();

            return(Json(users));
        }
コード例 #5
0
        public async Task <JsonResult> Get()
        {
            var mongoDbService = new MongoDbService(DatabaseName, "Todos", DatabaseUrl);
            var allTodos       = await mongoDbService.GetAllTodos();

            return(Json(allTodos));
        }
コード例 #6
0
ファイル: HomeController.cs プロジェクト: xxxfly/MongoDBDemo
 static void UpdateOne()
 {
     var ss = new MongoDbService().Update <BsonDocument>("db1", "colTest1", m => m["CreateTime"].AsString.Contains("2017-12-26"), n => new BsonDocument {
         { "CreateTime", BsonDateTime.Create(DateTime.Parse(n["CreateTime"].AsString)) }
     }
                                                         );
 }
コード例 #7
0
 public CoverArtService(IBackgroundQueue <CoverArtJob> queue, ILogger <CoverArtService> logger, IMemoryCache memoryCache, MongoDbService dataService)
 {
     _queue       = queue;
     _logger      = logger;
     _dataService = dataService;
     _memoryCache = memoryCache;
 }
コード例 #8
0
ファイル: HomeController.cs プロジェクト: xxxfly/MongoDBDemo
        static void GetOne()
        {
            var s1 = new MongoDbService().List <BsonDocument>("db1", "colTest2", m => true, m => m, null);

            foreach (BsonDocument item in s1)
            {
            }
        }
コード例 #9
0
 public UsersController(IServiceProvider serviceProvider)
 {
     _configuration  = serviceProvider.GetService <IConfiguration>();
     _memoryCache    = serviceProvider.GetService <IMemoryCache>();
     _emailService   = serviceProvider.GetService <EmailService>();
     _mongoDbService = serviceProvider.GetService <MongoDbService>();
     _signInManager  = serviceProvider.GetService <SignInManager <ApplicationUser> >();
     _userManager    = serviceProvider.GetService <UserManager <ApplicationUser> >();
 }
コード例 #10
0
        public NotificationService(MongoDbService mongoDbService,
                                   IHttpClientFactory httpClientFactory)
        {
            _mongoDbNotification = new MongoDbUtil <Notification>(mongoDbService.Database);
            _httpClientFactory   = httpClientFactory;

            _mongoDbNotification.Collection.Indexes.CreateOne(new CreateIndexModel <Notification>(
                                                                  Builders <Notification> .IndexKeys.Ascending(x => x.Region)));
        }
コード例 #11
0
ファイル: SourceService.cs プロジェクト: ppaarrkk/web-crawler
        public SourceService(MongoDbService mongoDbService)
        {
            _mongoDbSource = new MongoDbUtil <Source>(mongoDbService.Database);

            _mongoDbSource.Collection.Indexes.CreateOne(new CreateIndexModel <Source>(
                                                            Builders <Source> .IndexKeys.Ascending(x => x.Type)));

            _mongoDbSource.Collection.Indexes.CreateOne(new CreateIndexModel <Source>(
                                                            Builders <Source> .IndexKeys.Ascending(x => x.Type).Ascending(x => x.BoardId)));
        }
コード例 #12
0
        public NotificationService(MongoDbService mongoDbService,
                                   IHttpClientFactory httpClientFactory,
                                   SourceService sourceService)
        {
            _mongoDbNotification = new MongoDbUtil <Notification>(mongoDbService.Database);
            _httpClientFactory   = httpClientFactory;

            _sourceService = sourceService;

            _mongoDbNotification.Collection.Indexes.CreateOne(new CreateIndexModel <Notification>(
                                                                  Builders <Notification> .IndexKeys.Ascending(x => x.SourceId)
                                                                  .Ascending(x => x.CrawlingType)
                                                                  .Ascending(x => x.Type)));
        }
コード例 #13
0
        public TrackingService(IConfiguration configuration,
                               MongoDbService mongoDbService,
                               NotificationService notificationService,
                               IHttpClientFactory httpClientFactory)
        {
            _riotApiCrawler      = new RiotCrawler(mongoDbService.Database, httpClientFactory.CreateClient()).Create(configuration.GetRiotApiCrawlerSettings().RiotApiKey);
            _notificationService = notificationService;

            var champions = _riotApiCrawler.GetChampions(Region.KR).Result;

            if (champions != null)
            {
                _champions = champions.ToDictionary(x => x.Key);
            }
        }
コード例 #14
0
        static void Main(string[] args)
        {
            mongoDbService = new MongoDbService("mongodb://localhost:27017", "sirene_app");
            //Test3("42","015");


            List <Etablissement> data = GetEtablissementsCommune("42", "015");

            foreach (Etablissement x in data)
            {
                Console.WriteLine($"nomen_long: {x.nomen_long}, libnj: {x.libnj}, natetab: {x.natetab}, libapet: {x.libapet}");
            }

            Console.Read();
        }
コード例 #15
0
        public void log(string Operator, string Method, string boo, string reason)
        {
            var dbService = new MongoDbService();

            var id = Guid.NewGuid().ToString();

            dbService.Add(new LogEntity
            {
                _id      = id,
                Operator = Operator,
                Method   = Method,
                boo      = boo,
                reason   = reason,
                Time     = DateTime.Now
            });
        }
コード例 #16
0
        public FeedCrawlingService(MongoDbService mongoDbService,
                                   RssService rssService,
                                   NotificationService notificationService)
        {
            _mongoDbService      = mongoDbService;
            _rssService          = rssService;
            _notificationService = notificationService;
            _mongoFeedData       = new MongoDbUtil <FeedData>(mongoDbService.Database);

            _mongoFeedData.Collection.Indexes.CreateOne(new CreateIndexModel <FeedData>(
                                                            Builders <FeedData> .IndexKeys.Ascending(x => x.DateTime)));

            _mongoFeedData.Collection.Indexes.CreateOne(new CreateIndexModel <FeedData>(
                                                            Builders <FeedData> .IndexKeys.Ascending(x => x.ItemTitle)));

            _mongoFeedData.Collection.Indexes.CreateOne(new CreateIndexModel <FeedData>(
                                                            Builders <FeedData> .IndexKeys.Ascending(x => x.FeedTitle)));
        }
コード例 #17
0
        public WebCrawlingService(MongoDbService mongoDbService,
                                  SourceService sourceService,
                                  NotificationService notificationService)
        {
            _mongoDbService      = mongoDbService;
            _sourceService       = sourceService;
            _notificationService = notificationService;
            _mongoCrawlingData   = new MongoDbUtil <CrawlingData>(mongoDbService.Database);

            _mongoCrawlingData.Collection.Indexes.CreateOne(new CreateIndexModel <CrawlingData>(
                                                                Builders <CrawlingData> .IndexKeys.Ascending(x => x.DateTime)));

            _mongoCrawlingData.Collection.Indexes.CreateOne(new CreateIndexModel <CrawlingData>(
                                                                Builders <CrawlingData> .IndexKeys.Ascending(x => x.Title)));

            _mongoCrawlingData.Collection.Indexes.CreateOne(new CreateIndexModel <CrawlingData>(
                                                                Builders <CrawlingData> .IndexKeys.Ascending(x => x.Type)));

            _mongoCrawlingData.Collection.Indexes.CreateOne(new CreateIndexModel <CrawlingData>(
                                                                Builders <CrawlingData> .IndexKeys.Ascending(x => x.Type).Ascending(x => x.BoardId)));
        }
コード例 #18
0
ファイル: MongoDBController.cs プロジェクト: FB208/Finance
        // GET: MongoDB
        public ActionResult Index()
        {
            //var database = "FinanceDB";
            //        var collection = "Test1";
            //            var db = new MongoClient("mongodb://123.207.187.133:27017").GetDatabase(database);
            //             var coll = db.GetCollection<TestMongo>(collection);

            //             var entity = new TestMongo
            //             {
            //                     Name = "SkyChen",
            //                     Amount = 100,
            //                   CreateDateTime = DateTime.Now
            //                 };

            //            coll.InsertOneAsync(entity).ConfigureAwait(false);

            var ss = new MongoDbService().List <User>(m => true);


            return(View());
        }
コード例 #19
0
        /// <summary>
        ///  获取公告
        /// </summary>
        /// <returns></returns>
        public ActionResult GetNotice()
        {
            DateTime dtNow = DateTime.Now;

            //判断是否有登录用户
            if (Session["AN"] != null)
            {
                var msgStatus = DALUtility.MDbS.List <NoticState>("XMShop", "noticstate", x => x.uid.Equals(AN) && x.state < 2, x => new NoticState()
                {
                    msgid = x.msgid
                }, null);
                var result = DALUtility.MDbS.List <NoticEntity>("XMShop", "notic", x => x.starttime <dtNow && x.endtime> dtNow && (x.receiver == null || x.receiver.Contains(Agent_Acc)) && (x.receivermember == null || x.receivermember.Contains(AN)), null, null);
                return(PagerData(-1, new { msgStatus, result }));
            }
            else
            {
                MongoDbService dbService = new MongoDbService();
                var            result    = dbService.List <NoticEntity>("XMShop", "notic", x => x.starttime <dtNow && x.endtime> dtNow && x.receiver == null, null, null);
                return(PagerData(result.Count, result));
            }
        }
コード例 #20
0
        public ActionResult <IEnumerable <string> > Get()
        {
            MongoDbService      mongoService = new MongoDbService();
            List <BsonDocument> mongoData    = mongoService.GetAllCollection();

            //var student1 = new BsonDocument
            //{
            //  {"firstname", "Ugo"},
            //  {"lastname", "Damian"},
            //  {"subjects", new BsonArray {"English", "Mathematics", "Physics", "Biology"}},
            //  {"class", "JSS 3"},
            //  {"age", 23}
            //};

            //var student2 = new BsonDocument
            //{
            //  {"firstname", "Julie"},
            //  {"lastname", "Lerman"},
            //  {"subjects", new BsonArray {"English", "Mathematics", "Spanish"}},
            //  {"class", "JSS 3"},
            //  {"age", 23}
            //};

            //var student3 = new BsonDocument
            //{
            //  {"firstname", "Julie"},
            //  {"lastname", "Lerman"},
            //  {"subjects", new BsonArray {"English", "Mathematics", "Physics", "Chemistry"}},
            //  {"class", "JSS 1"},
            //  {"age", 25}
            //};
            //List<BsonDocument> temps = new List<BsonDocument>();
            //temps.Add(student1);
            //temps.Add(student2);
            //temps.Add(student3);
            //mongoService.AddDocuments(temps, "Test");
            return(new string[] { "value1", "value2" });
        }
コード例 #21
0
 public async Task Post([FromBody] UserModel model)
 {
     var mongoDbService = new MongoDbService("mongodb://*****:*****@ds149754.mlab.com:49754/chatter", "chatter", "users");
     await mongoDbService.InserUserAsync(model);
 }
コード例 #22
0
 public ConfigurationController(MongoDbService service)
 {
     _service = service;
 }
コード例 #23
0
 static CustomerRespository()
 {
     mongoDbService = mongoDbService ?? new MongoDbService();
 }
コード例 #24
0
 public SummonerService(IConfiguration configuration,
                        MongoDbService mongoDbService,
                        IHttpClientFactory httpClientFactory)
 {
     _riotApiCrawler = new RiotCrawler(mongoDbService.Database, httpClientFactory.CreateClient()).Create(configuration.GetRiotApiCrawlerSettings().RiotApiKey);
 }
コード例 #25
0
 public ProductsController(IServiceProvider serviceProvider)
 {
     _mongoDbService = serviceProvider.GetService <MongoDbService>();
 }
コード例 #26
0
 public SuppliersController(IServiceProvider serviceProvider)
 {
     _mongoDbService = serviceProvider.GetService <MongoDbService>();
 }
コード例 #27
0
 public AnamailController()
 {
     _mongoDbService = new MongoDbService("AnimalDatabase", "Animal", "mongodb://localhost:27017");
 }
コード例 #28
0
 public BooksController()
 {
     _bookService = new MongoDbService <Book>("Books");
 }
コード例 #29
0
 public CategoriesController(IServiceProvider serviceProvider)
 {
     _mongoDbService = serviceProvider.GetService <MongoDbService>();
 }
コード例 #30
0
        static User Get(string id)
        {
            var result = new MongoDbService().Get <User>(a => a._id == id);

            return(result);
        }