public List <Bet> Parse()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            Bets.Clear();
            if (_thUpdate == null)
            {
                _thUpdate = new Thread(Update);
                _thUpdate.IsBackground = true;
                _thUpdate.Start();
                Logger.AddLog($"Запустили Updater. Ушло времени {sw.ElapsedMilliseconds} мс", Logger.LogTarget.Marafon, Logger.LogLevel.Info);
            }

            List <Bet> rezult = new List <Bet>();

            foreach (KeyValuePair <string, Bet> key in _bets)
            {
                if (key.Value == null)
                {
                    continue;
                }
                var deltaTime = DateTime.Now - key.Value.Created;
                if (deltaTime.TotalMilliseconds < MainConfigurate.Configurate.MarafonMaxTime)
                {
                    rezult.Add(key.Value);
                }
            }
            sw.Stop();
            Logger.AddLog("На парсинг времени затраченно: " + sw.ElapsedMilliseconds + ". Собранно вилок: " + rezult.Count, Logger.LogTarget.Marafon);
            Thread.Sleep(1000);

            return(rezult);
        }
Exemple #2
0
 public void Populate(BetShortInfoModel[] items)
 {
     Bets.Clear();
     foreach (var item in items)
     {
         Bets.Add(item);
     }
 }
Exemple #3
0
        public void Update()
        {
            IEnumerable <BetDisplayModel> bets = facade.GetAll();

            Bets.Clear();
            foreach (BetDisplayModel bet in bets)
            {
                Bets.Add(bet);
            }
        }
 public void SetStrategy(BaseStrategy Strategy)
 {
     if (Strategy is DoormatBot.Strategies.Labouchere)
     {
         this.Strategy = Strategy as DoormatBot.Strategies.Labouchere;
         Bets.Clear();
         if (this.Strategy != null && this.Strategy.BetList != null)
         {
             foreach (decimal x in this.Strategy?.BetList)
             {
                 Bets.Add(new LabBet {
                     Amount = x
                 });
             }
         }
         if (Bets.Count == 0)
         {
             Bets.Add(new LabBet {
                 Amount = 0.00000001m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000002m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000003m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000004m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000005m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000006m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000005m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000004m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000003m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000002m
             });
             Bets.Add(new LabBet {
                 Amount = 0.00000001m
             });
         }
         OnPropertyChanged(nameof(Bets));
         StartControl.DataContext = Strategy;
     }
 }
        public List <Bet> Parse()
        {
            Bets.Clear();
            _req.CharacterSet = Encoding.UTF8;
            _req.UserAgent    = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36";

            //_req.Proxy=ProxyClient.Parse(ProxyType.Http,"127.0.0.1:8888");



            Stopwatch sw = new Stopwatch();

            sw.Start();

            if (_fonbetClient == null)
            {
                _fonbetClient = new FonbetClient(_url);
                _fonbetClient.Start();
            }


            var line = _fonbetClient.GetLine();



            List <Bet> rez      = new List <Bet>();
            var        lastTime = (DateTime.Now - line.LastUpdate).TotalMilliseconds;

            if (lastTime > MainConfigurate.Configurate.FonbetMaxTime)
            {
                Logger.AddLog($"Последний раз обновляли линию {lastTime} мс назад. Это долго", Logger.LogTarget.Fonbet, Logger.LogLevel.Warn);
            }
            else
            {
                foreach (KeyValuePair <int, Event> @event in line.Events)
                {
                    var ev = @event.Value;

                    if (ev.IsBlock)
                    {
                        continue;
                    }
                    if (ev.Level != 1)
                    {
                        continue;
                    }

                    string team1     = ev.Team1;
                    string team2     = ev.Team2;
                    string sportName = line.Sports[ev.SportId].Name;

                    /*
                     *
                     * 974,1809,1812,1815       \   Итб1
                     * 976,1810,1813,1816       /   Итм1
                     *
                     * 978,1854,1873,1880       \   Итб2
                     * 980,1871,1874,1881       /   Итм2
                     *
                     * */


                    Bet bet = new Bet
                    {
                        URL       = "live/?locale=ru#" + ev.Id,
                        Bookmaker = BookmakerType.Fonbet,
                        Team1     = team1,
                        Team2     = team2
                    };

                    if (ev.Team1Id == -1)
                    {
                        continue;
                    }
                    if (ev.Team2Id == -1)
                    {
                        continue;
                    }
                    bet.Team1Id = ev.Team1Id;
                    bet.Team2Id = ev.Team2Id;


                    IBTBet ibt1 = new IBTBet();
                    IBTBet ibt2 = new IBTBet();
                    ibt1.TeamName = bet.Team1;
                    ibt2.TeamName = bet.Team2;

                    bet.SportType = SportTypeHelper.Parse(sportName);

                    bet.Groupe = sportName.Split('.')[0].Trim();
                    bet.Name   = team1 + " - " + team2;
                    bet.Site   = "F";

                    bet = SetEvents(bet, ev);
                    if (bet == null)
                    {
                        continue;
                    }


                    if (ev.Factors.ContainsKey(974))
                    {
                        if (!ev.Factors[974].IsBlocked)
                        {
                            ibt1.Tmax  = ev.Factors[974].V;
                            ibt1.Tmaxo = ev.Factors[974].E + "f974,974," + ev.Id;
                        }
                    }
                    if (ev.Factors.ContainsKey(976))
                    {
                        if (!ev.Factors[976].IsBlocked)
                        {
                            ibt1.Tmin  = ev.Factors[976].V;
                            ibt1.Tmino = ev.Factors[976].E + "f976,976," + ev.Id;
                            ibt1.Coeff = SetValue(ev.Factors[976].Pt);
                        }
                    }

                    if (ev.Factors.ContainsKey(978))
                    {
                        if (!ev.Factors[978].IsBlocked)
                        {
                            ibt2.Tmax  = ev.Factors[978].V;
                            ibt2.Tmaxo = ev.Factors[978].E + "f978,978," + ev.Id;
                            ibt2.Coeff = SetValue(ev.Factors[978].Pt);
                        }
                    }
                    if (ev.Factors.ContainsKey(980))
                    {
                        if (!ev.Factors[980].IsBlocked)
                        {
                            ibt2.Tmin  = ev.Factors[980].V;
                            ibt2.Tmino = ev.Factors[980].E + "f980,980," + ev.Id;
                        }
                    }


                    if (ibt1.Isvalid())
                    {
                        bet.IBTList.Add(ibt1);
                    }
                    if (ibt2.Isvalid())
                    {
                        bet.IBTList.Add(ibt2);
                    }

                    //Достаем список доп. таймов к матчу
                    List <Event> times = line.GetAdditionTime(ev.Id);
                    foreach (Event time in times)
                    {
                        Bet betmini = bet.ShortCopy();
                        betmini = SetEvents(betmini, time, false);
                        if (betmini == null)
                        {
                            continue;
                        }

                        if (betmini.Games.Count != 0)
                        {
                            bet.Games.AddRange(betmini.Games);
                            betmini.Games.Clear();
                        }

                        Regex  reg      = new Regex("(.-)");
                        Match  match    = reg.Match(time.Name);
                        string partData = match.Value.Split('-').First();
                        if (time.Name.Contains("пол"))
                        {
                            partData = "1" + partData;
                        }

                        SportTimePart part = SportTimePartHelper.Parse(partData);
                        if (part == SportTimePart.Nan)
                        {
                            continue;
                        }
                        bet.Parts.Add(part, betmini);
                    }

                    rez.Add(bet);
                }
            }


            sw.Stop();
            if (sw.ElapsedMilliseconds < 1000)
            {
                Thread.Sleep(1000 - (int)sw.ElapsedMilliseconds);
            }
            Logger.AddLog($"Fonbet parse: {sw.Elapsed} мс. ставок: {rez.Count}; всего ставок: {line.Events.Count}", Logger.LogTarget.Fonbet);
            return(rez);
        }