示例#1
0
 public void CrawlGolfBettingMarketName()
 {
     string url = "";
     string htmlcontent = Helper.GetWebSiteContent(url);
     HtmlAgilityPack.HtmlDocument doc = Helper.LoadHtml(htmlcontent);
     XmlDocument xmldoc = new XmlDocument();
     CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
     var row11 = doc.DocumentNode.SelectSingleNode("//ul[@class='more-outrights 1']");
     var rows = row11.SelectNodes("./a");
     if (rows != null)
     {
         List<MarketMaster> lit = new List<MarketMaster>();
         for (int i = 0; i < rows.Count; i++)
         {
             MarketMaster market = new MarketMaster();
             string li = rows[i].InnerText;
             var linkrow = rows[i].SelectNodes("./span");
             market.MarketMarketName = linkrow[0].InnerText;
             market.MarketResultLink = "http://www.oddschecker.com" + rows[0].Attributes["href"].Value;
             market.MarketSportID = 29;
             InsertMasterMarket(market);
             lit.Add(market);
         }
         xmldoc = GenerateXmlGolfMarketMaster(lit);
     }
 }
        public void CrawlBettingMarkets(object tp)
        {
            ThreadParameters t = tp as ThreadParameters;
            string url = t.URL;
            int matchid = t.MatchID;
            try
            {
                TraceService("Crawling Betting Market, MatchID:" + matchid + " and URL: " + url + " ----");
                string htmlcontent = Helper.GetWebSiteContent(url);
                HtmlAgilityPack.HtmlDocument doc = Helper.LoadHtml(htmlcontent);
                List<BettingMarket> bettinglist = new List<BettingMarket>();
                XmlDocument xmldoc = new XmlDocument();
                CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
                var row11 = doc.DocumentNode.SelectSingleNode("//div[@id='mc']");
                var rows = row11.SelectNodes("//ul//li[@class='more-list-li']");
                if (rows != null)
                {
                    for (int i = 0; i < rows.Count; i++)
                    {
                        string li = rows[i].InnerText;
                        var linkrow = rows[i].SelectNodes("./a");
                        string link = "http://www.oddschecker.com" + linkrow[0].Attributes["href"].Value;
                        //links+=li+" "+link+" ";
                        if (!bettinglist.Exists(bettingmarket => bettingmarket.bettingmarket==li))
                            bettinglist.Add(new BettingMarket() { matchid = matchid, bettingmarket = li, bettinglink = link });
                    }
                }

                xmldoc = GenerateXml(bettinglist);
                crawldata.InsertMarkets(xmldoc);
                TraceService("Betting Market Data Inserted MatchID:" + matchid + " and URL:" + url + "------");
            }
            catch (Exception ex)
            {
                ErrorLog("CrawlBettingMarket______MatchID: " + matchid + " and URL:" + url +" Error:"+ex.ToString());
            }
        }
