コード例 #1
1
 private ApplicationIdentityContext(IMongoCollection<ApplicationUser> users, IMongoCollection<IdentityRole> roles, IMongoCollection<Client> clients, IMongoCollection<RefreshToken> refreshTokens)
 {
     Users = users;
     Roles = roles;
     Clients = clients;
     RefreshTokens = refreshTokens;
 }
コード例 #2
0
ファイル: Querying.cs プロジェクト: maximburyak/TODA
        public Querying()
        {
            client = new MongoClient(); ;
            database = client.GetDatabase("test");

            collection = database.GetCollection<Student>("Users");
        }
コード例 #3
0
ファイル: ChoiceRepository.cs プロジェクト: dsb92/patientcare
 public ChoiceRepository()
 {
     var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare"].ConnectionString);
     _log = new Logger("WebAPI:ChoiceController");
     _db = client.GetDatabase("patientcaredb");
     _choices = _db.GetCollection<BsonDocument>("Choice");
 }
コード例 #4
0
		public UserStoreTests(string collectionPrefix)
		{
			collectionPrefix = $"{typeof(UserStoreTests).Name}_{collectionPrefix}";

			_databaseFixture = new DatabaseFixture(collectionPrefix);
			_userCollection = _databaseFixture.GetCollection<IdentityUser>();
			_roleCollection = _databaseFixture.GetCollection<IdentityRole>();
			_databaseContext = new IdentityDatabaseContext { UserCollection = _userCollection, RoleCollection = _roleCollection };

			_errorDescriber = new IdentityErrorDescriber();
			_userStore = new UserStore<IdentityUser, IdentityRole>(_databaseContext, null, _errorDescriber);


			_claim1 = new Claim("ClaimType1", "some value");
			_claim2 = new Claim("ClaimType2", "some other value");
			_claim3 = new Claim("other type", "some other value");

			_claim1SameType = new Claim(_claim1.Type, _claim1.Value + " different");

			_identityClaim1 = new IdentityClaim(_claim1);
			_identityClaim2 = new IdentityClaim(_claim2);
			_identityClaim3 = new IdentityClaim(_claim3);

			_identityClaim1SameType = new IdentityClaim(_claim1SameType);
		}
        public AccountController()
        {
            mongoClient = new MongoClient(Settings.Default.MongoDBConnectionString);

            KonradRequirementsDatabase = mongoClient.GetDatabase("KonradRequirements");
            usersCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Users");
        }
コード例 #6
0
        public WorkitemsController()
        {

            _client = new MongoClient("mongodb://localhost:27017");
            _database = _client.GetDatabase("integrity");
            _collection = _database.GetCollection<BsonDocument>("workitems");
        }
コード例 #7
0
 /// <summary>
 /// CategoryController constructor
 /// </summary>
 public CategoryController()
 {
     var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare"].ConnectionString);
     _log = new Logger("WebAPI:CategoryController");
     _db = client.GetDatabase("patientcaredb");
     _categories = _db.GetCollection<BsonDocument>("Category");
 }
コード例 #8
0
 public HomeController()
 {
     connectionString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
     mongoClient = new MongoClient(connectionString);
     db = mongoClient.GetDatabase("zngndb");
     userCollection = db.GetCollection<BsonDocument>("User");
 }
 public MessageDeduplicationPersistorMongoDb()
 {
     var settings = DeduplicationFilterSettings.Instance;
     var mongoClient = new MongoClient(settings.ConnectionStringMongoDb);
     var mongoDatabase = mongoClient.GetDatabase(settings.DatabaseNameMongoDb);
     _collection = mongoDatabase.GetCollection<ProcessedMessage>(settings.CollectionNameMongoDb);
 }
コード例 #10
0
 public MongoService()
 {
     var mongo = new Mongo();
     mongo.Connect();
     IMongoDatabase mongoDatabase = mongo.GetDatabase(ConfigurationManager.AppSettings["Database"]);
     _collection = mongoDatabase.GetCollection<Entity>("entity");
 }
コード例 #11
0
 public UpdateModifiersTests()
 {
     var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");
     _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false&strict=true");
     _collection = _server.GetCollection<Post>("Posts");
     _buildInfo = admin.BuildInfo();
 }
コード例 #12
0
ファイル: Logger.cs プロジェクト: dsb92/patientcare
 public Logger(string logger)
 {
     var client = new MongoClient(Properties.Settings.Default.Mongo_log);
     _db = client.GetDatabase("patientcarelog");
     _logCollection = _db.GetCollection<BsonDocument>("Logs");
     _logger = logger;
 }
コード例 #13
0
 /// <summary />
 public PatientRepository()
 {
     var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare_datamock"].ConnectionString);
     _log = new Logger("WebAPI : PatientRepository");
     _db = client.GetDatabase("patientcare_datamock");
     _patients = _db.GetCollection<BsonDocument>("Patients");
 }
