public async Task <bool> MainCompWorker() { dbChecker = new DbChecker(); int max = await dbChecker.GetMaxCountDB("category"); LinkToCompanyParser parser = new LinkToCompanyParser(); curentValueProgress = 0; ActivateVisibilityMonitor(); for (int i = 1; i <= max; i++) { if (!isActive) { return(true); } (string link, int categoryId) = await dbChecker.GetLinkAndIdByKey(i, "category"); if (link == "0" || link == "") { continue; } for (int j = 1; j <= 100; j++) { curentValueProgress++; prepareProcessUpdate((max - 7) * 100); if (!isActive) { return(true); } var result = await parser.Parse(j, link, i); if (result == null) { curentValueProgress += (100 - j); prepareProcessUpdate((max - 7) * 100); break; } ShowTotalParsed(); OnNewData?.Invoke(this, result); Console.WriteLine($"Цикл страницы {j} завершен"); } } dbChecker.PutIntProcessToDb("step_2", 0, true); dbChecker.PutIntProcessToDb("internal-string-time-elapsed", 0, false); isActive = false; FinishProcessMonitoring(); return(true); }
public async void DetailCompWorker() { ActivateVisibilityMonitor(); dbChecker = new DbChecker(); curentValueProgress = 0; DetailCompanyParser detailParser = new DetailCompanyParser(); string whatTable = "temp"; int maxKey = await dbChecker.GetMaxCountDB(whatTable); int linkId = await dbChecker.GetMaxCountDB(); if (linkId == 0) { linkId = 1; } for (int i = linkId + 1; i < maxKey; i++) { curentValueProgress = i; totalProcessUpdate(maxKey); if (!isActive) { return; } (string link, int categoryId) = await dbChecker.GetLinkAndIdByKey(i, whatTable); var result = await detailParser.Parse(0, link, categoryId); dbChecker.markCompanyAsParsed(i); ShowTotalParsed(); OnNewData?.Invoke(this, result); } FinishProcessMonitoring(); isActive = false; startAllButton.Enabled = true; abortButton.Enabled = false; Message("All work is done!"); }