private void UpdateNotConnected(BkGame bkGame) { var existBkGame = _freeBkGameList.Get(eg => eg.BkGame.EventName == bkGame.EventName && bkGame.Bookmaker == eg.BkGame.Bookmaker); var existsOtherBkGames = GamesComparer.FindBkGames(bkGame, _freeBkGameList.Get()) .Where(fg => fg.BkGame.Bookmaker != bkGame.Bookmaker) .ToArray(); if (existsOtherBkGames.Any()) { var game = new Game(bkGame.Group); game.AddBkGame(bkGame); foreach (var existsOtherBkGame in existsOtherBkGames) { game.AddBkGame(existsOtherBkGame); } _gameList.Add(game); var ids = GamesComparer .FindBkGames(bkGame, _freeBkGameList.Get()) .Select(g => g.Id); _freeBkGameList.Remove(decorator => ids.Contains(decorator.Id)); } else if (existBkGame == null) { _freeBkGameList.Add(new BkGameDecorator(bkGame)); } else { existBkGame.Update(bkGame); } }
public void Update(BkGame newData) { BkGame.PartsScore = newData.PartsScore; BkGame.SecondsPassed = newData.SecondsPassed; BkGame.Total = newData.Total; BkGame.TotalKef = newData.TotalKef; BkGame.Hc = newData.Hc; BkGame.HcKef = newData.HcKef; UpdateDate = DateTime.UtcNow; }
private static bool IsSameTeams(BkGame existsBkGame, BkGame newBkGame) { var dice = existsBkGame.EventName .DiceCoefficient(newBkGame.EventName); int leven = existsBkGame.EventName .LevenshteinDistance(newBkGame.EventName); return(dice > 0.6 && leven < 25); }
public static IEnumerable <BkGameDecorator> FindBkGames(BkGame bkGame, IEnumerable <BkGameDecorator> src, Game game = null) { return(src.Where(existsGame => { var existsBkGame = existsGame.BkGame; return bkGame.EventName == existsBkGame.EventName || IsSameStats(existsGame.BkGame, bkGame, game); })); }
private static bool IsInsidePeriod(Game game, BkGame bksGame, BkGame existsBkGame) { if (game == null) { return(existsBkGame.SecondsPassed - 50 <= bksGame.SecondsPassed && existsBkGame.SecondsPassed + 50 >= bksGame.SecondsPassed); } return(game.SecondsMin <= bksGame.SecondsPassed && game.SecondsMax >= bksGame.SecondsPassed); }
private static bool IsSameStats(BkGame existsBkGame, BkGame bkGame, Game game) { if (bkGame.SecondsPassed < 100 || bkGame.PartsScore.Count() == 1 && bkGame.PartsScore.First().Equals("0:0")) { return(false); } return(existsBkGame.Group.Equals(bkGame.Group, StringComparison.CurrentCultureIgnoreCase) && IsPartsEqual(existsBkGame, bkGame) && IsInsidePeriod(game, bkGame, existsBkGame)); }
public void UpdateBkGame(BkGame bkGame) { var foundGame = BkGames.FirstOrDefault(bg => bg.BkGame.Bookmaker == bkGame.Bookmaker); if (foundGame == null) { AddBkGame(bkGame); } else { Update(foundGame, bkGame); } }
private static bool IsPartsEqual(BkGame existsBkGame, BkGame newBkGame) { var existsGameParts = existsBkGame.PartsScore.ToList(); var newGameParts = newBkGame.PartsScore.ToList(); var count = newGameParts.Count; if (count != existsGameParts.Count) { return(false); } for (int i = 0; i < count; i++) { var existsPart = existsGameParts[i]; var newPart = newGameParts[i]; if (!newPart.Equals(existsPart, StringComparison.CurrentCultureIgnoreCase)) { if (i == count - 1) { try { var existsSplit = existsPart.Split(':'); var newSplit = newPart.Split(':'); var existsOne = int.Parse(existsSplit[0]); var existsTwo = int.Parse(existsSplit[1]); var newOne = int.Parse(newSplit[0]); var newTwo = int.Parse(newSplit[1]); return(existsOne - 5 <= newOne && existsOne + 5 >= newOne && existsTwo - 5 <= newTwo && existsTwo + 5 >= newTwo); } catch (Exception ex) { throw; } } return(false); } } return(true); }
public BkGameDecorator(BkGame bkGame) { BkGame = bkGame; UpdateDate = DateTime.UtcNow; }
private void Update(BkGameDecorator bkGame, BkGame newData) { bkGame.Update(newData); SecondsMin = bkGame.BkGame.SecondsPassed - 50; SecondsMax = bkGame.BkGame.SecondsPassed + 50; }
public void AddBkGame(BkGame bkGame) { var gameDec = new BkGameDecorator(bkGame); BkGames.Add(gameDec); }
public bool IsSameEvent(BkGame bkGame) { return(GamesComparer .FindBkGames(bkGame, BkGames, this) .Any()); }
public static IEnumerable <BkGameDecorator> CheckGamesStats(BkGame bkGame, IEnumerable <BkGameDecorator> src, Game game) { return(src.Where(existsGame => IsSameStats(existsGame.BkGame, bkGame, game))); }