public override void parse(CsvReader csv)
        {
            while (csv.ReadNextRecord())
            {
                //Rewind blank lines to find Cinema name
                int index = FieldsParser.OneFieldCheck(csv);
                if (index > -1)
                {
                    if (cinema == null)
                    {
                        cinema = new Cinema();
                        cinema.Name = csv[index];

                        //Rewind blank lines to find date
                        for (int i = 0; i<5; i++)
                        {
                            csv.ReadNextRecord();
                            if ((index = FieldsParser.OneFieldCheck(csv)) >= 0)
                            {
                                if (FieldsParser.GrandParseDate(csv[index], out StartDate))
                                {
                                    break;
                                }
                            }
                        }
                    }

                    for (int i = 0; i < 10; i++)
                    {
                        csv.ReadNextRecord();
                        if ((csv[0] == "CIN" || csv[0] == "CINE"))
                            break;
                    }

                    //Parse Movies
                    while (csv.ReadNextRecord())
                    {
                        if (csv[0] != "" && csv[1] != "")
                        {
                            movie = new Movie();
                            movie.Tittle = csv[1];
                            //movie.TimeInMinutes = FieldsParser.ParseMovieDuration(csv[2]);
                            movie.Rating = csv[2];

                            for (int i = 3; i < csv.FieldCount; i++)
                            {
                                if (csv[i] != "")
                                {
                                    if ((index = FieldsParser.ParseMovieStartTime(csv[i], out CurrentDate)) >= 0)
                                    {
                                        //Add all days of week
                                        for (double day = 0; day < 7; day++)
                                        {

                                            SheduleNoteDate NoteDate = new SheduleNoteDate();
                                            NoteDate.DateTimeStart = StartDate + new TimeSpan(CurrentDate.Hour, CurrentDate.Minute, CurrentDate.Second);

                                            if (CurrentDate.Hour < 3)
                                                NoteDate.DateTimeStart = NoteDate.DateTimeStart.AddDays(1);

                                            NoteDate.DateTimeStart = NoteDate.DateTimeStart.AddDays(day);

                                            NoteDate.Hall = FieldsParser.HallChoice(csv[0]);

                                            movie.SheduleNoteDates.Add(NoteDate);

                                        }
                                    }

                                }
                            }

                            cinema.Movies.Add(movie);
                        }
                    }
                }
            }
            Program.CinemaList.Add(cinema);
        }
