Exemplo n.º 1
0
 public HltvParserResultSaver(HltvParserResult result, Action callback)
 {
     Result = result;
     Context = new BettyContextCsgo();
     Callback = callback;
 }
Exemplo n.º 2
0
        private void InitCsgoInfo()
        {
            using (BettyContextCsgo context = new BettyContextCsgo())
            {
                List<CsgoTeam> teams = context.csgo_team.AsEnumerable().ToList();
                List<CsgoPlayer> players = context.csgo_player.AsEnumerable().ToList();
                List<CsgoMatch> matches = context.csgo_match.AsEnumerable().ToList();
                List<CsgoBets> bets = context.csgo_bets.AsEnumerable().ToList();

                CsgoInfo = new CsgoInfo(teams, players, matches, bets);

                new CsgoLadder(CsgoInfo).CalculateTeams();

                CsgoInfo.Teams = context.csgo_team.AsEnumerable().ToList();
            }
        }
Exemplo n.º 3
0
        private void CsgoBetsTrueBtnClick(object sender, MouseButtonEventArgs e)
        {
            using (BettyContextCsgo context = new BettyContextCsgo())
            {
                int id = Convert.ToInt32((CsgoBetsList.SelectedItem as ListBoxItem)
                    .Content.ToString().Split(new char[] { '.' })[0]);

                context.csgo_bets.First(b => b.Id == id).IsTrue = true;

                context.SaveChanges();

                CsgoInfo.Bets = context.csgo_bets.AsEnumerable().ToList();
            }

            FillCsgoBetsList();
            CsgoBetResultLbl.Content = "";
        }
Exemplo n.º 4
0
        private void CsgoParserParseBtnClick(object sender, MouseButtonEventArgs e)
        {
            ChangeLabelVisibility(CsgoParserParseBtn, Visibility.Hidden);
            ChangeCheckBoxVisiblity(TeamsCheckBox, Visibility.Hidden);
            ChangeCheckBoxVisiblity(TeamsFullCheckBox, Visibility.Hidden);
            ChangeCheckBoxVisiblity(PlayersCheckBox, Visibility.Hidden);

            HltvParser parser = new HltvParser();

            parser.Callback = () =>
            {
                HltvParserResultSaver saver = new HltvParserResultSaver(parser.Result,
                    () =>
                    {
                        ChangeLabelVisibility(CsgoParserParseBtn, Visibility.Visible);
                        ChangeCheckBoxVisiblity(TeamsCheckBox, Visibility.Visible);
                        ChangeCheckBoxVisiblity(TeamsFullCheckBox, Visibility.Visible);
                        ChangeCheckBoxVisiblity(PlayersCheckBox, Visibility.Visible);

                        CsgoInit();
                    });
                saver.ParserOutput += new ParserOutputHandler(CsgoParserConsoleOutput);
                Thread saverThread = new Thread(saver.Save);
                saverThread.SetApartmentState(ApartmentState.STA);
                saverThread.Start();
            };

            parser.ParserOutput += new ParserOutputHandler(CsgoParserConsoleOutput);

            using (BettyContextCsgo context = new BettyContextCsgo())
            {
                if (context.csgo_parser_details.Count() != 0)
                {
                    parser.LastUrl = context.csgo_parser_details.AsEnumerable().First().Url;
                }
                else
                {
                    parser.LastUrl = null;
                }

                if ((bool)TeamsCheckBox.IsChecked && !(bool)TeamsFullCheckBox.IsChecked)
                {
                    List<string> oldTeamUrls = new List<string>();

                    foreach (CsgoTeam team in context.csgo_team)
                    {
                        oldTeamUrls.Add(team.Url);
                    }

                    parser.OldTeamUrls = oldTeamUrls;
                }
            }

            parser.DoFullTeamsParsing = (bool)TeamsFullCheckBox.IsChecked;
            parser.DoTeamsParsing = (bool)TeamsCheckBox.IsChecked;
            parser.DoPlayersParsing = (bool)PlayersCheckBox.IsChecked;

            Thread t = new Thread(parser.Start);
            t.Start();
        }
Exemplo n.º 5
0
        private void CsgoBetsSaveBtnClick(object sender, MouseButtonEventArgs e)
        {
            using (BettyContextCsgo context = new BettyContextCsgo())
            {
                context.csgo_bets.Add(new CsgoBets
                    {
                        Date = DateTime.Now,
                        FirstTeamId = LastResult.FirstTeamId,
                        SecondTeamId = LastResult.SecondTeamId,
                        Chance = LastResult.FirstTeamChance,
                        IsTrue = false,
                        WinnerTeamId = LastResult.FirstTeamChance >= 50f
                            ? LastResult.FirstTeamId
                            : LastResult.SecondTeamId
                    });
                context.SaveChanges();

                List<CsgoBets> bets = context.csgo_bets.AsEnumerable().ToList();
                CsgoInfo.Bets = bets;
            }

            FillCsgoBetsList();
            CsgoBetsSaveBtn.Visibility = Visibility.Hidden;
        }