public PagesController(PagesManagerService pages, ElasticService elastic, AppDbContext db, WorkerAlarmService alarm) { _pages = pages; _elastic = elastic; _db = db; _alarm = alarm; }
public PinPaiGongYu(HouseDapper houseDapper, ConfigDapper configDapper, ElasticService elastic) : base(houseDapper, configDapper, elastic) { this.Source = SourceEnum.PinPaiGongYu; _restClient = new RestClient(); _restClient.BaseUrl = new Uri("https://appgongyu.58.com/house/listing/"); }
public Douban(NewHouseDapper houseDapper, ConfigDapper configDapper, IOptions <AppSettings> configuration, HouseMapContext houseDataContext, ElasticService elasticsearch) : base(houseDapper, configDapper, elasticsearch) { this.Source = SourceEnum.Douban; _houseDataContext = houseDataContext; }
public Nuan(HouseDapper houseDapper, ConfigDapper configDapper, ElasticService elastic, RedisTool redisTool) : base(houseDapper, configDapper, elastic, redisTool) { _restClient = new RestClient("https://nuan.io"); _restClient.AddDefaultHeader("user-agent", "Mozilla/5.0 (Linux; Android 5.1; vivo V3M A Build/LMY47I) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 MicroMessenger/7.0.3.1400(0x2700033C) Process/appbrand0 NetType/WIFI Language/zh_CN"); this.Source = SourceEnum.Nuan; }
public SuggestService(AppDbContext db, ElasticService elastic, IUrlHelper urlHelper, IMapper mapper) { _db = db; _elastic = elastic; _url = urlHelper; _mapper = mapper; }
public void TestIndexCreationAndInsert() { var config = IConfigServiceMock.Build(new Dictionary <string, string> { { "ELASTICSEARCH_URL", "http://localhost:9200" }, }); var elasticService = new ElasticService(config); // Only run tests when a elastic endpoint is available if (!elasticService.Ping()) { return; } var indexStatus = elasticService.EnsureIndex <TestIndex>(); Assert.True(indexStatus); var subject = new TestIndex { Id = 123, Value = "potato" }; var insertStatus = elasticService.Index(subject); Assert.True(insertStatus); }
public BaseCrawler(HouseDapper houseDapper, ConfigDapper configDapper, ElasticService elasticService, RedisTool redisTool) { this._houseDapper = houseDapper; this._configDapper = configDapper; _elasticService = elasticService; _redisTool = redisTool; }
public AnXuan(HouseDapper houseDapper, ConfigDapper configDapper, ElasticService elasticService, RedisTool redisTool) : base(houseDapper, configDapper, elasticService, redisTool) { this.Source = SourceEnum.Anxuan; _restClient = new RestClient(); _restClient.BaseUrl = new Uri("https://1109393218718134.cn-shanghai.fc.aliyuncs.com"); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, [Queue("outqueue"), StorageAccount("AzureWebJobsStorage")] ICollector <string> msg, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); var client = new ElasticService(); // if match id == null, fetch last 10 matches string matchId = req.Query["id"]; IReadOnlyCollection <MatchModel> searchResults = null; if (string.IsNullOrEmpty(matchId) || string.IsNullOrWhiteSpace(matchId)) { searchResults = await client.GetMatches(""); } else { searchResults = await client.GetMatches(matchId); } return(searchResults != null ? (ActionResult) new OkObjectResult(new { matches = searchResults }) : new BadRequestObjectResult("Matches not found.")); }
public Douban(HouseDapper houseDapper, ConfigDapper configDapper, ElasticService elasticsearch, RedisTool redisTool) : base(houseDapper, configDapper, elasticsearch, redisTool) { this.Source = SourceEnum.Douban; _restClient = new RestClient("http://10.3.255.179"); //_restClient = new RestClient("https://api.douban.com"); }
public AnXuan(HouseDapper houseDapper, ConfigDapper configDapper, ElasticService elasticService, RedisTool redisTool) : base(houseDapper, configDapper, elasticService, redisTool) { this.Source = SourceEnum.Anxuan; _restClient = new RestClient(); _restClient.BaseUrl = new Uri("http://192.168.1.2"); }
public Hangzhouzhufang(HouseDapper houseDapper, ConfigDapper configDapper, ElasticService elastic, RedisTool redisTool) : base(houseDapper, configDapper, elastic, redisTool) { this.Source = SourceEnum.Hangzhouzhufang; _restClient = new RestClient(); _restClient.BaseUrl = new Uri("http://zl.hzfc.gov.cn"); }
public CCBHouse(HouseDapper houseDapper, ConfigDapper configDapper, ElasticService elasticService, RedisTool redisTool) : base(houseDapper, configDapper, elasticService, redisTool) { this.Source = SourceEnum.CCBHouse; this._restClient = new RestClient("http://api.jiayuan.ccbhome.cn"); // this._restClient.Proxy = new WebProxy("house-map.cn", 3128); }
public void Snippets_Muessen_Ve_Titel_Beinhaltet_Wenn_Titel_Snippet_Leer_Ist() { // arrange var elasticSettings = new Mock <IElasticSettings>(); var userAccess = new UserAccess("123", AccessRoles.RoleOe1, null, null, false); var query = new ElasticQuery(); var mockResponse = new { took = 1, timed_out = false, _shards = new { total = 2, successful = 2, failed = 0 }, hits = new { total = new { value = 1 }, max_score = 1.0, hits = new[] { new { _index = "project", _type = "project", _id = "Project", _score = 1.0, _source = new TreeRecord { ArchiveRecordId = "1", PrimaryDataFulltextAccessTokens = new List <string> { AccessRoles.RoleBAR }, Title = "Ve Title" }, highlight = new { all_Metadata_Text = new[] { "<em>Fundstelle</em>", "Dies ist eine andere <em>Fundstelle</em>" }, all_Primarydata = new[] { "<em>Fundstelle</em> in den Primärdaten" } } } } } }; var clientProvider = CreateClientProvider(mockResponse); var service = new ElasticService(clientProvider, elasticSettings.Object); // act var result = service.RunQuery <TreeRecord>(query, userAccess); // assert result.Data.Items[0].Highlight["title"] .Values <string>().First().Should() .Be("Ve Title"); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, [Queue("outqueue"), StorageAccount("AzureWebJobsStorage")] ICollector <string> msg, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); // pull out body text string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); if (string.IsNullOrEmpty(requestBody) || string.IsNullOrWhiteSpace(requestBody)) { return(new BadRequestObjectResult("Your player signup payload was empty. Please send correct payload.")); } // store message in data queue // Add a message to the output collection. msg.Add(requestBody.ToString()); // deserialize PlayerSignupModel data = JsonConvert.DeserializeObject <PlayerSignupModel>(requestBody); //TODO: SHOULD PROBABLY CHECK IF DATA IS GOOD if (string.IsNullOrEmpty(data.Name) || string.IsNullOrWhiteSpace(data.Name)) { return(new BadRequestObjectResult("Player Name was empty. Please submit payload with player name.")); } if (string.IsNullOrEmpty(data.QuakeId) || string.IsNullOrWhiteSpace(data.QuakeId)) { return(new BadRequestObjectResult("Player QuakeId was empty. Please submit payload with player QuakeId.")); } // Post player signup data to elastic var esService = new ElasticService(); var ids = await esService.GetListOfQuakeIds(); if (ids.Contains(data.QuakeId)) { return(new BadRequestObjectResult($"QuakeId: '{data.QuakeId}' already exists. Please submit request again with new QuakeId.")); } var asyncIndexResponse = await esService.PostPlayer(data); if (asyncIndexResponse.IsValid) { log.LogInformation($"Signup data: Name: '{data.Name}' with Code: '{data.QuakeLoginCode}' and ID: '{data.QuakeId}' posted to elastic"); } else { log.LogError($"Signup data: Name: '{data.Name}' with Code: '{data.QuakeLoginCode}' and ID: '{data.QuakeId}' posted to elastic"); } return(data != null ? (ActionResult) new OkObjectResult("Player is signed up.") : new BadRequestObjectResult("Unable to sign up player.")); }
public void Primaerdaten_Snippets_duerfen_nicht_fehlen_wenn_Titel_In_Metadaten_Vorkommt() { // arrange var elasticSettings = new Mock <IElasticSettings>(); var userAccess = new UserAccess("123", AccessRoles.RoleBAR, null, null, false); var query = new ElasticQuery(); var mockResponse = new { took = 1, timed_out = false, _shards = new { total = 2, successful = 2, failed = 0 }, hits = new { total = 1, max_score = 1.0, hits = new[] { new { _index = "project", _type = "project", _id = "Project", _score = 1.0, _source = new TreeRecord { ArchiveRecordId = "1", PrimaryDataFulltextAccessTokens = new List <string> { AccessRoles.RoleBAR } }, highlight = new { title = new[] { "<em>Titel</em>" }, all_Metadata_Text = new[] { "<em>Titel</em>" }, all_Primarydata = new[] { "<em>Primärdaten-Snippet</em>" } } } } } }; var clientProvider = CreateClientProvider(mockResponse); var service = new ElasticService(clientProvider, elasticSettings.Object); // act var result = service.RunQuery <TreeRecord>(query, userAccess); // assert result.Data.Items[0].Highlight["mostRelevantVektor"] .Values <string>().First().Should() .Be("<em>Primärdaten-Snippet</em>"); }
public async Task PostToElastic_FiresOffHttpRequest() { var elasticService = new ElasticService(_httpWrapper, "elasticUri", "elasticAuth"); var result = await elasticService.PostToElastic(_pingResults); Assert.AreEqual(true, result); }
public DataAdminController(ICardRepository context, UserManager <ApplicationUser> userManager, ElasticService es) { _cardRepository = context; _userManager = userManager; _es = es; }
public AuthController(AuthService auth, PagesManagerService pages, ElasticService elastic, AppConfigService cfgProvider, AppDbContext db) { _auth = auth; _pages = pages; _elastic = elastic; _cfgProvider = cfgProvider; _db = db; }
public CardRepository(ApplicationDbContext ctx, IDistributedCache cache, ElasticService es, UserManager <ApplicationUser> userManager) { _ctx = ctx; _cache = cache; _es = es; _userManager = userManager; }
public Douban(HouseDapper houseDapper, ConfigDapper configDapper, ElasticService elasticsearch, RedisTool redisTool) : base(houseDapper, configDapper, elasticsearch, redisTool) { this.Source = SourceEnum.Douban; _restClient = new RestClient(); _restClient.BaseUrl = new Uri("https://frodo.douban.com"); _restClient.Timeout = 120 * 1000; _restClient.UserAgent = "api-client/1 com.douban.frodo/7.1.0(205) Android/29 product/perseus vendor/Xiaomi model/Mi MIX 3 rom/miui6 network/wifi udid/a0f9cde79ec841a748625f766273e8f4333ed9c1 platform/mobile nd/1"; //_restClient = new RestClient("https://api.douban.com"); }
public void Primaerdaten_Snippets_Muessen_Auf_Berechtigungen_geprueft_werden() { // arrange var elasticSettings = new Mock <IElasticSettings>(); var userAccess = new UserAccess("123", AccessRoles.RoleOe1, null, null, false); var query = new ElasticQuery(); var mockResponse = new { took = 1, timed_out = false, _shards = new { total = 2, successful = 2, failed = 0 }, hits = new { total = 1, max_score = 1.0, hits = new[] { new { _index = "project", _type = "project", _id = "Project", _score = 1.0, _source = new TreeRecord { ArchiveRecordId = "1", PrimaryDataFulltextAccessTokens = new List <string> { AccessRoles.RoleBAR } }, highlight = new { all_Primarydata = new[] { "<em>Geheimer</em>", "Dies ist ein <em>Geheimer</em> Text" } } } } } }; var clientProvider = CreateClientProvider(mockResponse); var service = new ElasticService(clientProvider, elasticSettings.Object); // act var result = service.RunQuery <TreeRecord>(query, userAccess); // assert result.Data.Items[0].Highlight["mostRelevantVektor"].Should().BeNullOrEmpty(); }
static void Main(string[] args) { ElasticService service = new ElasticService(); try { service.DeleteIndex(); } catch { } service.CreateIndex(); service.IndexData(new SampleDataModel { Id = 0, SampleText = "Hanoi City" }); service.IndexData(new SampleDataModel { Id = 1, SampleText = "Ho Chi Minh City" }); service.IndexData(new SampleDataModel { Id = 2, SampleText = "Danang City" }); service.IndexData(new SampleDataModel { Id = 3, SampleText = "Nhatrang City" }); service.IndexData(new SampleDataModel { Id = 4, SampleText = "Hai phong City" }); service.IndexData(new SampleDataModel { Id = 5, SampleText = "Hue City" }); service.IndexData(new SampleDataModel { Id = 6, SampleText = "Can tho City" }); var r1 = service.Search("city"); var r2 = service.Search("Ci"); var r3 = service.Search("cit"); var r4 = service.Search("ho"); var r5 = service.Search("ho chi"); }
public void When_get_category_null_and_value_null_Then_return_null_items() { Mock <IElasticRepository> elastic = new Mock <IElasticRepository>(); Mock <IMapper> mapper = new Mock <IMapper>(); ElasticService service = new ElasticService(elastic.Object, mapper.Object); NewsFromElastic result = service.GetByCategoryAndSearchTerm(string.Empty, string.Empty, It.IsAny <int>(), It.IsAny <int>()); Assert.AreEqual(result.Data.Count, 0); }
public DataSourcesQueueService(NSCRegDbContext ctx, CreateService createSvc, EditService editSvc, ServicesSettings config, DbMandatoryFields dbMandatoryFields) { _dbContext = ctx; _createSvc = createSvc; _editSvc = editSvc; _rootPath = config.RootPath; _uploadDir = config.UploadDir; _dbMandatoryFields = dbMandatoryFields; _statUnitDeleteService = new DeleteService(ctx); _elasticService = new ElasticService(ctx); }
public async Task <IActionResult> ToElastic(string game, [FromServices] ElasticService elastic) { var strings = await _store.GetStrings(game); await elastic.Index(game, strings .Where(s => s.En.Length >= 4) .Select(s => new { Resource = s.Res, Line = s.Index, Text = s.En })); return(Ok()); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, [Queue("outqueue"), StorageAccount("AzureWebJobsStorage")] ICollector <string> msg, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); var client = new ElasticService(); var searchResults = await client.GetSignedupPlayers(); // TODO: what if search returns nothing? return(searchResults != null ? (ActionResult) new OkObjectResult(new { players = searchResults }) : new BadRequestObjectResult("Players not found.")); }
public JsonResult loadData(string search, string appName) { if (string.IsNullOrWhiteSpace(appName)) { appName = null; } IElasticService service = new ElasticService(); var r = service.Search(search, appName); return(Json(new { data = r.Select(a => new { Id = a.Id, TimeChanged = a.TimeChanged.ToString(), TimeCreated = a.TimeCreated.ToString(), Version = a.Version, FileName = a.Filename, AppFolderName = a.AppFolderName, Highlights = string.Join(" </br> ", a.Highlights) }).ToArray() }, JsonRequestBehavior.AllowGet)); }
public BlogController(PostService postService, ElasticService elasticService) { _postService = postService; _elasticService = elasticService; }
public MoviesController(ElasticService elasticSearch) { _elasticSearch = elasticSearch; }