Beispiel #1
0
        private void btnScan_Click(object sender, EventArgs e)
        {
            if (btnScanSbobet.Text == "Scan")
            {
                btnScanSbobet.Text = "Stop";
                ThreadSbo          = new Thread(delegate()
                {
                    string linkName = "img.eaxybox.com";
                    string link     = "http://" + linkName;
                    string data     = "";

                    help               = new HttpHelper();
                    data               = help.Fetch(link + "/betting.aspx", HttpHelper.HttpMethod.Get, null, null);
                    string HidCK       = Util.HtmlGetAttributeValue(data, "value", "//input[@id='HidCK']");
                    string tag         = Util.EscapeDataString(Util.HtmlGetAttributeValue(data, "value", "//input[@id='tag']"));
                    string tk          = Util.EscapeDataString(Util.GetSubstringByString(data, "'ms','ps'],[", "]));"));
                    string fingerprint = "2cf5547e23492b793471c401989931ac";

                    string post        = "id=" + txtUsernameSbobet.Text + "&password="******"&lang=en&tk=" + tk + "&type=form&tzDiff=1&HidCK=" + HidCK + "&tag=" + tag + "&fingerprint=" + fingerprint;
                    string welcomeLink = help.FetchResponseUri(link + "/web/public/process-sign-in.aspx", HttpHelper.HttpMethod.Post, link + "/betting.aspx", post);
                    string defaultLink = help.FetchResponseUri(welcomeLink, HttpHelper.HttpMethod.Get, link + "/betting.aspx", null);
                    string mainName    = Util.GetSubstringByString(welcomeLink, "http://", "/web-root");
                    string mainLink    = "http://" + mainName;
                    while (true && btnScanSbobet.Text == "Stop")
                    {
                        string scanTime = db.getServerStringDate();
                        if (sbochay)
                        {
                            try
                            {
                                sboxong           = false;
                                lblSboStatus.Text = "Running";
                                ////////////////////////////////////////////////Live///////////////////////////////////////////////////////////
                                //string DataOddSboLive = help.Fetch(mainLink + "/web-root/restricted/odds-display/today-data.aspx?od-param=2,1,1,1,2,2,2,2,3,1&fi=0&v=0&dl=3", HttpHelper.HttpMethod.Get, null, null);
                                //DataOddSboLive = DataOddSboLive.Replace("\\u200C", "");

                                //string leagueDataLive = "[" + Util.GetSubstringByString(DataOddSboLive, "[[[", "]],[[") + "]";
                                //leagueDataLive = leagueDataLive.Replace("],[", "]\n[");
                                //hsLeague.Clear();
                                //foreach (string league in leagueDataLive.Split('\n'))
                                //{
                                //    string leagueTemp = league.Replace("[", "").Replace("]", "").Replace("'", "");
                                //    hsLeague.Add(leagueTemp.Split(',')[0], leagueTemp.Split(',')[1]);
                                //}

                                //string matchDataLive = "[" + Util.GetSubstringByString(DataOddSboLive, "]],[[", "]],[[") + "]";
                                //matchDataLive = matchDataLive.Replace("],[", "]\n[");
                                //hsMatch.Clear();
                                //foreach (string matchLive in matchDataLive.Split('\n'))
                                //{
                                //    string matchTempLive = matchLive.Replace("[", "").Replace("]", "").Replace("'", "");
                                //    string[] arr_matchTempLive = matchTempLive.Split(',');
                                //    string idmatchLive = Util.GetSubstringByStringLast(DataOddSboLive, "[", "," + arr_matchTempLive[0]);
                                //    hsMatch.Add(idmatchLive, hsLeague[arr_matchTempLive[2]].ToString() + "," + arr_matchTempLive[3] + "," + arr_matchTempLive[4] + "," + arr_matchTempLive[7]);
                                //}
                                //string oddDataLive = "[[" + Util.GetSubstringByString(DataOddSboLive, ",,[[", "]]],,") + "]]]";
                                //hsOdd.Clear();
                                //SboLive.Clear();
                                //foreach (string OddTempLive in oddDataLive.Split(new string[] { "]],[" }, StringSplitOptions.None))
                                //{
                                //    try
                                //    {
                                //        objMatch OddLive = new objMatch();
                                //        string OddTemp = OddTempLive.Replace("[", "").Replace("]", "").Replace("'", "");
                                //        string[] arr_OddTemp = OddTemp.Split(',');
                                //        if (hsMatch[arr_OddTemp[1]] != null)
                                //        {
                                //            string infomatch = hsMatch[arr_OddTemp[1]].ToString();
                                //            OddLive.LeaugeName = infomatch.Split(',')[0];
                                //            OddLive.HomeName = infomatch.Split(',')[1];
                                //            OddLive.AwayName = infomatch.Split(',')[2];
                                //            OddLive.TimeLive = infomatch.Split(',')[3];

                                //            OddLive.IdKeo = arr_OddTemp[0];
                                //            OddLive.Keo = arr_OddTemp[5];
                                //            OddLive.BetType = arr_OddTemp[2];
                                //            OddLive.Odd1 = arr_OddTemp[6];
                                //            OddLive.Odd2 = arr_OddTemp[7];
                                //            //////////////////////////////////////////////Live///////////////////////////////////////////////////////////
                                //            SboLive.Add(OddLive);
                                //        }
                                //    }
                                //    catch (Exception ex)
                                //    {
                                //        MessageBox.Show(ex.Message);
                                //    }
                                //}

                                //////////////////////////////////////////////NonLive///////////////////////////////////////////////////////////
                                string DataOddSboNonLive = help.Fetch(mainLink + "/web-root/restricted/odds-display/today-data.aspx?od-param=2,1,1,1,2,2,2,2,3,1&fi=1&v=0&dl=3", HttpHelper.HttpMethod.Get, null, null);
                                string leagueDataNonLive = "[" + Util.GetSubstringByString(DataOddSboNonLive, "[[[", "]],[[") + "]";
                                leagueDataNonLive        = leagueDataNonLive.Replace("],[", "]\n[");
                                hsLeague.Clear();
                                foreach (string league in leagueDataNonLive.Split('\n'))
                                {
                                    string leagueTemp = league.Replace("[", "").Replace("]", "").Replace("'", "");
                                    hsLeague.Add(leagueTemp.Split(',')[0], leagueTemp.Split(',')[1]);
                                }

                                string matchDataNonLive = "[" + Util.GetSubstringByString(DataOddSboNonLive, "]],[[", "]],[[") + "]";
                                matchDataNonLive        = matchDataNonLive.Replace("],[", "]\n[");
                                hsMatch.Clear();
                                foreach (string matchNonLive in matchDataNonLive.Split('\n'))
                                {
                                    string matchTempNonLive       = matchNonLive.Replace("[", "").Replace("]", "").Replace("'", "");
                                    string[] arr_matchTempNonLive = matchTempNonLive.Split(',');
                                    string idmatchNonLive         = Util.GetSubstringByStringLast(DataOddSboNonLive, "[", "," + arr_matchTempNonLive[0]);
                                    hsMatch.Add(idmatchNonLive, hsLeague[arr_matchTempNonLive[2]].ToString() + "," + arr_matchTempNonLive[3] + "," + arr_matchTempNonLive[4] + "," + arr_matchTempNonLive[7]);
                                }
                                string oddDataNonLive = "[[" + Util.GetSubstringByString(DataOddSboNonLive, ",,[[", "]]],,") + "]]]";
                                hsOdd.Clear();
                                SboNonLive.Clear();
                                foreach (string OddTempNonLive in oddDataNonLive.Split(new string[] { "]],[" }, StringSplitOptions.None))
                                {
                                    objMatch OddNonLive    = new objMatch();
                                    string OddTemp         = OddTempNonLive.Replace("[", "").Replace("]", "").Replace("'", "");
                                    string[] arr_OddTemp   = OddTemp.Split(',');
                                    string infomatch       = hsMatch[arr_OddTemp[1]].ToString();
                                    OddNonLive.LeaugeName  = infomatch.Split(',')[0];
                                    OddNonLive.HomeName    = infomatch.Split(',')[1];
                                    OddNonLive.AwayName    = infomatch.Split(',')[2];
                                    OddNonLive.TimeNonLive = infomatch.Split(',')[3];

                                    OddNonLive.IdKeo    = arr_OddTemp[0];
                                    OddNonLive.Keo      = arr_OddTemp[5];
                                    OddNonLive.BetType  = arr_OddTemp[2];
                                    OddNonLive.Odd1     = arr_OddTemp[6];
                                    OddNonLive.Odd2     = arr_OddTemp[7];
                                    OddNonLive.scantime = scanTime;

                                    string key = OddNonLive.HomeName + OddNonLive.Keo + OddNonLive.BetType;
                                    if (!hsCheckOdd.Contains(key))
                                    {
                                        OddNonLive.afterseconds = 0;
                                        hsCheckOdd.Add(key, OddNonLive);
                                        SboNonLive.Add(OddNonLive);
                                    }
                                    else
                                    {
                                        if (((objMatch)hsCheckOdd[key]).Odd1 != OddNonLive.Odd1)
                                        {
                                            OddNonLive.afterseconds = DateTime.Parse(OddNonLive.scantime).Subtract(DateTime.Parse(((objMatch)hsCheckOdd[key]).scantime)).TotalSeconds;
                                            hsCheckOdd[key]         = OddNonLive;
                                            SboNonLive.Add(OddNonLive);
                                        }
                                    }
                                    lblSboStatus.Text = OddNonLive.Show();
                                }
                                //////////////////////////////////////////////NonLive///////////////////////////////////////////////////////////

                                string sql_row       = "";
                                List <string> lstSql = new List <string>();
                                int int_1000         = 0;
                                foreach (objMatch o in SboLive)
                                {
                                    int_1000++;
                                    sql_row += o.toSQL(true) + ",";

                                    if (int_1000 >= 1000)
                                    {
                                        lstSql.Add(sql_row);
                                        sql_row  = "";
                                        int_1000 = 0;
                                    }
                                }
                                int_1000 = 0;
                                foreach (objMatch o in SboNonLive)
                                {
                                    int_1000++;
                                    sql_row += o.toSQL(false) + ",";

                                    if (int_1000 >= 1000)
                                    {
                                        lstSql.Add(sql_row);
                                        sql_row  = "";
                                        int_1000 = 0;
                                    }
                                }
                                if (sql_row.Length > 0)
                                {
                                    lstSql.Add(sql_row);
                                }

                                foreach (string sql in lstSql)
                                {
                                    db.doInsertSboOdds(sql);
                                }
                            }
                            catch (Exception ex)
                            {
                                Thread.Sleep(5000);
                            }
                        }
                        Thread.Sleep(5000);
                    }
                });
                ThreadSbo.Start();
            }
            else
            {
                btnScanSbobet.Text = "Scan";
                ThreadSbo.Abort();
            }
        }