public AdminCommands(AppSettings settings, MongoDbClient dbClient) { _settings = settings; _dbClient = dbClient; _guildCollection = _dbClient.GetCollection <Guild>(_settings.Mongo.Collections.Guilds); }
public AddSourceInfoHandler(MongoDbClient mongoDbClient, Authorizer authorizer, SourceStorage sourceStorage, ILog log) { this.mongoDbClient = mongoDbClient; this.authorizer = authorizer; this.log = log; this.sourceStorage = sourceStorage; }
/// <summary> /// Do we want to pass a client, or just the database? /// </summary> /// <param name="database"></param> public BaseRepository(MongoDbClient client, string tableName) { _Context = client.GetContext(); //Convention to name the collection the same as the base class. This will cause issues if we ever refactor. //Type currentEntity = typeof(T); _Collection = _Context.GetCollection <T>(tableName); }
public WatcherService(AppSettings settings, MongoDbClient dbClient, HttpClient httpClient) { _settings = settings; _dbClient = dbClient; _httpClient = httpClient; _guildCollection = _dbClient.GetCollection <Guild>(_settings.Mongo.Collections.Guilds); _gameCollection = _dbClient.GetCollection <Game>(_settings.Mongo.Collections.Games); }
public DiscordBotService(AppSettings settings, MongoDbClient dbClient, IServiceProvider sp, ILoggerFactory factory) { _settings = settings; _dbClient = dbClient; _sp = sp; _factory = factory; _watcherService = _sp.GetRequiredService <WatcherService>(); _guildCollection = _dbClient.GetCollection <Guild>(_settings.Mongo.Collections.Guilds); }
public IActionResult Details(string id) { MongoDbClient dbClient = new MongoDbClient(); var result = dbClient.Query(id) .Select(x => (SearchDetailsViewModel)x) .ToList(); return(View("SearchDetailsViewModel", result.FirstOrDefault())); }
public SendMessageHandler(MessageSender messageSender, MongoDbClient mongoClient, SourceStorage sourceStorage, Authorizer authorizer, TimeSpan ttl) { this.messageSender = messageSender; this.mongoClient = mongoClient; this.sourceStorage = sourceStorage; this.authorizer = authorizer; this.ttl = ttl; }
public void Index() { mClient.DeleteIndex(mIndexName); CreateIndex(); using (MongoDbClient client = new MongoDbClient()) { IList <SearchData> docs = client.QueryAll().Cast <SearchData>().ToList(); foreach (Data data in docs) { var indexResponse = mClient.IndexDocument((SearchData)data); } } }
public async Task <IActionResult> Init() { MongoDbClient dbClient = new MongoDbClient(); ElasticSearchClient esClient = new ElasticSearchClient(); AzureClient aClient = new AzureClient(); dbClient.Init(); esClient.Index(); await aClient.Init(); return(new ContentResult() { Content = "Ok" }); }
static void Main(string[] args) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); var log = log4net.LogManager.GetLogger(typeof(Program)); var settings = GetSettings(); var mongoDbClient = new MongoDbClient(settings.MongoConnectionString, TimeSpan.FromSeconds(2)); ThreadPool.SetMaxThreads(32767, 32767); ThreadPool.SetMinThreads(2048, 2048); var(authorizer, sourceStorage) = new StateRestorer(mongoDbClient).Restore().GetAwaiter().GetResult(); var addUserInfoHandler = new AddSourceInfoHandler(mongoDbClient, authorizer, sourceStorage, log); var sseClient = new SseClient(); var subscriber = new Subscriber(authorizer, sourceStorage, sseClient); var messagSender = new MessageSender(); var sendMessageHandler = new SendMessageHandler(messagSender, mongoDbClient, sourceStorage, authorizer, settings.dataTtl); var handlerMapper = new HandlerMapper(); var expDaemon = new ExpirationDaemon(sourceStorage, settings.dataTtl); handlerMapper.Add("/addUserInfo", HttpMethod.Post, addUserInfoHandler); handlerMapper.Add("/subscribe", HttpMethod.Get, new SubscribeOnSourceHandler(subscriber)); handlerMapper.Add("/sendMessage", HttpMethod.Post, sendMessageHandler); var routingHandler = new RoutingHandler(handlerMapper, log); var host = WebHost.CreateDefaultBuilder(args) .ConfigureServices(s => { s.AddSingleton(routingHandler); s.AddHttpContextAccessor(); }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseKestrel() .UseStartup <Startup>() .ConfigureKestrel((context, options) => { //options.Listen(new IPAddress(new byte[] { 10, 33, 54, 120 }), 5000); options.Listen(new IPAddress(new byte[] { 0, 0, 0, 0 }), 5000); }) .Build(); host.Run(); }
public override async Task <QueryResult <double> > HandleAsync(GetAverageFollowersQuery query) { var groupingDoc = new BsonDocument { { "_id", "null" }, { "avgFollowers", new BsonDocument("$avg", "$Followers") } }; var filter = !string.IsNullOrEmpty(query.Hashtag) ? new BsonDocument { { "$text", new BsonDocument("$search", query.Hashtag) } } : new BsonDocument(); var aggregateResult = await MongoDbClient.Aggregate <Tweet>(filter, groupingDoc); return(new QueryResult <double>(aggregateResult.Data.First()["avgFollowers"].AsDouble, aggregateResult.ExecutionTime)); }
static void Main(string[] args) { MongoDbClient myClient = new MongoDbClient(); IUnitOfWork uow = new UnitOfWork(myClient); //uow.GamerRepository.DeleteAll(); //uow.GamerRepository.Insert(new Gamer("Test")); //for (int i = 0; i < 1000; i++) //{ // uow.GamerRepository.Insert(new Gamer($"Number: {i}")); //} var myItem = uow.GamerRepository.GetById(new Guid("15c81567-cc4c-44bf-9436-29c88ab1507a")); myItem.SetName("NewName!"); uow.GamerRepository.Update(myItem); //var thingToUpdate = uow.GamerRepository.GetByID(0); //Console.WriteLine("Retrieved: " + thingToUpdate.Name); //thingToUpdate.SetName("Daniel"); //Console.WriteLine("Core Executed!"); //uow.GamerRepository.Update(thingToUpdate); //Console.WriteLine("Query Executed!"); //var isThisUpdated = uow.GamerRepository.GetByID(0); //Console.WriteLine("Now named: " + isThisUpdated.Name); var listOfAllEntries = uow.GamerRepository.GetAll(); foreach (var item in listOfAllEntries) { Console.WriteLine(item.Id + " " + item.Name); } Console.Read(); }
private static void MongoDb() { string connectionString = @"mongodb://localhost:27017"; string dbName = "FirstDB"; string tName = "tName"; IDbClient client = new MongoDbClient(connectionString, dbName, tName); //client.CreateTable(); client.DeleteDatabase(); //var data = new List<string> //{ // "str1", // "str2", // "str3" //}; //client.InsertData(data); //var res = client.GetData(); }
public GamerRepository(MongoDbClient client, string tableName) : base(client, tableName) { }
/// <summary> /// KafkaResponseRepository /// </summary> /// <param name="dataContext"></param> public KafkaResponseRepository(MongoDbClient dataContext) : base(dataContext) { }
public ImgwClimateMeteDataRepository(MongoDbClient client) { _client = client; }
/// <summary> Initializes instances </summary> /// <param name="dataContext"></param> public DestinationMongoRepository(MongoDbClient dataContext) : base(dataContext) { _collection = CollectionName <DBModel.Destination>(); }
public GradeStorage(ILogger <GradeStorage> logger, MongoDbClient mongoDbClient) { Logger = logger; Database = mongoDbClient; }
/// <summary> Initializes instances </summary> /// <param name="dataContext"></param> public FormularyMongoRepository(MongoDbClient dataContext, IMapper mapper) : base(dataContext) { _collection = base.CollectionName <Formulary>(); _mapper = mapper; }
/// <summary> /// MongoRepository /// </summary> /// <param name="dataContext"></param> public MongoRepository(MongoDbClient dataContext) : base(dataContext) { }
/// <summary> </summary> /// <param name="mongoClient"></param> protected BaseRepository(MongoDbClient mongoClient) { _context = mongoClient.GetContext(); }
/// <summary> /// /// </summary> /// <param name="mongoClient"></param> public BaseRepository(MongoDbClient mongoClient) { _Context = mongoClient.GetContext(); }
/// <summary> Initializes instances </summary> /// <param name="dataContext"></param> public FacilityMongoRepository(MongoDbClient dataContext, IMapper mapper) : base(dataContext) { _collection = CollectionName <Facility>(); _mapper = mapper; }
/// <summary> Initializes instances </summary> /// <param name="dataContext"></param> public LastAduXrefMongoRepository(MongoDbClient dataContext) : base(dataContext) { }
public GetAverageFollowersQueryHandler(MongoDbClient mongoDbClient) : base(mongoDbClient) { }
public TransactionQueueRepository(MongoDbClient mongoClient) { _Context = mongoClient.GetContext(); }
/// <summary> Initializes instances </summary> /// <param name="dataContext"></param> public TransactionQueueMongoRepository(MongoDbClient dataContext, IMapper mapper) : base(dataContext) { _collection = CollectionName <DBModel.TransactionQueue>(); _mapper = mapper; }
/// <summary> Initializes instances </summary> /// <param name="dataContext"></param> public TransactionPriorityMongoRepository(MongoDbClient dataContext, IMapper mapper) : base(dataContext) { _collection = base.CollectionName <TransactionPriority>(); _mapper = mapper; }
public ISADetailRepository(MongoDbClient mongoClient) : base(mongoClient) { }
public MongoDatabaseInteractor(string containerName, string host, int port, string username, string password) { ContainerName = containerName; Host = host; this.client = new MongoDbClient(host, port, username, password, "TweetCollection"); }