Esempio n. 1
0
        private void FindProductsTaskCompleted(Task task)
        {
            DGrid_FoundProducts.Invoke(new Action(() =>
            {
                if (task.IsFaulted)
                {
                    Rtbx_DebugLog.Invoke((MethodInvoker) delegate
                    {
                        if (Rtbx_DebugLog.Text.Length > Logger.MaxLogMesssages)
                        {
                            Rtbx_DebugLog.Clear();
                        }
                    });

                    Rtbx_DebugLog.AppendText(task.Exception?.StackTrace + Environment.NewLine);
                    label_FindingStatus.Text      = @"Some Errors!";
                    label_FindingStatus.ForeColor = Color.Red;
                }
                else
                {
                    label_FindingStatus.Text      = @"Done!";
                    label_FindingStatus.ForeColor = Color.DarkGreen;
                }

                btn_FindProducts.Enabled = true;
            }));
        }
Esempio n. 2
0
        private void FindAction(ScraperBase scraper)
        {
            var searchOptions   = (SearchSettingsBase)PGrid_Bot.SelectedObject;
            var convertedFilter = searchOptions;

            if (searchOptions.GetType() != scraper.SearchSettingsType)
            {
                convertedFilter = SearchSettingsBase.ConvertToChild(searchOptions, scraper.SearchSettingsType);
            }

            scraper.ScrapeItems(out var products, convertedFilter, _findTokenSource.Token);
            if (AppSettings.Default.PostStartMessage)
            {
                products.AsParallel().ForAll(product =>
                {
                    var pDetails = product.GetDetails(_findTokenSource.Token);
                    pDetails.Validate();
                    PostProduct(pDetails);
                });
            }


            DGrid_FoundProducts.Invoke(new Action(() =>
            {
                lock (_listOfProducts)
                {
                    products.ForEach(product => _listOfProducts.Add(product));
                    _findTokenSource.Token.ThrowIfCancellationRequested();
                }
            }));
        }
Esempio n. 3
0
        private void btn_FindProducts_Click(object sender, EventArgs e)
        {
            _findTokenSource = new CancellationTokenSource();
            _listOfProducts.Clear();
            DGrid_FoundProducts.Refresh();
            btn_FindProducts.Enabled      = false;
            label_FindingStatus.ForeColor = Color.SaddleBrown;
            label_FindingStatus.Text      = @"Processing...";

            var scrapers = Clbx_Websites.CheckedItems;

            var tasks = new List <Task>();

            foreach (var obj in scrapers)
            {
                var scraper = (ScraperBase)obj;
                tasks.Add(Task.Run(() => FindAction(scraper)));
            }

            Task.WhenAll(tasks).ContinueWith(FindProductsTaskCompleted);
        }
Esempio n. 4
0
 private void Btn_SelectAllProducts_Click(object sender, EventArgs e)
 {
     DGrid_FoundProducts.ColumnHeadersVisible = false;
     DGrid_FoundProducts.SelectAll();
     DGrid_FoundProducts.ColumnHeadersVisible = true;
 }