public ElasticRepositoryTests() { _mockDocumentWithoutId = new MockDocument { Name = "mock #1", Value = "mock #1's value", CreationDate = DateTime.UtcNow, IsActive = true }; _mockDocumentWithId = new MockDocument { Id = "99", Name = "mock #2", Value = "mock #2's value", CreationDate = DateTime.UtcNow, IsActive = false }; ElasticClientManager.Initialize(new List <string> { string.Format(_testEndpoint, _testUsername, _testPassword) }, _testIndex); var client = ElasticClientManager.GetInstance(_testIndex); _mockRepo = new ElasticRepository <MockDocument>(client); }
public SearchLearningService( JavascriptExecutor javascriptExecutor, ElasticRepository elasticRepository) { _javascriptExecutor = javascriptExecutor; _elasticRepository = elasticRepository; }
public ElasticRepositoryTest() { this._repo = new ElasticRepository <Customer>(loggerFactory, this.Configuration["ElasticService:ServerUrl"], null, "Customer", this.Configuration["ElasticService:AppIndex"]); }
public async Task <TEntity> CreateAsync(TEntity entity) { var result = (await DbSet.AddAsync(entity)).Entity; await ElasticRepository.UpdateSearchIndex(result, CrudAction.Create); return(result); }
public async Task <string> ReIndex() { var allPosts = (await _complexStringRepository.GetAllAsync()).ToList(); var res = await ElasticRepository.ReIndex(allPosts); return(res); }
public async Task <TEntity> Update(TEntity entity) { var result = DbSet.Update(entity).Entity; await ElasticRepository.UpdateSearchIndex(result, CrudAction.Update); return(result); }
public async Task ItShouldSearchAllExistingCoursesWithAnEmptyCriteria() { var existingCourse = BackofficeCourseMother.Random(); var anotherExistingCourse = BackofficeCourseMother.Random(); var existingCourses = new List <BackofficeCourse> { existingCourse, anotherExistingCourse }; await ElasticRepository.Save(existingCourse); await ElasticRepository.Save(anotherExistingCourse); await WaitFor(async() => (await ElasticRepository.SearchAll()).Any()); Assert.Equal(existingCourses, (await ElasticRepository.Matching(CriteriaMother.Empty())).ToList()); }
public async Task <bool> UpdateBool(TEntity entity) { var entityDb = entity as Entity; if (entityDb != null) { var existingEntity = DbSet.Find(entityDb.Id); if (existingEntity == null) { return(false); } context.Entry(existingEntity).State = EntityState.Detached; await ElasticRepository.UpdateSearchIndex(existingEntity, CrudAction.Update); } context.Entry(entity).State = EntityState.Modified; return(true); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); StructureMapFactory.Init(); var container = StructureMapFactory.GetContainer(); container.Configure(x => x.For <IControllerActivator>().Use <StructureMapControllerActivator>()); DependencyResolver.SetResolver(new StructureMapDependencyResolver(container)); var config = GlobalConfiguration.Configuration; config.Services.Replace(typeof(IHttpControllerActivator), new StructureMapWebApiActivator(config)); ElasticRepository.ElasticSearchCreateIndices(); }
public static void Main(string[] args) { var configRepository = new SqlServerRepository <TransportHistory>(); foreach (var xmlPath in GetXmlPaths()) { var sourceDatabaseInformationByXml = new DatabaseInformationByXml(xmlPath, RootNodeName.Elastic); var targetDatabaseInformationByXml = new DatabaseInformationByXml(xmlPath, RootNodeName.Sql); var sourceRepository = new ElasticRepository(sourceDatabaseInformationByXml); var targetRepository = new SqlServerRepository(targetDatabaseInformationByXml); var mapper = new Elastic2SqlMapper(sourceDatabaseInformationByXml, targetDatabaseInformationByXml); new Program( configRepository , sourceRepository , targetRepository , mapper ).Execute(args); } }
public async Task ItShouldFilterByCriteria() { var dddInPhpCourse = BackofficeCourseMother.WithName("DDD en PHP"); var dddInCSharpCourse = BackofficeCourseMother.WithName("DDD en C#"); var exprimiendoIntellij = BackofficeCourseMother.WithName("Exprimiendo Intellij"); var courses = new List <BackofficeCourse>() { dddInPhpCourse, dddInCSharpCourse }; var nameContainsDddCriteria = BackofficeCourseCriteriaMother.NameContains("DDD"); await ElasticRepository.Save(dddInPhpCourse); await ElasticRepository.Save(dddInCSharpCourse); await ElasticRepository.Save(exprimiendoIntellij); await WaitFor(async() => (await ElasticRepository.Matching(nameContainsDddCriteria)).Any()); Assert.Equal(courses, (await ElasticRepository.Matching(nameContainsDddCriteria)).ToList()); }
public void ItShouldSaveAValidCourse() { ElasticRepository.Save(BackofficeCourseMother.Random()); }
public CachedElasticRepository(ElasticRepository elasticRepository, IDistributedCache distributedCache) { _elasticRepository = elasticRepository; _distributedCache = distributedCache; }
public OperationEventCustomerController() { repository = new ElasticRepository <EventCustomer>(); }
public FeedService() { _repository = new ElasticRepository(); }
public EventCustomerElasticCrudTest() { repository = new ElasticRepository <EventCustomer>("test-event-customer"); }
public ElasticService() { _elasticRepository = new ElasticRepository(GetElasticNodesFromConfiguration()); }
public AppReplicationServer(ILoggerFactory loggerFactory, IConfigurationRoot Configuration) { if (loggerFactory == null) { throw new ArgumentNullException("LoggerFactory needed for AppReplicationServer initialization"); } if (Configuration == null) { throw new ArgumentNullException("Configuration needed for AppReplicationServer initialization"); } this._loggerFactory = loggerFactory; this._logger = this._loggerFactory.CreateLogger <AppReplicationServer>(); this._config = Configuration; // Get Kafka Service related configuration this._kafkaServerAddress = Configuration["KafkaService:Server"]; // --------------------- Setup Kafka Consumer ------------------------- // this._crudMsgQueueTopic = Configuration["KafkaService:Topic"]; this._notificationGroup = Configuration["KafkaService:Group"]; this._appEventMsgConsumer = new app.common.messaging.generic.KafkaConsumer <AppEventArgs <Customer> >(loggerFactory); var customerConfig = new Dictionary <string, object> { { "bootstrap.servers", this._kafkaServerAddress }, { "group.id", this._notificationGroup }, { "auto.commit.interval.ms", 5000 }, { "auto.offset.reset", "earliest" } }; var consumeTopics = new List <string>() { this._crudMsgQueueTopic }; this._appEventMsgConsumer.Setup(customerConfig, consumeTopics); // -------------- Setup Kafka Notification Producer ----------------------- // this._notificationMsgQueueTopic = Configuration["KafkaService:NotificationTopic"]; this._notificationProducer = new app.common.messaging.generic.KafkaProducer <EmailEventArgs>(loggerFactory); this._notificationProducer.Setup(new Dictionary <string, object> { { "bootstrap.servers", this._kafkaServerAddress } }); // -------------------- Configure data replication repository ---------------------------- // this._custrepo = new MongoRepository <Customer>(this._loggerFactory); this._custrepo.Setup( Configuration["ConnectionStrings:CustomerDb:url"], Configuration["ConnectionStrings:CustomerDb:db"], Configuration["ConnectionStrings:CustomerDb:collection"]); // ------------- Configure ElasticSearch repository -------------------------------- // this._searchrepo = new ElasticRepository <Customer>(loggerFactory, Configuration["ElasticService:ServerUrl"], null, "customer", Configuration["ElasticService:AppIndex"]); }