コード例 #1
0
        public static OddDTO SearchOdd(eOddType oddType, string oddtoSearch, bool a, System.Collections.Generic.List <OddDTO> dataSource)
        {
            OddDTO  result = null;
            string  __odd  = oddtoSearch.ToLower().Trim();
            decimal od     = Math.Abs(decimal.Parse(__odd));

            if (dataSource != null)
            {
                try
                {
                    System.Collections.Generic.List <OddDTO> list = (
                        from odd in dataSource
                        where odd.Type == oddType && (float.Parse(ConvertOdd(odd.Odd.ToLower().Trim())) == (float.Parse((od.ToString()))))
                        select odd).ToList <OddDTO>();
                    if (list.Count == 1)
                    {
                        result = list[0];
                    }
                    else
                    {
                        result = null;
                    }
                }
                catch (Exception ex)
                {
#if DEBUG
                    iBet.Utilities.WriteLog.Write("Error 006 Can not search: " + oddtoSearch + ",ex: " + ex);
#endif
                    result = null;
                }
            }
            return(result);
        }
コード例 #2
0
        public static OddDTO SearchOdd(eOddType oddType, string oddtoSearch, System.Collections.Generic.List <OddDTO> dataSource)
        {
            OddDTO result = null;
            string __odd  = oddtoSearch.ToLower().Replace("0", "").Replace(" ", "");

            if (dataSource != null)
            {
                try
                {
                    System.Collections.Generic.List <OddDTO> list = (
                        from odd in dataSource
                        where odd.Type == oddType && odd.Odd.ToLower().Replace("0", "").Replace(" ", "").Equals(__odd)
                        select odd).ToList <OddDTO>();
                    if (list.Count == 1)
                    {
                        result = list[0];
                    }
                    else
                    {
                        result = null;
                    }
                }
                catch (Exception ex)
                {
#if DEBUG
                    iBet.Utilities.WriteLog.Write("Error 006 Can not search: " + oddtoSearch + ",ex: " + ex);
#endif
                    result = null;
                }
            }
            return(result);
        }
コード例 #3
0
ファイル: MatchDTO.cs プロジェクト: conghq85/CYMS
        private void OddsParse(string HTML, string node, eOddType type)
        {
            List <OddDTO> listOdds = new List <OddDTO>();

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(HTML);

            var node1 = doc.DocumentNode.SelectSingleNode(node)
                        .Descendants("tr")
                        .Skip(2)
                        .Where(tr => tr.Elements("td").Count() > 1);

            List <List <string> > table = node1.Select(tr => tr.Elements("td").Select(td => td.OuterHtml.Trim()).ToList())
                                          .ToList();

            foreach (List <string> lstOdd in table)
            {
                OddDTO odd = new OddDTO();
                odd.AtTime = Utils.StripHTML(lstOdd[0]);
                odd.Score  = Utils.StripHTML(lstOdd[1]);
                float fl = 0;
                if (float.TryParse(Utils.StripHTML(lstOdd[2]), out fl))
                {
                    odd.Home = fl;
                }
                odd.Odd = Utils.StripHTML(lstOdd[3]);
                if (float.TryParse(Utils.StripHTML(lstOdd[4]), out fl))
                {
                    odd.Away = fl;
                }
                odd.OddTime = Utils.StripHTML(lstOdd[5]);
                odd.Status  = Utils.StripHTML(lstOdd[6]);
                odd.Type    = type;

                if (lstOdd[2].Contains("red"))
                {
                    odd.isRedHome = true;
                }
                if (lstOdd[3].Contains("red"))
                {
                    odd.isRedOdd = true;
                }
                if (lstOdd[4].Contains("red"))
                {
                    odd.isRedAway = true;
                }

                if (lstOdd[2].Contains("green"))
                {
                    odd.isGreenHome = true;
                }
                if (lstOdd[4].Contains("green"))
                {
                    odd.isGreenAway = true;
                }

                this.Odds.Add(odd);
            }
        }
コード例 #4
0
        private bool HasOddDefChange(float oldDef, float newDef, eOddType oType)
        {
            return(Math.Abs(oldDef) != Math.Abs(newDef));
            //if (oType == eOddType.OU || oType == eOddType.HalfOU
            //    || (oldDef >= 0 && newDef >= 0) || (oldDef < 0 && newDef < 0))
            //{
            //    return !oldDef.Equals(newDef);
            //}

            //return oldDef + newDef != 0;
        }
コード例 #5
0
 public MatchOddDTO(string matchID, string leagueName, string homeTeamName,
                    string awayTeamName, eTimeMatchType timeType, int minutes, string oddID, float odd, float homeOdd,
                    float awayOdd, eOddType oddType)
 {
     this.MatchID      = matchID;
     this.LeagueName   = leagueName;
     this.HomeTeamName = homeTeamName;
     this.AwayTeamName = awayTeamName;
     this.TimeType     = timeType;
     this.Minutes      = minutes;
     this.OddID        = oddID;
     this.Odd          = odd;
     this.HomeOdd      = homeOdd;
     this.AwayOdd      = awayOdd;
     this.OddType      = oddType;
     this.ServerType   = eServerType.Ibet;
 }
コード例 #6
0
        public bool IsValidTime(eTimeMatchType matchTimeType, int matchMinute, eOddType oddType)
        {
            if (MinTimeToBet == 0)
            {
                return(true);
            }

            if (matchTimeType == eTimeMatchType.H1 &&
                (oddType == eOddType.HalfHCP || oddType == eOddType.HalfOU))
            {
                return(matchMinute + MinTimeToBet < 45);
            }

            if (matchTimeType == eTimeMatchType.H2)
            {
                return(matchMinute + MinTimeToBet < 45);
            }

            return(true);
        }
コード例 #7
0
ファイル: MatchDTO.cs プロジェクト: conghq85/CYMS
        public float GiaChuan(eOddType type)
        {
            float giachuan = 0;
            var   odds     = this.Odds.Where(o => o.Type == type);

            foreach (OddDTO odd in odds)
            {
                if (odd.Home == 1 || odd.Away == 1)
                {
                    giachuan = odd.Home + odd.Away;
                    if (type == eOddType.OverUnder)
                    {
                        this.GiaChuanOU = giachuan;
                    }
                    else if (type == eOddType.Handicap)
                    {
                        this.GiaChuanHDC = giachuan;
                    }
                }
            }
            return(giachuan);
        }
コード例 #8
0
        private void UpdateOdd(MatchDTO matchDTO, string oddID, eOddType oddType, string odd, string home, string away, string checkHorA = "")
        {
            float homeOdd = 0f;
            float awayOdd = 0f;

            float.TryParse(home, out homeOdd);
            float.TryParse(away, out awayOdd);
            float oddValue = ConvertOdd(odd, checkHorA);

            OddDTO odDto = matchDTO.Odds.FirstOrDefault(m => m.OddID == oddID);

            if (odDto == null)
            {
                odDto = new OddDTO();
                matchDTO.Odds.Add(odDto);
            }
            odDto.IsDeleted = false;
            odDto.OddID     = oddID;
            odDto.OddType   = oddType;
            odDto.Odd       = oddValue;
            odDto.HomeOdd   = homeOdd;
            odDto.AwayOdd   = awayOdd;
        }
