public DataSet GetLeague() { CrawlFirstPageData crawldata = new CrawlFirstPageData(); DataSet ds = crawldata.GetLeagues(); return ds; }
//public string CrawlEachSport() //{ // try // { // CrawlFirstPageData crawldata = new CrawlFirstPageData(); // DataTable dt = crawldata.GetSports(); // for (int i = 0; i < dt.Rows.Count; i++) // { // string link = dt.Rows[i]["link"].ToString(); // int sportid = Convert.ToInt32(dt.Rows[i]["sportid"].ToString()); // if (sportid.Equals(2)) // { // CrawlLeagues(link); // CrawlWorldMarkets(); // DataSet ds = crawldata.GetLeagues(); // for (int j = 0; j < ds.Tables[0].Rows.Count; j++) // { // string matchlink = Convert.ToString(ds.Tables[0].Rows[j]["link"]); // int sport_id = Convert.ToInt32(ds.Tables[0].Rows[j]["sportid"]); // long leagueid = Convert.ToInt32(ds.Tables[0].Rows[j]["leagueid"]); // CrawlMyPage(matchlink, sportid, leagueid); // } // } // else if (sportid.Equals(29)) // { // CrawlGolf golf = new CrawlGolf(); // golf.CrawlGolfTurnament(link, sportid.ToString()); // } // else // CrawlMyPage(link, sportid, 0); // } // return "Command completed successfully"; // } // catch (Exception ex) // { // return ex.Message; // } //} #endregion public string CrawlEachSport() { try { CrawlFirstPageData crawldata = new CrawlFirstPageData(); DataTable dt = crawldata.GetSports(); for (int i = 0; i < dt.Rows.Count; i++) { string link = dt.Rows[i]["link"].ToString(); int sportid = Convert.ToInt32(dt.Rows[i]["sportid"].ToString()); if (sportid.Equals(2)) { ThreadParameters tp = new ThreadParameters(); tp.URL = link; ThreadPool.QueueUserWorkItem(new WaitCallback(CrawlLeagues), tp); // CrawlLeagues(link); CrawlWorldMarkets(); DataSet ds = crawldata.GetLeagues(); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { string matchlink = Convert.ToString(ds.Tables[0].Rows[j]["link"]); int sport_id = Convert.ToInt32(ds.Tables[0].Rows[j]["sportid"]); long leagueid = Convert.ToInt32(ds.Tables[0].Rows[j]["leagueid"]); ThreadParameters t = new ThreadParameters(); t.URL = matchlink; t.SportID = sport_id; t.LeagueID = leagueid; ThreadPool.QueueUserWorkItem(new WaitCallback(CrawlMyPage), t); // CrawlMyPage(matchlink, sportid, leagueid); } } else if(sportid.Equals(29)) { CrawlGolf golf = new CrawlGolf(); // golf.CrawlGolfTurnament(link,sportid.ToString()); ThreadParameters t = new ThreadParameters(); t.URL = link; t.SportID = sportid; t.LeagueID = 0; ThreadPool.QueueUserWorkItem(new WaitCallback(CrawlGolfTurnament), t); } else { ThreadParameters t = new ThreadParameters(); t.URL = link; t.SportID = sportid; t.LeagueID = 0; ThreadPool.QueueUserWorkItem(new WaitCallback(CrawlMyPage), t); // CrawlMyPage(link, sportid, 0); } } return "Command completed successfully"; } catch (Exception ex) { return ex.Message; } }