コード例 #14
0
ファイル: DS_MONGODB.cs プロジェクト: overload17/Database
 public void Initialize()
 {
     var connect = "mongodb://localhost";
     _client = new MongoClient(connect);
     _db = _client.GetDatabase("local");
     _collection = _db.GetCollection<Person>("Person");
 }
コード例 #15
0
 public TodoItemRepository(string mongoConnection, string databaseName)
 {
     collectionName = "todoitems";
     var client = new MongoClient(mongoConnection);
     this.database = client.GetDatabase(databaseName);
     this.collection = database.GetCollection<TodoItem>(collectionName);
 }
コード例 #16
0
ファイル: FilterMeasuring.cs プロジェクト: RavenZZ/MDRelation
 private static Task ExpressionMethod(IMongoCollection<Person> col)
 {
     var filter = new ExpressionFilterDefinition<Person>(x => x.Id == "my id" && x.Name == "Jack");
     filter.Render(col.DocumentSerializer, col.Settings.SerializerRegistry);
     //await col.Find(x => x.Id == "my id" && x.Name == "Jack").ToListAsync();
     return Task.FromResult(true);
 }
コード例 #17
0
 public SCORMObjectModel(String connectionString)
 {
     _ConnectionString = connectionString;
     _Connection = Mongo.Create(connectionString);
     _DB = _Connection.GetCollection<SCORMObject>();
     _FileStore = Norm.GridFS.Helpers.Files<SCORMObject>(_DB);
 }
コード例 #18
0
ファイル: DBHelper.cs プロジェクト: ozt88/MongoLog
 public void Init()
 {
     Client = new MongoClient(ConnString);
     DataBase = Client.GetDatabase("mongoLog");
     Users = DataBase.GetCollection<User>("Users");
     Datas = DataBase.GetCollection<Data>("Datas");
 }
コード例 #19
0
        public async Task<IEnumerable<Climb>> ExecuteAsync(GetClimbsQueryParameters parameters,
            IMongoCollection<Climb> collection)
        {
            var filters = new List<FilterDefinition<Climb>>();

            if (parameters.Id != Guid.Empty)
            {
                var filter = Builders<Climb>.Filter.Eq(c => c.Id == parameters.Id, true);

                filters.Add(filter);
            }

            if (parameters.Styles != null && parameters.Styles.Count > 0)
            {
                var filter = Builders<Climb>.Filter.AnyIn(c => c.Styles, parameters.Styles);
                filters.Add(filter);
            }

            if (!string.IsNullOrEmpty(parameters.Name))
            {
                var filter = Builders<Climb>.Filter.Eq(c => c.Name == parameters.Name, true);
                filters.Add(filter);
            }

            var complexFilter = Builders<Climb>.Filter.And(filters);

            var fullCollection = await collection.FindAsync(complexFilter);
            return await fullCollection.ToListAsync();
        }
コード例 #20
0
 public PreviousMonthsController()
 {
     var client = new MongoClient();
     var database = client.GetDatabase("Operativ");
     сollectionBisc = database.GetCollection<Month>("BISC");
     collectionIsc = database.GetCollection<Month>("ISC");
 }
コード例 #21
0
		public MongoDBStorage(IMongoDatabase database)
		{
			Revisions = database.GetCollection<RevisionModel>("revisions");
			Users = database.GetCollection<UserModel>("users");

			Task.Run(() => SetUp()).Wait();
		}
コード例 #22
0
    public void loadColors(IMongoCollection<board_item> coll, string boardName)
    {
        List<board_item> colors = coll.Find(brd => brd.Type == "Color" && brd.Board_Name == boardName)
            .ToListAsync()
            .Result;

        int i = 1;
        foreach (board_item color in colors)
        {
            if (i == 1)
            {
                colorPlace1.ImageUrl = color.Image_Link;
                i++;
                colorPlace2.ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Solid_white.svg/2000px-Solid_white.svg.png";
            }
            else if (i == 2)
            {
                colorPlace2.ImageUrl = color.Image_Link;
                i++;
                colorPlace3.ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Solid_white.svg/2000px-Solid_white.svg.png";
            }
            else if (i == 3)
            {
                colorPlace3.ImageUrl = color.Image_Link;
            }
        }
    }
コード例 #23
0
 private static void AddMovies(IMongoCollection<Movie> collection)
 {
     var movies = new List<Movie>
     {
         new Movie
         {
             Title = "The Perfect Developer",
             Category = "SciFi",
             Minutes = 118
         },
         new Movie
         {
             Title = "Lost In Frankfurt am Main",
             Category = "Horror",
             Minutes = 122
         },
         new Movie
         {
             Title = "The Infinite Standup",
             Category = "Horror",
             Minutes = 341
         }
     };
     //collection.InsertBatch(movies);
     collection.InsertManyAsync(movies).Wait();
 }
