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; }
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; }