/// <summary>
        ///
        /// </summary>
        /// <param name="tokens"></param>
        /// <returns></returns>
        public TimeAndSiteAndExams Parse(List <string> tokens)
        {
            current             = 0;
            this.tokens         = tokens;
            timeAndSiteAndExams = new TimeAndSiteAndExams();

            bool valid = Program();

            if (valid)
            {
                return(timeAndSiteAndExams);
            }
            else
            {
                throw new Exception();
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputFile">Name and path of the intermediate2 file</param>
        /// <param name="saveFile">Name and path of the goal version file</param>
        /// <param name="save">Detremines whether you want to save the file or not</param>
        /// <returns></returns>
        public static List <GoalVersionOfferedCoursesRow> ConvertFromOfferedCoursesIntermediate2FormToGoalVersionXmlFormat(string inputFile, string saveFile, bool save = true)
        {
            List <OfferedCoursesRow> ocr1;

            DeserializeFromXmlFile(inputFile, out ocr1);

            List <GoalVersionOfferedCoursesRow> gvocr1 = new List <GoalVersionOfferedCoursesRow>();

            foreach (var ocr in ocr1)
            {
                var lst = new TimeAndSitesAndExamTokenizer().Tokenize(ocr.RawStringTimeAndSitesAndExam);
                TimeAndSitesAndExamParser parser = new TimeAndSitesAndExamParser();
                TimeAndSiteAndExams       tasax  = parser.Parse(lst);

                GoalVersionOfferedCoursesRow goalV = new GoalVersionOfferedCoursesRow();
                goalV.Capacity             = ocr.Capacity;
                goalV.CourseTitle          = ocr.CourseTitle;
                goalV.DepartmentId         = ocr.DepartmentId;
                goalV.DepartmentName       = ocr.DepartmentName;
                goalV.Description          = ocr.Description;
                goalV.EducationalGroupId   = ocr.EducationalGroupId;
                goalV.EducationalGroupName = ocr.EducationalGroupName;
                goalV.Gender        = ocr.Gender;
                goalV.Id            = ocr.Id;
                goalV.InWaitingList = ocr.InWaitingList;
                goalV.ProfessorName = ocr.ProfessorName;
                goalV.RawStringTimeAndSitesAndExam = ocr.RawStringTimeAndSitesAndExam.Replace("#", Environment.NewLine);
                goalV.Registered          = ocr.Registered;
                goalV.Status              = ocr.Status;
                goalV.TimeAndSitesAndExam = tasax;
                goalV.Units = ocr.Units;

                gvocr1.Add(goalV);
            }

            if (save)
            {
                SerializeToXmlFile(saveFile, gvocr1);
            }

            return(gvocr1);
        }