Exemplo n.º 1
0
        static QueueMessageHandler()
        {
            // Global Db api connection antrypoint, using in OnNext handler
            CrawlerApi.ConfigureStaticInstance(Program.Configuration["CrawlerApi:Configuration"]);

            logger = Program.LoggerFactory.CreateLogger <QueueMessageHandler>();
        }
Exemplo n.º 2
0
        public static async Task Main(string[] args)
        {
            var logger = ConfigLogger();

            if (args.Length >= 1)
            {
                await CrawlerApi.CreateCmdArgs(args, logger);
            }
            else // for non cmd approach - call the crawler from the api you need to execute
            {
                await CrawlerApi.RunBundesarbeitsgerichtAsync(logger);
            }
        }
Exemplo n.º 3
0
        public async static Task <IApi> GetApi()
        {
            if (apiHelper is null)
            {
                StorageFile storageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///rule.json"));

                var randomAccessStream = await storageFile.OpenReadAsync();

                Stream stream = randomAccessStream.AsStreamForRead();

                apiHelper = CrawlerApi.GetApi(ApiType.BCY, stream);
            }

            return(apiHelper);
        }
Exemplo n.º 4
0
        public static async void OnNext(string url)
        {
            try
            {
                Task.Delay(20000).Wait(); // Database is weak

                var pageItems = await HtmlPageParser.GetPageItems(url);

                var pageItemsSerialized = MessagePackSerializer.Serialize(pageItems);
                await CrawlerApi.PostPageInfoAsync(pageItemsSerialized);

                logger.LogInformation($"Page getted: {url}");
            }
            catch (Exception)
            {
                // do nothing
            }
        }
Exemplo n.º 5
0
 public StoreOrdersService(WiseContext db, CrawlerApi crawlerApi)
 {
     _db         = db;
     _crawlerApi = crawlerApi;
 }