コード例 #1
0
        void input_Completed(object sender, PopUpEventArgs <string, PopUpResult> e)
        {
            int  number;
            bool parsed = int.TryParse(e.Result, out number);

            if (e.Result == null)
            {
                MessageBox.Show(AppResources.JerseyMustBeANumber, _messageBoxTitle, MessageBoxButton.OK);
            }
            else if (e.Result.Length > 3)
            {
                MessageBox.Show(AppResources.JerseyMustBeLessThan3Characters, _messageBoxTitle, MessageBoxButton.OK);
            }
            else if (parsed == false)
            {
                MessageBox.Show(AppResources.JerseyMustBeANumber, _messageBoxTitle, MessageBoxButton.OK);
            }
            else
            {
                TeamRoster teamRoster = new TeamRoster();

                teamRoster.TeamID        = App.gPromptForJerseyTeamID;
                teamRoster.PlayerID      = App.gPromptForJerseyPlayerID;
                teamRoster.UniformNumber = e.Result.ToString();
                teamRoster.Active        = "Y";
                BaseTableDataAccess.Instance().UpsertTeamRoster(teamRoster);

                //Now need to reload team roster so added player with his jersey is displayed.
                _vm.Initialize(teamRoster.TeamID);
            }
        }
コード例 #2
0
        public static void BackOutTeamShootOutOpp(int gameID, int goalScoringTeamID)
        {
            try
            {
                //Need to get the current home and away score so we can update it
                Game game = new Game();
                game = BaseTableDataAccess.Instance().GetGameByGameID(gameID);

                if (game.HomeTeamID == goalScoringTeamID)
                {
                    game.HomeTeamShootOutGoalOpp = game.HomeTeamShootOutGoalOpp - 1;
                }
                else
                {
                    game.AwayTeamShootOutGoalOpp = game.AwayTeamShootOutGoalOpp - 1;
                }

                BaseTableDataAccess.Instance().UpdateGameAwayTeamShootoutOpp(gameID, game.AwayTeamShootOutGoalOpp);
                BaseTableDataAccess.Instance().UpdateGameHomeTeamShootoutOpp(gameID, game.HomeTeamShootOutGoalOpp);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #3
0
        public void Initialize(int gameId, int teamId)
        {
            _gameId = gameId;
            _game   = DAL.Instance().GetGame(_gameId);

            if (_game.AwayTeam.TeamID == teamId)
            {
                AwayTeamName       = _game.AwayTeam.TeamName;
                AwayTeamShortName  = Game.AwayTeam.TeamShortName;
                AwayTeamJerseyPath = BaseTableDataAccess.Instance().GetJerseyByJerseyID(Game.AwayTeam.JerseyID).ImagePath;
                GameTitle          = string.Format(_gameTitleTemplate, Game.AwayTeam.TeamName);
                ShowAwayCircle     = "Visible";
                ShowHomeCircle     = "Collapsed";
            }
            else
            {
                HomeTeamName       = _game.HomeTeam.TeamName;
                HomeTeamShortName  = Game.HomeTeam.TeamShortName;
                HomeTeamJerseyPath = BaseTableDataAccess.Instance().GetJerseyByJerseyID(Game.HomeTeam.JerseyID).ImagePath;
                GameTitle          = string.Format(_gameTitleTemplate, Game.HomeTeam.TeamName);
                ShowHomeCircle     = "Visible";
                ShowAwayCircle     = "Collapsed";
            }

            BoxscoreItems = LoadPlayerSats(teamId);
            LoadLegend();
        }
コード例 #4
0
        //TJY TO DO, Any players in RosterList = DAL.Instance().GetTeamRoster(TeamID) we do not want to include from PlayersList = DAL.Instance().GetAllPlayers below
        private void PopulatePlayersList(string displayDeletedPlayers, string searchCharacter)
        {
            ObservableCollection <TeamRosterModel> teamRosterList   = BaseTableDataAccess.Instance().GetTeamRoster(TeamID);
            ObservableCollection <PlayerModel>     globalPlayerList = new ObservableCollection <PlayerModel>(DAL.Instance().GetAllPlayers(displayDeletedPlayers, searchCharacter).Where(x => x.Player.SampleData.ToUpper().Equals("N")));

            PlayersList = new ObservableCollection <PlayerModel>();

            foreach (var globalplayerEntry in globalPlayerList)
            {
                if (Common.Instance().IsPlayerInList(teamRosterList, globalplayerEntry.Player.PlayerID) == false)
                {
                    globalplayerEntry.PlayerDeleted       += item_PlayerDeleted;
                    globalplayerEntry.PlayerAddedToRoster += item_PlayerAddedToRoster;

                    PlayersList.Add(globalplayerEntry);
                }
            }

            //If this is simply the displaying of the Players screen (i.e. not adding a player to a team, then no need to show the add button)
            if (TeamID == 0)
            {
                PlayersList.ToList().ForEach(x => x.IsAddButtonVisible = Visibility.Collapsed);
                IsAddCaptionVisible = Visibility.Collapsed;
            }
            else
            {
                PlayersList.ToList().ForEach(x => x.IsAddButtonVisible = Visibility.Visible);
                IsAddCaptionVisible = Visibility.Visible;
            }
        }
コード例 #5
0
        private void AddPlayerToEventRoster()
        {
            EventRoster eventRosterEntry = new EventRoster();
            EventRoster checkForExists   = new EventRoster();

            try
            {
                checkForExists = BaseTableDataAccess.Instance().GetEventRosterByGameTeamPlayer(GameID, App.gPromptForJerseyTeamID, App.gPromptForJerseyPlayerID);

                //Should never get to this point, but just in case, we do not want to insert a player on the roster more than once
                if (checkForExists == null)
                {
                    eventRosterEntry.GameID   = GameID;
                    eventRosterEntry.TeamID   = App.gPromptForJerseyTeamID;
                    eventRosterEntry.PlayerID = App.gPromptForJerseyPlayerID;
                    eventRosterEntry.Starter  = "N";
                    DAL.Instance().UpdatePlayersGameStartedStat(GameID, App.gPromptForJerseyTeamID, App.gPromptForJerseyPlayerID, false);
                    eventRosterEntry.IsPlayerOnField    = "N";
                    eventRosterEntry.GMPlayerPositionID = "";

                    BaseTableDataAccess.Instance().InsertEventRoster(eventRosterEntry);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #6
0
        public static void GoalWasDeletedBackOutGoalFromGameScoreAndUpdatePBPRunningScore(Play play, int goalScoringTeamID)
        {
            try
            {
                //Need to get the current home and away score so we can update it
                Game game = new Game();
                game = BaseTableDataAccess.Instance().GetGameByGameID(play.GameID);

                if (game.HomeTeamID == goalScoringTeamID)
                {
                    game.HomeTeamScore = game.HomeTeamScore - 1;
                }
                else
                {
                    game.AwayTeamScore = game.AwayTeamScore - 1;
                }

                BaseTableDataAccess.Instance().UpdateGameAwayTeamScore(play.GameID, game.AwayTeamScore);
                BaseTableDataAccess.Instance().UpdateGameHomeTeamScore(play.GameID, game.HomeTeamScore);

                //update the running score of the game
                RebuildRunningScoreDueToScoringPlayChangedNEW(play, "DELETE");
                // RebuildRunningScoreDueToScoringPlayChangedOLD(play);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #7
0
        void input_Completed(object sender, PopUpEventArgs <string, PopUpResult> e)
        {
            int  number;
            bool parsed = int.TryParse(e.Result, out number);

            if (e.Result.Length > 3)
            {
                MessageBox.Show(AppResources.JerseyMustBeLessThan3Characters, _messageBoxTitle, MessageBoxButton.OK);
            }
            else if (parsed == false)
            {
                MessageBox.Show(AppResources.JerseyMustBeANumber, _messageBoxTitle, MessageBoxButton.OK);
            }
            else
            {
                TeamRoster teamRoster = new TeamRoster();

                teamRoster.TeamID        = App.gPromptForJerseyTeamID;
                teamRoster.PlayerID      = App.gPromptForJerseyPlayerID;
                teamRoster.UniformNumber = e.Result.ToString();
                teamRoster.Active        = "Y";
                BaseTableDataAccess.Instance().UpsertTeamRoster(teamRoster);

                //Game Manager is calling AddPlayerToRoster via the + button, so also need to save this player to event roster/isonfield = false and return
                AddPlayerToEventRoster();
                (Application.Current.RootVisual as Frame).GoBack();
            }
        }
コード例 #8
0
        private void PopulateRosterList()
        {
            string activeStatus = string.Empty;

            RosterList = BaseTableDataAccess.Instance().GetTeamRoster(TeamID);

            foreach (var item in RosterList)
            {
                item.PlayerRosterDeleted += item_PlayerRosterDeleted;

                Player player = new Player();
                player = DAL.Instance().GetPlayer(item.Player.PlayerID);

                if (item.TeamRoster.Active == "Y")
                {
                    activeStatus = AppResources.Active.PadRight(7);
                }
                else
                {
                    activeStatus = AppResources.InActive;
                }

                item.RosterDisplayText = item.TeamRoster.UniformNumber.PadRight(4, ' ') + activeStatus + " " + player.FirstName + " " + player.LastName;
            }
        }
コード例 #9
0
        public void Initialize(int teamID)
        {
            Team team = BaseTableDataAccess.Instance().GetTeamByTeamID(teamID);

            TeamID    = teamID;
            TeamName  = team.TeamName;
            PageTitle = TeamName;
            PopulateRosterList();
        }
コード例 #10
0
ファイル: TeamModel.cs プロジェクト: Mahopacs/SoccerApp
        private void GoToDeleteTeam()
        {
            MessageBoxResult result = MessageBox.Show(AppResources.Delete + " '" + Team.TeamName + "' " + AppResources.Team + "?", AppResources.DeleteTeam, MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                this.Team.Visible = "N";
                BaseTableDataAccess.Instance().UpsertTeam(this.Team);
                OnTeamDeleted(EventArgs.Empty);
            }
        }
コード例 #11
0
ファイル: LeagueModel.cs プロジェクト: Mahopacs/SoccerApp
        private void GoToDeleteLeague()
        {
            MessageBoxResult result = MessageBox.Show(AppResources.Delete + " '" + League.LeagueName + "' " + AppResources.League + "?", AppResources.DeleteLeague, MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                this.League.Visible = "N";
                BaseTableDataAccess.Instance().UpsertLeague(this.League);
                OnLeagueDeleted(EventArgs.Empty);
            }
        }
コード例 #12
0
        private void GoToDeletePlayer()
        {
            MessageBoxResult result = MessageBox.Show(AppResources.Delete + " '" + Player.FirstName + " " + Player.LastName + "'" + AppResources.FromPlayerList + "?", AppResources.DeletePlayer, MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                this.Player.Visible = "N";
                BaseTableDataAccess.Instance().UpsertPlayer(this.Player, 0, 0);
                //Also need to delete player from ANY team roster
                DAL.Instance().DeletePlayerFromAnyAllTeamRosters(Player.PlayerID);
                OnPlayerDeleted(EventArgs.Empty);
            }
        }
コード例 #13
0
        public void SaveToDatabase(int teamID)
        {
            BaseTableDataAccess.Instance().UpsertPlayer(this.PlayerDetails, GameID, teamID);

            if (teamID != 0)
            {
                TeamRoster teamRoster = new TeamRoster();
                teamRoster.PlayerID      = this.PlayerDetails.PlayerID;
                teamRoster.TeamID        = teamID;
                teamRoster.UniformNumber = UniformNumber;
                teamRoster.Active        = Active;
                BaseTableDataAccess.Instance().UpsertTeamRoster(teamRoster);
            }
        }
コード例 #14
0
        public void Initialize(int gameId)
        {
            _gameId = gameId;
            _game   = DAL.Instance().GetGame(_gameId);

            AwayTeamName = _game.AwayTeam.TeamName;
            HomeTeamName = _game.HomeTeam.TeamName;

            AwayTeamShortName = Game.AwayTeam.TeamShortName;
            HomeTeamShortName = Game.HomeTeam.TeamShortName;

            AwayTeamJerseyPath = BaseTableDataAccess.Instance().GetJerseyByJerseyID(Game.AwayTeam.JerseyID).ImagePath;
            HomeTeamJerseyPath = BaseTableDataAccess.Instance().GetJerseyByJerseyID(Game.HomeTeam.JerseyID).ImagePath;

            GameDate_NoTime = _game.Game.GameDate_NoTime;

            LoadGameStats(_gameId);
        }
コード例 #15
0
        public void Initialize(int gameId)
        {
            _gameId = gameId;
            _game   = DAL.Instance().GetGame(_gameId);

            AwayTeamName = _game.AwayTeam.TeamName;
            HomeTeamName = _game.HomeTeam.TeamName;

            AwayTeamShortName = Game.AwayTeam.TeamShortName;
            HomeTeamShortName = Game.HomeTeam.TeamShortName;

            AwayTeamJerseyPath = BaseTableDataAccess.Instance().GetJerseyByJerseyID(Game.AwayTeam.JerseyID).ImagePath;
            HomeTeamJerseyPath = BaseTableDataAccess.Instance().GetJerseyByJerseyID(Game.HomeTeam.JerseyID).ImagePath;

            GameDate_NoTime = _game.Game.GameDate_NoTime;

            PlayByPlayList = DAL.Instance().GetPlaysForGame(_gameId, "DESC");
            PlayByPlayList.Reverse();
        }
コード例 #16
0
        private void AddPlayerToEventRoster()
        {
            EventRoster eventRosterEntry = new EventRoster();

            try
            {
                eventRosterEntry.GameID             = GameID;
                eventRosterEntry.TeamID             = App.gPromptForJerseyTeamID;
                eventRosterEntry.PlayerID           = App.gPromptForJerseyPlayerID;
                eventRosterEntry.Starter            = "N";
                eventRosterEntry.IsPlayerOnField    = "N";
                eventRosterEntry.GMPlayerPositionID = "";

                BaseTableDataAccess.Instance().InsertEventRoster(eventRosterEntry);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #17
0
        void item_PlayerAddedToRoster(object sender, EventArgs e)
        {
            PlayerModel player     = (PlayerModel)sender;
            TeamRoster  teamRoster = new TeamRoster();

            teamRoster.TeamID        = TeamID;
            teamRoster.PlayerID      = player.Player.PlayerID;
            teamRoster.UniformNumber = "0";
            teamRoster.Active        = "Y";
            BaseTableDataAccess.Instance().UpsertTeamRoster(teamRoster);

            Common.Instance().SetTeamRosterPromptForJersey(TeamID, TeamName, player.Player.PlayerID);

            if (GameID != 0)
            {
                if (App.gPromptForJersey == true)
                {
                    InputPrompt input = new InputPrompt();


                    InputScope     scope = new InputScope();
                    InputScopeName name  = new InputScopeName();

                    name.NameValue = InputScopeNameValue.Number;
                    scope.Names.Add(name);

                    input.Completed += input_Completed;
                    input.Title      = AppResources.JerseyNumber;
                    input.Message    = AppResources.EnterPlayersJerseyNumber;
                    input.InputScope = scope;
                    input.Show();
                }
                App.gPromptForJersey = false;
            }
            else  //Player List was called from Rosters screen so go back to that screen to get jersey number
            {
                (Application.Current.RootVisual as Frame).GoBack();
            }
        }
コード例 #18
0
        public void Initialize(int gameId)
        {
            _gameId = gameId;
            _game   = DAL.Instance().GetGame(_gameId);

            GameDate = _game.Game.GameDate.ToString("d");

            AwayTeamName = _game.AwayTeam.TeamName;
            HomeTeamName = _game.HomeTeam.TeamName;

            BoxscoreAwayItems = new ObservableCollection <FlatTotalsModel>();
            BoxscoreHomeItems = new ObservableCollection <FlatTotalsModel>();

            GameTitle    = string.Format(gameTitleTemplate, Game.AwayTeam.TeamName, _game.Game.AwayTeamScore, _game.Game.HomeTeamScore, Game.HomeTeam.TeamName);
            AwayBoxscore = Game.AwayTeam.TeamShortName + " Boxscore";
            HomeBoxscore = Game.HomeTeam.TeamShortName + " Boxscore";

            AwayTeamShortName = Game.AwayTeam.TeamShortName;
            HomeTeamShortName = Game.HomeTeam.TeamShortName;

            AwayTeamJerseyPath = BaseTableDataAccess.Instance().GetJerseyByJerseyID(Game.AwayTeam.JerseyID).ImagePath;
            HomeTeamJerseyPath = BaseTableDataAccess.Instance().GetJerseyByJerseyID(Game.HomeTeam.JerseyID).ImagePath;

            ObservableCollection <StatCategoryModel> allStats = DAL.Instance().GetVisibleStats(false, false);

            PlayByPlayList = DAL.Instance().GetPlaysForGame(_gameId, "DESC");
            PlayByPlayList.Reverse();

            //StatCalculationsModule.CalculateALLPlayerMinutes(_gameId);
            //StatCalculationsModule.CalculateALLPlayerPlusMinus(_gameId);

            BoxscoreAwayItems = LoadPlayerSats(_game.AwayTeam.TeamID);
            BoxscoreHomeItems = LoadPlayerSats(_game.HomeTeam.TeamID);

            LoadTimeline();
            LoadGameStats(_gameId);
            LoadLegend();
        }
コード例 #19
0
 public void SaveToDatabase()
 {
     BaseTableDataAccess.Instance().UpsertLeague(this.LeagueDetails.League);
 }
コード例 #20
0
        public static void RebuildRunningScoreDueToScoringPlayChangedNEW(Play play, string addOrDeletedGoal)
        {
            string homeOrAwayTeamGoal = string.Empty;

            try
            {
                //  Debug.WriteLine(DateTime.Now + " - Start - RebuildRunningScoreDueToScoringPlayChangedNEW");

                GameModel game = new GameModel();
                game = DAL.Instance().GetGame(play.GameID);

                //Determine the team id of the goalscoring team, determine if they are home or away (do not count own goals or shootout goals)
                if (Common.Instance().IsThisAGCoalScoredPlay(play, false, false))
                {
                    if (game.Game.HomeTeamID == play.TeamID)
                    {
                        homeOrAwayTeamGoal = "Home";
                    }
                    else
                    {
                        homeOrAwayTeamGoal = "Away";
                    }
                }
                else if (play.StatCategoryID == 12) //Own Goal (12)
                {
                    if (game.Game.AwayTeamID == play.TeamID)
                    {
                        homeOrAwayTeamGoal = "Home";
                    }
                    else
                    {
                        homeOrAwayTeamGoal = "Away";
                    }
                }

                if (homeOrAwayTeamGoal == "Home")
                {
                    if (addOrDeletedGoal.ToUpper() == "ADD")
                    {
                        BaseTableDataAccess.Instance().AddOneToHomePlayScoreForPlaysForGameAfterDeletedGoal(play.GameID, play.ElapsedTimeInSeconds);
                    }
                    else
                    {
                        BaseTableDataAccess.Instance().SubtractOneFromHomePlayScoreForPlaysForGameAfterDeletedGoal(play.GameID, play.ElapsedTimeInSeconds);
                    }
                }
                else if (homeOrAwayTeamGoal == "Away")
                {
                    if (addOrDeletedGoal.ToUpper() == "ADD")
                    {
                        BaseTableDataAccess.Instance().AddOneToAwayPlayScoreForPlaysForGameAfterDeletedGoal(play.GameID, play.ElapsedTimeInSeconds);
                    }
                    else
                    {
                        BaseTableDataAccess.Instance().SubtractOneFromAwayPlayScoreForPlaysForGameAfterDeletedGoal(play.GameID, play.ElapsedTimeInSeconds);
                    }
                }
                // Debug.WriteLine(DateTime.Now + " - End - RebuildRunningScoreDueToScoringPlayChangedNEW");
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #21
0
        public static void CalculateALLPlayerPlusMinus(int gameID)
        {
            int goalScoringTeamID;
            int goalAllowedTeamID;
            int elapsedTimeInGameAtTimeOfGoalScored;
            ObservableCollection <PlayModel> playByPlayList      = new ObservableCollection <PlayModel>();
            List <EventRoster> subPlayerINListForGoalScoringTeam = new List <EventRoster>();
            List <EventRoster> subPlayerINListForGoalAllowedTeam = new List <EventRoster>();

            try
            {
                //  Debug.WriteLine(DateTime.Now + " - Start - CalculateALLPlayerPlusMinus. GameID =" + gameID);

                BaseTableDataAccess.Instance().DeleteEntireGamesPlusMinusStats(gameID);

                //Get list of all plays for the game
                playByPlayList = DAL.Instance().GetPlaysForGame(gameID, "ASC");

                foreach (var playEntry in playByPlayList)
                {
                    //for every goal scored play in game   (own goals count, shootout goals do not)
                    if (Common.Instance().IsThisAGCoalScoredPlay(playEntry.Play, true, false) == true)
                    {
                        if (playEntry.Play.StatCategoryID == 12)    //Own Goal (12)
                        {
                            goalAllowedTeamID = playEntry.Play.TeamID;
                            goalScoringTeamID = Common.Instance().GetOtherTeamID(playEntry.Play.GameID, playEntry.Play.TeamID);
                        }
                        else
                        {
                            goalScoringTeamID = playEntry.Play.TeamID;
                            goalAllowedTeamID = Common.Instance().GetOtherTeamID(playEntry.Play.GameID, playEntry.Play.TeamID);
                        }

                        elapsedTimeInGameAtTimeOfGoalScored = playEntry.Play.ElapsedTimeInSeconds;

                        //get list of players on the field at the time of the goal scored for the team that SCORED the goal
                        subPlayerINListForGoalScoringTeam = DAL.Instance().GetPlayersInGivenPointInGame(gameID, goalScoringTeamID, elapsedTimeInGameAtTimeOfGoalScored);

                        //for each one of these players add 1 to their plus minus value
                        foreach (var playerInGame in subPlayerINListForGoalScoringTeam)
                        {
                            Play plusMinus = new Play();

                            plusMinus.GameID            = gameID;
                            plusMinus.Player1ID         = playerInGame.PlayerID;
                            plusMinus.TeamID            = goalScoringTeamID;
                            plusMinus.StatCategoryID    = 25; //PlusMinus (25)
                            plusMinus.StatDescriptionID = 0;
                            plusMinus.PlayText          = "Plus";
                            DAL.Instance().UpsertStatPlayToFlatTotals(plusMinus, false);
                        }

                        //get list of players on the field at the time of the goal scored for the team that ALLOWED the goal
                        subPlayerINListForGoalAllowedTeam = DAL.Instance().GetPlayersInGivenPointInGame(gameID, goalAllowedTeamID, elapsedTimeInGameAtTimeOfGoalScored);

                        //for each one of these players add -1 to their plus minus value
                        foreach (var playerInGame in subPlayerINListForGoalAllowedTeam)
                        {
                            Play plusMinus = new Play();

                            plusMinus.GameID            = gameID;
                            plusMinus.Player1ID         = playerInGame.PlayerID;
                            plusMinus.TeamID            = goalAllowedTeamID;
                            plusMinus.StatCategoryID    = 25; //PlusMinus (25)
                            plusMinus.StatDescriptionID = 0;
                            plusMinus.PlayText          = "Minus";
                            DAL.Instance().UpsertStatPlayToFlatTotals(plusMinus, false);
                        }
                    }
                }
                //     Debug.WriteLine(DateTime.Now + " - End - CalculateALLPlayerPlusMinus. GameID =" + gameID);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #22
0
        //this should only be called for a goal scored play (shootout goals do not effect plus minus)
        public static void AdjustPlusMinus(Play play, string addOrDeletedGoal, string whosCalling)
        {
            int goalScoringTeamID;
            int goalAllowedTeamID;
            List <EventRoster> eventRosterList = new List <EventRoster>();
            ObservableCollection <PlayModel> playByPlayList = new ObservableCollection <PlayModel>();

            try
            {
                if (App.DoesUserHaveAbilityToTrackAllStats() == false)
                {
                    return;
                }

                // Debug.WriteLine(DateTime.Now + " - Start - AdjustPlusMinus. Play = " + play.GameTime + " " + play.PlayText);

                //if goal scored play (own goals count, shootout goals do not)
                if (Common.Instance().IsThisAGCoalScoredPlay(play, true, false))
                {
                    if (play.StatCategoryID == 12)  //Own Goal (12)
                    {
                        goalAllowedTeamID = play.TeamID;
                        goalScoringTeamID = Common.Instance().GetOtherTeamID(play.GameID, play.TeamID);
                    }
                    else
                    {
                        goalScoringTeamID = play.TeamID;
                        goalAllowedTeamID = Common.Instance().GetOtherTeamID(play.GameID, play.TeamID);
                    }

                    //get list of players on the field at the time of the goal scored for the team that SCORED the goal
                    //If GM is calling then we can simply take the players on the field, otherwise call into proc to determine players on field based on the time of the play
                    if (whosCalling.ToUpper() == "GM")
                    {
                        eventRosterList = BaseTableDataAccess.Instance().GetListOfPlayersOnTheField(play.GameID, goalScoringTeamID);
                    }
                    else
                    {
                        eventRosterList = DAL.Instance().GetPlayersInGivenPointInGame(play.GameID, goalScoringTeamID, play.ElapsedTimeInSeconds);
                    }

                    //for each one of these players add 1 to their plus minus value
                    foreach (var playerInGame in eventRosterList)
                    {
                        Play plusMinus = new Play();

                        plusMinus.GameID            = play.GameID;
                        plusMinus.Player1ID         = (int)playerInGame.PlayerID;
                        plusMinus.TeamID            = goalScoringTeamID;
                        plusMinus.StatCategoryID    = 25; //PlusMinus (25)
                        plusMinus.StatDescriptionID = 0;

                        if (addOrDeletedGoal.ToUpper() == "ADD")
                        {
                            plusMinus.PlayText = "Plus";
                        }
                        else
                        {
                            plusMinus.PlayText = "Minus";
                        }

                        DAL.Instance().UpsertStatPlayToFlatTotals(plusMinus, false);
                    }

                    //get list of players on the field at the time of the goal scored for the team that ALLOWED the goal
                    //If GM is calling then we can simply take the players on the field, otherwise call into proc to determine players on field based on the time of the play
                    if (whosCalling.ToUpper() == "GM")
                    {
                        eventRosterList = BaseTableDataAccess.Instance().GetListOfPlayersOnTheField(play.GameID, goalAllowedTeamID);
                    }
                    else
                    {
                        eventRosterList = DAL.Instance().GetPlayersInGivenPointInGame(play.GameID, goalAllowedTeamID, play.ElapsedTimeInSeconds);
                    }

                    //for each one of these players add -1 to their plus minus value
                    foreach (var playerInGame in eventRosterList)
                    {
                        Play plusMinus = new Play();

                        plusMinus.GameID            = play.GameID;
                        plusMinus.Player1ID         = (int)playerInGame.PlayerID;
                        plusMinus.TeamID            = goalAllowedTeamID;
                        plusMinus.StatCategoryID    = 25; //PlusMinus (25)
                        plusMinus.StatDescriptionID = 0;

                        if (addOrDeletedGoal.ToUpper() == "ADD")
                        {
                            plusMinus.PlayText = "Minus";
                        }
                        else
                        {
                            plusMinus.PlayText = "Plus";
                        }

                        DAL.Instance().UpsertStatPlayToFlatTotals(plusMinus, false);
                    }
                    //   Debug.WriteLine(DateTime.Now + " - End - AdjustPlusMinus. Play = " + play.GameTime + " " + play.PlayText);
                }
            }

            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #23
0
        //With this approach we are not using clock tick events.
        //As a result our database does not reflect an accurate depiction of minutes/seconds played at any given time
        //Which is fine since we will be doing our recalculation based on when the user clicks on a stat report generation
        //(OR we could decide to run this behind the scenes every X seconds)

        //For EVERY player in event roster for BOTH teams, we need to determine each players minutes/seconds played

        //public static void CalculateALLPlayerMinutesOLD(int gameID)
        //{
        //    int inPeriod;
        //    string inClock;
        //    int outPeriod;
        //    string outClock;
        //    int playerSecondsPlayed;
        //    string playersMostRecentTrans = string.Empty;
        //    Game game = new Game();
        //    List<EventRoster> eventRosterList = new List<EventRoster>();

        //    try
        //    {
        //        Debug.WriteLine(DateTime.Now + " - Start - CalculatePlayerMinutes");
        //        //Get game info -> periods, period length, OT, OT length, current period, current clock are all needed
        //        game = BaseTableDataAccess.Instance().GetGameByGameID(gameID);

        //        //Get list of all players for both teams who were on roster for this game
        //        eventRosterList = BaseTableDataAccess.Instance().GetEventRosterByGameID(gameID);

        //        //Go through all players and determine their minutes/seconds played
        //        foreach (var eventRosterEntry in eventRosterList)
        //        {
        //            playerSecondsPlayed = 0;

        //            //get this players sub transactions/plays
        //            List<Play> playersSubTransactionsList = new List<Play>();
        //            playersSubTransactionsList = BaseTableDataAccess.Instance().GetAllSubPlaysForGameByPlayerID(gameID, eventRosterEntry.PlayerID, eventRosterEntry.TeamID);

        //            //If this player had no sub transations then they never left the game
        //            //If they started we need to determine their minutes played (which is simply time elapsed in game)
        //            //If they did not start then they never got in game and minutes played = 0
        //            if (playersSubTransactionsList.Count == 0)
        //            {
        //                if (eventRosterEntry.Starter == "Y")
        //                {
        //                    playerSecondsPlayed = CalculateTimeElapsedInGameInSeconds(game, game.CurrentPeriod, game.CurrentClock);
        //                }
        //                else //player did not start and has no sub transactions so this player has never appeared in the game
        //                {
        //                    playerSecondsPlayed = 0;
        //                }
        //            }
        //            else //this player has sub transactions so need to go through them to determine players minutes played
        //            {
        //                //If the player was a starter then their first sub will be an OUT, so we can initiailize their IN varialbles to the 1st period and period length (i.e. time period started)
        //                if (eventRosterEntry.Starter == "Y")
        //                {
        //                    playersMostRecentTrans = "IN";
        //                    if (game.ClockUpOrDown.ToUpper() == "UP")
        //                    {
        //                        inPeriod = 1; inClock = "00:00"; outPeriod = -99; outClock = "-99";
        //                    }
        //                    else
        //                    {
        //                        inPeriod = 1; inClock = game.PeriodLength.ToString() + ":00"; outPeriod = -99; outClock = "-99";
        //                    }
        //                }
        //                else //We do not need to initialize the IN varaibles if this player did not start, as their first sub will be an IN, BUT .NET requires variables to be assigned if their first use is in if statment logic
        //                {
        //                    playersMostRecentTrans = "OUT";
        //                    inPeriod = -99; inClock = "-99"; outPeriod = -99; outClock = "-99";
        //                }

        //                foreach (var playerSubTrans in playersSubTransactionsList)
        //                {
        //                    //Check if this is an IN (their ID is in player1ID) or OUT (their ID is in player2ID) sub transaction for the player
        //                    if (eventRosterEntry.PlayerID == playerSubTrans.Player1ID)
        //                    {
        //                        //this is an IN sub for player
        //                        if (playersMostRecentTrans != "IN")
        //                        {
        //                            inPeriod = playerSubTrans.Period; inClock = playerSubTrans.GameTime;
        //                            outPeriod = 0; outClock = "0";
        //                            playersMostRecentTrans = "IN";
        //                        }
        //                    }
        //                    else
        //                    {
        //                        //this is an OUT sub for player
        //                        if (playersMostRecentTrans != "OUT")
        //                        {
        //                            outPeriod = playerSubTrans.Period; outClock = playerSubTrans.GameTime;
        //                            playersMostRecentTrans = "OUT";
        //                            playerSecondsPlayed = playerSecondsPlayed + HowLongHasPlayerBeenInGame(game, inPeriod, outPeriod, inClock, outClock);
        //                        }
        //                    }
        //                } // next trans for player

        //                //If outPeriod = 0, then player is still on field (as we have not received an OUT sub for them),
        //                //so need to add time since they came in to their total time (i.e. inClock - currentClock)
        //                if (outPeriod == 0)
        //                {
        //                    playerSecondsPlayed = playerSecondsPlayed + HowLongHasPlayerBeenInGame(game, inPeriod, game.CurrentPeriod, inClock, game.CurrentClock);
        //                }
        //            }
        //            //for this player write their seconds and minutes played to Stat totals, then we can move on to next player
        //            SavePlayersTimePlayedToStatTotals(gameID, eventRosterEntry.TeamID, eventRosterEntry.PlayerID, playerSecondsPlayed);
        //        } // next player
        //        Debug.WriteLine(DateTime.Now + " - End - CalculatePlayerMinutes");
        //    }
        //    catch (Exception ex)
        //    {
        //        throw;
        //    }

        //}

        public static void CalculateALLPlayerMinutes(int gameID)
        {
            int                inPeriod;
            string             inClock;
            int                outPeriod;
            string             outClock;
            int                playerSecondsPlayed;
            int                gamesElapsedTimeInSeconds;
            string             playersMostRecentTrans = string.Empty;
            Game               game                     = new Game();
            List <EventRoster> eventRosterList          = new List <EventRoster>();
            List <Play>        gamesSubTransactionsList = new List <Play>();;

            try
            {
                if (App.DoesUserHaveAbilityToTrackAllStats() == false)
                {
                    return;
                }

                // Debug.WriteLine(DateTime.Now.ToLongTimeString() + " - Start - CalculatePlayerMinutes");

                //Get game info -> periods, period length, OT, OT length, current period, current clock are all needed
                game = BaseTableDataAccess.Instance().GetGameByGameID(gameID);

                gamesElapsedTimeInSeconds = CalculateTimeElapsedInGameInSeconds(game, game.CurrentPeriod, game.CurrentClock);

                //Get list of all players for both teams who were on roster for this game
                eventRosterList = BaseTableDataAccess.Instance().GetEventRosterByGameID(gameID);

                gamesSubTransactionsList = BaseTableDataAccess.Instance().GetAllSubPlaysForGame(gameID);

                //Go through all players and determine their minutes/seconds played
                foreach (var eventRosterEntry in eventRosterList)
                {
                    playerSecondsPlayed = 0;

                    //get this players sub transactions/plays
                    var playersSubTransactionsList = gamesSubTransactionsList.Where(x => (x.Player1ID == eventRosterEntry.PlayerID || x.Player2ID == eventRosterEntry.PlayerID) &&
                                                                                    x.TeamID == eventRosterEntry.TeamID).ToList();

                    //If this player had no sub transations then they never left the game
                    //If they started we need to determine their minutes played (which is simply time elapsed in game)
                    //If they did not start then they never got in game and minutes played = 0
                    if (playersSubTransactionsList.Count == 0)
                    {
                        if (eventRosterEntry.Starter == "Y")
                        {
                            playerSecondsPlayed = gamesElapsedTimeInSeconds;
                        }
                        else //player did not start and has no sub transactions so this player has never appeared in the game
                        {
                            playerSecondsPlayed = 0;
                        }
                    }
                    else //this player has sub transactions so need to go through them to determine players minutes played
                    {
                        //If the player was a starter then their first sub will be an OUT, so we can initiailize their IN varialbles to the 1st period and period length (i.e. time period started)
                        if (eventRosterEntry.Starter == "Y")
                        {
                            playersMostRecentTrans = "IN";
                            if (game.ClockUpOrDown.ToUpper() == "UP")
                            {
                                inPeriod = 1; inClock = "00:00"; outPeriod = -99; outClock = "-99";
                            }
                            else
                            {
                                inPeriod = 1; inClock = game.PeriodLength.ToString() + ":00"; outPeriod = -99; outClock = "-99";
                            }
                        }
                        else //We do not need to initialize the IN varaibles if this player did not start, as their first sub will be an IN, BUT .NET requires variables to be assigned if their first use is in if statment logic
                        {
                            playersMostRecentTrans = "OUT";
                            inPeriod = -99; inClock = "-99"; outPeriod = -99; outClock = "-99";
                        }

                        foreach (var playerSubTrans in playersSubTransactionsList)
                        {
                            //Check if this is an IN (their ID is in player1ID) or OUT (their ID is in player2ID) sub transaction for the player
                            if (eventRosterEntry.PlayerID == playerSubTrans.Player1ID)
                            {
                                //this is an IN sub for player
                                if (playersMostRecentTrans != "IN")
                                {
                                    inPeriod  = playerSubTrans.Period; inClock = playerSubTrans.GameTime;
                                    outPeriod = 0; outClock = "0";
                                    playersMostRecentTrans = "IN";
                                }
                            }
                            else
                            {
                                //this is an OUT sub for player
                                if (playersMostRecentTrans != "OUT")
                                {
                                    outPeriod = playerSubTrans.Period; outClock = playerSubTrans.GameTime;
                                    playersMostRecentTrans = "OUT";
                                    playerSecondsPlayed    = playerSecondsPlayed + HowLongHasPlayerBeenInGame(game, inPeriod, outPeriod, inClock, outClock);
                                }
                            }
                        } // next trans for player

                        //If outPeriod = 0, then player is still on field (as we have not received an OUT sub for them),
                        //so need to add time since they came in to their total time (i.e. inClock - currentClock)
                        if (outPeriod == 0)
                        {
                            playerSecondsPlayed = playerSecondsPlayed + HowLongHasPlayerBeenInGame(game, inPeriod, game.CurrentPeriod, inClock, game.CurrentClock);
                        }
                    }
                    //for this player write their seconds and minutes played to Stat totals, then we can move on to next player
                    SavePlayersTimePlayedToStatTotals(gameID, eventRosterEntry.TeamID, eventRosterEntry.PlayerID, playerSecondsPlayed);
                } // next player
                  // Debug.WriteLine(DateTime.Now.ToLongTimeString() + " - End - CalculatePlayerMinutes");
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #24
0
 public void SaveToDatabase()
 {
     BaseTableDataAccess.Instance().UpsertTeam(this.TeamDetails.Team);
 }
コード例 #25
0
        //If an edit need to delete old play and then insert new play, if only an add then insert new play
        public void SaveToDatabase()
        {
            string statCategoryName;

            if (ValidateScreen() == true)
            {
                Play play = new Play();

                if (PlayID != 0)
                {
                    Play playDetails = new Play();
                    playDetails = BaseTableDataAccess.Instance().GetPlay(Game.Game.GameID, PlayID);
                    DAL.Instance().BackOutStatsForAPlay(Game.Game.GameID, playDetails);

                    //Since this is an edit, we need to reuse the same playid
                    play.PlayID = PlayID;
                }

                play.GameID         = Game.Game.GameID;
                play.TeamID         = SelectedTeam.TeamID;
                play.StatCategoryID = SelectedStatCategory.StatCategory.StatCategoryID;

                if (SelectedStatCategoryDescription != null)
                {
                    play.StatDescriptionID = SelectedStatCategoryDescription.StatDescriptionID;
                }

                if (play.StatCategoryID == 22)  //Substitution (22)
                {
                    play.Player1ID = SelectedPlayerIn.Player.PlayerID;
                    play.Player2ID = SelectedPlayerOut.Player.PlayerID;
                }
                else
                {
                    play.Player1ID = SelectedPlayer.Player.PlayerID;
                    play.Player2ID = null;
                }

                play.Period            = Convert.ToInt32(SelectedPeriod);
                play.PlayerPosition    = "";
                play.GameTime          = Clock;
                play.OtherTeamGoalieID = GetOtherTeamGoalieIdValue();

                //Check to see if this is a shot type play
                statCategoryName = DAL.Instance().GetStatCategoryNameById(play.StatCategoryID);
                if ((statCategoryName == "Shot") || (statCategoryName == "Shootout Kick") || (statCategoryName == "Penalty Kick") ||
                    (statCategoryName == "Direct Free Kick") || (statCategoryName == "Corner Kick"))
                {
                    play.AssistID        = GetAssistIdValue();
                    play.ShotBlockedByID = GetShotBlockedByIdValue();
                    play.ShotOnGoal      = GetShotOnGoalValue();
                    play.ShotTypeID      = GetShotTypeIdValue();
                }
                else //Not a shot play
                {
                    play.AssistID        = null;
                    play.ShotBlockedByID = null;
                    play.ShotOnGoal      = "N";
                    play.ShotTypeID      = null;
                }

                if (statCategoryName == "Substitution")
                {
                    DAL.Instance().SaveSubstitutionPlay("PBPSCREEN", play.GameID, play.TeamID, play.Period, play.GameTime, play.Player1ID, play.GMPlayer1PositionID, play.Player2ID, play.GMPlayer2PositionID);
                }
                else
                {
                    DAL.Instance().UpsertPlay(play, "PBPSCREEN");
                }
            }
        }