Ejemplo n.º 1
0
        private bool IsVirtual(Ticket ticket)
        {
            if (ticket.TipItems.Count <= 0)
            {
                return(false);
            }

            if (ticket.TipItems.ToSyncList().ElementAt(0).Odd == null)
            {
                return(false);
            }

            SportRadar.DAL.OldLineObjects.eServerSourceType type = ticket.TipItems.ToSyncList().ElementAt(0).Odd.BetDomain.Match.SourceType;

            return(type == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVhc || type == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVfl);
        }
Ejemplo n.º 2
0
        public TicketWS CreateNewTicketWS(Ticket newticket)
        {
            var rTicketWs = new TicketWS();

            List <ITipItemVw> ti = newticket.TipItems.ToSyncList().Where(x => x.IsChecked).ToList();


            try
            {
                PasswordGenerator PWGen = new PasswordGenerator();
                //if (string.IsNullOrEmpty(rTicketWs.TicketNbr))

                //try
                //{
                //    long number, creditnumber, transactionnumber;
                //    creditnumber = WsdlRepository.GetBusinessProps(StationRepository.StationNumber, out number, out transactionnumber);
                //    BusinessPropsHelper.Initialize(StationRepository.StationNumber, new BusinessProps(number, creditnumber, transactionnumber));
                //}
                //catch (Exception excp)
                //{
                //    Log.Error(ExcpHelper.FormatException(excp, "Initialize(sStationNumber = '{0}', {1}) ERROR", StationRepository.StationNumber, ""));

                //}
                rTicketWs.ticketNbr = BusinessPropsHelper.GenerateNextTicketNumber();


                //rTicketWs.TicketNbr = StationSettings.GetSettings.StationNumber+DateTime.Now.ToString("yy")+StationSettings.GetSettings.NewTicketNumber.ToString("0000000");
                //rTicketWs.TicketNbr = PWGen.Generate(14, 14, true);
                rTicketWs.checkSum = PWGen.Generate(4, 4, true);


                rTicketWs.paidBy        = StationTyp;
                rTicketWs.paidTime      = DateTime.Now;
                rTicketWs.paid          = false;
                rTicketWs.acceptedBy    = StationTyp;
                rTicketWs.acceptedTime  = DateTime.Now;
                rTicketWs.stake         = newticket.Stake;
                rTicketWs.cancelledTime = DateTimeUtils.DATETIMENULL;
                rTicketWs.enablePayTime = DateTime.MaxValue;
                rTicketWs.wonExpireTime = DateTimeUtils.DATETIMENULL;
                rTicketWs.userId        = (int)ChangeTracker.CurrentUser.AccountId;

                //string bonusX = newticket.BonusValue.ToString(CultureInfo.InvariantCulture);
                //string manFeeX = newticket.ManipulationFeeValue.ToString(CultureInfo.InvariantCulture);

                //string a = Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator;

                //if (bonusX.IndexOf(a) != -1)
                //{
                //    bonusX = bonusX.Substring(0, bonusX.IndexOf(a) + 3);
                //    newticket.BonusValue = Decimal.Parse(bonusX, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture);
                //}
                //if (manFeeX.IndexOf(a) != -1)
                //{
                //    manFeeX = manFeeX.Substring(0, manFeeX.IndexOf(a) + 3);
                //    newticket.ManipulationFeeValue = Decimal.Parse(manFeeX, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture);
                //}

                newticket.BonusValue           = ChangeTracker.TruncateDecimal(newticket.BonusValue);
                newticket.ManipulationFeeValue = ChangeTracker.TruncateDecimal(newticket.ManipulationFeeValue);

                rTicketWs.manipulationFeeValue = ChangeTracker.TruncateDecimal(newticket.ManipulationFeeValue);// newticket.ManipulationFeeValue;
                rTicketWs.superBonusValue      = ChangeTracker.TruncateDecimal(newticket.BonusValue);

                BetWS bets = new BetWS();
                bets.systemX = bets.systemY = newticket.NumberOfBets;

                switch (newticket.TicketState)
                {
                case TicketStates.Multy:

                    var dup             = newticket.TipItems.ToSyncList().GroupBy(x => new { x.Match.MatchId }).Select(group => new { Name = group.Key, Count = group.Count() }).OrderByDescending(x => x.Count);
                    int duplicatesCount = 0;
                    foreach (var x in dup)
                    {
                        if (x.Count > 1)
                        {
                            duplicatesCount += x.Count;
                        }
                    }
                    int baseSize = newticket.NumberOfBets - duplicatesCount;
                    if (duplicatesCount > 0 && baseSize > 0)     //means there are ways
                    {
                        bets.systemX = bets.systemY = baseSize;
                    }

                    bets.betType = Bet.BET_TYPE_COMBI;
                    break;

                case TicketStates.System:
                    bets.betType = Bet.BET_TYPE_SYSTEM;
                    bets.systemX = newticket.SystemX;
                    bets.systemY = newticket.SystemY;
                    break;

                default:
                    bets.betType = Bet.BET_TYPE_SINGLE;
                    break;
                }
                bets.maxOdd = newticket.TotalOddDisplay;
                //bets.MaxWin = rTicketWs.Stake * bets.MaxOdd;
                bets.maxWin      = newticket.CurrentTicketPossibleWin;
                bets.stake       = rTicketWs.stake;
                bets.isMaxOddBet = newticket.IsMaxOddBet;

                rTicketWs.bets            = new BetWS[] { bets };
                rTicketWs.superBonus      = StationRepository.GetBonusValueForBets(newticket) / 100 + 1;
                rTicketWs.manipulationFee = StationRepository.GetManipulationFeePercentage(newticket);

                Dictionary <long, int> matchIDCountDictionary = new Dictionary <long, int>();

                foreach (TipItemVw t in ti)
                {
                    long iMatchCode = t.Match.MatchId;

                    if (matchIDCountDictionary.ContainsKey(iMatchCode))
                    {
                        matchIDCountDictionary[iMatchCode]++;
                    }
                    else
                    {
                        matchIDCountDictionary.Add(iMatchCode, 1);
                    }
                }

                int liveBetTipCount  = 0;
                int sportBetTipCount = 0;
                var tips2BetMulti    = new ObservableCollection <TipWS>();
                var bankTips         = new ObservableCollection <TipWS>();
                foreach (TipItemVw t in ti)
                {
                    if (t.Odd != null)
                    {
                        if (t.Odd.IsLiveBet.Value)
                        {
                            liveBetTipCount++;
                        }
                        else
                        {
                            sportBetTipCount++;
                        }
                    }
                    TipWS tip = new TipWS();
                    tip.bank = t.IsBank;

                    if (t.Odd != null)
                    {
                        tip.odd      = t.Value;
                        tip.svrOddID = t.Odd.OutcomeId; //TODO: Wurde auf ServerOddID umgewandelt *g* 05.03.2008 by GMU

                        SportRadar.DAL.OldLineObjects.eServerSourceType sType = t.Odd.BetDomain.Match.SourceType;
                        if (sType == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrLive || sType == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVfl || sType == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVhc)
                        {
                            tip.svrOddID = tip.svrOddID * -1;
                        }

                        tip.betDomainNumber = t.Odd.BetDomain.BetDomainNumber.Value;
                        tip.matchCode       = t.Odd.BetDomain.Match.Code.Value;
                        tip.oddTag          = t.Odd.OddTag.Value;
                    }

                    if (tip.bank || matchIDCountDictionary[t.Match.MatchId] != 1)
                    {
                        tip.bankGroupID = t.Match.MatchId;
                        tip.bank        = matchIDCountDictionary[t.Match.MatchId] == 1; //Mehrwege haben kein Bank-Flag
                        if (newticket.TicketState == TicketStates.Multy && matchIDCountDictionary[t.Match.MatchId] != 1)
                        {
                            bets.betType = Bet.BET_TYPE_COMBIPATH;
                        }
                        else if (newticket.TicketState == TicketStates.System && matchIDCountDictionary[t.Match.MatchId] != 1)
                        {
                            bets.betType = Bet.BET_TYPE_SYSTEMPATH;
                        }
                        tips2BetMulti.Add(tip); //banken von system mit banken
                    }
                    else
                    {
                        bankTips.Add(tip); //system, kombi, einzeln
                    }
                }
                bets.tips2BetMulti = tips2BetMulti.ToArray();
                bets.bankTips      = bankTips.ToArray();

                if (newticket.TipItems[0].Match.MatchView.LineObject.SourceType == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVfl)
                {
                    rTicketWs.ticketTyp = Ticket.TICKET_TYP_VFL;
                }
                else if (newticket.TipItems[0].Match.MatchView.LineObject.SourceType == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVhc)
                {
                    rTicketWs.ticketTyp = Ticket.TICKET_TYP_VHC;
                }
                else if (liveBetTipCount > 0 && sportBetTipCount == 0)
                {
                    rTicketWs.ticketTyp = Ticket.TICKET_TYP_LIVEBET;
                }
                else if (liveBetTipCount == 0 && sportBetTipCount > 0)
                {
                    rTicketWs.ticketTyp = Ticket.TICKET_TYP_SPORTBET;
                }
                else
                {
                    rTicketWs.ticketTyp = Ticket.TICKET_TYP_BOTH;
                }

                int rowCount = 1;
                int[,] temp;
                if (newticket.TicketState == TicketStates.System)
                {
                    OddUtilities.SetPermutations(out temp, bets.systemY, bets.systemX);
                    rowCount = temp.GetLength(0);
                }
                Dictionary <int, int> tempMatchCodeCountDict = new Dictionary <int, int>();
                foreach (TipWS t in bets.tips2BetMulti)
                {
                    if (tempMatchCodeCountDict.ContainsKey(t.matchCode))
                    {
                        tempMatchCodeCountDict[t.matchCode]++;
                    }
                    else
                    {
                        tempMatchCodeCountDict.Add(t.matchCode, 1);
                    }
                }
                foreach (int curCount in tempMatchCodeCountDict.Values)
                {
                    rowCount *= curCount;
                }
                bets.rows = rowCount;
                return(rTicketWs);
            }
            catch (Exception ex)
            {
                WriteRemoteError2Log(ex.Message, 1, ex.GetType().ToString(), NbtLogSr.MSG_TERMINAL);
                return(null);
            }
        }
