Beispiel #1
0
        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);
        }
Beispiel #2
0
        public async Task <bool> Worker(string link)
        {
            CategoryParser    categoryParser = new CategoryParser();
            SubCategoryParser subCatParser   = new SubCategoryParser();
            var result = await categoryParser.Parse(1, $"{link}");

            var subresult = await subCatParser.Parse(1, $"{link}");

            OnNewData?.Invoke(this, result);
            OnNewData?.Invoke(this, subresult);
            dbChecker.PutIntProcessToDb("step_1", 0, true);
            isActive = false;
            return(true);
        }