コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            mbl bl1 = new mbl();

            mcl.Films films = bl1.GetFilms(@"C:\Users\C855-1G_\Documents\Visual Studio 2015\Projects\MyNovusProject\MyNovusProject\TestData.csv");

            bl1 = null;
        }
コード例 #2
0
        //--------------------------------------------------------------------- CSV
        public mcl.Films GetCsvData(string CsvPath)
        {
            mcl.Films films = new mcl.Films();

            //-- FilmID = csv[0];
            //-- FilmName = csv[1];
            //-- ImdbRating = csv[2];
            //-- FilmYear = csv[7];
            //-- DirectorID = csv[3];
            //-- DirectorName = csv[4];
            //-- ActorID = csv[5];
            //-- ActorName = csv[6];

            using (CsvReader csv = new CsvReader(new StreamReader(CsvPath), true))
            {
                int fieldCount = csv.FieldCount;

                string[] headers = csv.GetFieldHeaders();
                while (csv.ReadNextRecord())
                {
                    if (films.Any(item => item.FilmId == csv[csvMovies.FilmID]))
                    {
                        mcl.Film tmpFilm = films.Find(item => item.FilmId == csv[csvMovies.FilmID]);
                        if (tmpFilm.Directors.Any(item => item.PersonId == csv[csvMovies.DirectorID]))
                        {
                        }
                        else
                        {
                            mcl.Director director = getDirectorFromCSV(csv);
                            tmpFilm.Directors.Add(director);
                        }
                        if (tmpFilm.Actors.Any(item => item.PersonId == csv[csvMovies.ActorID]))
                        {
                        }
                        else
                        {
                            mcl.Actor actor = getActorFromCSV(csv);
                            tmpFilm.Actors.Add(actor);
                        }
                    }
                    else
                    {
                        mcl.Film film = getFilmFromCSV(csv);
                        films.Add(film);
                    }
                }
            }
            return(films);
        }