示例#1
0
        private List <LineDTO> ParseEvent(EventSub @event)
        {
            var random = ProxyList.PickRandom();

            try
            {
                var converter = new S888LineConverter();

                var lineTemplate = converter.CreateLine(@event, Host, Name);

                if (lineTemplate == null)
                {
                    return(new List <LineDTO>());
                }

                var eventFull = ConverterHelper.GetFullLine(@event.Event.id, random, Host);

                if (eventFull == null)
                {
                    return(new List <LineDTO>());
                }

                return(converter.GetLinesFromEvent(lineTemplate, eventFull));
            }
            catch (WebException e)
            {
                Log.Info("888sport WebException " + JsonConvert.SerializeObject(e));
                ParseEvent(@event);
            }
            catch (Exception e)
            {
                Log.Info("888sport Parse event exception " + JsonConvert.SerializeObject(e));
            }

            return(new List <LineDTO>());
        }
示例#2
0
        public List <LineDTO> GetLinesFromEvent(LineDTO template, EventFull @event)
        {
            var localLines = new List <LineDTO>();

            var simpleMap = new Dictionary <string, string>
            {
                { template.Team1, "1" },
                { template.Team2, "2" },
            };

            foreach (var offer in @event.BetOffers.Where(bo => !bo.suspended))
            {
                var copy = template.Clone();

                // Извлекаем тип игры: угловые, (желтые, красные карты), картер, и т.д.

                //if (!ConverterHelper.CheckCriterion(offer.criterion, out var period)) continue;

                foreach (var outcome in offer.outcomes)
                {
                    if (outcome.status != "OPEN")
                    {
                        continue;
                    }

                    var line = copy.Clone();


                    switch (offer.betOfferType.englishName)
                    {
                    case "Match":
                        switch (offer.criterion.englishLabel)
                        {
                        case "Full Time":
                        case "1st Half":
                        case "2nd Half":
                        case "Half Time":
                        case "Period 1":
                        case "Period 2":
                        case "Period 3":
                        case "2nd Half (3-way)":
                        case "Including Overtime":
                        case "Quarter 1":
                        case "Quarter 2":
                        case "Quarter 3":
                        case "Quarter 4":

                            line.CoeffKind = outcome.englishLabel;
                            break;

                        case "Draw No Bet":
                        case "Draw No Bet - 1st Half":
                        case "Draw No Bet - 2nd Half":
                        case "Draw No Bet - Regular Time":
                        case "Draw No Bet - Quarter 1":
                        case "Draw No Bet - Quarter 2":
                        case "Draw No Bet - Quarter 3":
                        case "Draw No Bet - Quarter 4":
                        case "Draw No Bet - Period 1":
                        case "Draw No Bet - Period 2":
                        case "Draw No Bet - Period 3":

                            line.CoeffKind = "W" + outcome.englishLabel;
                            break;

                        default:
                            continue;
                        }
                        break;

                    case "Handicap":
                    case "Asian Handicap":
                        if (offer.criterion.englishLabel == "Handicap" ||
                            offer.criterion.englishLabel == "Handicap - 1st Half" ||
                            offer.criterion.englishLabel == "Handicap - Quarter 1" ||
                            offer.criterion.englishLabel == "Handicap - Quarter 2" ||
                            offer.criterion.englishLabel == "Handicap - Quarter 3" ||
                            offer.criterion.englishLabel == "Handicap - Quarter 4" ||
                            offer.criterion.englishLabel == "Handicap - Including Overtime" ||
                            offer.criterion.englishLabel == "Handicap - Period 1" ||
                            offer.criterion.englishLabel == "Handicap - Period 2" ||
                            offer.criterion.englishLabel == "Handicap - Period 3" ||
                            offer.criterion.englishLabel == "Handicap - Regular Time")
                        {
                            line.CoeffKind = "HANDICAP" + simpleMap[outcome.englishLabel];
                        }
                        else if (Regex.IsMatch(offer.criterion.englishLabel, "Asian Handicap \\([0-9] - [0-9]\\)"))
                        {
                            line.CoeffKind = "HANDICAP" + simpleMap[outcome.englishLabel];
                        }
                        else
                        {
                            continue;
                        }
                        break;

                    case "Over/Under":
                    case "Asian Over/Under":
                        switch (offer.criterion.englishLabel)
                        {
                        case "Total Points - 1st Half":
                        case "Total Points - Quarter 1":
                        case "Total Points - Quarter 2":
                        case "Total Points - Quarter 3":
                        case "Total Points - Quarter 4":
                        case "Total Points - Including Overtime":
                        case "Total Goals":
                        case "Total Goals - 1st Half":
                        case "Total Goals - Period 1":
                        case "Total Goals - Period 2":
                        case "Total Goals - Period 3":
                        case "Total Goals - Regular Time":
                            line.CoeffKind = "TOTAL" + outcome.englishLabel;
                            break;

                        case "Asian Total":
                        case "Asian Total - 1st Half":
                            line.CoeffKind = "TOTAL" + outcome.englishLabel;
                            break;

                        case "Total Goals by Away Team":
                        case "Total Goals by Away Team - 1st Half":
                        case "Total Goals by Away Team - 2nd Half":
                        case "Total Goals by Away Team - Period 1":
                        case "Total Goals by Away Team - Period 2":
                        case "Total Goals by Away Team - Period 3":
                        case "Total Goals by Away Team - Regular Time":
                            line.CoeffKind = "ITOTAL" + outcome.englishLabel + "2";
                            break;

                        case "Total Goals by Home Team":
                        case "Total Goals by Home Team - 1st Half":
                        case "Total Goals by Home Team - 2nd Half":
                        case "Total Goals by Home Team - Period 1":
                        case "Total Goals by Home Team - Period 2":
                        case "Total Goals by Home Team - Period 3":
                        case "Total Goals by Home Team - Regular Time":
                            line.CoeffKind = "ITOTAL" + outcome.englishLabel + "1";
                            break;

                        default:
                            continue;
                        }
                        break;

                    case "Double Chance":
                        switch (offer.criterion.englishLabel)
                        {
                        case "Double Chance":
                        case "Double Chance - Period 1":
                        case "Double Chance - Period 2":
                        case "Double Chance - Period 3":
                            line.CoeffKind = outcome.englishLabel;
                            break;

                        default:
                            continue;
                        }
                        break;

                    case "Odd/Even":
                        switch (offer.criterion.englishLabel)
                        {
                        case "Total Goals Odd/Even":
                        case "Total Goals Odd/Even - 1st Half":
                        case "Total Goals Odd/Even - 2nd Half":
                        case "Total Points Odd/Even - Including Overtime":
                            line.CoeffKind = outcome.englishLabel;
                            break;

                        default:
                            continue;
                        }
                        break;

                    default:
                        continue;
                    }

                    //Параметр
                    if (outcome.line != null)
                    {
                        line.CoeffParam = Math.Round(outcome.line.Value / 1000m, 2);
                    }

                    line.CoeffType = ConverterHelper.GetPeriod(offer.criterion.englishLabel);

                    line.CoeffValue = Math.Round(outcome.odds / 1000m, 2);
                    line.LineData   = outcome.odds + ";" + outcome.id;
                    line.LineObject = "| Outcome | " + JsonConvert.SerializeObject(outcome) + " | Offer | " + JsonConvert.SerializeObject(offer);
                    line.UpdateName();
                    localLines.Add(line);
                }
            }

            return(localLines);
        }