Ejemplo n.º 1
0
        private static void ReadWriteTeamFile(string inputPathFile)
        {
            string[] columnValue;
            string   textLine = null;

            using (StreamReader reader = new StreamReader(inputPathFile))
            {
                while (!reader.EndOfStream)
                {
                    try
                    {
                        textLine = reader.ReadLine();
                    }
                    catch (Exception e)
                    {
                        // Let the user know what went wrong.
                        Console.WriteLine("The " + inputPathFile + " file could not be read:");
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }

                    columnValue = textLine.Split('|');

                    TeamDTO teamDTO = new TeamDTO();

                    teamDTO.RecordID       = Guid.NewGuid();
                    teamDTO.SeasonYear     = columnValue[0];
                    teamDTO.SeasonGameType = columnValue[1];
                    teamDTO.TeamID         = columnValue[2];
                    teamDTO.League         = columnValue[3];
                    teamDTO.City           = columnValue[4];
                    teamDTO.Name           = columnValue[5];

                    TeamPersist.CreateTeam(teamDTO);
                    Console.WriteLine(textLine);
                }
            }
        }
Ejemplo n.º 2
0
        private static void ReadWriteTeamFile()
        {
            string[] columnValue;
            string   textLine = null;

            using (StreamReader reader = new StreamReader(@"C:\users\mmr\documents\retrosheet\2016 Regular Season\Output\TEAM2016_team"))
            {
                while (!reader.EndOfStream)
                {
                    try
                    {
                        textLine = reader.ReadLine();
                    }
                    catch (Exception e)
                    {
                        // Let the user know what went wrong.
                        Console.WriteLine("The " + @"C:\users\mmr\documents\retrosheet\2016 Regular Season\Output\2016SLN\TEAM2016_team" + " file could not be read:");
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }

                    columnValue = textLine.Split('|');

                    TeamDTO teamDTO = new TeamDTO();


                    teamDTO.RecordID = Guid.NewGuid();
                    teamDTO.TeamID   = columnValue[0];
                    teamDTO.League   = columnValue[1];
                    teamDTO.City     = columnValue[2];
                    teamDTO.Name     = columnValue[3];

                    TeamPersist.CreateTeam(teamDTO);
                    Console.WriteLine(textLine);
                }
            }
        }