static QueueMessageHandler() { // Global Db api connection antrypoint, using in OnNext handler CrawlerApi.ConfigureStaticInstance(Program.Configuration["CrawlerApi:Configuration"]); logger = Program.LoggerFactory.CreateLogger <QueueMessageHandler>(); }
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); } }
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); }
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 } }
public StoreOrdersService(WiseContext db, CrawlerApi crawlerApi) { _db = db; _crawlerApi = crawlerApi; }