private void LoadTreeViewForGolf() { CrawlGolf golf = new CrawlGolf(); DataTable dt = golf.GetGolfTurnament(); TreeNode tn_group = new TreeNode("GolfTurnaments"); foreach (DataRow drSport in dt.Rows) { TreeNode Duration = new TreeNode(drSport["Duration"].ToString()); TreeNode Turnament=new TreeNode(drSport["Turnament"].ToString()+":"+drSport["GolfID"].ToString()); Turnament.Nodes.Add(new TreeNode(drSport["Course"].ToString())); Turnament.Nodes.Add(new TreeNode(drSport["Champion"].ToString())); Duration.Nodes.Add(Turnament); tn_group.Nodes.Add(Duration); } if (InvokeRequired) { Action a = () => { treeView1.Nodes.Add(tn_group); }; BeginInvoke(a); } }
//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; } }