コード例 #24
0
ファイル: DetailController.cs プロジェクト: dsb92/patientcare
 /// <summary>
 /// Details controller constructor
 /// </summary>
 public DetailController()
 {
     var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare"].ConnectionString);
     _log = new Logger("WebAPI:DetailController");
     _db = client.GetDatabase("patientcaredb");
     _details = _db.GetCollection<BsonDocument>("Detail");
 }
コード例 #25
0
 public LogEntryRepository(MongoClient mongoClient, IConfiguration configuration, string databaseName = "Kelpie")
 {
     _mongoClient = mongoClient;
     _configuration = configuration;
     _database = _mongoClient.GetDatabase(databaseName);
     _collection = _database.GetCollection<LogEntry>("LogEntry");
 }
コード例 #26
-1
        private static void SearchByName(IMongoCollection<EnergyDrink> collection)
        {
            Console.Clear();
            Console.Write("Enter the name:");
            var inputName = Console.ReadLine();

            var fileter = Builders<EnergyDrink>.Filter.Eq("Name", inputName);
            var result = collection.Find(fileter).ToListAsync().Result;

            if (result.Count == 0)
            {
                Console.WriteLine("\nThere are no drinks with name {0}", inputName);
            }

            else
            {
                foreach (var item in result)
                {
                    Console.WriteLine("Name: {0} => Price: {1}", item.Name, item.Price);
                }
            }

            Console.WriteLine("\nPress any key to continue..");
            Console.ReadLine();
        }
コード例 #27
-1
 public GameRepository()
 {
     string connection = System.Configuration.ConfigurationManager.ConnectionStrings["Mongodb"].ConnectionString;
     _client = new MongoClient(connection);
     _database = _client.GetDatabase(System.Configuration.ConfigurationManager.AppSettings["DataBaseName"]);
     _collection = _database.GetCollection<GameEntity>("games");
 }
コード例 #28
-1
        protected void SetUp()
        {
            var f = new FileStream("config.json", FileMode.Open);
            var sr = new StreamReader(f);
            try
            {
                var settings = JsonConvert
                    .DeserializeObject<MongoSettings>(sr.ReadToEnd());
                var client = new MongoClient(new MongoUrl(settings.Url));
                _database = client.GetDatabase(settings.DatabaseName);
            }
            catch (FileNotFoundException)
            {
                throw new Exception("Talk to John about why this one fails");
            }
            finally
            {
                f.Dispose();
                sr.Dispose();
            }

            _collectionName = Guid.NewGuid().ToString();
            _collection = _database.GetCollection<Container>(_collectionName);
            var mapper = new StringMapper<BasePaymentModel>(x => x.PaymentType)
                .Register<AchInputModel>("ach")
                .Register<CreditCardInputModel>("cc")
                .Register<PayPalInputModel>("paypal");
            BsonSerializer.RegisterDiscriminatorConvention(
                typeof(BasePaymentModel),
                new DiscriminatorConvention<string, BasePaymentModel>(mapper));
        }
コード例 #29
-1
ファイル: Program2.cs プロジェクト: ax2015/testprojects
        static async Task findDocuments(IMongoCollection<student> collection, FilterDefinition<student> searchFilter)
        {

            //Option 1: for iterting over many documents on the server.
            Console.WriteLine("--------------------------------------------------------------------");
            using (var cursor = await collection.Find(searchFilter)
                .Sort("{student_id:1, score:-1}")
                .ToCursorAsync())
            {
                int i = 1;
                using (StreamWriter w = File.AppendText("c:\\data\\test2.txt"))
                {
                    while (await cursor.MoveNextAsync())  //iterate over each batch
                    {
                        foreach (var doc in cursor.Current)
                        {
                            string text = i + " :=> sid: " + doc.student_id + ":" + doc.score;
                            Console.WriteLine(text);
                            w.WriteLine(text);
                            if (i % 4 == 0)
                            {
                                Console.WriteLine("lowest score for " + doc.student_id + " is " + doc.score);
                                w.WriteLine("lowest score for " + doc.student_id + " is " + doc.score);
                                await collection.DeleteOneAsync(a => a.Id == doc.Id);
                            }
                            i++;
                        }
                    }
                }
            }
        }
コード例 #30
-1
    public void loadColors(IMongoCollection<board_item> coll, string boardName)
    {
        List<board_item> colors = coll.Find(brd => brd.Type == "Color" && brd.Board_Name == boardName)
            .ToListAsync()
            .Result;

        int i = 1;
        foreach (board_item color in colors)
        {
            if (i == 1)
            {
                colorPlace1.ImageUrl = color.Image_Link;
                i++;
            }
            else if (i == 2)
            {
                colorPlace2.ImageUrl = color.Image_Link;
                i++;
            }
            else if (i == 3)
            {
                colorPlace3.ImageUrl = color.Image_Link;
            }
        }
    }