Exemplo n.º 1
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            int          i;
            string       operation = "";
            AbstractBase obj       = null;

            if (e.Argument != null)
            {
                operation = e.Argument.ToString();
            }
            backgroundWorker.ReportProgress(0, new BGReport("Connecting to SoccerBase (Operation: " + operation + ") ..."));
            using (SqlConnection connection = new SqlConnection(MainForm.STRCONN))
            {
                connection.Open();
                switch (operation)
                {
                case "Ivnet":
                    obj       = new BackgroundWorks.IvnetNS.Ivnet();
                    obj.Links = new Dictionary <string, string[]>()
                    {
                        { "Belgium,Pro League,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/belgium/belgium.htm", ""
                          } },
                        { "Denmark,Superligaen,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/denmark/denmark.htm", ""
                          } },
                        { "England,Premier League,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/england/england.htm", ""
                          } },
                        { "France,Ligue 1,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/france/france.htm", ""
                          } },
                        { "Germany,Bundesliga,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/germany/germany.htm", ""
                          } },
                        { "Greece,Super League,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/greece/greece.htm", ""
                          } },
                        { "Netherlands,Eredivisie,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/nether/nether.htm", ""
                          } },
                        { "Italy,Serie A,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/italy/italy.htm", ""
                          } },
                        { "Portugal,Liga Zon Sagres,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/portugal/portugal.htm", ""
                          } },
                        { "Romania,First Division,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/romania/romania.htm", ""
                          } },
                        { "Russia,Premier League,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/russia/russia.htm", ""
                          } },
                        //{"Scotland,Premier League,2011/12", new string[] {"http://invarius.ivnet.ru/soccer/champ/scotland/scotland.htm",""}},
                        { "Spain,Primera Division,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/spain/spain.htm", ""
                          } },
                        { "Turkey,Super Lig,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/turkey/turkey.htm", ""
                          } },
                        { "Ukraine,Premier League,2011/12", new string[] {
                              "http://invarius.ivnet.ru/soccer/champ/ukraine/ukraine.htm", ""
                          } }
                    };
                    obj.Connection = connection;
                    obj.Table      = "Ivnet";
                    while (obj.enrLinks.MoveNext())
                    {
                        double percent = (double)(obj.Index + 1) / obj.Links.Count * 100;
                        backgroundWorker.ReportProgress((int)percent, new BGReport(obj.ProcessLink()));
                    }
                    break;

                case "NewIvnet":
                    BackgroundWorks.IvnetNS.Ivnet newIvnet = new BackgroundWorks.IvnetNS.Ivnet();
                    newIvnet.Links = new Dictionary <string, string[]>()
                    {
                        { "New matches", new string[] { "http://invarius.ivnet.ru/soccer/champ/champ.htm", "" } }
                    };
                    newIvnet.Connection = connection;
                    newIvnet.isNew      = true;
                    if (newIvnet.enrLinks.MoveNext())
                    {
                        backgroundWorker.ReportProgress(100, new BGReport(newIvnet.ProcessLink()));
                    }
                    break;

                case "SportRadar":
                    obj       = new SportRadar();
                    obj.Links = new Dictionary <string, string[]>()
                    {
                        { "Belgium,Pro League,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_33,22_1,5_3414,9_fixtures,231_full,23_1", ""
                          } },
                        { "Denmark,Superligaen,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_8,22_1,5_3376,9_fixtures,231_full,23_1", ""
                          } },
                        { "England,Premier League,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_1,22_1,5_3391,9_fixtures,231_full,23_1", ""
                          } },
                        { "France,Ligue 1,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_7,22_1,5_3380,9_fixtures,231_full,23_1", ""
                          } },
                        { "Germany,Bundesliga,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_30,22_1,5_3405,9_fixtures,231_full,23_1", ""
                          } },
                        { "Greece,Super League,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_67,22_1,5_3735,9_fixtures,231_full,23_1", ""
                          } },
                        { "Italy,Serie A,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_31,22_1,5_3639,9_fixtures,231_full,23_1", ""
                          } },
                        { "Netherlands,Eredivisie,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_35,22_1,5_3432,9_fixtures,231_full,23_1", ""
                          } },
                        { "Portugal,Liga Zon Sagres,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_44,22_1,5_3462,9_fixtures,231_full,23_1", ""
                          } },
                        { "Romania,First Division,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_77,22_1,5_3539,9_fixtures,231_full,23_1", ""
                          } },
                        { "Russia,Premier League,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_21,22_1,5_3288,9_fixtures,231_full,23_1", ""
                          } },
                        //{"Scotland,Premier League,2011/12", new string[] {
                        //    "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_22,22_1,5_3392,9_fixtures,231_full,23_2",""
                        //}},
                        { "Spain,Primera Division,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_32,22_1,5_3502,9_fixtures,231_full,23_1", ""
                          } },
                        { "Turkey,Super Lig,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_46,22_1,5_3831,9_fixtures,231_full,23_1", ""
                          } },
                        { "Ukraine,Premier League,2011/12", new string[] {
                              "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_86,22_1,5_3390,9_fixtures,231_full,23_1", ""
                          } }
                    };
                    obj.Connection = connection;
                    obj.Table      = "SportRadar";
                    while (obj.enrLinks.MoveNext())
                    {
                        double percent = (double)(obj.Index + 1) / obj.Links.Count * 100;
                        backgroundWorker.ReportProgress((int)percent, new BGReport(obj.ProcessLink()));
                    }
                    break;

                case "Link":
                    BackgroundWorks.IvnetNS.Link link = new BackgroundWorks.IvnetNS.Link();
                    link.Connection = connection;
                    link.process();
                    break;

                /* ------------------------------------------------------------------------ */
                case "Truncate":
                    SqlCommand sql = new SqlCommand("TRUNCATE TABLE dbo.archive", connection);
                    backgroundWorker.ReportProgress(10, new BGReport("Truncating archive ..."));
                    sql.ExecuteNonQuery();
                    sql = new SqlCommand("TRUNCATE TABLE dbo.Leagues", connection);
                    backgroundWorker.ReportProgress(40, new BGReport("Truncating Leagues ..."));
                    sql.ExecuteNonQuery();
                    sql = new SqlCommand("TRUNCATE TABLE dbo.history", connection);
                    backgroundWorker.ReportProgress(70, new BGReport("Truncating history ..."));
                    sql.ExecuteNonQuery();
                    break;

                case "Archive":
                    obj            = new SportRadar();
                    obj.Links      = archiveLinks;
                    obj.Table      = "archive";
                    obj.Connection = connection;
                    i = 1;
                    while (obj.enrLinks.MoveNext())
                    {
                        double percent = (double)(i++) / obj.Links.Count * 100;
                        backgroundWorker.ReportProgress((int)percent, new BGReport("  " + obj.ProcessLink()));
                    }
                    break;

                case "Leagues":
                    Leagues leagues = new Leagues();
                    leagues.Connection = connection;
                    backgroundWorker.ReportProgress(10, new BGReport("Processing Leagues ..."));
                    leagues.process();
                    break;

                case "History":
                    History history = new History();
                    History.mainForm   = this;
                    history.Connection = connection;
                    openExcel();
                    history.process();
                    closeExcel();
                    break;

                case "PrevAvgStrength":
                    PrevAvgStrength strength = new PrevAvgStrength();
                    PrevAvgStrength.mainForm = this;
                    strength.Connection      = connection;
                    openExcel();
                    strength.process();
                    closeExcel();
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            int i;
            string operation = "";
            AbstractBase obj = null;

            if (e.Argument != null) operation = e.Argument.ToString();
            backgroundWorker.ReportProgress(0, new BGReport("Connecting to SoccerBase (Operation: " + operation + ") ..."));
            using (SqlConnection connection = new SqlConnection(MainForm.STRCONN))
            {
                connection.Open();
                switch (operation)
                {
                    case "Ivnet":
                        obj = new BackgroundWorks.IvnetNS.Ivnet();
                        obj.Links = new Dictionary<string, string[]>(){
                            {"Belgium,Pro League,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/belgium/belgium.htm",""
                            }},
                            {"Denmark,Superligaen,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/denmark/denmark.htm",""
                            }},
                            {"England,Premier League,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/england/england.htm",""
                            }},
                            {"France,Ligue 1,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/france/france.htm",""
                            }},
                            {"Germany,Bundesliga,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/germany/germany.htm",""
                            }},
                            {"Greece,Super League,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/greece/greece.htm",""
                            }},
                            {"Netherlands,Eredivisie,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/nether/nether.htm",""
                            }},
                            {"Italy,Serie A,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/italy/italy.htm",""
                            }},
                            {"Portugal,Liga Zon Sagres,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/portugal/portugal.htm",""
                            }},
                            {"Romania,First Division,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/romania/romania.htm",""
                            }},
                            {"Russia,Premier League,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/russia/russia.htm",""
                            }},
                            //{"Scotland,Premier League,2011/12", new string[] {"http://invarius.ivnet.ru/soccer/champ/scotland/scotland.htm",""}},
                            {"Spain,Primera Division,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/spain/spain.htm",""
                            }},
                            {"Turkey,Super Lig,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/turkey/turkey.htm",""
                            }},
                            {"Ukraine,Premier League,2011/12", new string[] {
                                "http://invarius.ivnet.ru/soccer/champ/ukraine/ukraine.htm",""
                            }}
                        };
                        obj.Connection = connection;
                        obj.Table = "Ivnet";
                        while (obj.enrLinks.MoveNext())
                        {
                            double percent = (double)(obj.Index + 1) / obj.Links.Count * 100;
                            backgroundWorker.ReportProgress((int)percent, new BGReport(obj.ProcessLink()));
                        }
                        break;
                    case "NewIvnet":
                        BackgroundWorks.IvnetNS.Ivnet newIvnet = new BackgroundWorks.IvnetNS.Ivnet();
                        newIvnet.Links = new Dictionary<string, string[]>()
                        {
                            {"New matches",new string[] {"http://invarius.ivnet.ru/soccer/champ/champ.htm",""}}
                        };
                        newIvnet.Connection = connection;
                        newIvnet.isNew = true;
                        if (newIvnet.enrLinks.MoveNext()) backgroundWorker.ReportProgress(100, new BGReport(newIvnet.ProcessLink()));
                        break;
                    case "SportRadar":
                        obj = new SportRadar();
                        obj.Links = new Dictionary<string,string[]>(){
                            {"Belgium,Pro League,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_33,22_1,5_3414,9_fixtures,231_full,23_1",""
                            }},
                            {"Denmark,Superligaen,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_8,22_1,5_3376,9_fixtures,231_full,23_1",""
                            }},
                            {"England,Premier League,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_1,22_1,5_3391,9_fixtures,231_full,23_1",""
                            }},
                            {"France,Ligue 1,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_7,22_1,5_3380,9_fixtures,231_full,23_1",""
                            }},
                            {"Germany,Bundesliga,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_30,22_1,5_3405,9_fixtures,231_full,23_1",""
                            }},
                            {"Greece,Super League,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_67,22_1,5_3735,9_fixtures,231_full,23_1",""
                            }},
                            {"Italy,Serie A,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_31,22_1,5_3639,9_fixtures,231_full,23_1",""
                            }},
                            {"Netherlands,Eredivisie,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_35,22_1,5_3432,9_fixtures,231_full,23_1",""
                            }},
                            {"Portugal,Liga Zon Sagres,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_44,22_1,5_3462,9_fixtures,231_full,23_1",""
                            }},
                            {"Romania,First Division,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_77,22_1,5_3539,9_fixtures,231_full,23_1",""
                            }},
                            {"Russia,Premier League,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_21,22_1,5_3288,9_fixtures,231_full,23_1",""
                            }},
                            //{"Scotland,Premier League,2011/12", new string[] {
                            //    "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_22,22_1,5_3392,9_fixtures,231_full,23_2",""
                            //}},
                            {"Spain,Primera Division,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_32,22_1,5_3502,9_fixtures,231_full,23_1",""
                            }},
                            {"Turkey,Super Lig,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_46,22_1,5_3831,9_fixtures,231_full,23_1",""
                            }},
                            {"Ukraine,Premier League,2011/12", new string[] {
                                "http://stats.betradar.com/s4/gismo.php?&html=1&id=1827&clientid=4&state=2_1,3_86,22_1,5_3390,9_fixtures,231_full,23_1",""
                            }}
                        };
                        obj.Connection = connection;
                        obj.Table = "SportRadar";
                        while (obj.enrLinks.MoveNext())
                        {
                            double percent = (double)(obj.Index + 1) / obj.Links.Count * 100;
                            backgroundWorker.ReportProgress((int)percent, new BGReport(obj.ProcessLink()));
                        }
                        break;
                    case "Link":
                        BackgroundWorks.IvnetNS.Link link = new BackgroundWorks.IvnetNS.Link();
                        link.Connection = connection;
                        link.process();
                        break;
                    /* ------------------------------------------------------------------------ */
                    case "Truncate":
                        SqlCommand sql = new SqlCommand("TRUNCATE TABLE dbo.archive", connection);
                        backgroundWorker.ReportProgress(10, new BGReport("Truncating archive ..."));
                        sql.ExecuteNonQuery();
                        sql = new SqlCommand("TRUNCATE TABLE dbo.Leagues", connection);
                        backgroundWorker.ReportProgress(40, new BGReport("Truncating Leagues ..."));
                        sql.ExecuteNonQuery();
                        sql = new SqlCommand("TRUNCATE TABLE dbo.history", connection);
                        backgroundWorker.ReportProgress(70, new BGReport("Truncating history ..."));
                        sql.ExecuteNonQuery();
                        break;
                    case "Archive":
                        obj = new SportRadar();
                        obj.Links = archiveLinks;
                        obj.Table = "archive";
                        obj.Connection = connection;
                        i = 1;
                        while (obj.enrLinks.MoveNext())
                        {
                            double percent = (double)(i++) / obj.Links.Count * 100;
                            backgroundWorker.ReportProgress((int)percent, new BGReport("  " + obj.ProcessLink()));
                        }
                        break;
                    case "Leagues":
                        Leagues leagues = new Leagues();
                        leagues.Connection = connection;
                        backgroundWorker.ReportProgress(10, new BGReport("Processing Leagues ..."));
                        leagues.process();
                        break;
                    case "History":
                        History history = new History();
                        History.mainForm = this;
                        history.Connection = connection;
                        openExcel();
                        history.process();
                        closeExcel();
                        break;
                    case "PrevAvgStrength":
                        PrevAvgStrength strength = new PrevAvgStrength();
                        PrevAvgStrength.mainForm = this;
                        strength.Connection = connection;
                        openExcel();
                        strength.process();
                        closeExcel();
                        break;
                }
            }
        }