Example #2
0
        public override void parse(CsvReader csv)
        {
            while (csv.ReadNextRecord())
            {
                //Rewind blank lines to find Cinema name
                int index = FieldsParser.OneFieldCheck(csv);
                if (index > -1)
                {
                    if (cinema == null)
                    {
                        cinema = new Cinema();
                        cinema.Name = csv[index];

                        //Rewind blank lines to find date
                        for (int i = 0; i<5; i++)
                        {
                            csv.ReadNextRecord();
                            if ((index = FieldsParser.OneFieldCheck(csv)) >= 0)
                            {
                                if (FieldsParser.GrandParseDate(csv[index], out StartDate))
                                {
                                    break;
                                }
                            }
                        }
                    }

                    for (int i = 0; i < 10; i++)
                    {
                        csv.ReadNextRecord();
                        if ((csv[0] == "CIN" || csv[0] == "CINE"))
                            break;
                    }

                    //Parse Movies
                    while (csv.ReadNextRecord())
                    {
                        if (csv[1] != "" && csv[2] != "")
                        {
                            movie = new Movie();
                            movie.Tittle = csv[1];
                            movie.TimeInMinutes = FieldsParser.ParseMovieDuration(csv[2]);
                            movie.Rating = csv[3];

                            //Filling of SheduleNoteDates
                            int Factor = 0;
                            int LastHour = 0;
                            bool MidnightFlag = false;

                            for (int i = 4; i < csv.FieldCount; i++)
                            {
                                if (csv[i] != "")
                                {
                                    if ((index = FieldsParser.ParseMovieStartTime(csv[i], out CurrentDate)) == 0)
                                    {
                                        if ((MidnightFlag == true) && (CurrentDate.Hour == 12))
                                        {
                                            Factor++;
                                        }

                                        if (CurrentDate.Hour < LastHour)
                                        {
                                            MidnightFlag = true;

                                            Factor++;
                                        }

                                        //If the movie starts in the afternoon
                                        if (i == 6 && csv[5] == "" && CurrentDate.Hour < 6)
                                            Factor++;

                                        LastHour = CurrentDate.Hour;
                                        CurrentDate = CurrentDate.AddHours(Factor * 12);

                                    }
                                    if (index >= 0)
                                    {
                                        //Add all days of week
                                        for (double day = 0; day < 7; day++)
                                        {

                                            SheduleNoteDate NoteDate = new SheduleNoteDate();
                                            NoteDate.DateTimeStart = StartDate + new TimeSpan(CurrentDate.Hour, CurrentDate.Minute, CurrentDate.Second);

                                            if (Factor == 2)
                                                NoteDate.DateTimeStart = NoteDate.DateTimeStart.AddHours(12);
                                            if (csv[5] == "" && csv[6] == "")
                                                NoteDate.DateTimeStart = NoteDate.DateTimeStart.AddHours(12);

                                            NoteDate.DateTimeStart = NoteDate.DateTimeStart.AddDays(day);

                                            NoteDate.Hall = FieldsParser.HallChoice(csv[0]);

                                            movie.SheduleNoteDates.Add(NoteDate);

                                        }
                                    }
                                }
                            }

                            cinema.Movies.Add(movie);
                        }
                        if ((index = FieldsParser.OneFieldCheck(csv)) > 0)
                        {
                            Program.CinemaList.Add(cinema);
                            cinema = new Cinema();
                            cinema.Name = csv[index];
                            break;
                        }
                    }
                }
            }
            Program.CinemaList.Add(cinema);
        }
Example #3
0
        int DayCount; //Counter of first row days in VOX file.. Some "Thursday to Saturday" = 3

        #endregion Fields

        #region Methods

        public override void parse(CsvReader csv)
        {
            int index = 0;

            string LastFilm = "";

            string CurrentHall = "";

            int HallCredit = 0;

            //Parse cinema
            for (int i = 0; i < 8; i++)
            {
                csv.ReadNextRecord();

                index = FieldsParser.OneFieldCheck(csv);
                if (index > -1)
                {
                    cinema = new Cinema();
                    cinema.Name = csv[index];
                    break;
                }
            }

            //Parse date
            for (int i = 0; i < 5; i++)
            {
                csv.ReadNextRecord();
                if ((index = FieldsParser.OneFieldCheck(csv)) >= 0)
                {
                    if (FieldsParser.VoxParseDate(csv[index], out StartDate))
                    {
                        break;
                    }
                }
            }

            //Parse day of weeks
            for (int i = 0; i < 2; i++)
            {
                csv.ReadNextRecord();
                for (int j = 0; j < csv.FieldCount; j++)
                {
                    DayCount = FieldsParser.DifferenceDayOfWeek(csv[j]);
                    if (DayCount >= 0)
                        break;
                }
                if (DayCount >= 0)
                        break;
            }

            //Skip empty lines
            for (int i = 0; i < 2; i++)
            {
                csv.ReadNextRecord();
                if (String.Compare("Cinema", csv[0], true) == 0)
                    break;
            }

            //Parse movies
            while (csv.ReadNextRecord())
            {
                for (int i = 0; i <= 1; i++)
                {
                    if (csv[1 + i * 6] != "" && csv[2 + i * 6] != "")
                    {

                        if (LastFilm != csv[1 + i * 6])
                        {
                            //This Movie is not
                            if (!cinema.Movies.Exists(temp_cinema => temp_cinema.Tittle == csv[1 + i * 6]))
                            {
                                movie = new Movie();

                                movie.Tittle = csv[1 + i * 6];

                                movie.Rating = csv[4 + i * 6];

                                movie.TimeInMinutes = (FieldsParser.ParseMovieDuration(csv[3 + i * 6]) - FieldsParser.ParseMovieDuration(csv[2 + i * 6]) + 1440) % 1440;

                                cinema.Movies.Add(movie);
                            }
                            //This Movie is exist
                            else
                            {
                                movie = cinema.Movies.Find(temp_cinema => temp_cinema.Tittle == csv[1 + i * 6]);
                            }

                            if (HallCredit <= 0)
                                CurrentHall = "";

                        }

                        if (CurrentHall == "")
                        {
                            CurrentHall = FieldsParser.HallChoice(csv[0]);

                            if (CurrentHall != "")
                                HallCredit = 8;
                        }

                        // Parse SheduleNoteDates
                        for (int k = (DayCount + 1) * i; k <= DayCount + i * (6 - DayCount); k++)
                        {
                            if ((FieldsParser.ParseMovieStartTime(csv[2 + i * 6], out CurrentDate)) == 1)
                            {
                                SheduleNoteDate NoteDate = new SheduleNoteDate();
                                NoteDate.DateTimeStart = StartDate.AddHours(CurrentDate.Hour).AddMinutes(CurrentDate.Minute).AddDays(k + FieldsParser.IsMidnight(CurrentDate.Hour));
                                NoteDate.Hall = CurrentHall;
                                movie.SheduleNoteDates.Add(NoteDate);

                            }
                        }

                        LastFilm = csv[1 + i * 6];
                    }
                }

                HallCredit--;
            }

            Program.CinemaList.Add(cinema);
        }