示例#3
0
 public static string GetMarketName(long marketid)
 {
     CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
     return crawldata.GetMarketName(marketid);
 }
        public DataTable GetMatchResult(int matchid,int sportid)
        {
            CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
         return   crawldata.GetMatchResult(matchid,sportid);

        }
 public DataSet GetMatchByDate(int sportid)
 {
     CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
     return crawldata.GetMatchByDate(sportid);
 }
 public DataTable GetMatchesByCoupon()
 {
     CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
     return crawldata.GetMatchesByCoupon();
 }
 public string[] GetChampionMatchInfo(int matchid)
 {
     CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
     return crawldata.GetMatchinfobyid(matchid);
 }
 /// <summary>
 /// Added my dev nagar
 /// for Info of Matches by League id
 /// </summary>
 /// <param name="leagueid"></param>
 /// <returns>datatable</returns>
 public DataTable GetMatchesByLeague(int leagueid)
 {
     CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
     return crawldata.GetMatches(leagueid);
 }
        public DataSet GetMatchesAndMarketsFoSoccer()
        {

            CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
            return crawldata.GetMatchesAndMarketsForSoccer();
        }
 public DataTable GetBettingMarkets(long matchid)
 {
     
     CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
     return crawldata.GetBettingMarkets(matchid);
 }
 public DataTable GetMasterMarketName(int sportid)
 {
     CrawlAllMarketsData crawldata = new CrawlAllMarketsData();
     return crawldata.GetMasterMarketName(sportid);
 }
        private void MatchResult(string[] result, string matchid)
        {
            CrawlEachMarketData crawl = new CrawlEachMarketData();
            int sportid = crawl.GetSportID(Convert.ToInt32(matchid));
             CrawlAllMarkets crawls=new CrawlAllMarkets();
            DataTable dt = new DataTable();
            dt = crawls.GetMatchResult(Convert.ToInt32(matchid),sportid);
            Dictionary<string, string> data = new Dictionary<string, string>();
            if (dt.Rows.Count > 0)
            {
                for(int i=0;i<dt.Rows.Count;i++)
                {
                    DataRow row=dt.Rows[i];
                    if (row[0].ToString() == "Winner")
                    {
                        string[] score = result[1].Split('-');
                        if (Convert.ToInt32(score[0]) > Convert.ToInt32(score[1]))
                            dt.Rows[i][1] = "Home";

                        else if (Convert.ToInt32(score[0]) < Convert.ToInt32(score[1]))
                            dt.Rows[i][1] = "Away";
                        else dt.Rows[i][1] = "Draw";
                    }
                    else if (row[0].ToString() == "HalfTime")
                        dt.Rows[i][1] =((result[2].Substring(result[2].IndexOf('-') - 1, 1)) + "-" + (result[2].Substring(result[2].IndexOf('-') + 1, 1)));
                    else if (row[0].ToString() == "BothTeamToScore")
                    {
                        string[] scorefull = result[1].Split('-'); string full;
                        if (Convert.ToInt32(scorefull[0]) > 0 & Convert.ToInt32(scorefull[1]) > 0)
                            dt.Rows[i][1] = "YES";
                        else dt.Rows[i][1] = "NO";
                    }
                    else if (row[0].ToString() == "HalfTimeFullTimeWinner")
                    {
                        string[] scorefull = result[1].Split('-'); string full;
                        string[] scorehalf = ((result[2].Substring(result[2].IndexOf('-') - 1, 1)) + "-" + (result[2].Substring(result[2].IndexOf('-') + 1, 1))).Split('-'); string half = "";
                        if (Convert.ToInt32(scorehalf[0]) > Convert.ToInt32(scorehalf[1]))
                            half = "Home";
                        else if (Convert.ToInt32(scorehalf[0]) < Convert.ToInt32(scorehalf[1]))
                            half = "Away";
                        else half = "Draw";

                        if (Convert.ToInt32(scorefull[0]) > Convert.ToInt32(scorefull[1]))
                            full = "Home";
                        else if (Convert.ToInt32(scorefull[0]) < Convert.ToInt32(scorefull[1]))
                            full = "Away";
                        else full = "Draw";
                       
                        dt.Rows[i][1]= half + "/" + full;
                    }
                    else if (row[0].ToString() == "CorrectScore")
                    {
                      dt.Rows[i][1]=   result[2].Substring(0, result[2].IndexOf('-') - 1) + " " + result[1] + " " + result[2].Substring(result[2].IndexOf('-') + 2, result[2].Length - result[2].Substring(0, result[2].IndexOf('-') + 1).Length);
                    }
                    else if (row[0].ToString() == "HalfTimeScore")
                    {
                        dt.Rows[i][1] =((result[2].Substring(result[2].IndexOf('-') - 1, 1)) + "-" + (result[2].Substring(result[2].IndexOf('-') + 1, 1)));
                    }
                    else if (row[0].ToString() == "Handicaps")
                    {
                        dt.Rows[i][1] = "";
                    }
                    else if (row[0].ToString() == "AlternativeHandicaps")
                    {
                        dt.Rows[i][1] = "";
                    }
                    else if (row[0].ToString() == "MatchResultAndBoth")
                    {
                        string[] scorefull = result[1].Split('-'); string full;
                        if (Convert.ToInt32(scorefull[0]) > 0 & Convert.ToInt32(scorefull[1]) > 0)
                            dt.Rows[i][1] = "YES" +" "+result[1];
                        else dt.Rows[i][1] = "NO" + " " + result[1];
                    }
                    else if (row[0].ToString() == "DoubleChanceWinner")
                    {
                        string[] scorefull = result[1].Split('-'); string full;
                        if (Convert.ToInt32(scorefull[0]) ==Convert.ToInt32(scorefull[1]))
                            dt.Rows[i][1] = "Home or Draw, Away or Draw";
                        else if(Convert.ToInt32(scorefull[0]) >Convert.ToInt32(scorefull[1]))
                            dt.Rows[i][1] = "Home or Away, Home or Draw";
                        else if (Convert.ToInt32(scorefull[0]) < Convert.ToInt32(scorefull[1]))
                            dt.Rows[i][1] = "Home or Away , Away or Draw";
                    }
                    else if (row[0].ToString() == "DoubleChanceBeaten")
                    {
                        string[] scorefull = result[1].Split('-'); string full;
                        if (Convert.ToInt32(scorefull[0]) == Convert.ToInt32(scorefull[1]))
                            dt.Rows[i][1] = "Home or Away";
                        else if (Convert.ToInt32(scorefull[0]) > Convert.ToInt32(scorefull[1]))
                            dt.Rows[i][1] = "Away or Draw";
                        else if (Convert.ToInt32(scorefull[0]) < Convert.ToInt32(scorefull[1]))
                            dt.Rows[i][1] = "Home or Draw";
                    }
                    else if (row[0].ToString() == "TeamToScoreFirst")
                    {
                        string hgt = result[8].Substring(result[8].IndexOf("mins") - 3, 2) + "";
                        string agt = result[10].Substring(result[10].IndexOf("mins") - 3, 2) + "";
                        if (Convert.ToInt32(hgt) < Convert.ToInt32(agt))
                            dt.Rows[i][1] = "Home";
                        else if (Convert.ToInt32(hgt) < Convert.ToInt32(agt))
                            dt.Rows[i][1] = "Away";
                        else dt.Rows[i][1] = "Both";
                    }
                    else if (row[0].ToString() == "ToWinBothHalves")
                    {
                        string[] hscore =((result[2].Substring(result[2].IndexOf('-') - 1, 1)) + "-" + (result[2].Substring(result[2].IndexOf('-') + 1, 1))).Split('-');
                        string[] score = result[1].Split('-');
                        if (Convert.ToInt32(score[0]) > Convert.ToInt32(score[1]) && Convert.ToInt32(hscore[0]) > Convert.ToInt32(hscore[1]))
                            dt.Rows[i][1] = "Home";
                        else if (Convert.ToInt32(score[0]) < Convert.ToInt32(score[1]) && Convert.ToInt32(hscore[0]) < Convert.ToInt32(hscore[1]))
                            dt.Rows[i][1] = "Away";
                        else dt.Rows[i][1] = "Nither";
                    }
                    else if (row[0].ToString() == "ToWinEitherHalf")
                    {
                        string[] hscore =((result[2].Substring(result[2].IndexOf('-') - 1, 1)) + "-" + (result[2].Substring(result[2].IndexOf('-') + 1, 1))).Split('-');
                        string[] score = result[1].Split('-');
                        if (Convert.ToInt32(hscore[0]) > Convert.ToInt32(hscore[1]))
                            dt.Rows[i][1] = "Home";
                        else if (Convert.ToInt32(hscore[0]) > Convert.ToInt32(hscore[1])) dt.Rows[i][1] = "Away";
                        else dt.Rows[i][1] = "Draw";

                         if (Convert.ToInt32(score[0]) > Convert.ToInt32(score[1]))
                            dt.Rows[i][1] += "Home";
                         else if (Convert.ToInt32(score[0]) < Convert.ToInt32(score[1])) dt.Rows[i][1] += "Away";
                        else dt.Rows[i][1] += "Draw";
                    }
                    else if (row[0].ToString() == "ToWinFormBehind")
                    {
                        string[] hscore =((result[2].Substring(result[2].IndexOf('-') - 1, 1)) + "-" + (result[2].Substring(result[2].IndexOf('-') + 1, 1))).Split('-');
                        string[] score = result[1].Split('-');
                        if (Convert.ToInt32(hscore[0]) < Convert.ToInt32(hscore[1]) && Convert.ToInt32(score[0]) > Convert.ToInt32(score[1]))
                            dt.Rows[i][1] = "Home";
                        else if(Convert.ToInt32(hscore[0]) > Convert.ToInt32(hscore[1]) && Convert.ToInt32(score[0]) < Convert.ToInt32(score[1]))
                            dt.Rows[i][1] = "Away";
                        else dt.Rows[i][1] = "Nither";
                    }
                    else if (row[0].ToString() == "TimeOfFirstGoal")
                    {
                        dt.Rows[i][1] = result[6];
                    }
                    else if (row[0].ToString() == "TimeofLastGoal")
                    {
                        dt.Rows[i][1] = result[7];
                    }
                    else if (row[0].ToString() == "ExactTotalGoal")
                    {
                        dt.Rows[i][1] = "";
                    }
                    else if (row[0].ToString() == "ToScoreFirstAndNotWin")
                    {
                        string[] score = result[1].Split('-');
                        string hgt = result[8].Substring(result[8].IndexOf("mins") - 3, 2) + "";
                        string agt = result[10].Substring(result[10].IndexOf("mins") - 3, 2) + "";
                        if (Convert.ToInt32(hgt) < Convert.ToInt32(agt))
                        {
                            if(Convert.ToInt32(score[0])<Convert.ToInt32(score[1]))
                            dt.Rows[i][1] = "Home";
                        }
                        else if (Convert.ToInt32(hgt) < Convert.ToInt32(agt))
                        {
                            if (Convert.ToInt32(score[0]) > Convert.ToInt32(score[1]))
                            dt.Rows[i][1] = "Away";
                        }
                        if (dt.Rows[i][1].ToString() == "") dt.Rows[i][1] = "No One";
                    }
                    else if (row[0].ToString() == "FirstGoalScorer")
                    {
                        dt.Rows[i][1] = result[3];
                    }
                    else if (row[0].ToString() == "LastGoalScorer")
                    {
                        dt.Rows[i][1] = result[4];
                    }
                    else if (row[0].ToString() == "AnyTimeGoalScorer")
                    {
                        dt.Rows[i][1] = ""; 
                    }
                    else if (row[0].ToString() == "ToScoreToOrMoreGoales")
                    {
                        dt.Rows[i][1] = "";
                    }
                    else if (row[0].ToString() == "ToScoreHatTrick")
                    {
                        dt.Rows[i][1] = "";
                    }
                    else if (row[0].ToString() == "TotalScore")
                    {
                        dt.Rows[i][1] = result[1];
                    }
                    else if (row[0].ToString() == "OverUnder0.5")
                    {
                        string[] score = result[1].ToString().Trim(' ').Split('-');
                        int total = Convert.ToInt32(score[0]) + Convert.ToInt32(score[1]);
                        if (total >= 1)
                            dt.Rows[i][1] = "Winner";
                        else dt.Rows[i][1] = "Beaten";
                    }
                    else if (row[0].ToString() == "OverUnder1.5")
                    {
                        string[] score = result[1].Trim(' ').Split('-');
                        int total = Convert.ToInt32(score[0]) + Convert.ToInt32(score[1]);
                        if (total >= 2)
                            dt.Rows[i][1] = "Winner";
                        else dt.Rows[i][1] = "Beaten";
                    }
                    else if (row[0].ToString() == "OverUnder2.5")
                    {
                        string[] score = result[1].Trim(' ').Split('-');
                        int total = Convert.ToInt32(score[0]) + Convert.ToInt32(score[1]);
                        if (total >= 3)
                            dt.Rows[i][1] = "Winner";
                        else dt.Rows[i][1] = "Beaten";
                    }
                    else if (row[0].ToString() == "OverUnder3.5")
                    {
                        string[] score = result[1].Trim(' ').Split('-');
                        int total = Convert.ToInt32(score[0]) + Convert.ToInt32(score[1]);
                        if (total >= 4)
                            dt.Rows[i][1] = "Winner";
                        else dt.Rows[i][1] = "Beaten";
                    }
                    else if (row[0].ToString() == "OverUnder4.5")
                    {
                        string[] score = result[1].Trim(' ').Split('-');
                        int total = Convert.ToInt32(score[0]) + Convert.ToInt32(score[1]);
                        if (total >= 5)
                            dt.Rows[i][1] = "Winner";
                        else dt.Rows[i][1] = "Beaten";
                    }
                    else if (row[0].ToString() == "")
                    {
                    }
                }

                // Update to database
                CrawlAllMarketsData marketdata = new CrawlAllMarketsData();
                marketdata.UpdateMarketResults(dt,Convert.ToInt32(matchid), sportid);
            }
        }