/// <summary> /// Creates new instance of <see cref="RepositoryBase"/> /// </summary> /// <param name="setting">setting</param> public RepositoryBase(MongoDbSetting setting) { var client = new MongoClient(setting.ConnectionString); this._setting = setting; this._db = client.GetDatabase(setting.DatabaseName); }
public UserRoleController(IOptions <MongoDbSetting> mongoDbOptions) { _mongoDbOptions = mongoDbOptions.Value; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.userRoleCollection = db.GetCollection <UserRoles>("UserRoles"); }
public ResetPasswordModel(UserManager <IdentityUser> userManager, IOptions <MongoDbSetting> mongoDbOptions) { _mongoDbOptions = mongoDbOptions.Value; _userManager = userManager; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.collection = db.GetCollection <RegisterModel.InputModel>("Register"); }
public HomeController(IOptions <MongoDbSetting> mongoDbOptions, IDistributedCache cache) { _mongoDbOptions = mongoDbOptions.Value; _cache = cache; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.collection = db.GetCollection <Movies>("Movies"); }
public HomeController(IOptions <MongoDbSetting> mongoDbOptions, IEmailSender emailSender) { _mongoDbOptions = mongoDbOptions.Value; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.usersCollection = db.GetCollection <Users>("Users"); this.userRoleCollection = db.GetCollection <UserRoles>("UserRoles"); _emailSender = emailSender; }
internal static MongoDbSetting Create(string connectionString) { MongoUrlBuilder mongoUrlBuilder = new MongoUrlBuilder(connectionString); MongoDbSetting setting = new MongoDbSetting(); setting.Database = mongoUrlBuilder.DatabaseName; setting.ConnectionString = connectionString; return(setting); }
public UserController(IConfiguration configuration, IOptions <MongoDbSetting> mongoDbOptions) { _mongoDbOptions = mongoDbOptions.Value; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); _configuration = configuration; this.theatreMovie = db.GetCollection <TheatreMovie>("TheatreMovie"); this.user = db.GetCollection <UserDetails>("UserDetails"); }
public AdminController(IOptions <MongoDbSetting> mongoDbOptions, IWebHostEnvironment hostEnvironment) { _mongoDbOptions = mongoDbOptions.Value; _hostEnvironment = hostEnvironment; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.collection = db.GetCollection <Movies>("Movies"); this.theatre = db.GetCollection <Theatre>("Theatre"); this.theatreMovie = db.GetCollection <TheatreMovie>("TheatreMovie"); }
/// <summary> /// 从配置文件中初始化 /// 注意:仅供框架调用,不需要在代码中调用。 /// </summary> /// <param name="config"></param> public void Init(WriterSection config) { string value = config.GetOptionValue("ConnectionString"); if (string.IsNullOrEmpty(value)) { throw new LogConfigException("日志配置文件中,没有为MongoDbWriter指定ConnectionString属性。"); } s_configSetting = MongoDbSetting.Create(value); }
public BadgeController(IWebHostEnvironment hostEnvironment, IOptions <MongoDbSetting> mongoDbOptions, Repository <DataAccess.Badge> badge, ISolrOperations <SolrBadgeModel> solr) { _badge = badge; _solr = solr; _mongoDbOptions = mongoDbOptions.Value; _hostEnvironment = hostEnvironment; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.badgeCollection = db.GetCollection <DigiBadges.Models.Badge>("Badges"); }
public UsersController(IOptions <MongoDbSetting> mongoDbOptions, IEmailSender emailSender, ISolrOperations <SolrUsersModel> solr) { _mongoDbOptions = mongoDbOptions.Value; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.usersCollection = db.GetCollection <Users>("Users"); this.userRoleCollection = db.GetCollection <UserRoles>("UserRoles"); this.issuersCollection = db.GetCollection <Issuers>("Issuers"); _emailSender = emailSender; _solr = solr; }
public LoginModel(SignInManager <IdentityUser> signInManager, ILogger <LoginModel> logger, UserManager <IdentityUser> userManager, IOptions <MongoDbSetting> mongoDbOptions) { _mongoDbOptions = mongoDbOptions.Value; _userManager = userManager; _signInManager = signInManager; _logger = logger; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.collection = db.GetCollection <RegisterModel.InputModel>("Register"); }
public BadgeController(IWebHostEnvironment hostEnvironment, Repository <DigiBadges.DataAccess.EarnerBadgeDetails> ed, Repository <DigiBadges.DataAccess.Badge> badges, IOptions <MongoDbSetting> mongoDbOptions) { _hostEnvironment = hostEnvironment; _badges = badges; _ed = ed; _mongoDbOptions = mongoDbOptions.Value; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); EarnerBadgeDetails = db.GetCollection <EarnerBadgeDetails>("EarnerBadgeDetails"); BadgeCollections = db.GetCollection <BadgeCollections>("BadgeCollections"); Issuers = db.GetCollection <Issuers>("Issuers"); Badge = db.GetCollection <Badge>("Badges"); }
} //To get the connection string and database which we defined in AppSetting #endregion #region CONSTRUCTOR public IssuersController(Repository <DataAccess.Badge> b, IEmailSender emailSender, Repository <DataAccess.UserRoles> userRoles, Repository <DataAccess.Issuers> i, IWebHostEnvironment hostEnvironment, Repository <DataAccess.Users> user, IOptions <MongoDbSetting> mongoDbOptions, ISolrOperations <SolrUsersModel> solr, ISolrOperations <SolrIssuersModel> solrIssuer) { _mongoDbOptions = mongoDbOptions.Value; _b = b; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); //To Establish connection with mongoDb this.collection = db.GetCollection <Issuers>("Issuers"); //To establish connection with Issuer Collection _hostEnvironment = hostEnvironment; _user = user; _userRoles = userRoles; _i = i; _emailSender = emailSender; _solr = solr; _solrIssuer = solrIssuer; }
static Startup() { MongoDbSetting mg = MongoDbProvider.GetMongoDbSetting(); UserManagerFactory = () => mg.UserManager; OAuthAuthorizationServerOptions authorizationServerOptions = new OAuthAuthorizationServerOptions(); authorizationServerOptions.TokenEndpointPath = new PathString("/login"); authorizationServerOptions.Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory); authorizationServerOptions.AccessTokenExpireTimeSpan = TimeSpan.FromDays(14.0); int num = 1; authorizationServerOptions.AllowInsecureHttp = num != 0; OAuthOptions = authorizationServerOptions; OAuthBearerOptions = new OAuthBearerAuthenticationOptions(); }
public StaffController(IWebHostEnvironment hostEnvironment, IOptions <MongoDbSetting> mongoDbOptions, IEmailSender emailSender, Repository <DigiBadges.DataAccess.UserRoles> ur, Repository <DigiBadges.DataAccess.Users> u, Repository <DigiBadges.DataAccess.Issuers> i, ISolrOperations <SolrUsersModel> solr, ISolrOperations <SolrIssuersModel> solrIssuer) { _i = i; _u = u; _mongoDbOptions = mongoDbOptions.Value; _ur = ur; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); Users = db.GetCollection <Users>("Users"); collection = db.GetCollection <Issuers>("Issuers"); UserRoles = db.GetCollection <UserRoles>("UserRoles"); _hostEnvironment = hostEnvironment; _emailSender = emailSender; _solr = solr; _solrIssuer = solrIssuer; }
private void CreateDatebases() { foreach (var item in databaseRegistry.DatabaseDescriptors) { IDatabaseSetting databaseSetting = null; switch (item.DatabaseType) { case DatabaseType.MongoDB: databaseSetting = new MongoDbSetting(item.Address, item.Name, item.IsAuth, item.UserName, item.Password, false, false, string.Empty); break; default: break; } databases.Add(item.DatabaseName, databaseFactory.CreateDatabase(databaseSetting)); } }
public IssuersController(IWebHostEnvironment hostEnvironment, IOptions <MongoDbSetting> mongoDbOptions, IEmailSender emailSender, ISolrOperations <SolrBadgeModel> solr, Repository <DigiBadges.DataAccess.EarnerBadgeDetails> ed, Repository <DigiBadges.DataAccess.Badge> b, Repository <DigiBadges.DataAccess.Users> u, Repository <DigiBadges.DataAccess.Issuers> i) { _mongoDbOptions = mongoDbOptions.Value; _b = b; _solr = solr; _i = i; _ed = ed; _u = u; var client = new MongoClient(_mongoDbOptions.ConnectionString); IMongoDatabase db = client.GetDatabase(_mongoDbOptions.Database); this.collection = db.GetCollection <Issuers>("Issuers"); this.badgeCollection = db.GetCollection <Badge>("Badges"); Users = db.GetCollection <Users>("Users"); this.earnerBadgeDetails = db.GetCollection <EarnerBadgeDetails>("EarnerBadgeDetails"); Staff = db.GetCollection <Staff>("Staff"); _hostEnvironment = hostEnvironment; _emailSender = emailSender; }
/// <summary> /// Creates new instance of <see cref="ExamRepository"/> /// </summary> /// <param name="setting">setting</param> public ExamRepository(MongoDbSetting setting) : base(setting) { this._exams = this._db.GetCollection <Exam>("Exams"); }
/// <summary> /// 设置默认的连接字符串。 /// 注意:默认情况下并不需要调用这个方法,除非需要直接使用MongoDbWriter /// </summary> /// <param name="connectionString"></param> public void SetConnectionString(string connectionString) { _currentSetting = MongoDbSetting.Create(connectionString); }