Example #4
0
        public override void parse(CsvReader csv)
        {
            string CurrentHall = "";

            while (csv.ReadNextRecord())
            {
                //Rewind blank lines to find Cinema name
                int index = FieldsParser.OneFieldCheck(csv);
                if (index > -1)
                {
                    if (cinema == null)
                    {
                        cinema = new Cinema();
                        cinema.Name = csv[index];

                        //Rewind blank lines to find date
                        for (int i = 0; i<5; i++)
                        {
                            csv.ReadNextRecord();
                            if ((index = FieldsParser.OneFieldCheck(csv)) >= 0)
                            {
                                if (FieldsParser.RoyalParseDate(csv[index], out StartDate))
                                {
                                    break;
                                }
                            }
                        }
                    }

                    //Parse Movies
                    while (csv.ReadNextRecord())
                    {
                        if (csv[0] != "" && csv[1] == "" && csv[2] != "")
                        {
                            movie = new Movie();

                            //Hall choice
                            CurrentHall = FieldsParser.HallChoice(csv[0]);

                            csv.ReadNextRecord();

                            movie.Tittle = csv[0];

                            //Filling of SheduleNoteDates
                            for (int k = 0; k < 7; k++)
                            {
                                for (int i = 0; i < 7; i++)
                                {
                                    if ((FieldsParser.ParseMovieStartTime(csv[k + 2], out CurrentDate)) == 1)
                                    {
                                        SheduleNoteDate NoteDate = new SheduleNoteDate();
                                        NoteDate.DateTimeStart = StartDate.AddHours(CurrentDate.Hour).AddMinutes(CurrentDate.Minute).AddDays(i + FieldsParser.IsMidnight(CurrentDate.Hour));
                                        NoteDate.Hall = CurrentHall;
                                        movie.SheduleNoteDates.Add(NoteDate);
                                    }
                                }
                            }
                            //Skip not needed lines
                            csv.ReadNextRecord();
                            csv.ReadNextRecord();
                            csv.ReadNextRecord();

                            //Parse movie duration
                            for (int k = 2; k < csv.FieldCount; k++)
                            {
                                if (csv[k] == "")
                                    continue;

                                movie.TimeInMinutes = FieldsParser.ParseMovieDuration(csv[k]);

                                if (movie.TimeInMinutes != 0)
                                    break;

                            }
                            //Parse rating
                            movie.Rating = csv[0];

                            cinema.Movies.Add(movie);
                        }
                        if ((index = FieldsParser.OneFieldCheck(csv)) > 0)
                        {
                            Program.CinemaList.Add(cinema);
                            cinema = new Cinema();
                            cinema.Name = csv[index];
                            break;
                        }
                    }
                }
            }
            Program.CinemaList.Add(cinema);
        }