public HouseDapper(IOptions <APPConfiguration> configuration, RedisService redis,
                    ElasticsearchService elasticsearchService)
 {
     this.configuration        = configuration.Value;
     this.redis                = redis;
     this.elasticsearchService = elasticsearchService;
 }
Пример #2
0
 public HomeController(TodayHouseDashboardJob houseDashboardJob,
                       HouseDapper houseDapper,
                       HouseDashboardService houseDashboardService,
                       PinPaiGongYuHouseCrawler pinpai,
                       PeopleRentingCrawler people,
                       DoubanHouseCrawler douban,
                       CCBHouesCrawler ccbHouse,
                       ZuberHouseCrawler zuber,
                       MoGuHouseCrawler mogu,
                       HKSpaciousCrawler hkSpacious,
                       BaiXingHouseCrawler baixing,
                       SyncHousesToESJob syncHousesToESJob,
                       ElasticsearchService elasticsearchService)
 {
     this.houseDashboardJob     = houseDashboardJob;
     this.houseDapper           = houseDapper;
     this.houseDashboardService = houseDashboardService;
     this.pinpai               = pinpai;
     this.people               = people;
     this.douban               = douban;
     this.ccbHouse             = ccbHouse;
     this.zuber                = zuber;
     this.mogu                 = mogu;
     this.hkSpacious           = hkSpacious;
     this.baixing              = baixing;
     this.syncHousesToESJob    = syncHousesToESJob;
     this.elasticsearchService = elasticsearchService;
 }
Пример #3
0
        static async Task Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            IConfiguration config = new ConfigurationBuilder()
                                    .SetBasePath(Directory.GetCurrentDirectory())
                                    .AddJsonFile("appsettings.json")
                                    .Build();
            var elasticsearchSettings = new ElasticsearchSettings();

            config.Bind(nameof(ElasticsearchSettings), elasticsearchSettings);

            var unitOfWork           = new UnitOfWork();
            var printService         = new PrintService();
            var elasticsearchService = new ElasticsearchService(elasticsearchSettings, unitOfWork, printService);
            await elasticsearchService.SeedDataAsync();

            printService.PrintInfo($"Enter sesrch text (or quit to exit)...{Environment.NewLine}", false);

            // input search text: "1", "1st", "first", "one", "One", "ONe", "First", "FIRST", "FiRsT", "2nd", "avenue", "Avenue", "1 ave", "1 avenue", "ave"
            while (true)
            {
                Console.Write("> ");
                string search = Console.ReadLine();
                if (search.Equals("quit", StringComparison.InvariantCultureIgnoreCase))
                {
                    break;
                }

                var result = await elasticsearchService.SearchAsync(search);

                printService.PrintInfo(result);
                printService.PrintInfo($"Total items founded by search='{search}': {result.Count()}{Environment.NewLine}", false);
            }
        }
Пример #4
0
        public IActionResult GetHouseInfo(string cityName, string source = "", int houseCount = 500,
                                          int withAnyDays = 7, string keyword = "")
        {
            var houses = houseDapper.SearchHouseInfo(cityName, source, houseCount, withAnyDays, keyword);
            var rooms  = houses.Select(house =>
            {
                var markBGType = string.Empty;
                int housePrice = (int)house.HousePrice;
                if (housePrice > 0)
                {
                    markBGType = LocationMarkBGType.SelectColor(housePrice / 1000);
                }

                return(new HouseInfo
                {
                    Source = house.Source,
                    Money = house.DisPlayPrice,
                    HouseURL = house.HouseOnlineURL,
                    HouseLocation = house.HouseLocation,
                    HouseTime = house.PubTime.ToString(),
                    HouseTitle = house.HouseTitle,
                    HousePrice = housePrice,
                    LocationMarkBG = markBGType,
                    DisplaySource = ConstConfigurationName.ConvertToDisPlayName(house.Source)
                });
            });

            ElasticsearchService.AddHouse(houses.ToList());
            return(Json(new { IsSuccess = true, HouseInfos = rooms }));
        }
Пример #5
0
        public async Task Should_Find_For_Words(string keyword)
        {
            var es = new ElasticsearchService(INDEX_NAME);

            var res1 = await es.SearchAsync(keyword);

            Assert.IsTrue(res1.Total > 0);
        }