Ejemplo n.º 3
0
        public decimal CalculateFactor(Ticket ticket)
        {
            //return 1000000;
            //should not work for virtual sports
            if (ticket.TipItems.Count > 0)
            {
                SportRadar.DAL.OldLineObjects.eServerSourceType type = ticket.TipItems.ToSyncList().ElementAt(0).Odd.BetDomain.Match.SourceType;
                if (type == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVfl || type == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVhc)
                {
                    return(Decimal.MaxValue);
                }
            }

            string localDelimeter  = "*";
            string serverDelimeter = "|";

            decimal matchConfidenceFactor  = 0;
            decimal maxBetLiability        = 0;
            decimal marketConfidenceFactor = 0;

            decimal userConfidenceFactor = 1;

            if (ticket.User != null)
            {
                userConfidenceFactor = ticket.User.UserConfidenceRaiting;
            }

            foreach (ITipItemVw tipItemVw in ticket.TipItems.ToSyncList())
            {
                string matchId         = tipItemVw.Match.MatchId.ToString();
                string oddTag          = tipItemVw.Odd.OddTag.Value;
                string tournamentId    = tipItemVw.Match.MatchView == null ? "" : tipItemVw.Match.MatchView.TournamentView.LineObject.SvrGroupId.ToString();
                string btrTournamentId = "";
                if (tipItemVw.IsLiveBet && tipItemVw.Match.MatchView != null)
                {
                    var btrid = (SportRadarId.FromLongId(tipItemVw.Match.MatchView.TournamentView.LineObject.Id).ObjectId - 2) >> 6;

                    btrTournamentId = btrid.ToString();
                }

                string sportId = tipItemVw.Match.MatchView == null ? "" : tipItemVw.Match.MatchView.SportView.LineObject.SvrGroupId.ToString();
                if (tipItemVw.IsLiveBet && tipItemVw.Match.MatchView != null)
                {
                    var btrid = (SportRadarId.FromLongId(tipItemVw.Match.MatchView.SportView.LineObject.Id).ObjectId - 3) >> 6;
                    var group = MyLineSr.GetAllGroups().Where(x => x.GroupSport != null).Where(x => x.SvrGroupId > 0).FirstOrDefault(x => x.GroupSport.BtrSportId == btrid);
                    if (@group != null)
                    {
                        sportId = @group.SvrGroupId.ToString();
                    }
                }
                LiabilityLn liab = MyLineSr.GetAllLiabilities(matchId + localDelimeter + LineSr.MATCH_FACTOR);
                if (liab != null)
                {
                    decimal factor = liab.factor;

                    if (factor < matchConfidenceFactor || matchConfidenceFactor == 0)
                    {
                        matchConfidenceFactor = factor;
                    }
                }
                else
                {
                    if (1 < matchConfidenceFactor)
                    {
                        matchConfidenceFactor = 1;
                    }
                }

                liab = MyLineSr.GetAllLiabilities(tournamentId + localDelimeter + LineSr.TOURN_CONF_RATING);
                if (liab != null)
                {
                    decimal factor = liab.factor;

                    LiabilityLn franchisorRating = MyLineSr.GetAllLiabilities(factor.ToString() + localDelimeter + LineSr.CONF_RATING_VALUES);

                    if (franchisorRating != null)
                    {
                        decimal franfactor = tipItemVw.IsLiveBet ? franchisorRating.livefactor * franchisorRating.factor : franchisorRating.factor;
                        if (franfactor < maxBetLiability || maxBetLiability == 0)
                        {
                            maxBetLiability = franfactor;
                        }
                    }
                }
                else
                {
                    liab = MyLineSr.GetAllLiabilities(btrTournamentId + localDelimeter + LineSr.TOURN_CONF_RATING);
                    if (liab != null)
                    {
                        decimal factor = liab.factor;

                        LiabilityLn franchisorRating = MyLineSr.GetAllLiabilities(factor.ToString() + localDelimeter + LineSr.CONF_RATING_VALUES);

                        if (franchisorRating != null)
                        {
                            decimal franfactor = tipItemVw.IsLiveBet ? franchisorRating.livefactor * franchisorRating.factor : franchisorRating.factor;
                            if (franfactor < maxBetLiability || maxBetLiability == 0)
                            {
                                maxBetLiability = franfactor;
                            }
                        }
                    }
                    else
                    {
                        LiabilityLn franchisorRating = MyLineSr.GetAllLiabilities("3" + localDelimeter + LineSr.CONF_RATING_VALUES); //default value if specific not found
                        if (franchisorRating != null)
                        {
                            decimal franfactor = tipItemVw.IsLiveBet ? franchisorRating.livefactor * franchisorRating.factor : franchisorRating.factor;
                            if (franfactor < maxBetLiability || maxBetLiability == 0)
                            {
                                maxBetLiability = franfactor;
                            }
                        }
                    }
                }

                liab = MyLineSr.GetAllLiabilities("MATCH" + serverDelimeter + matchId + serverDelimeter + oddTag + localDelimeter + LineSr.LIMIT_FACTORS);
                if (liab == null)
                {
                    liab = MyLineSr.GetAllLiabilities("TOURNAMENT" + serverDelimeter + tournamentId + serverDelimeter + oddTag + localDelimeter + LineSr.LIMIT_FACTORS);
                    if (liab == null)
                    {
                        liab = MyLineSr.GetAllLiabilities("SPORT" + serverDelimeter + sportId + serverDelimeter + oddTag + localDelimeter + LineSr.LIMIT_FACTORS);
                        if (liab == null)
                        {
                            liab = MyLineSr.GetAllLiabilities("SPORT" + serverDelimeter + sportId + serverDelimeter + "DEFAULT" + localDelimeter + LineSr.LIMIT_FACTORS);
                            if (liab != null)
                            {
                                decimal factor = liab.factor;
                                if ((factor < marketConfidenceFactor || marketConfidenceFactor == 0))
                                {
                                    marketConfidenceFactor = factor;
                                }
                            }
                            else
                            {
                                if (1 < marketConfidenceFactor)
                                {
                                    marketConfidenceFactor = 1;
                                }
                            }
                        }
                        else
                        {
                            decimal factor = liab.factor;
                            if (factor < marketConfidenceFactor || marketConfidenceFactor == 0)
                            {
                                marketConfidenceFactor = factor;
                            }
                        }
                    }
                    else
                    {
                        decimal factor = liab.factor;

                        if (factor < marketConfidenceFactor || marketConfidenceFactor == 0)
                        {
                            marketConfidenceFactor = factor;
                        }
                    }
                }
                else
                {
                    decimal factor = liab.factor;

                    if (factor < marketConfidenceFactor || marketConfidenceFactor == 0)
                    {
                        marketConfidenceFactor = factor;
                    }
                }
            }

            if (matchConfidenceFactor == 0)
            {
                matchConfidenceFactor = 1;
            }

            if (marketConfidenceFactor == 0)
            {
                marketConfidenceFactor = 1;
            }


            return(ticket.TotalOdd == 1 ? 0 : matchConfidenceFactor *maxBetLiability *marketConfidenceFactor *userConfidenceFactor / (ticket.TotalOddDisplay - 1));
        }