Esempio n. 1
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(SelectedBookies()))
                {
                    if (ActiveMdiChild is OddsCrawler)
                    {
                        if (IsProcessRunning)
                        {
                            MessageBox.Show("A process is already running");
                            return;
                        }

                        OddsCrawler crawl = ActiveMdiChild as OddsCrawler;

                        markets = crawl.SelectedMarkets();

                        if (markets.Count > 0)
                        {
                            crawl.ClearFlowLayoutPanel();
                            SetProgress(true);
                            IsProcessRunning  = true;
                            crawl.countthread = 0;
                            string[] sportid = markets[0].Split(',');
                            if (sportid.Length > 1)
                            {
                                crawl.SetLabelSportIdText(sportid[3]);
                            }
                            //string bookies = SelectedBookies();
                            //foreach (string market in markets)
                            //{
                            //string[] info = market.Split(',');

                            //Task taskB = Task.Factory.StartNew(() =>
                            //{
                            //     crawl.FillData(info[2], Convert.ToInt64(info[0]), Convert.ToInt64(info[1]), bookies, markets.Count);
                            Thread thread = new Thread(MyThread);
                            thread.Start();
                            //});
                        }

                        //}
                    }

                    else
                    if (ActiveMdiChild is AddMarket)
                    {
                        if (IsProcessRunning)
                        {
                            MessageBox.Show("A process is already running");
                            return;
                        }

                        AddMarket crawl1 = ActiveMdiChild as AddMarket;
                        addmarkets = crawl1.SelectedMarkets();
                        if (addmarkets.Count > 0)
                        {
                            //List<string> markets = crawl.SelectedMarkets();
                            crawl1.ClearFlowLayoutPanel();
                            SetProgress(true);
                            IsCouponProcessRunning = true;
                            crawl1.countthread     = 0;

                            Thread thread = new Thread(AddMarketThread);
                            thread.Start();
                        }
                    }

                    else
                    if (ActiveMdiChild is Coupons)
                    {
                        if (IsCouponProcessRunning)
                        {
                            MessageBox.Show("A process is already running");
                            return;
                        }
                        Coupons coupon = ActiveMdiChild as Coupons;
                        if (coupon.SelectedMarkets().Count > 0)
                        {
                            List <string> markets = coupon.SelectedMarkets();
                            coupon.ClearFlowLayoutPanel();
                            SetProgress(true);
                            IsCouponProcessRunning = true;
                            coupon.countthread     = 0;
                            Task taskB = Task.Factory.StartNew(() =>
                            {
                                foreach (string market in markets)
                                {
                                    string[] info = market.Split(',');
                                    coupon.FillData(info[2], Convert.ToInt64(info[0]), Convert.ToInt64(info[1]), info[3], markets.Count);
                                }
                            });
                        }
                        else
                        {
                            MessageBox.Show("Please select a coupon");
                        }
                    }

                    else
                    if (ActiveMdiChild is UpdatePrice)
                    {
                        if (IsCouponProcessRunning)
                        {
                            MessageBox.Show("A process is already running");
                            return;
                        }

                        UpdatePrice update = ActiveMdiChild as UpdatePrice;
                        updatemarkets = update.SelectedMarkets();
                        if (updatemarkets.Count > 0)
                        {
                            //List<string> markets = crawl.SelectedMarkets();
                            update.ClearFlowLayoutPanel();
                            SetProgress(true);
                            IsCouponProcessRunning = true;
                            update.countthread     = 0;

                            Thread thread = new Thread(UpdateMarketThread);
                            thread.Start();
                            //foreach (string market in markets)
                            //{
                            //    string[] info = market.Split(',');

                            //    Task taskB = Task.Factory.StartNew(() =>
                            //    {
                            //        crawl.FillData(info[2], Convert.ToInt64(info[0]), Convert.ToInt64(info[1]), SelectedBookies(), markets.Count);
                            //    });


                            //}
                        }
                    }

                    else
                    {
                        MessageBox.Show("Please select atleast one market");
                    }
                }
                else
                {
                    MessageBox.Show("Please select atleast one bookie from Select Bookies menu");
                }
            }
            catch (Exception ex)
            {
                IsProcessRunning = false;
                SetProgress(false);
                IsCouponProcessRunning = false;
            }
        }