Exemplo n.º 1
0
 public List<TimetableItem> GetFullTimetable()
 {
     Parser parser = new Parser();
     List<TimetableItem> list = new List<TimetableItem>();
     list.AddRange(parser.GetTimetableForYear(StudyYear.I1, HalfYear.A));
     list.AddRange(parser.GetTimetableForYear(StudyYear.I1, HalfYear.B));
     list.AddRange(parser.GetTimetableForYear(StudyYear.I2, HalfYear.A));
     list.AddRange(parser.GetTimetableForYear(StudyYear.I2, HalfYear.B));
     list.AddRange(parser.GetTimetableForYear(StudyYear.I3, HalfYear.A));
     list.AddRange(parser.GetTimetableForYear(StudyYear.I3, HalfYear.B));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MIS1));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MIS2));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MLC1));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MLC2));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MOC1));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MOC2));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MSD1));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MSD2));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MSI1));
     list.AddRange(parser.GetTimetableForYear(StudyYear.MSI2));
     return list;
 }
Exemplo n.º 2
0
        public string ConvertToXML(Timetable timetable, List<Subject> availableSubjects)
        {
            var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
            var rootTimetable = new XElement("timetable");

            var monday = new XElement("monday");
            var tuesday = new XElement("tuesday");
            var wednesday = new XElement("wednesday");
            var thursday = new XElement("thursday");
            var friday = new XElement("friday");
            var saturday = new XElement("saturday");
            var sunday = new XElement("sunday");

            foreach (var item in timetable.TimetableItems)
            {
                var timetableSubitem = new XElement("tableItem");
                if (availableSubjects != null)
                {
                    var subjectItem =
                        availableSubjects.Find(delegate(Subject subject) { return subject.Name == item.ClassName; });
                    if (subjectItem != null)
                        timetableSubitem.Add(new XAttribute("id", subjectItem._id.ToString()));
                }
                timetableSubitem.Add(new XElement("startTime", item.StartTime));
                timetableSubitem.Add(new XElement("endTime", item.EndTime));
                timetableSubitem.Add(new XElement("className", item.ClassName));
                timetableSubitem.Add(new XElement("classType", (int)item.TypeOfClass));
                timetableSubitem.Add(new XElement("teacherName", item.Teacher));
                timetableSubitem.Add(new XElement("roomNumber", item.RoomNumber));
                timetableSubitem.Add(new XElement("frequency", (int)item.Frequency));
                timetableSubitem.Add(new XElement("optionalPackage", item.OptionalPackage));

                var groups = new XElement("groups");

                foreach (var groupItem in item.StudyGroups)
                {
                    string group = GetGroupName(groupItem, timetable.Faculty);
                    var parser = new Parser();
                    var fiiGroupItem = parser.GetGroupFromCell(group);
                    var groupElement = new XElement("group");
                    groupElement.Add(new XElement("yearOfStudy", (int)fiiGroupItem.YearOfStudy));
                    groupElement.Add(new XElement("halfYearOfStudy", fiiGroupItem.HalfYearOfStudy));
                    groupElement.Add(new XElement("groupNumber", fiiGroupItem.Number));
                    groups.Add(groupElement);
                }

                timetableSubitem.Add(groups);

                switch (item.Day)
                {
                    case DayOfWeek.Friday:
                        friday.Add(timetableSubitem);
                        break;
                    case DayOfWeek.Monday:
                        monday.Add(timetableSubitem);
                        break;
                    case DayOfWeek.Saturday:
                        saturday.Add(timetableSubitem);
                        break;
                    case DayOfWeek.Sunday:
                        sunday.Add(timetableSubitem);
                        break;
                    case DayOfWeek.Thursday:
                        thursday.Add(timetableSubitem);
                        break;
                    case DayOfWeek.Tuesday:
                        tuesday.Add(timetableSubitem);
                        break;
                    case DayOfWeek.Wednesday:
                        wednesday.Add(timetableSubitem);
                        break;
                }
            }

            rootTimetable.Add(monday);
            rootTimetable.Add(tuesday);
            rootTimetable.Add(wednesday);
            rootTimetable.Add(thursday);
            rootTimetable.Add(friday);
            rootTimetable.Add(saturday);
            rootTimetable.Add(sunday);
            document.Add(rootTimetable);
            return document.ToString();
        }
Exemplo n.º 3
0
        public void ShouldSetTimetableForFii()
        {
            var timetablesBL = new TimetablesBL();
            var usersBL = new UsersBL();
            List<string> list = usersBL.GetGroupsByFaculty("info.uaic.ro");

            foreach (var group in list)
            {
                Timetable timetable = new Timetable();
                timetable.Faculty = "info.uaic.ro";
                timetable.GroupId = group;
                string name = usersBL.GetGroupName(group, "info.uaic.ro");

                    StudyYear year = StudyYear.None;
                    HalfYear halfYear = HalfYear.None;
                    string number = null;

                    if(name.StartsWith("I")) // licenta
                    {
                        if(name.StartsWith("I1")) // lic 1
                        {
                            year = StudyYear.I1;
                        }
                        else if(name.StartsWith("I2")) // lic 2
                        {
                            year = StudyYear.I2;
                        }
                        else if(name.StartsWith("I3")) // lic 3
                        {
                            year = StudyYear.I3;
                        }

                        if (name.Length > 2)
                        {
                            switch (name[2])
                            {
                                case 'A':
                                    halfYear = HalfYear.A;
                                    break;
                                case 'B':
                                    halfYear = HalfYear.B;
                                    break;
                            }
                        }
                        number = name.Substring(3);
                    }
                    else if(name.StartsWith("M")) // master
                    {
                        halfYear = HalfYear.None;
                        if(name.StartsWith("MIS"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MIS1;
                                    break;
                                case '2':
                                    year = StudyYear.MIS2;
                                    break;
                            }
                            number = name[4].ToString();
                        }
                        else if(name.StartsWith("MLC"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MLC1;
                                    break;
                                case '2':
                                    year = StudyYear.MLC2;
                                    break;
                            }
                        }
                        else if (name.StartsWith("MOC"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MOC1;
                                    break;
                                case '2':
                                    year = StudyYear.MOC2;
                                    break;
                            }
                        }
                        else if (name.StartsWith("MSD"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MSD1;
                                    break;
                                case '2':
                                    year = StudyYear.MSD2;
                                    break;
                            }
                        }
                        else if (name.StartsWith("MSI"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MSI1;
                                    break;
                                case '2':
                                    year = StudyYear.MSI2;
                                    break;
                            }
                        }
                    }
                    var parser = new Parser();
                    var timetableForGroup = parser.GetTimetableForGroup(year, halfYear, number);

                timetable.TimetableItems = ConvertToRegularTimetable(timetableForGroup);
                timetablesBL.SaveTimetable(timetable);
            }
        }