Пример #6
0
 public Douban(NewHouseDapper houseDapper, ConfigDapper configDapper, IOptions <AppSettings> configuration,
               HouseDapper oldHouseDapper, ElasticsearchService elasticsearch)
     : base(houseDapper, configDapper)
 {
     this.Source     = SourceEnum.Douban;
     _oldHouseDapper = oldHouseDapper;
     _elasticsearch  = elasticsearch;
 }
Пример #7
0
 public Douban(NewHouseDapper houseDapper, ConfigDapper configDapper, IOptions <AppSettings> configuration,
               HouseMapContext houseDataContext, ElasticsearchService elasticsearch)
     : base(houseDapper, configDapper)
 {
     this.Source       = SourceEnum.Douban;
     _houseDataContext = houseDataContext;
     _elasticsearch    = elasticsearch;
 }
Пример #8
0
        private static int Main(string[] args)
        {
            if (args.Length == 2 && args[0] == "--clean-shutdown")
            {
                var sent = ControlCDispatcher.Send(int.Parse(args[1]));
                return(sent ? 0 : 1);
            }
            if (args.Length == 1 && args[0] == "--debug-env")
            {
                WriteEnvironmentDebugInformation();
                return(0);
            }
            if (args.Length == 1 && args[0] == "--java-home")
            {
                Console.WriteLine(JavaConfiguration.Default.JavaHomeCanonical);
                return(0);
            }
            ElasticsearchService service = null;

            try
            {
                if (Environment.UserInteractive && JavaConfiguration.Default.Using32BitJava)
                {
                    Console.WriteLine("You are using a 32bit version this may cause the JVM to start, consider installing a 64bit JVM");
                }

                service = new ElasticsearchService(args);
                if (Environment.UserInteractive)
                {
                    Console.Title = $"Elasticsearch {AssemblyVersionInformation.AssemblyFileVersion}";
                }
                service.Run();
                var exitCode = service.LastExitCode ?? 0;
                return(exitCode);
            }
            catch (Exception e)
            {
                var exitCode = service?.LastExitCode ?? 1;
                if (Environment.UserInteractive)
                {
                    e.ToConsole("An exception occurred while trying to start elasticsearch.");
                }
                e.ToEventLog("Elasticsearch");
                return(exitCode);
            }
            finally
            {
                service?.Dispose();
                Console.ResetColor();
            }
        }
        public override bool OnStart()
        {
            // Not sure what this should be. Hopefully storage over smb doesn't open a million connections
            ServicePointManager.DefaultConnectionLimit = 12;


            var settings = ElasticsearchServiceSettings.FromStorage(storage);

            service = ElasticsearchService.FromSettings(settings);
            bool result = base.OnStart();

            Trace.TraceInformation("ElasticsearchRole has been started");

            return(result);
        }
Пример #10
0
        public async Task Content_Should_Be_Indexed()
        {
            var es = new ElasticsearchService(INDEX_NAME);

            var res = new List <bool>
            {
                await es.IndexAsync(new IndexDTO()
                {
                    Id           = 1,
                    LocationName = "Ankara",
                    Title        = "Acil ekipman aranıyor",
                    Detail       = "",
                })
            };

            Assert.IsTrue(res.Count(t => t == true) == res.Count);
        }
Пример #11
0
        public void TestInsertBasic()
        {
            using (ElasticsearchService s1 = ElasticsearchService.GetInstance())
            {
                Data d = new Data()
                {
                    ID   = Guid.NewGuid(),
                    Age  = 1,
                    Name = "Name"
                };

                FilterCondition filter = new FilterCondition("bool", TableCompareType.STREE,
                                                             new FilterCondition("must", TableCompareType.STREE,
                                                                                 new FilterCondition("ID", TableCompareType.EQ, d.ID)));

                s1.InsertItem("data", d);
                Data nd = s1.GetItem <Data>("data", filter);
                Assert.AreEqual(nd.Age, d.Age);
            }
        }
Пример #12
0
        public void TestRemoveItem()
        {
            using (ElasticsearchService s1 = ElasticsearchService.GetInstance())
            {
                Data d = new Data()
                {
                    ID   = Guid.NewGuid(),
                    Age  = 1,
                    Name = "Name"
                };

                FilterCondition filter = new FilterCondition("bool", TableCompareType.STREE,
                                                             new FilterCondition("must", TableCompareType.STREE,
                                                                                 new FilterCondition("Age", TableCompareType.EQ, d.ID)));

                s1.InsertItem("data", d);

                Assert.IsTrue(s1.RemoveItem <Data>("data", filter));
                Assert.IsNull(s1.GetItem <Data>("data", filter));
            }
        }