コード例 #9
0
        private TransactionDTO PlaceSingleIBET(string BetStrategy, string oddPrice, MatchDTO ibetMatch, string oddID, string oddValue, eOddType oddType, string ibetOddType, string stake, string homeScore, string awayScore, IBetEngine ibetEngine, bool followtype, string followref, string accountName)
        {
            this._betting = true;
            TransactionDTO transactionDTO = new TransactionDTO();
            string acctoScan = "";
            List<Bet> bl;
            string RefID = "";
            if (BetStrategy.Contains("Over15_XA"))
            {
                bl = this._ibetEngine.ibetAgent2.betList;
                acctoScan = this._ibetEngine.ibetAgent2.Config.Account;
                string[] array = BetStrategy.Split(new string[] { "Ref ID:" }, System.StringSplitOptions.None);
                RefID = array[1];
                if (!AllowOddBet(RefID + ibetOddType, ibetOddType))
                {
                    transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                    transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                    transactionDTO.Note = "Under account: " + acctoScan + " just bet on this odd";
                    transactionDTO.DateTime = DateTime.Now;
                    this._betting = false;
                    return transactionDTO;
                }
            }            
            else
            {
                bl = this._ibetEngine.ibetAgent.betList;
                acctoScan = this._ibetEngine.ibetAgent.Config.Account;
            }
            if (BetStrategy.Contains("Warning"))
            {
                transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                transactionDTO.Note = BetStrategy;
                transactionDTO.DateTime = DateTime.Now;
                this._betting = false;
                return transactionDTO;
            }
            foreach (Bet bet in bl)
            {
                if (bet.Home == ibetMatch.HomeTeamName)
                {                    
                    if (bet.Handicap == decimal.Parse(oddValue))
                    {
                        if (bet.Choice.ToString().ToLower() == ibetOddType)
                        {
                            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                            transactionDTO.Note = acctoScan + " : Bet list contains this odd already";
                            transactionDTO.DateTime = DateTime.Now;
                            this._betting = false;
                            return transactionDTO;
                        }
                    }                    
                }
            }
            if (!AllowOddBet(oddID + ibetOddType,ibetOddType))
            {
                transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                transactionDTO.Note = acctoScan + " just bet on this odd";
                transactionDTO.DateTime = DateTime.Now;
                this._betting = false;
                return transactionDTO;
            }
            if (this._ibetEngine.ibetAgent.Config.Balance < int.Parse(stake))
            {
                transactionDTO.HomeTeamName = ibetMatch.HomeTeamName;
                transactionDTO.AwayTeamName = ibetMatch.AwayTeamName;
                transactionDTO.Note = "Not enough money";
                transactionDTO.DateTime = DateTime.Now;
                this._betting = false;
                return transactionDTO;
            }

            
            string following = string.Empty;
            if (followtype)
                following = "following";
            else
                following = "unfollowing";

            string betKindValue = string.Empty;
            string homeTeamName = string.Empty;
            string awayTeamName = string.Empty;
            string newOddValue = string.Empty;
            string newHomeScore = string.Empty;
            string newAwayScore = string.Empty;

            bool flag = false;
            bool flag2 = false;
            string text = string.Empty;

            //System.Collections.Generic.List<MatchDTO> listIbetMatch = this._listIBETMatch;
            Dictionary<string, IbetMatch> listIbetMatch = this._ibetMatchs;
            //MatchDTO matchDTO = MatchDTO.SearchMatchFull(ibetMatch, listIbetMatch);
            if (ibetMatch != null && ibetMatch.HomeTeamName != string.Empty)
            {
                //OddDTO oddDTO = OddDTO.SearchOdd(oddType, odd, true, ibetMatch.Odds);
                //if (oddDTO != null)
                //{
                    string ibetOddNow = string.Empty;
                    //if (ibetOddType == "a")
                    //    ibetOddNow = oddDTO.Away.ToString();
                    //else
                    //    ibetOddNow = oddDTO.Home.ToString();
                    if (followtype || (!followtype && ((float.Parse(ibetOddNow) >= (float)txtLowestOddValue.Value && float.Parse(ibetOddNow) > 0)) || float.Parse(ibetOddNow) < 0))
                    {
                        int maxBet = 0;
                        int minBet = 0;
                        string ibetOddID = oddID;
                        try
                        {
                            string valueAway = "";
                            if (BetStrategy == "Under" || BetStrategy == "Over")
                            {
                                #region UNDER_OVER
                                if (BetStrategy == "Under")
                                {
                                    ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                    valueAway = newOddValue;
                                    Thread.Sleep(2000);
                                    ibetEngine.PrepareBet2(ibetOddID, "a", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                }
                                else if (BetStrategy == "Over")
                                {
                                    ibetEngine.PrepareBet2(ibetOddID, "a", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                    valueAway = newOddValue;
                                    Thread.Sleep(2000);
                                    ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                }
                                if (homeTeamName == ibetMatch.HomeTeamName)
                                {
                                    if (valueAway == newOddValue)
                                    {
                                        ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                        if (!flag2)
                                        {
                                            if (BetStrategy == "Under")
                                                text = "Under:: Confirm bet failed";
                                            else
                                                text = "Over:: Confirm bet failed";
                                        }
                                        else
                                        {
                                            this._lastTransactionTime = DateTime.Now;
                                            if (BetStrategy == "Under")
                                            {
                                                text = "Under:: - Success ";
                                                UpdateOddBetHistory(oddID + "a", "a");
                                            }
                                            else
                                            {
                                                text = "Over:: - Success ";
                                                UpdateOddBetHistory(oddID + "h", "h");
                                            }
                                            this._ibetEngine.ibetAgent.RefreshBetList();
                                        }
                                    }
                                    else
                                    {
                                        if (BetStrategy == "Under")
                                            text = "Under:: Odd requested: " + oddPrice.ToString();
                                        else
                                            text = "Over:: Odd requested: " + oddPrice.ToString();
                                    }
                                }
                                else
                                {
                                    if (BetStrategy == "Under")
                                        text = "Under:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                    else
                                        text = "Over:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                }
                                #endregion
                            }
                            else if (BetStrategy == "Over9290")
                            {
                                #region Over9290
                                ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (flag && homeTeamName == ibetMatch.HomeTeamName)
                                {
                                    ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                    if (!flag2)
                                    {
                                        text = "Over 92/90:: Confirm bet failed";
                                    }
                                    else
                                    {
                                        this._lastTransactionTime = DateTime.Now;
                                        text = "Over 92/90:: - Success ";
                                        //this._ibetEngine.ibetAgent.RefreshBetList();
                                        UpdateOddBetHistory(oddID + "h", "h");
                                    }
                                }
                                else
                                {
                                    text = "Over1.75:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                }
                                #endregion 
                            }
                            else if (BetStrategy == "SapKeo")
                            {
                                #region SAP_KEO
                                stake = ((int)(int.Parse(stake) * 1.5)).ToString();
                                ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (newOddValue == oddPrice.ToString())
                                {
                                    if (homeTeamName == ibetMatch.HomeTeamName)
                                    {
                                        ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                        if (!flag2)
                                        {
                                            text = "Sap Keo:: Confirm bet failed";
                                        }
                                        else
                                        {
                                            this._lastTransactionTime = DateTime.Now;
                                            text = "Odd Down:: - Success ";
                                            //this._ibetEngine.ibetAgent.RefreshBetList();
                                            UpdateOddBetHistory(oddID + "h", "h");
                                        }
                                    }
                                    else
                                    {
                                        text = "Sap Keo:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                    }
                                }
                                else
                                {
                                    text = "Sap Keo:: Odd change. Requested: " + oddPrice.ToString();
                                }
                                #endregion
                            }
                            else if (BetStrategy == "Over1.75")
                            {
                                #region Over1.75
                                ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (homeTeamName == ibetMatch.HomeTeamName)
                                {
                                    ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                    if (!flag2)
                                    {
                                        text = "Over1.75:: Confirm bet failed";
                                    }
                                    else
                                    {
                                        this._lastTransactionTime = DateTime.Now;
                                        text = "Over1.75:: - Success ";
                                        //this._ibetEngine.ibetAgent.RefreshBetList();
                                        UpdateOddBetHistory(oddID + "h", "h");
                                    }
                                }
                                else
                                {
                                    text = "Over1.75:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                }
                                #endregion
                            }
                            else if (BetStrategy == "nguoc" || BetStrategy == "xuoi")
                            {
                                #region BEST_STRATEGIES
                                if (BetStrategy == "nguoc")
                                {
                                    ibetEngine.PrepareBet2(ibetOddID, "a", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                    valueAway = newOddValue;
                                    Thread.Sleep(2000);
                                    ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                }
                                else if (BetStrategy == "xuoi")
                                {
                                    ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                    valueAway = newOddValue;
                                    Thread.Sleep(2000);
                                    ibetEngine.PrepareBet2(ibetOddID, "a", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                }

                                if (homeTeamName == ibetMatch.HomeTeamName)
                                {
                                    if (valueAway == newOddValue)
                                    {
                                        ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                        if (!flag2)
                                        {
                                            text = "Best Strategy:: Confirm bet failed";
                                        }
                                        else
                                        {
                                            this._lastTransactionTime = DateTime.Now;
                                            text = "Best Strategy:" + this.txtAddValue.Value.ToString() + " : - Success. " + BetStrategy.Replace("nguoc", "Over").Replace("xuoi", "Under");
                                            this._ibetEngine.ibetAgent.RefreshBetList();
                                            if (BetStrategy == "nguoc")
                                            {
                                                UpdateOddBetHistory(oddID + "h", "h");
                                            }
                                            else if (BetStrategy == "xuoi")
                                            {
                                                UpdateOddBetHistory(oddID + "a", "a");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        text = "Best Strategy:: Odd requested: " + oddPrice.ToString();
                                    }
                                }
                                else
                                {
                                    text = "Best Strategy:: Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                                }
                                #endregion
                            }
                            #region IBET_vs_IBET_Over
                            else if (BetStrategy.Contains("Over15_Fang"))
                            {

                                ibetEngine.PrepareBet2(ibetOddID, "h", oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (homeTeamName == ibetMatch.HomeTeamName
                                    && (homeTeamName.Contains("30:01-45:00") || homeTeamName.Contains("75:01-90:00"))
                                    )
                                {
                                    ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                    if (!flag2)
                                    {
                                        text = "Over_15:: Confirm bet failed";
                                    }
                                    else
                                    {
                                        this._lastTransactionTime = DateTime.Now;
                                        text = "Over_15:: - Success ";
                                        UpdateOddBetHistory(oddID + "h", "h");

                                        //this._ibetEngine.ibetAgent.RefreshBetList();
                                    }
                                }
                            }

                            #endregion
                            else if (BetStrategy.Contains("Over15_XA"))
                            {
                                #region IBET_vs_IBET_Over30-45_XA

                                ibetEngine.PrepareBetFor2ndIBET(ibetOddID, ibetOddType, oddPrice.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                                if (homeTeamName.TrimEnd() == ibetMatch.HomeTeamName && awayTeamName.TrimEnd() == ibetMatch.AwayTeamName)
                                {
                                    
                                    if (float.Parse(newOddValue) >= 0.35f || float.Parse(newOddValue) < 0f)//tranh suu ban
                                    {
                                        if (!betKindValue.EndsWith("75"))
                                        {
                                            ibetEngine.ConfirmBetFor2ndIBET(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                            if (!flag2)
                                            {
                                                text = BetStrategy + ":: Confirm bet failed";
                                            }
                                            else
                                            {
                                                this._lastTransactionTime = DateTime.Now;
                                                text = BetStrategy + ":: - Success ";
                                                UpdateOddBetHistory(oddID + ibetOddType, ibetOddType);
                                                UpdateOddBetHistory(RefID + ibetOddType, ibetOddType);
                                                this._ibetEngine.ibetAgent2.RefreshBetList();
                                            }
                                        }
                                    }
                                    else
                                    {
                                        text = BetStrategy + ":: Keo nho hon 0.35 >> Hien tai: " + newOddValue + ". Xem xet xa tay >>>>>>>>>>";
                                    }
                                }
                                else
                                {
                                    iBet.Utilities.WriteLog.Write("Not same match: Tim: " + ibetMatch.HomeTeamName + "-" 
                                    + ibetMatch.AwayTeamName + "Tra ve: " + homeTeamName + "-" + awayTeamName);
                                }

                                #endregion


                            }                            
                        }
                        catch (Exception ex)
                        {
                            text = ex.Message;
                        }
                    }
                    else
                    {
                        text = "Odd value is smaller than lowest accepted:" + ibetOddNow;
                    }
                //}
                //else
                //{
                //    string text2 = string.Empty;                    
                //    text = "Odd not found.";
                //}
            }
            else
                text = "Match not found ";


            transactionDTO.HomeTeamName = homeTeamName + ":" + homeScore;
            transactionDTO.AwayTeamName = awayTeamName + ":" + awayScore;
            transactionDTO.HomeScore = homeScore;
            transactionDTO.AwayScore = awayScore;
            transactionDTO.Score = homeScore + "-" + awayScore;
            transactionDTO.AccountPair = this._ibetAccount;// +" - " + this._ibetSubAccount;
            transactionDTO.OddType = oddType.ToString();
            transactionDTO.Odd = betKindValue;
            transactionDTO.OddKindValue = betKindValue;
            transactionDTO.OddValue = newOddValue;
            transactionDTO.Stake = stake;            
            transactionDTO.Note = text + " >>> " + acctoScan;
            transactionDTO.IBETTrade = flag2;
            transactionDTO.IBETAllow = flag;
            transactionDTO.IsFollowTypeTrans = true;
            transactionDTO.DateTime = DateTime.Now;
            transactionDTO.FollowRef = followref;

            this._betting = false;
            return transactionDTO;
        }
コード例 #10
0
ファイル: frmSboBet.cs プロジェクト: LeTranMinhQuoc/BetBroker
        private void btnTrade_Click(object sender, EventArgs e)
        {
            //List<int> listA= new List<int>(){1,2,3,4,5};
            //List<int> listB = new List<int>() { 10, 20, 30, 40, 50 };
            //if (ckSellAfter.Checked)
            //{
            //    UpdateLogText(string.Format("{0} aa", DateTime.Now));
            //    return;
            //}
            //int timeWaitSell = (int) numSellAfterSecond.Value;
            //Task.Factory.StartNew(() =>
            //{
            //    var buySt2atus = Parallel.ForEach(listA, (engine) =>
            //    {
            //        UpdateLogText(string.Format("{0} value {1}", DateTime.Now, engine));
            //    }).IsCompleted;

            //});

            //Task.Factory.StartNew(() =>
            //{
            //    //Task.Delay(timeWaitSell);
            //    Thread.Sleep(timeWaitSell);
            //    var buySt2atus = Parallel.ForEach(listB, (engine) =>
            //    {
            //        UpdateLogText(string.Format("{0} value {1}", DateTime.Now, engine));
            //    }).IsCompleted;

            //});
            // return;

            if (dgvLogScan.SelectedCells.Count > 0)
            {
                bool hasSellAfter = ckSellAfter.Checked;
                int  timeWaitSell = (int)numSellAfterSecond.Value;

                if (hasSellAfter && string.IsNullOrEmpty(txtStake.Text))
                {
                    UpdateLogText("Lỗi chưa nhập tổng tiền mua.", eLogTextType.Error);
                    return;
                }

                int selectedrowindex = dgvLogScan.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow  = dgvLogScan.Rows[selectedrowindex];
                string          value1       = selectedRow.Cells[0].Value.ToString();
                bool            isLive       = value1 == "LIVE";
                string          homeTeamName = selectedRow.Cells[1].Value.ToString();
                string          awayTeamName = selectedRow.Cells[2].Value.ToString();
                eOddType        oddType      = (eOddType)selectedRow.Cells[3].Value;
                float           odd          = (float)selectedRow.Cells[4].Value;

                eBetType buyBetType  = rdBetHome.Checked ? eBetType.Home : eBetType.Away;
                eBetType sellBetType = buyBetType == eBetType.Home ? eBetType.Away : eBetType.Home;
                int      stake;
                int.TryParse(txtStake.Text, out stake);
                if (stake == 0)
                {
                    stake = -1;
                }

                if (hasSellAfter)
                {
                    UpdateLogText("Bắt đầu giao dịch!", eLogTextType.Warning);

                    var buyOnlineEngine = buyAccEngines.Where(b => b.AccountStatus == eAccountStatus.Online).ToList();

                    int sumBuyStake = 0;
                    int stakeBuy    = (int)Math.Round((double)(stake / buyOnlineEngine.Count), 0);
                    Task.Factory.StartNew(() =>
                    {
                        var buyStatus = Parallel.ForEach(buyOnlineEngine, (engine) =>
                        {
                            int realStake;
                            if (engine.ProcessBetAnyway(stakeBuy, homeTeamName, awayTeamName, odd, oddType, buyBetType, isLive, out realStake))
                            {
                                sumBuyStake += realStake;
                                UpdateLogText(string.Format("MUA {0} điểm vào tài khoản [{1}] trận {2} - {3} thành công!",
                                                            realStake, engine.UserName, homeTeamName, awayTeamName), eLogTextType.Highlight);
                            }
                            else
                            {
                                UpdateLogText(string.Format("MUA vào tài khoản [{0}] trận {1} - {2} không thành công!",
                                                            engine.UserName, homeTeamName, awayTeamName), eLogTextType.Error);
                            }
                        }).IsCompleted;

                        UpdateLogText(string.Format("TỔNG MUA: {0}", sumBuyStake), eLogTextType.Highlight);
                    });

                    var sellOnlineEngine = sellAccEngines.Where(b => b.AccountStatus == eAccountStatus.Online).ToList();

                    var sumSell   = ConvertExchange(stake, buyExchange, sellExchange);
                    var sellStake = (int)Math.Round((double)(sumSell / sellOnlineEngine.Count), 0);
                    UpdateLogText(string.Format("CHUẨN BỊ BÁN: {0}", sumSell), eLogTextType.Highlight);

                    Task.Factory.StartNew(() =>
                    {
                        Thread.Sleep(timeWaitSell);
                        int sumSellStake = 0;
                        var sellStatus   = Parallel.ForEach(sellOnlineEngine, (engine) =>
                        {
                            int realStake;
                            if (engine.ProcessBetAnyway(sellStake, homeTeamName, awayTeamName, odd, oddType, sellBetType,
                                                        isLive, out realStake))
                            {
                                sumSellStake += realStake;
                                UpdateLogText(
                                    string.Format("BÁN {0} điểm vào tài khoản [{1}] trận {2} - {3} thành công!",
                                                  realStake, engine.UserName, homeTeamName, awayTeamName), eLogTextType.Highlight);
                            }
                            else
                            {
                                UpdateLogText(string.Format("BÁN vào tài khoản [{0}] trận {1} - {2} không thành công!",
                                                            engine.UserName, homeTeamName, awayTeamName), eLogTextType.Error);
                            }
                        }).IsCompleted;
                        UpdateLogText(string.Format("TỔNG BÁN: {0}", sumSellStake), eLogTextType.Highlight);
                    });
                }
                else
                {
                    Task.Run(() =>
                    {
                        UpdateLogText("Bắt đầu giao dịch!", eLogTextType.Warning);

                        var buyOnlineEngine = buyAccEngines.Where(b => b.AccountStatus == eAccountStatus.Online).ToList();

                        int sumBuyStake = 0;
                        var buyStatus   = Parallel.ForEach(buyOnlineEngine, (engine) =>
                        {
                            int realStake;
                            if (engine.ProcessBetAnyway(stake, homeTeamName, awayTeamName, odd, oddType, buyBetType, isLive, out realStake))
                            {
                                sumBuyStake += realStake;
                                UpdateLogText(string.Format("MUA {0} điểm vào tài khoản [{1}] trận {2} - {3} thành công!",
                                                            realStake, engine.UserName, homeTeamName, awayTeamName), eLogTextType.Highlight);
                            }
                            else
                            {
                                UpdateLogText(string.Format("MUA vào tài khoản [{0}] trận {1} - {2} không thành công!",
                                                            engine.UserName, homeTeamName, awayTeamName), eLogTextType.Error);
                            }
                        }).IsCompleted;

                        UpdateLogText(string.Format("TỔNG MUA: {0}", sumBuyStake), eLogTextType.Highlight);

                        if (sumBuyStake == 0)
                        {
                            UpdateLogText("Hoàn thành giao dịch!", eLogTextType.Warning);
                            return;
                        }

                        var sellOnlineEngine = sellAccEngines.Where(b => b.AccountStatus == eAccountStatus.Online).ToList();
                        var sellStake        = (int)Math.Round((double)(ConvertExchange(sumBuyStake, buyExchange, sellExchange) / sellOnlineEngine.Count), 0);
                        int sumSellStake     = 0;
                        var sellStatus       = Parallel.ForEach(sellOnlineEngine, (engine) =>
                        {
                            int realStake;
                            if (engine.ProcessBetAnyway(sellStake, homeTeamName, awayTeamName, odd, oddType, sellBetType, isLive, out realStake))
                            {
                                sumSellStake += realStake;
                                UpdateLogText(string.Format("BÁN {0} điểm vào tài khoản [{1}] trận {2} - {3} thành công!",
                                                            realStake, engine.UserName, homeTeamName, awayTeamName), eLogTextType.Highlight);
                            }
                            else
                            {
                                UpdateLogText(string.Format("BÁN vào tài khoản [{0}] trận {1} - {2} không thành công!",
                                                            engine.UserName, homeTeamName, awayTeamName), eLogTextType.Error);
                            }
                        }).IsCompleted;
                        UpdateLogText(string.Format("TỔNG BÁN: {0}", sumSellStake), eLogTextType.Highlight);
                        UpdateLogText("Hoàn thành giao dịch!", eLogTextType.Warning);
                    });
                }
            }
        }
コード例 #11
0
 internal void AddOddToClound(string fromIbetAccount, MatchDTO ibetmatch, MatchDTO sbobetmatch, eOddType oddtype, string ibetodd, string sbobetodd, string ibetoddType, string sbobetoddType, string ibetoddValue, string sbobetoddValue, bool homeFavor)
 {
     if (chkSCloud.Checked)
     {
         OddNews odd = new OddNews();
         odd.HomeTeamName = ibetmatch.HomeTeamName;
         odd.AwayTeamName = ibetmatch.AwayTeamName;
         odd.LeagueName = ibetmatch.LeagueName;
         odd.OddType = oddtype.ToString();
         odd.IbetOddType = ibetoddType;
         odd.SbobetOddType = sbobetoddType;
         odd.IbetOddValue = ibetoddValue;
         odd.SbobetOddValue = sbobetoddValue;
         odd.HomeFavor = homeFavor.ToString();
         odd.IbetOdd = ibetodd;
         odd.SbobetOdd = sbobetodd;
         try
         {
             betBrokerSvc.GetOdd(odd, this._currentUserID);
         }
         catch (TimeoutException exception)
         {
             //Console.WriteLine("Got {0}", exception.GetType());
             //.Abort();
         }
         catch (CommunicationException exception)
         {
             //InitializeWCFService();
         }
     }
 }
コード例 #12
0
        internal void AddLocalValidOdd(string fromIbetAccount, MatchDTO ibetmatch, MatchDTO sbobetmatch, eOddType oddtype, string ibetodd, string sbobetodd, string ibetoddType, string sbobetoddType, string ibetoddValue, string sbobetoddValue, bool homeFavor)
        {

            foreach (TerminalFormIBETSBO current in this._listTerminal2)
            {
                current.GetOddFromLocalCommunity(fromIbetAccount, ibetmatch, sbobetmatch, oddtype, ibetodd, sbobetodd, ibetoddType, sbobetoddType, ibetoddValue, sbobetoddValue, homeFavor);
            }            
        }
コード例 #13
0
        internal void GetOddFromLocalCommunity(string ibetAccount, MatchDTO ibetmatch, MatchDTO sbobetmatch, eOddType oddtype, string ibetOdd, string sbobetOdd, string ibetoddType, string sbobetoddType, string ibetoddValue, string sbobetoddValue, bool homeFavor)
        {
            if (!checkEdit15.Checked && (checkEdit14.Checked && ibetAccount != this._ibetAccount && this._running && !this._betting && this._listSameMatch != null))
            {
                try
                {
                    TransactionDTO transactionDTO;
                    //phai tim betID trong list vi khong giong nhau cho tung user
                    string sbobetoddID = string.Empty;
                    string ibetoddID = string.Empty;
                    System.Collections.Generic.List<MatchDTO> listSbobetMatch = this._listSbobetMatch;
                    System.Collections.Generic.List<MatchDTO> listIbetMatch = this._listIBETMatch;
                    MatchDTO matchDTO = MatchDTO.SearchMatch(ibetmatch, listSbobetMatch);
                    if (matchDTO != null && matchDTO.Odds.Count > 0)
                    {
                        OddDTO oddDTO = OddDTO.SearchOdd(oddtype, sbobetOdd, matchDTO.Odds);
                        if (oddDTO != null)
                        {
                            sbobetoddID = oddDTO.ID;
                            MatchDTO matchDTO2 = MatchDTO.SearchMatch(ibetmatch, listIbetMatch);
                            if (matchDTO2 != null && matchDTO.Odds.Count > 0)
                            {
                                OddDTO oddDTO2 = OddDTO.SearchOdd(oddtype, ibetOdd, matchDTO2.Odds);
                                if (oddDTO2 != null)
                                {
                                    ibetoddID = oddDTO2.ID;
                                    if (this.AllowOddBet(ibetoddID,""))
                                    {
                                        if (this.chbRandomStake.Checked)
                                        {
                                            int num = 0;
                                            while (num == 0)
                                            {
                                                string strNum = this.txtStake.Lines[new System.Random().Next(this.txtStake.Lines.Length)];
                                                int.TryParse(strNum, out num);
                                            }
                                            int ibetStake = num;
                                            int sbobetStake = num;

                                            transactionDTO = this.PlaceBetAllowMaxBet(false, ibetmatch, matchDTO, oddtype, ibetoddID, sbobetoddID, ibetoddType, sbobetoddType, ibetoddValue, sbobetoddValue.ToString(), ibetStake, sbobetStake, homeFavor, this._ibetEngine, this._sbobetEngine, sbobetOdd);
                                            transactionDTO.OddType = oddtype + " - " + ibetoddType + " / " + sbobetoddType;
                                            this.AddTransaction(transactionDTO);
                                        }
                                        else
                                        {
                                            int num = 0;
                                            while (num == 0)
                                            {
                                                string strNum = this.txtStake.Lines[new System.Random().Next(this.txtStake.Lines.Length)];
                                                int.TryParse(strNum, out num);
                                            }

                                            int ibetStake = num;
                                            int sbobetStake = (int)Math.Round(num * ((float)this.txtSBOBETFixedStake.Value / (float)this.txtIBETFixedStake.Value));

                                            transactionDTO = this.PlaceBet(false, ibetmatch, matchDTO, oddtype, ibetoddID, sbobetoddID, ibetoddType, sbobetoddType, ibetoddValue, sbobetoddValue.ToString(), ibetStake, sbobetStake, this._ibetEngine, this._sbobetEngine, sbobetOdd, homeFavor);
                                            transactionDTO.OddType = oddtype + " - " + ibetoddType + " / " + sbobetoddType;
                                            this.AddTransaction(transactionDTO);
                                        }
                                        if (transactionDTO != null && transactionDTO.IBETTrade)
                                        {
                                            this.UpdateOddBetHistory(ibetoddID,"");
                                        }
                                    }
                                }
                                else
                                    SendReportToMainForm(this._ibetAccount + "-" + this._sbobetAccount + " >> " + ibetmatch.HomeTeamName + " - " + ibetmatch.AwayTeamName + " : can not find odd " + sbobetOdd + "in IBET list");
                            }
                            else
                                SendReportToMainForm(this._ibetAccount + " match not found in ibet list");                            
                        }
                        else
                            SendReportToMainForm(this._ibetAccount + "-" + this._sbobetAccount + " >> " + ibetmatch.HomeTeamName + " - " + ibetmatch.AwayTeamName + " : can not find odd " + sbobetOdd + "in SBOBET list");
                    }
                    else
                        SendReportToMainForm(this._ibetAccount + "-" + this._sbobetAccount + " >> " + ibetmatch.HomeTeamName + " - " + ibetmatch.AwayTeamName + ": match not found in sbobet list");
                    
                }
                catch (Exception ex)
                {
                    //ShowWarningDialog("Error: " + ex);
                }
            }
        }
コード例 #14
0
 private void AddOddToLocalCommunity(MatchDTO ibetmatch, MatchDTO sbobetmatch, eOddType oddtype, string ibetodd, string sbobetodd, string ibetoddType, string sbobetoddType, string ibetoddValue, string sbobetoddValue, bool homeFavor)
 {
     this._mainForm.AddLocalValidOdd(this._ibetAccount, ibetmatch, sbobetmatch, oddtype, ibetodd, sbobetodd, ibetoddType, sbobetoddType, ibetoddValue, sbobetoddValue, homeFavor);
     if (this._mainForm.chkSCloud.Checked)
         this._mainForm.AddOddToClound(this._ibetAccount, ibetmatch, sbobetmatch, oddtype, ibetodd, sbobetodd, ibetoddType, sbobetoddType, ibetoddValue, sbobetoddValue, homeFavor);
 }
コード例 #15
0
        private TransactionDTO PlaceBetAllowMaxBet(bool sendOrNOT, MatchDTO ibetMatch, MatchDTO sbobetMatch, eOddType oddType, string ibetOddID, string sbobetOddID, string ibetOddType, string sbobetOddType, string ibetOddValue, string sbobetOddValue, int ibetStake, int sbobetStake, bool ibetHomeGive, IBetEngine ibetEngine, SbobetEngine sbobetEngine, string sbobetOdd)
        {
            this._betting = true;
            TransactionDTO transactionDTO = new TransactionDTO();
            
            //transactionDTO.OddType = current2.Type.ToString() + " - Home / Away";
            string text = "";
            string text2 = "";
            string text3 = "";
            bool flag = false;
            bool flag2 = false;
            int num = 0;
            int num2 = 0;
            string text4 = "";
            string text5 = "";
            string text6 = "";
            bool flag3 = false;
            bool flag4 = false;
            bool sBOBETReTrade = false;
            int num3 = 0;
            string text7 = "";
            string betCount = "";
            string text8 = "";
            bool flag5 = false;

            float ibetOddValue_ = float.Parse(ibetOddValue);
            float sboOddValue_ = float.Parse(sbobetOddValue);

            if (ibetOddValue_ > 0.84 || (ibetOddValue_ > 0f && txtAddValue.Value.ToString() == "0.01"))
            {
                float valueAdd = ibetStake * (float)txtAddValue.Value;
                ibetStake = ibetStake + (int)valueAdd;
            }
            if (sboOddValue_ > 0.84 || (sboOddValue_ > 0f && txtAddValue.Value.ToString() == "0.01"))
            {
                float valueAdd = sbobetStake * (float)txtAddValue.Value;
                sbobetStake = sbobetStake + (int)valueAdd;
            }

            bool ibetGoFirst = true;// who is Away or Under

            if (checkEdit11.Checked) //safe bet
            {
                if (sbobetOddType == "a") //  ibet  vs sbo
                {
                    if (oddType == eOddType.FirstHalfOverUnder || oddType == eOddType.FulltimeOverUnder)//neu bong over under
                    {
                        ibetGoFirst = false;
                    }
                    else // bong handicap
                    {
                        if (ibetHomeGive) // neu away la doi cua duoi
                        {
                            ibetGoFirst = false;
                        }
                    }
                }
                else //  sbo vs ibet
                {
                    if (oddType == eOddType.FirstHalfOverUnder || oddType == eOddType.FulltimeOverUnder)//neu bong over under
                    {
                        ibetGoFirst = true;
                    }
                    else // bong handicap
                    {
                        if (ibetHomeGive) // neu away la doi cua duoi
                        {
                            ibetGoFirst = true;
                        }
                    }
                }
            }

            if (MatchDTO.IsSameMatch(ibetMatch.HomeTeamName.ToLower(), sbobetMatch.HomeTeamName.ToLower(), ibetMatch.AwayTeamName.ToLower(), sbobetMatch.AwayTeamName.ToLower()))
            {
                try
                {
                    ibetEngine.PrepareBet(ibetOddID, ibetOddType, ibetOddValue, ibetStake.ToString(), out flag, out num, out num2, out text4, out text2, out text3);
                    sbobetEngine.PrepareBet(sbobetOddID, sbobetOddValue, sbobetOddType, out betCount, out num3, out flag3, out text7, out text5, out text6);
                    //object result = this.CallJavascriptFunction("bet", new object[] { 0, ibetMatch.ID.Remove(0, 2), ibetOddID, ibetOddType, ibetOddValue });
                    
                    if (MatchDTO.IsSameMatch(text2, text5, text3, text6)) // ten hom - away giong nhau
                    {                        
                        float num4 = 0f;
                        float num5 = 0f;
                        if (flag && flag3 && float.TryParse(text4, out num4) && float.TryParse(text7, out num5))
                        {
                            if ((checkEdit13.Checked || checkEdit15.Checked) && sendOrNOT)//gui lenh
                            {
                                var taskA = new Task(() => this.AddOddToLocalCommunity(ibetMatch, sbobetMatch, oddType, sbobetOdd, sbobetOdd, ibetOddType, sbobetOddType, ibetOddValue, sbobetOddValue, ibetHomeGive));
                                taskA.Start();
                            }

                            //try parse de tranh hien tuong mat Odd 1 ben
                            //float num4 = float.Parse(text4); 
                            //float num5 = float.Parse(text7);
                            if (num4 + num5 == 0f || num4 == num5)
                            {
                                int num6 = 0;
                                if (num2 >= num3) // num2 maxbet ibet
                                {
                                    num6 = num3; // num3 maxbet sbo
                                }
                                else
                                {
                                    if (num2 <= num3)
                                    {
                                        num6 = num2;
                                    }
                                }
                                if (ibetStake >= num6)
                                {
                                    ibetStake = num6;
                                }
                                if (sbobetStake >= num6)
                                {
                                    sbobetStake = num6;
                                }
                                try
                                {
                                    float currentCredit = 0;
                                    float currentCredit2 = 0;
                                    if (checkEdit8.Checked)
                                    {
                                        currentCredit = ibetEngine.GetCurrentCredit();
                                        currentCredit2 = sbobetEngine.GetCurrentCredit();
                                    }
                                    else
                                    {
                                        currentCredit = ibetEngine._currentCredit;
                                        currentCredit2 = sbobetEngine._currentCredit;
                                    }

                                    if ((float)ibetStake <= currentCredit && (float)sbobetStake <= currentCredit2)
                                    {
                                        try
                                        {
                                            if (ibetGoFirst)
                                            {
                                                
#if TESTMODE
                                                #region IBET_FIRTST_THEN_SBO
                                                if (!checkEdit12.Checked || (checkEdit12.Checked && ibetOddType == "a" && (oddType == eOddType.FirstHalfOverUnder || oddType == eOddType.FulltimeOverUnder)))
                                                    ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), num.ToString(), num2.ToString(), out flag2);
                                                if (flag2 && !checkEdit12.Checked)
                                                {
                                                    sbobetEngine.ConfirmBet(sbobetOddID, sbobetOddValue, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out flag4);
                                                    if (!flag4)
                                                    {
                                                        try
                                                        {
                                                            sbobetEngine.PrepareBet(sbobetOddID, text8, sbobetOddType, out betCount, out num3, out flag5, out text7, out text5, out text6);
                                                            if (MatchDTO.IsSameMatch(text2, text5, text3, text6))
                                                            {
                                                                if (!float.TryParse(text7, out num5)) //text 7 = BetKindValue
                                                                {
                                                                    Thread.Sleep(3000);
                                                                    sbobetEngine.PrepareBet(sbobetOddID, text8, sbobetOddType, out betCount, out num3, out flag5, out text7, out text5, out text6);
                                                                    float.TryParse(text7, out num5);
                                                                }

                                                                if (num4 + num5 == 0f || num4 == num5)
                                                                {
                                                                    text = "Retrade. IBET: " + ibetOddValue + " -  SBOBET: " + text8;
                                                                    //text = "No retrade in this version please trade manually.";
                                                                    sbobetEngine.ConfirmBet(sbobetOddID, text8, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out sBOBETReTrade);
                                                                    this._lastTransactionTime = System.DateTime.Now;
                                                                    playSound(false);
                                                                    
                                                                }
                                                                else
                                                                {
                                                                    text = "Invalid Odd in SBOBET. IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                                                                    playSound(false);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                text = string.Concat(new string[]
															    {
																    "Not Same Match - Retrade. IBET: ", 
																    text2, 
																    " / ", 
																    text3, 
																    " - SBOBET: ", 
																    text5, 
																    " / ", 
																    text6
															    });
                                                            }
                                                        }
                                                        catch (System.Exception ex)
                                                        {
                                                            text = "Error while Retrade. Details: " + ex.Message;
                                                            playSound(false);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        playSound(true);
                                                    }

                                                    this._lastTransactionTime = System.DateTime.Now;
                                                    object obj = text;
                                                    text = string.Concat(new object[]
												    {
													    obj, 
													    " - Success Transaction. Half: ", 
													    ibetMatch.Half, 
													    " - Minute: ", 
													    ibetMatch.Minute, 
													    " - Halftime: ", 
													    ibetMatch.IsHalfTime
												    });
                                                    ibetEngine.GetCurrentCredit();
                                                    sbobetEngine.GetCurrentCredit();

                                                }
                                                
                                                #endregion
#endif
                                            }

                                            else
                                            {
                                                text = "No more SBOBET comes first.";
                                                //#region SBO_BET_FIRST_THEN_IBET

                                                //sbobetEngine.ConfirmBet(sbobetOddID, sbobetOddValue, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out flag4);
                                                //if (flag4)
                                                //{ 
                                                //    ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), num.ToString(), num2.ToString(), out flag2);
                                                //    if (!flag2)
                                                //    {
                                                //        text = "Invalid Odd while Retrade.";// IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                                                //        sbobetEngine.GetCurrentCredit();
                                                //        playSound(false);
                                                //    }
                                                //    else
                                                //    {
                                                //        this._lastTransactionTime = System.DateTime.Now;
                                                //        object obj = text;
                                                //        text = string.Concat(new object[]
                                                //        {
                                                //            obj, 
                                                //            " - Success Transaction. Half: ", 
                                                //            ibetMatch.Half, 
                                                //            " - Minute: ", 
                                                //            ibetMatch.Minute, 
                                                //            " - Halftime: ", 
                                                //            ibetMatch.IsHalfTime
                                                //        });
                                                //        ibetEngine.GetCurrentCredit();
                                                //        sbobetEngine.GetCurrentCredit();
                                                //        playSound(true);
                                                //    }
                                                //}

                                                //#endregion
                                            }

                                        }
                                        catch (System.Exception ex)
                                        {
                                            text = "Error while Trading. Details: " + ex.Message;
                                        }
                                    }
                                    else
                                    {
                                        text = string.Concat(new object[]
										{
											"Out of Cash. IBET Credit: ", 
											currentCredit, 
											" -  SBOBET Credit: ", 
											currentCredit2
										});
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                    text = "Error while getting Credit. Details: " + ex.Message;
                                }
                            }
                            else
                            {
                                text = "Invalid Odd while Preparing Ticket. IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                            }
                        }
                    }                        
                    else
                    {
                        text = string.Concat(new string[]
						{
							"Not Same Match - Preparing Ticket. IBET: ", 
							text2, 
							" / ", 
							text3, 
							" - SBOBET: ", 
							text5, 
							" / ", 
							text6
						});
                    }                    
                }
                catch (System.Exception ex)
                {
                    text = "Error while Preparing Trade. Details: " + ex.Message;
                }
            }
            else
            {
                text = string.Concat(new string[]
				{
					"Not Same Match - Comparing. IBET: ", 
					ibetMatch.HomeTeamName, 
					" / ", 
					ibetMatch.AwayTeamName, 
					" - SBOBET: ", 
					sbobetMatch.HomeTeamName, 
					" / ", 
					sbobetMatch.AwayTeamName
				});
            }
            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName + ":" + ibetMatch.HomeScore + " / " + sbobetMatch.HomeTeamName;
            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName + ":" + ibetMatch.AwayScore + " / " + sbobetMatch.AwayTeamName;
            transactionDTO.Odd = text4 + " / " + text7;
            transactionDTO.OddKindValue = text4 + " / " + text7;
            transactionDTO.OddValue = ibetOddValue + " / " + sbobetOddValue;
            transactionDTO.Stake = ibetStake + " / " + sbobetStake;
            transactionDTO.IBETAllow = flag;
            transactionDTO.IBETTrade = flag2;
            transactionDTO.IBETReTrade = false;
            transactionDTO.SBOBETAllow = flag3;
            transactionDTO.SBOBETTrade = flag4;
            transactionDTO.SBOBETReTrade = sBOBETReTrade;
            //transactionDTO.OddType = oddType.ToString() + ;
            transactionDTO.OddType = oddType.ToString() + " - " + ibetOddType.Replace("h", "Home").Replace("a", "Away") + " / " + sbobetOddType.Replace("h", "Home").Replace("a", "Away");
            transactionDTO.Note = text;
            transactionDTO.DateTime = System.DateTime.Now.ToLocalTime();

            transactionDTO.HomeTeamSBOBET = sbobetMatch.HomeTeamName;
            transactionDTO.AwayTeamSBOBET = sbobetMatch.AwayTeamName;
            
            this._betting = false;
            return transactionDTO;            
        }        
コード例 #16
0
        private TransactionDTO PlaceBet(bool sendOrNOT, MatchDTO ibetMatch, MatchDTO sbobetMatch, eOddType oddType, string ibetOddID, string sbobetOddID, string ibetOddType, string sbobetOddType, string ibetOddValue, string sbobetOddValue, int ibetStake, int sbobetStake, IBetEngine ibetEngine, SbobetEngine sbobetEngine, string sbobetOdd, bool ibetHomeGive)
        {
            this._betting = true;
            TransactionDTO transactionDTO = new TransactionDTO();
            //transactionDTO.OddType = oddType.ToString() + " - " + ibetOddType.Replace("h", "Home").Replace("a", "Away") + " / " + sbobetOddType.Replace("h", "Home").Replace("a", "Away");
            string text = "";
            string text2 = "";
            string text3 = "";
            bool flag = false;
            bool flag2 = false;
            int num = 0;
            int num2 = 0;
            string text4 = "";
            string text5 = "";
            string text6 = "";
            bool flag3 = false;
            bool flag4 = false;
            bool sBOBETReTrade = false;
            int num3 = 0;
            string text7 = "";
            string betCount = "";
            string text8 = "";
            bool flag5 = false;

            float ibetOddValue_ = float.Parse(ibetOddValue);
            float sboOddValue_ = float.Parse(sbobetOddValue);

            if (ibetOddValue_ > 0.84 || (ibetOddValue_ > 0f && txtAddValue.Value.ToString() == "0.01"))
            {
                float valueAdd = ibetStake * (float)txtAddValue.Value;
                ibetStake = ibetStake + (int)valueAdd;
            }
            if (sboOddValue_ > 0.84 || (sboOddValue_ > 0f && txtAddValue.Value.ToString() == "0.01"))
            {
                float valueAdd = sbobetStake * (float)txtAddValue.Value;
                sbobetStake = sbobetStake + (int)valueAdd;
            }

            if (MatchDTO.IsSameMatch(ibetMatch.HomeTeamName.ToLower(), sbobetMatch.HomeTeamName.ToLower(), ibetMatch.AwayTeamName.ToLower(), sbobetMatch.AwayTeamName.ToLower()))
            {
                try
                {
                    ibetEngine.PrepareBet(ibetOddID, ibetOddType, ibetOddValue, ibetStake.ToString(), out flag, out num, out num2, out text4, out text2, out text3);
                    sbobetEngine.PrepareBet(sbobetOddID, sbobetOddValue, sbobetOddType, out betCount, out num3, out flag3, out text7, out text5, out text6);
                    if (MatchDTO.IsSameMatch(text2, text5, text3, text6))
                    {
                        if (flag && flag3)
                        {
                            if ((checkEdit13.Checked || checkEdit15.Checked) && sendOrNOT)//gui lenh
                            {
                                var taskA = new Task(() => this.AddOddToLocalCommunity(ibetMatch, sbobetMatch, oddType, sbobetOdd, sbobetOdd, ibetOddType, sbobetOddType, ibetOddValue, sbobetOddValue, ibetHomeGive));
                                taskA.Start();
                            }
                            float num4 = float.Parse(text4);
                            float num5 = float.Parse(text7);
                            if (num4 + num5 == 0f || num4 == num5)
                            {
                                if (ibetStake <= num2 && sbobetStake <= num3)
                                {
                                    try
                                    {                                        
                                        float currentCredit = 0;
                                        float currentCredit2 = 0;
                                        if (checkEdit8.Checked)
                                        {
                                            currentCredit = ibetEngine.GetCurrentCredit();
                                            currentCredit2 = sbobetEngine.GetCurrentCredit();
                                        }
                                        else
                                        {
                                            currentCredit = ibetEngine._currentCredit;
                                            currentCredit2 = sbobetEngine._currentCredit;
                                        }

                                        if ((float)ibetStake <= currentCredit && (float)sbobetStake <= currentCredit2)
                                        {
                                            try
                                            {
                                                
                                                ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), num.ToString(), num2.ToString(), out flag2);
                                                if (flag2)
                                                {
                                                    sbobetEngine.ConfirmBet(sbobetOddID, sbobetOddValue, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out flag4);
                                                    if (!flag4)
                                                    {
                                                        try
                                                        {
                                                            sbobetEngine.PrepareBet(sbobetOddID, text8, sbobetOddType, out betCount, out num3, out flag5, out text7, out text5, out text6);
                                                            if (MatchDTO.IsSameMatch(text2, text5, text3, text6))
                                                            {
                                                                num5 = float.Parse(text7);
                                                                if (num4 + num5 == 0f || num4 == num5)
                                                                {
                                                                    text = "Retrade. IBET: " + ibetOddValue + " -  SBOBET: " + text8;
                                                                    sbobetEngine.ConfirmBet(sbobetOddID, text8, sbobetOddType, sbobetStake.ToString(), betCount, out text8, out sBOBETReTrade);
                                                                    this._lastTransactionTime = System.DateTime.Now;
                                                                }
                                                                else
                                                                {
                                                                    text = "Invalid Odd while Retrade. IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                text = string.Concat(new string[]
																{
																	"Not Same Match - Retrade. IBET: ", 
																	text2, 
																	" / ", 
																	text3, 
																	" - SBOBET: ", 
																	text5, 
																	" / ", 
																	text6
																});
                                                            }
                                                        }
                                                        catch (System.Exception ex)
                                                        {
                                                            text = "Error while Retrade. Details: " + ex.Message;
                                                        }
                                                    }
                                                    this._lastTransactionTime = System.DateTime.Now;
                                                    object obj = text;
                                                    text = string.Concat(new object[]
													{
														obj, 
														" - Success Transaction. Half: ", 
														ibetMatch.Half, 
														" - Minute: ", 
														ibetMatch.Minute, 
														" - Halftime: ", 
														ibetMatch.IsHalfTime
													});
                                                }
                                                
                                            }
                                            catch (System.Exception ex)
                                            {
                                                text = "Error while Trading. Details: " + ex.Message;
                                            }
                                        }
                                        else
                                        {
                                            text = string.Concat(new object[]
											{
												"Out of Cash. IBET Credit: ", 
												currentCredit, 
												" -  SBOBET Credit: ", 
												currentCredit2
											});
                                        }
                                    }
                                    catch (System.Exception ex)
                                    {
                                        text = "Error while getting Credit. Details: " + ex.Message;
                                    }
                                }
                                else
                                {
                                    text = string.Concat(new object[]
									{
										"Max Bet. IBET: ", 
										num2, 
										" - SBOBET: ", 
										num3
									});
                                }
                            }
                            else
                            {
                                text = "Invalid Odd while Preparing Ticket. IBET Odd: " + text4 + " - SBOBET Odd:" + text7;
                            }
                        }
                    }
                    else
                    {
                        text = string.Concat(new string[]
						{
							"Not Same Match - Preparing Ticket. IBET: ", 
							text2, 
							" / ", 
							text3, 
							" - SBOBET: ", 
							text5, 
							" / ", 
							text6
						});
                    }
                }
                catch (System.Exception ex)
                {
                    text = "Error while Preparing Trade. Details: " + ex.Message;
                }
            }
            else
            {
                text = string.Concat(new string[]
				{
					"Not Same Match - Comparing. IBET: ", 
					ibetMatch.HomeTeamName, 
					" / ", 
					ibetMatch.AwayTeamName, 
					" - SBOBET: ", 
					sbobetMatch.HomeTeamName, 
					" / ", 
					sbobetMatch.AwayTeamName
				});
            }
            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName + " / " + sbobetMatch.HomeTeamName;
            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName + " / " + sbobetMatch.AwayTeamName;
            transactionDTO.Odd = text4 + " / " + text7;
            transactionDTO.OddKindValue = text4 + " / " + text7;
            transactionDTO.OddValue = ibetOddValue + " / " + sbobetOddValue;
            transactionDTO.Stake = ibetStake + " / " + sbobetStake;
            transactionDTO.IBETAllow = flag;
            transactionDTO.IBETTrade = flag2;
            transactionDTO.IBETReTrade = false;
            transactionDTO.SBOBETAllow = flag3;
            transactionDTO.SBOBETTrade = flag4;
            transactionDTO.SBOBETReTrade = sBOBETReTrade;
            transactionDTO.OddType = oddType.ToString();
            transactionDTO.Note = text;
            transactionDTO.DateTime = System.DateTime.Now;
            transactionDTO.OddType = oddType.ToString() + " - " + ibetOddType.Replace("h", "Home").Replace("a", "Away") + " / " + sbobetOddType.Replace("h", "Home").Replace("a", "Away");
            this._betting = false;
            return transactionDTO;
            
        }
コード例 #17
0
        private TransactionDTO PlaceSingleIBET(MatchDTO ibetMatch, string odd, string oddValue, eOddType oddType, string ibetOddType, string stake, string homeScore, string awayScore, IBetEngine ibetEngine, bool followtype, string followref, string accountName)
        {
            this._betting = true;
            TransactionDTO transactionDTO = new TransactionDTO();
            string following = string.Empty;
            if (followtype)
                following = "following";
            else
                following = "unfollowing";

            string betKindValue = string.Empty;
            string homeTeamName = string.Empty;
            string awayTeamName = string.Empty;
            string newOddValue = string.Empty;
            string newHomeScore = string.Empty;
            string newAwayScore = string.Empty;

            bool flag = false;
            bool flag2 = false;
            string text = string.Empty;

            System.Collections.Generic.List<MatchDTO> listIbetMatch = this._listIBETMatch;
            //MatchDTO matchDTO = MatchDTO.SearchMatchFull(ibetMatch, listIbetMatch);
            if (ibetMatch != null && ibetMatch.HomeTeamName != string.Empty)
            {
                OddDTO oddDTO = OddDTO.SearchOdd(oddType, odd, true, ibetMatch.Odds);
                if (oddDTO != null)
                {
                    string ibetOddNow = string.Empty;
                    if (ibetOddType == "a")
                        ibetOddNow = oddDTO.Away.ToString();
                    else
                        ibetOddNow = oddDTO.Home.ToString();
                    if (followtype || (!followtype && ((float.Parse(ibetOddNow) >= (float)txtLowestOddValue.Value && float.Parse(ibetOddNow) > 0)) || float.Parse(ibetOddNow) < 0))
                    {
                        int maxBet = 0;
                        int minBet = 0;
                        string ibetOddID = oddDTO.ID;
                        try
                        {
                            ibetEngine.PrepareBet2(ibetOddID, ibetOddType, ibetOddNow.ToString(), stake, out flag, out minBet, out maxBet, out betKindValue, out homeTeamName, out awayTeamName, out newOddValue, out newHomeScore, out newAwayScore);
                            if (homeTeamName == ibetMatch.HomeTeamName)
                            {
                                if (newHomeScore == homeScore && newAwayScore == awayScore)
                                {
                                    float num1 = float.Parse(odd);
                                    float num2 = float.Parse(betKindValue);
                                    if (num1 + num2 == 0f || num1 == num2)
                                    {
                                        if (int.Parse(stake) > maxBet)
                                            stake = maxBet.ToString();

                                        float newIbetOddValue = float.Parse(newOddValue);
                                        float oldIbetOddValue = float.Parse(oddValue);

                                        //if (OddDTO.IsValidOddPair(newIbetOddValue, oldIbetOddValue, (float)txtAllowTradeMinValue.Value, true))
                                        //{
                                        ibetEngine.ConfirmBet(oddType, newOddValue, stake, minBet.ToString(), maxBet.ToString(), out flag2);
                                        if (!flag2)
                                        {
                                            //this._lastTransactionTime = System.DateTime.Now;
                                            //SendReportToMainForm("- Follow Bet: " + this._ibetAccount + " >> " + matchDTO.HomeTeamName + " - " + matchDTO.AwayTeamName + ": Bet confirmed failed. ");
                                            text = "Confirm bet failed";
                                        }
                                        else
                                        {
                                            this._lastTransactionTime = DateTime.Now;
                                            text = " - Success " + following + " " + this._ibetSubAccount + ". Follow: " + ibetOddType + " > " + accountName;
                                        }
                                        //}
                                        //else
                                        //{
                                        //    SendReportToMainForm("Follow Bet: " + this._ibetAccount + " >> " + matchDTO.HomeTeamName + " - " + matchDTO.AwayTeamName + ": New odd value: " + newOddValue + " is lower than allowed number ");
                                        //}
                                    }
                                    else
                                        text = "Invalid Odd while Preparing Ticket. IBET Odd: " + betKindValue;
                                }
                                else
                                {
                                    text = "Score changed.";
                                }
                            }
                            else
                            {
                                text = "Not same match. Comparing: " + ibetMatch.HomeTeamName + " - " + ibetMatch.AwayTeamName;
                            }
                        }
                        catch (Exception ex)
                        {
                            text = ex.Message;
                        }
                    }
                    else
                    {
                        text = "Odd value is smaller than lowest accepted:" + ibetOddNow;
                    }
                }
                else
                {
                    string text2 = string.Empty;
                    //foreach (OddDTO o in ibetMatch.Odds)
                    //{
                    //    text2 += o.Odd + ","; 
                    //}
                    text = "Odd not found.";
                }
            }
            else
                text = "Match not found ";


            transactionDTO.HomeTeamName = homeTeamName;
            transactionDTO.AwayTeamName = awayTeamName;
            transactionDTO.HomeScore = homeScore;
            transactionDTO.AwayScore = awayScore;
            transactionDTO.Score = homeScore + "-" + awayScore;
            transactionDTO.AccountPair = this._ibetAccount + " - " + this._ibetSubAccount;
            transactionDTO.OddType = oddType.ToString();
            transactionDTO.Odd = betKindValue;
            transactionDTO.OddKindValue = betKindValue;
            transactionDTO.OddValue = newOddValue;
            transactionDTO.Stake = stake;
            transactionDTO.Note = text;
            transactionDTO.IBETTrade = flag2;
            transactionDTO.IBETAllow = flag;
            transactionDTO.IsFollowTypeTrans = true;
            transactionDTO.DateTime = DateTime.Now;
            transactionDTO.FollowRef = followref;

            this._betting = false;
            return transactionDTO;
        }
コード例 #18
0
 private void TransactionProcess(MatchDTO ibetMatch, MatchDTO sbobetMatch, eOddType oddType, string ibetOddID, string sbobetOddID, string ibetOddType, string sbobetOddType, string ibetOddValue, string sbobetOddValue, int ibetStake, int sbobetStake, IBetEngine ibetEngine, SbobetEngine sbobetEngine, string sbobetOdd, bool homeFavor)
 {
     if (!this._betting)
     {
         TransactionDTO transactionDTO = new TransactionDTO();
         transactionDTO = this.PlaceBet(true, ibetMatch, sbobetMatch, oddType, ibetOddID, sbobetOddID, ibetOddType, sbobetOddType, ibetOddValue, sbobetOddValue.ToString(), ibetStake, sbobetStake, this._ibetEngine, this._sbobetEngine, sbobetOdd, homeFavor);
         this.AddTransaction(transactionDTO);
         if (transactionDTO != null && transactionDTO.IBETTrade)
         {
             this.UpdateOddBetHistory(ibetOddID,"");
         }
     }
 }
コード例 #19
0
        public void ConfirmBetFor2ndIBET(eOddType oddType,
                                    string oddValue,
                                    string stake,
                                    string minStake,
                                    string maxStake,
                                    out bool success)
        {
            success = false;
            try
            {
                string text = "BPstake=" + stake;
                text += "&btnBPSubmit=Process+Bet&HorseBPstake="; //related with cookies
                text += "&stakeRequest=&";
                text += "oddsRequest=" + oddValue;
                text += "&oddChange1=Odds+has+changed+from";
                text += "&oddChange2=to";
                text = text + "&MINBET=" + minStake;
                text = text + "&MAXBET=" + maxStake; // cho nay
                switch (oddType)
                {
                    case eOddType.FulltimeHandicap:
                        {
                            text += "&bettype=1";
                            break;
                        }
                    case eOddType.FulltimeOverUnder:
                        {
                            text += "&bettype=3";
                            break;
                        }
                    case eOddType.FirstHalfHandicap:
                        {
                            text += "&bettype=7";
                            break;
                        }
                    case eOddType.FirstHalfOverUnder:
                        {
                            text += "&bettype=8";
                            break;
                        }
                }
                text += "&lowerminmesg=Your+stake+is+lower+than+minimun+bet%21%21%21";
                text += "&highermaxmesg=Your+stake+is+higher+than+maximum+bet%21%21%21";
                text += "&areyousuremesg=Are+you+sure+you+want+process+the+bet%3F";
                text += "&areyousuremesg1=Your+previous+bet+is+still+processing%2C+are+you+sure+you+want+to+bet+%3F";
                text += "&incorrectStakeMesg=Incorrect+Stake.";
                text += "&oddsWarning=WARNING%21%21%21+WE+HAVE+GIVEN+A+NEW+ODDS+%26+NEW+STAKE%21%21%21";
                text += "&betconfirmmesg=Please+click+OK+to+confirm+the+bet%3F";
                text += "&siteType=";
                text += "&hidStake10=Stake+must+be+in+multiples+of+10";
                text += "&hidStake20=Stake+must+be+in+multiples+of+20";
                text += "&hidStake2=Stake+must+be+in+multiples+of+2";
                text += "&sporttype=1";
                text = text + "&username="******"&oddsType=4&cbAcceptBetterOdds=1";

                string data = CreateWebRequest("POST",
                    "http://" + this.ibetAgent2.Config.HostName + "/underover/confirm_bet_data.aspx",
                    "http://" + this.ibetAgent2.Config.HostName + "/LeftAllInOne.aspx",
                    this.ibetAgent2.cc,
                    this.ibetAgent2.Config.HostName, true, text);

                IBetEngine.ProcessConfirmBet(data, out success);
            }
            catch (System.Exception ex)
            {
                success = false;
                throw ex;
            }
        }
コード例 #20
0
        public static OddDTO SearchOdd(eOddType oddType, string oddtoSearch, bool a, System.Collections.Generic.List<OddDTO> dataSource)
        {
            OddDTO result = null;
            string __odd = oddtoSearch.ToLower().Trim();
            decimal od = Math.Abs(decimal.Parse(__odd));
            if (dataSource != null)
            {
                try
                {
                    System.Collections.Generic.List<OddDTO> list = (
                        from odd in dataSource
                        where odd.Type == oddType && (float.Parse(ConvertOdd(odd.Odd.ToLower().Trim())) == (float.Parse((od.ToString()))))
                        select odd).ToList<OddDTO>();
                    if (list.Count == 1)
                    {
                        result = list[0];
                    }
                    else
                    {
                        result = null;
                    }
                }
                catch (Exception ex)
                {
#if DEBUG
                    iBet.Utilities.WriteLog.Write("Error 006 Can not search: " + oddtoSearch + ",ex: " + ex);
#endif
                    result = null;
                }
            }
            return result;

        }
コード例 #21
0
        public static OddDTO SearchOdd(eOddType oddType, string oddtoSearch, System.Collections.Generic.List<OddDTO> dataSource)
        {
            OddDTO result = null;
            string __odd = oddtoSearch.ToLower().Replace("0", "").Replace(" ", "");
            if (dataSource != null)
            {
                try
                {
                    System.Collections.Generic.List<OddDTO> list = (
                        from odd in dataSource
                        where odd.Type == oddType && odd.Odd.ToLower().Replace("0", "").Replace(" ", "").Equals(__odd)
                        select odd).ToList<OddDTO>();
                    if (list.Count == 1)
                    {
                        result = list[0];
                    }
                    else
                    {
                        result = null;
                    }
                }
                catch (Exception ex)
                {
#if DEBUG
                    iBet.Utilities.WriteLog.Write("Error 006 Can not search: " + oddtoSearch + ",ex: " + ex);
#endif
                    result = null;
                }
            }
            return result;

        }
コード例 #22
0
		private TransactionDTO PlaceBet(
            MatchDTO ibetMatch,
            MatchDTO threein1betMatch,
            eOddType oddType,
            string ibetOddID,
            string ibetOddType,
            string ibetOddValue,
            OddDTO threein1Odd,
            string threein1OddType,
            int ibetStake,
            int threein1betStake,
            IBetEngine ibetEngine,
            ThreeIn1BetEngine threein1betEngine)
		{
			TransactionDTO transactionDTO = new TransactionDTO();
            string text = string.Empty;
            string text2 = string.Empty;
            string text3 = string.Empty;
			bool flag = false;
			bool flag2 = false;
			int num = 0;
			int num2 = 0;
            string text4 = string.Empty;
            string text5 = string.Empty;
            string text6 = string.Empty;
			bool flag3 = false;
			bool flag4 = false;
			bool sBOBETReTrade = false;
			int num3 = 0;
            
            string text7 = string.Empty;
            string betCount = string.Empty;
            
            string text8 = string.Empty;
			

            bool threein1betAllowance = false;
            int threein1betminStake = 0;
            int threein1betmaxStake = 0;
            string threein1betKindValue = string.Empty;
            string threein1betHomeTeamName = string.Empty;
            string threein1betAwayTeamName = string.Empty;
            string postBODY = string.Empty;  

            if (MatchDTO.IsSameMatch(ibetMatch.HomeTeamName.ToLower(), threein1betMatch.HomeTeamName.ToLower(), ibetMatch.AwayTeamName.ToLower(), threein1betMatch.AwayTeamName.ToLower()))
			{
				try
				{
					ibetEngine.PrepareBet(ibetOddID, ibetOddType, ibetOddValue, ibetStake.ToString(), out flag, out num, out num2, out text4, out text2, out text3);
                    threein1betEngine.PrepareBet(threein1Odd.ID, threein1Odd.Away.ToString(), threein1Odd.Type.ToString().Replace("FulltimeHandicap", "Hdp").Replace("", ""), "Away", threein1Odd.IsHomeGive.ToString().Replace("True", "1").Replace("False", "0"), threein1Odd.Odd, threein1betMatch.HomeScore, threein1betMatch.AwayScore, threein1betMatch.ID, threein1betMatch.IsHalfTime.ToString().Replace("True", "1").Replace("False", "0"), threein1betStake.ToString(),
                        out threein1betAllowance, out threein1betminStake, out threein1betmaxStake, out threein1betKindValue, out threein1betHomeTeamName, out threein1betAwayTeamName, out postBODY);
                    
                    if (MatchDTO.IsSameMatch(text2, text5, text3, text6))
					{
						if (flag && flag3)
						{
							float num4 = float.Parse(text4);
							float num5 = float.Parse(text7);
							if (num4 + num5 == 0f || num4 == num5)
							{
								if (ibetStake <= num2 && threein1betStake <= num3)
								{
									try
									{
										float currentCredit = ibetEngine.GetCurrentCredit();
                                        float currentCredit2 = threein1betEngine.GetCurrentCredit();
										if ((float)ibetStake <= currentCredit && (float)threein1betStake <= currentCredit2)
										{
											try
											{
												ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), num.ToString(), num2.ToString(), out flag2);
												if (flag2)
												{
                                                    //threeIn1BetEngine.ConfirmBet(oddType,
                                                    //    threein1betOddValue,
                                                    //    threein1betStake.ToString(), 
                                                    //    betCount, 
                                                    //    text8, 
                                                    //    out flag4);
													if (!flag4)
													{
														try
														{
                                                            //
														}
														catch (System.Exception ex)
														{
															text = "Error while Retrade. Details: " + ex.Message;
														}
													}
													this._lastTransactionTime = System.DateTime.Now;
													object obj = text;
													text = string.Concat(new object[]
													{
														obj, 
														" - Success Transaction. Half: ", 
														ibetMatch.Half, 
														" - Minute: ", 
														ibetMatch.Minute, 
														" - Halftime: ", 
														ibetMatch.IsHalfTime
													});
												}
											}
											catch (System.Exception ex)
											{
												text = "Error while Trading. Details: " + ex.Message;
											}
										}
										else
										{
											text = string.Concat(new object[]
											{
												"Out of Cash. IBET Credit: ", 
												currentCredit, 
												" -  3in1BET Credit: ", 
												currentCredit2
											});
										}
									}
									catch (System.Exception ex)
									{
										text = "Error while getting Credit. Details: " + ex.Message;
									}
								}
								else
								{
									text = string.Concat(new object[]
									{
										"Max Bet. IBET: ", 
										num2, 
										" - 3in1BET: ", 
										num3
									});
								}
							}
							else
							{
								text = "Invalid Odd while Preparing Ticket. IBET Odd: " + text4 + " - 3in1BET Odd:" + text7;
							}
						}
					}
					else
					{
						text = string.Concat(new string[]
						{
							"Not Same Match - Preparing Ticket. IBET: ", 
							text2, 
							" / ", 
							text3, 
							" - 3in1BET: ", 
							text5, 
							" / ", 
							text6
						});
					}
				}
				catch (System.Exception ex)
				{
					text = "Error while Preparing Trade. Details: " + ex.Message;
				}
			}
			else
			{
				text = string.Concat(new string[]
				{
					"Not Same Match - Comparing. IBET: ", 
					ibetMatch.HomeTeamName, 
					" / ", 
					ibetMatch.AwayTeamName, 
					" - 3in1BET: ", 
					threein1betMatch.HomeTeamName, 
					" / ", 
					threein1betMatch.AwayTeamName
				});
			}
            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName + " / " + threein1betMatch.HomeTeamName;
            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName + " / " + threein1betMatch.AwayTeamName;
			transactionDTO.Odd = text4 + " / " + text7;
			transactionDTO.OddKindValue = text4 + " / " + text7;
			transactionDTO.OddValue = ibetOddValue + " / " + threein1Odd.Away;
			transactionDTO.Stake = ibetStake + " / " + threein1betStake;
			transactionDTO.IBETAllow = flag;
			transactionDTO.IBETTrade = flag2;
			transactionDTO.IBETReTrade = false;
			transactionDTO.THREEIN1Allow = flag3;
			transactionDTO.THREEIN1Trade = flag4;
			transactionDTO.THREEIN1ReTrade = sBOBETReTrade;
			transactionDTO.OddType = oddType.ToString();
			transactionDTO.Note = text;
			transactionDTO.DateTime = System.DateTime.Now;
			return transactionDTO;
		}
コード例 #23
0
		private TransactionDTO PlaceBetAllowMaxBet(
            MatchDTO ibetMatch, 
            MatchDTO threein1betMatch, 
            eOddType oddType, 
            string ibetOddID,
            string ibetOddType,             
            string ibetOddValue, 
            OddDTO threein1Odd,
            string threein1OddType,
            int ibetStake, 
            int threein1betStake, 
            IBetEngine ibetEngine, 
            ThreeIn1BetEngine threein1betEngine)
		{
            
			TransactionDTO transactionDTO = new TransactionDTO(); //khoi tao transaction
            string text = string.Empty;			
            bool flagIBETOK = false;
            bool flag3IN1OK = false;
			
			bool threein1ReTrade = false;            
            string betCount = string.Empty;
            
            bool flagibetAllowance = false;
            int ibetminStake = 0;
            int ibetmaxStake = 0;
            string ibetBetKindValue = string.Empty;
            string ibetHomeTeamName = string.Empty;
            string ibetAwayTeamNam = string.Empty;

            bool ibetGoFirst = true;// who is Away or Under
            string threein1OddValue = string.Empty;
            if (threein1OddType == "Away") //neu 3in1 o vi tri away
            {
                threein1OddValue = threein1Odd.Away.ToString();
                if (threein1Odd.Type == eOddType.FirstHalfOverUnder || threein1Odd.Type == eOddType.FulltimeOverUnder) //neu 3in1 la Under
                {
                    ibetGoFirst = false; // cho 3in1 Confirm truoc
                }
                else // bong handicap
                {
                    if (threein1Odd.IsHomeGive) // neu away la doi cua duoi
                    {
                        ibetGoFirst = false;
                    }
                }
            }
            else if (threein1OddType == "Home") // neu 3in1 o vi tri home - ibet away
            {
                threein1OddValue = threein1Odd.Home.ToString();
                if (threein1Odd.Type == eOddType.FirstHalfOverUnder || threein1Odd.Type == eOddType.FulltimeOverUnder) //neu 3in1 la Over
                {
                    ibetGoFirst = true; // cho ibet Confirm truoc (under)
                }
                else // bong handicap
                {
                    if (!threein1Odd.IsHomeGive) // neu 3in1 la doi cua duoi
                    {
                        ibetGoFirst = false;
                    }
                }
            }

            bool flagthreein1betAllowance = false;
            int threein1betminStake = 0;
            int threein1betmaxStake = 0;
            string threein1betKindValue = string.Empty;
            string threein1betHomeTeamName = string.Empty;
            string threein1betAwayTeamName = string.Empty;
            
            string postBODY = string.Empty;            

            if (MatchDTO.IsSameMatch(ibetMatch.HomeTeamName.ToLower(), threein1betMatch.HomeTeamName.ToLower(), ibetMatch.AwayTeamName.ToLower(), threein1betMatch.AwayTeamName.ToLower()))
			{
				try
				{
                    ibetEngine.PrepareBet(ibetOddID, ibetOddType, ibetOddValue, ibetStake.ToString(), 
                        out flagibetAllowance, out ibetminStake, out ibetmaxStake, out ibetBetKindValue, out ibetHomeTeamName, out ibetAwayTeamNam);
                    
                    threein1betEngine.PrepareBet(
                        threein1Odd.ID,
                        threein1OddValue,//odd price
                        threein1Odd.Type.ToString(), 
                        threein1OddType, // "Away"
                        threein1Odd.IsHomeGive.ToString().Replace("True", "1").Replace("False", "0"),
                        threein1Odd.Odd, 
                        threein1betMatch.HomeScore, 
                        threein1betMatch.AwayScore, 
                        threein1betMatch.ID, 
                        threein1betMatch.IsHalfTime.ToString().Replace("True", "1").Replace("False", "0"), 
                        threein1betStake.ToString(),
                        out flagthreein1betAllowance, 
                        out threein1betminStake, 
                        out threein1betmaxStake, 
                        out threein1betKindValue, 
                        out threein1betHomeTeamName, 
                        out threein1betAwayTeamName,
                        out postBODY);
#if DEBUG
                    Utilities.WriteLog.Write("Calling threein1betEngine.PrepareBet");
#endif

                    if (MatchDTO.IsSameMatch(ibetHomeTeamName, threein1betHomeTeamName, ibetAwayTeamNam, threein1betAwayTeamName))
                    {
                        if (flagibetAllowance && flagthreein1betAllowance)
                        {
                            float numIbet = float.Parse(ibetBetKindValue);
                            float num3in1bet = float.Parse(threein1betKindValue);

                            if (numIbet + num3in1bet == 0f || numIbet == num3in1bet)
                            {
#if DEBUG
                                Utilities.WriteLog.Write("+ Valid bet, system is now going to confirm:" + ibetHomeTeamName + " - " + threein1betAwayTeamName);
#endif
                                int numMax = 0; // get minimum of Maximum bet allowed of two system
                                if (ibetmaxStake >= threein1betmaxStake)
                                {
                                    numMax = threein1betmaxStake;                                    
                                }
                                else
                                {
                                    numMax = ibetmaxStake;
                                }

                                if (ibetStake >= numMax) //compare stake with numMax
                                {
                                    ibetStake = numMax;
                                }
                                if (threein1betStake >= numMax)
                                {
                                    threein1betStake = numMax;
                                }

                                try
                                {
                                    float currentCredit = 0;
                                    float currentCredit2 = 0;
                                    if (checkEdit8.Checked)
                                    {
                                        currentCredit = ibetEngine.GetCurrentCredit();
                                        currentCredit2 = threein1betEngine.GetCurrentCredit();
                                    }
                                    else
                                    {
                                        currentCredit = ibetEngine._currentCredit;
                                        currentCredit2 = threein1betEngine._currentCredit;
                                    }
                                    
                                    
                                    if ((float)ibetStake <= currentCredit && (float)threein1betStake <= currentCredit2)
                                    {
                                        if (ibetGoFirst)
                                        {
                                            #region Confirm_IBET_first_then_3in1
#if DEBUG
                                            Utilities.WriteLog.Write("IBET GO FIRST!");
#endif
                                            try
                                            {
                                                ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), ibetminStake.ToString(), ibetmaxStake.ToString(), out flagIBETOK);
                                                if (flagIBETOK)// iBet Confirm thanh cong
                                                {
                                                    string odd3in1NEW = string.Empty;
                                                    threein1betEngine.ConfirmBet(postBODY, threein1betStake.ToString(), out flag3IN1OK, out odd3in1NEW);
                                                    if (!flag3IN1OK)
                                                    {
                                                        try
                                                        {
                                                            if (odd3in1NEW != "changed")
                                                            {
                                                                //threein1betEngine.ConfirmBet(postBODY, threein1betStake.ToString(), out flag3IN1OK, out odd3in1NEW);
                                                                this._lastTransactionTime = System.DateTime.Now;
                                                                playSound(false);
                                                                text = "Odd 3in1 changed";
                                                                this.lblIbetCurrentCredit.Caption = this._ibetEngine.GetCurrentCredit().ToString();
                                                                
                                                            }
                                                            else
                                                            {
                                                                text = "Invalid Odd while Retrade.";// IBET Odd: " +text4 + " - SBOBET Odd:" + text7;
                                                                this.lblIbetCurrentCredit.Caption = this._ibetEngine.GetCurrentCredit().ToString();
                                                                playSound(false);
                                                            }
                                                        }
                                                        catch (System.Exception ex)
                                                        {
                                                            text = "Error while Retrade. Details: " + ex.Message;
                                                            playSound(false);

#if DEBUG
                                                            Utilities.WriteLog.Write(text);
#endif
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.lbl3in1betCurrentCredit.Caption = this._3in1Engine.GetCurrentCredit().ToString();
                                                        this.lblIbetCurrentCredit.Caption = this._ibetEngine.GetCurrentCredit().ToString();
                                                        playSound(true);
                                                    }
                                                    this._lastTransactionTime = System.DateTime.Now;
                                                    object obj = text;
                                                    text = string.Concat(new object[]
												    {
													    obj, 
													    " - Success Transaction. Half: ", 
													    ibetMatch.Half, 
													    " - Minute: ", 
													    ibetMatch.Minute, 
													    " - Halftime: ", 
													    ibetMatch.IsHalfTime
												    });                                                    
                                                }
                                            }
                                            catch (System.Exception ex)
                                            {
                                                text = "Error while Trading. Details: " + ex.Message;
#if DEBUG
                                                Utilities.WriteLog.Write(text);
#endif
                                            }
                                            #endregion
                                        }
                                        else
                                        {
                                            #region Confirm_3in1_first_then_IBET
#if DEBUG
                                            Utilities.WriteLog.Write("3IN1BET GO FIRST!");
#endif
                                            try
                                            {
                                                string odd3in1NEW = string.Empty;
                                                threein1betEngine.ConfirmBet(postBODY, threein1betStake.ToString(), out flag3IN1OK, out odd3in1NEW);
                                                if (flag3IN1OK)
                                                {
                                                    ibetEngine.ConfirmBet(oddType, ibetOddValue, ibetStake.ToString(), ibetminStake.ToString(), ibetmaxStake.ToString(), out flagIBETOK);
                                                    if (!flagIBETOK)// iBet Confirm thanh cong
                                                    {
                                                        try
                                                        {
                                                            playSound(false);
#if DEBUG
                                                            Utilities.WriteLog.Write("iBet confirm failed.");
#endif
                                                        }

                                                        catch (System.Exception ex)
                                                        {
                                                            text = "Error while Retrade. Details: " + ex.Message;
                                                            playSound(false);
#if DEBUG
                                                            Utilities.WriteLog.Write(text);
#endif
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.lbl3in1betCurrentCredit.Caption = this._3in1Engine.GetCurrentCredit().ToString();
                                                        this.lblIbetCurrentCredit.Caption = this._ibetEngine.GetCurrentCredit().ToString();
                                                        playSound(true);
                                                    }
                                                    this._lastTransactionTime = System.DateTime.Now;
                                                    object obj = text;
                                                    text = string.Concat(new object[]
												    {
													    obj, 
													    " - Success Transaction. Half: ", 
													    ibetMatch.Half, 
													    " - Minute: ", 
													    ibetMatch.Minute, 
													    " - Halftime: ", 
													    ibetMatch.IsHalfTime
												    });
                                                }
                                            }
                                            catch (System.Exception ex)
                                            {
                                                text = "Error while Trading. Details: " + ex.Message;
#if DEBUG
                                                Utilities.WriteLog.Write(text);
#endif
                                            }
                                            #endregion
                                        }
                                    }
                                    else
                                    {
                                        text = string.Concat(new object[]
										{
											"Out of Cash. IBET Credit: ", 
											currentCredit, 
											" -  SBOBET Credit: ", 
											currentCredit2
										});
#if DEBUG
                                        Utilities.WriteLog.Write(text);
#endif
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                    text = "Error while getting Credit. Details: " + ex.Message;
#if DEBUG
                                    Utilities.WriteLog.Write(text);
#endif
                                }



                            }
                            else
                            {
                                text = "Invalid Odd while Preparing Ticket. IBET Odd: " + ibetBetKindValue + " - SBOBET Odd:" + threein1betKindValue;
#if DEBUG
                                Utilities.WriteLog.Write(text);
#endif
                            }
                        }
                        else
                        { 
#if DEBUG
                            if (!flagibetAllowance)
                                Utilities.WriteLog.Write("IBET DIDN'T ALLOW");
                            if (!flagthreein1betAllowance)
                                Utilities.WriteLog.Write("3IN1 DIDN'T ALLOW");
#endif

                        }
                    }

                    else
                    {
                        text = string.Concat(new string[]
						{
							"Not Same Match - Preparing Ticket. IBET: ", 
							ibetHomeTeamName, 
							" / ", 
							ibetAwayTeamNam, 
							" - 3in1BET: ", 
							threein1betHomeTeamName, 
							" / ", 
							threein1betAwayTeamName
						});
#if DEBUG
                        Utilities.WriteLog.Write(text);
#endif
                    }

                        
				}
				catch (System.Exception ex)
				{
					text = "Error while Preparing Trade. Details: " + ex.Message;
#if DEBUG
                    WriteLog.Write(" *** " + text);
#endif 
				}
			}
			else
			{
				text = string.Concat(new string[]
				{
					"Not Same Match - Comparing. IBET: ", 
					ibetMatch.HomeTeamName, 
					" / ", 
					ibetMatch.AwayTeamName, 
					" - 3in1BET: ", 
					threein1betMatch.HomeTeamName, 
					" / ", 
					threein1betMatch.AwayTeamName
				});
			}
            transactionDTO.HomeTeamName = ibetMatch.HomeTeamName + " / " + threein1betMatch.HomeTeamName;
            transactionDTO.AwayTeamName = ibetMatch.AwayTeamName + " / " + threein1betMatch.AwayTeamName;
            transactionDTO.Odd = ibetBetKindValue + " / " + threein1betKindValue;
			transactionDTO.OddKindValue = ibetBetKindValue + " / " + threein1betKindValue;
            transactionDTO.OddValue = ibetOddValue + " / " + threein1OddValue;
			transactionDTO.Stake = ibetStake + " / " + threein1betStake;
			transactionDTO.IBETAllow = flagibetAllowance;
            transactionDTO.IBETTrade = flagIBETOK;
			transactionDTO.IBETReTrade = false;
            transactionDTO.THREEIN1Allow = flagthreein1betAllowance;
            transactionDTO.THREEIN1Trade = flag3IN1OK;
			transactionDTO.THREEIN1ReTrade = threein1ReTrade;
			transactionDTO.OddType = oddType.ToString();
			transactionDTO.Note = text;
			transactionDTO.DateTime = System.DateTime.Now;
			return transactionDTO;
		}