protected BaseComponent( ComponentType componentType, BackgroundBaseContext context) { _type = componentType; _context = context; _statisticsBlock = StatisticsContainer.GetNewBlock(_type.ToString()); }
private DownloadInfo DoDownloadIfNeed(IndexShopContext context, XmlFileInfo xmlInfo) { var filePath = FilePathHelper.GetFilePath(_settings.DirectoryPath, xmlInfo); if (context.DownloadFresh || File.Exists(filePath) == false) { var downloadContext = new BackgroundBaseContext($"Download:{xmlInfo.Name}", "download"); downloadContext.Prepare(); downloadContext.Start(); context.Contexts.Add(downloadContext); var downloader = new FeedsDownloader(_settings.AttemptsToDownload, Db, downloadContext); var file = downloader.Download(_settings.DirectoryPath, xmlInfo); downloadContext.Content = "Все скачали"; downloadContext.Finish(); return(file); } return(new DownloadInfo(xmlInfo.ShopId, xmlInfo.NameLatin, xmlInfo.Weight) { ShopName = xmlInfo.NameLatin, FilePath = filePath }); }
public ProductsHandler( ElasticSearchClientSettings settings, BackgroundBaseContext context, BackgroundWorks works, DbHelper db) : base(settings, works, db) { _context = context; }
public FeedsDownloader( int numberAttempts, DbHelper dbHelper, BackgroundBaseContext context) : base(ComponentType.Downloader, context) { _numberAttempts = Math.Max(numberAttempts, 1); _db = dbHelper; }
public ProductLinker( ElasticSearchClientSettings settings, DbHelper dbHelper, BackgroundBaseContext context) : base(ComponentType.ProductLinker, context) { _elasticClient = new ElasticSearchClient <Product>(settings, context); _dbHelper = dbHelper; }
private void DownloadAll(List <XmlFileInfo> infos) { var downloadContext = new BackgroundBaseContext("Download:All", "download"); downloadContext.Prepare(); _context.AddContext(downloadContext); var downloader = new FeedsDownloader(_settings.AttemptsToDownload, Db, downloadContext); downloader.FileDownloaded += HandleDownloadEvent; downloadContext.Start(); downloader.DownloadsAll(_settings.DirectoryPath, infos); downloadContext.Content = "Все скачали"; downloadContext.Finish(); }
public OfferConverter(ShopData shopData, DbHelper dbHelper, BackgroundBaseContext context) : base(ComponentType.Converter, context) { _worker = ConverterBuilder.GetConverterByShop(shopData.Name, dbHelper); _offers = shopData.Offers; }
private static IElasticClient <IIndexedEntities> CreateElasticClient(BackgroundBaseContext context, ElasticSearchClientSettings settings) => new ElasticSearchClient <IIndexedEntities>(settings, context);
private ElasticSearchClient <IIndexedEntities> CreateElasticClient(BackgroundBaseContext context) =>
protected ElasticSearchClient <Product> CreateElasticClient(BackgroundBaseContext context) =>