Пример #13
0
        static void Main(string[] args)
        {
            try
            {
                using (var service = new ElasticsearchService(args))
                {
                    if (Environment.UserInteractive)
                    {
                        WarnRunningService();

                        var handle = new ManualResetEvent(false);
                        _consoleCtrlHandler += new ConsoleCtrlHandler(c =>
                        {
                            ElasticsearchConsole.WriteLine(ConsoleColor.Red, "Stopping Elasticsearch...");
                            service.StopInteractive();
                            handle.Set();
                            return(false);
                        });
                        SetConsoleCtrlHandler(_consoleCtrlHandler, true);
                        service.StartInteractive();
                        handle.WaitOne();
                    }
                    else
                    {
                        ServiceBase.Run(service);
                    }
                }
            }
            catch (Exception e)
            {
                e.ToEventLog("Elasticsearch");
                if (Environment.UserInteractive)
                {
                    e.ToConsole("An exception occurred in Main()");
                }
            }
        }
Пример #14
0
 public JobsController(TodayHouseDashboardJob houseDashboardJob,
                       HouseDapper houseDapper,
                       HouseDashboardService houseDashboardService,
                       PinPaiGongYuHouseCrawler pinpai,
                       PeopleRentingCrawler people,
                       DoubanHouseCrawler douban,
                       CCBHouesCrawler ccbHouse,
                       ZuberHouseCrawler zuber,
                       MoGuHouseCrawler mogu,
                       HKSpaciousCrawler hkSpacious,
                       BaiXingHouseCrawler baixing,
                       ChengduZufangCrawler chengdu,
                       SyncHousesToESJob syncHousesToESJob,
                       ElasticsearchService elasticsearchService,
                       RefreshHouseCacheJob refreshHouseCacheJob,
                       RefreshHouseSourceJob refreshHouseSourceJob,
                       BeikeHouseCrawler beike)
 {
     this.houseDashboardJob     = houseDashboardJob;
     this.houseDapper           = houseDapper;
     this.houseDashboardService = houseDashboardService;
     this.pinpai                = pinpai;
     this.people                = people;
     this.douban                = douban;
     this.ccbHouse              = ccbHouse;
     this.zuber                 = zuber;
     this.mogu                  = mogu;
     this.hkSpacious            = hkSpacious;
     this.baixing               = baixing;
     this.syncHousesToESJob     = syncHousesToESJob;
     this.elasticsearchService  = elasticsearchService;
     this.refreshHouseCacheJob  = refreshHouseCacheJob;
     this.refreshHouseSourceJob = refreshHouseSourceJob;
     this.beike                 = beike;
     this.chengdu               = chengdu;
 }
Пример #15
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage: WebGallery.Daemon [Elasticsearch endpoint] [Username] [Jobname]");
                Console.ReadKey();
                Environment.Exit(1);
            }

            Console.WriteLine("Starting WebGallery background jobs...");
            Console.WriteLine($"Elasticsearch endpoint: {args[0]}");
            Console.WriteLine($"User name: {args[1]}");
            Console.WriteLine($"Job name: {args[2]}");

            var esService = new ElasticsearchService(args[0], args[1]);

            if (args[2].ToLower() == nameof(ReIndexAllJob).ToLower())
            {
                var  job = new ReIndexAllJob(esService);
                Task t   = job.Run();
                t.Wait();
            }
            else if (args[2].ToLower() == nameof(AddAppPathToTagsJob).ToLower())
            {
                var  job = new AddAppPathToTagsJob(esService);
                Task t   = job.Run();
                t.Wait();
            }
            else
            {
                throw new Exception($"Unknown job '{args[2]}'");
            }

            Console.WriteLine($"Job completed. Press key to exit.");
            Console.ReadKey();
        }
Пример #16
0
 public LianJiaCrawler(ElasticsearchService elasticsearchService, IOptions <APPConfiguration> configuration)
 {
     this.elasticsearchService = elasticsearchService;
     this.configuration        = configuration.Value;
 }
Пример #17
0
 public UploadController(ElasticsearchService elasticsearchService, OCRService ocrService)
 {
     _elasticsearchService = elasticsearchService;
     _ocrService           = ocrService;
 }
Пример #18
0
 public SyncHousesToESJob(ElasticsearchService elasticsearchService,
                          HouseDapper houseDapper)
 {
     this.elasticsearchService = elasticsearchService;
     this.houseDapper          = houseDapper;
 }