예제 #1
0
        public static void HandlePitcher(List <clsPitcher> colPitchers)
        {
            PlayerBusinessLogic pBLL   = new PlayerBusinessLogic();
            PlayerDomainModel   player = new PlayerDomainModel();

            PlayerPostiionBusinessLogic ppBLL          = new PlayerPostiionBusinessLogic();
            PlayerPositionDomainModel   playerposition = new PlayerPositionDomainModel();

            StatBusinessLogic sBLL = new StatBusinessLogic();
            StatDomainModel   stat = new StatDomainModel();

            SeasonPlayerPositionStatBusinessLogic sppsBLL   = new SeasonPlayerPositionStatBusinessLogic();
            SeasonPlayerPositionStatDomainModel   statValue = new SeasonPlayerPositionStatDomainModel();

            SeasonPlayerBusinessLogic spBLL = new SeasonPlayerBusinessLogic();
            SeasonPlayerDomainModel   spDM  = new SeasonPlayerDomainModel();


            statValue.SeasonID   = C_SeasonID;
            statValue.PlayerGUID = player.PlayerGUID;
            sppsBLL.DeleteAllStatsForPlayer(statValue);

            foreach (clsPitcher cPitcher in colPitchers)
            {
                player.PlayerName = cPitcher.FirstName.Trim() + " " + cPitcher.LastName.Trim();
                pBLL.InsertPlayer(player);

                playerposition.PlayerGUID          = player.PlayerGUID;
                playerposition.PrimaryPositionID   = TransformPos(cPitcher.Pos);
                playerposition.SecondaryPostiionID = null;
                ppBLL.DeletePlayerPosition(playerposition);
                ppBLL.InsertPlayerPosition(playerposition);

                spDM.PlayerGUID = player.PlayerGUID;
                spDM.SeasonID   = C_SeasonID;
                spBLL.InsertSeasonPlayer(spDM);

                BindingFlags flags = BindingFlags.Instance |
                                     BindingFlags.Public | BindingFlags.NonPublic;


                foreach (FieldInfo f in cPitcher.GetType().GetFields(flags))
                {
                    Console.WriteLine("{0} = {1}", f.Name, f.GetValue(cPitcher));
                    System.Diagnostics.Debug.WriteLine("{0} = {1}", f.Name, f.GetValue(cPitcher));
                    string fieldName = _getBackingFieldName(f.Name.ToUpper());


                    if (fieldName != "FIRSTNAME" &&
                        fieldName != "LASTNAME" &&
                        fieldName != "PT" &&
                        fieldName != "POS")
                    {
                        stat.StatName       = fieldName;
                        stat.PositionTypeID = 2;    // 1 = hitter
                        stat = sBLL.InsertStat(stat);

                        statValue.SeasonID   = C_SeasonID;
                        statValue.PlayerGUID = player.PlayerGUID;
                        statValue.PositionID = TransformPos(cPitcher.Pos);
                        statValue.StatID     = stat.StatID;
                        if (f.GetValue(cPitcher) == null)
                        {
                            statValue.StatValue = null;
                        }
                        else
                        {
                            statValue.StatValue = f.GetValue(cPitcher).ToString();
                        }

                        sppsBLL.InsertStatValue(statValue);
                    }
                }
            }
        }