Exemplo n.º 1
0
        public DateTime DefaultDate = Convert.ToDateTime("1/1/2000"); // kdtodo move to constants
        // Constructor
        public LoadBoxScores(string LeagueName, string strLoadDateTime, DateTime StartGameDate)
        {
            new LeagueInfoDO(LeagueName, _oLeagueDTO, _ConnectionString); // Init _oLeagueDTO
            _strLoadDateTime = strLoadDateTime;
            DateTime GameDate = BoxScoreDO.GetMaxBoxScoresGameDate(_ConnectionString, LeagueName, DefaultDate);

            if (GameDate == DefaultDate)
            {
                GameDate = StartGameDate;
            }
            else
            {
                GameDate = GameDate.AddDays(1);
            }

            _oSeasonInfo = new SeasonInfoDO(GameDate, _oLeagueDTO.LeagueName);
            if (_oSeasonInfo.oSeasonInfoDTO.Bypass)
            {
                _oSeasonInfo.GetNextGameDate();
            }
            //
            RotationDO.DeleteRestOfRotation(GameDate, LeagueName);
        }
Exemplo n.º 2
0
        public int LoadBoxScore(DateTime GameDate) // Return NumOfMatchups
        {
            /*
             *
             * */
            DateTime LoadDateTime     = DateTime.Now;
            string   _strLoadDateTime = LoadDateTime.ToString();

            SortedList <string, CoversDTO> ocRotation = new SortedList <string, CoversDTO>();

            RotationDO.PopulateRotation(ocRotation, _oSeasonInfo.GameDate, _oLeagueDTO, _ConnectionString, _strLoadDateTime);
            if (ocRotation.Count == 0)
            {
                return(0);                      // No Games for GameDate
            }
            foreach (var matchup in ocRotation)
            {
                CoversDTO oCoversDTO = matchup.Value;
                // 1) Get BoxScore from Covers
                CoversBoxscore oCoversBoxscore = new CoversBoxscore(GameDate, _oLeagueDTO, oCoversDTO);
                oCoversBoxscore.GetBoxscore(); // Get BoxScore from Covers
                if (oCoversBoxscore.ReturnCode != 0)
                {
                    // kdtodo log error
                    continue;
                }
                string[] arVenue = new string[] { "Away", "Home" };
                for (int i = 0; i < 2; i++)
                {
                    try
                    {
                        // Write Away & Home rows to BoxScores
                        BoxScoresDTO BoxScoresDTO = new BoxScoresDTO();
                        oCoversBoxscore.PopulateBoxScoresDTO(BoxScoresDTO, arVenue[i], _oSeasonInfo.oSeasonInfoDTO.Season, _oSeasonInfo.oSeasonInfoDTO.SubSeason, LoadDateTime
                                                             , oCoversBoxscore.LoadTimeSecound, "Covers");
                        Bball.DAL.Tables.BoxScoreDO.InsertBoxScores(BoxScoresDTO);
                    }
                    catch (Exception ex)
                    {
                        string msg = $"BoxScore Load Error - "
                                     + $"{_oLeagueDTO.LeagueName}: {GameDate}  {oCoversDTO.RotNum}:{arVenue[i]}  {oCoversDTO.TeamAway}-{oCoversDTO.TeamHome} "
                                     + "\n" + oCoversDTO.Url;
                        throw new Exception(SysDAL.DALfunctions.StackTraceFormat(msg, ex, ""));
                    }
                }

                // Write Last 5 Minutes stats
                BoxScoresLast5MinDTO oLast5MinDTOHome = new BoxScoresLast5MinDTO()
                {
                    LeagueName = oCoversDTO.LeagueName
                    , GameDate = oCoversDTO.GameDate
                    , RotNum   = oCoversDTO.RotNum + 1
                    , Team     = oCoversDTO.TeamHome
                    , Opp      = oCoversDTO.TeamAway
                    , Venue    = "Home"
                    , LoadDate = LoadDateTime
                };
                try
                {
                    //Bball.DAL.Tables.
                    BoxScoreDO.InsertAwayHomeRowsBoxScoresLast5Min(oLast5MinDTOHome);
                }
                catch (Exception ex)
                {
                    string msg = $"BoxScoreL5Min Load Error - "
                                 + $"{_oLeagueDTO.LeagueName}: {GameDate}  {oCoversDTO.RotNum}:  {oCoversDTO.TeamAway}-{oCoversDTO.TeamHome} "
                                 + "\n" + Bball.DAL.Parsing.BoxScoresLast5Min.BuildBoxScoresLast5MinUrl(oLast5MinDTOHome);
                    // throw new Exception(SysDAL.DALfunctions.StackTraceFormat(msg, ex, ""));
                    //Trace.Trace.Log(SysDAL.DALfunctions.StackTraceFormat(msg, ex, ""));
                }
            } // foreach

            AdjustmentsDO oAdjustments = new AdjustmentsDO(GameDate, _oLeagueDTO.LeagueName, _ConnectionString);

            oAdjustments.ProcessDailyAdjustments(GameDate, _oLeagueDTO.LeagueName);

            return(ocRotation.Count); // return NumOfMatchups
        } // LoadBoxScore