Load() public method

Reloads xml file, parses and initializes properties which holds base data of the application. This method should be used for refreshing the model after updating thxml with timetable.
public Load ( string xmlPath ) : bool
xmlPath string Path to the source xml file.
return bool
Beispiel #1
0
        public bool LoadDatabase()
        {
            bool result = false;

            TimetableArchive = new List<OneXMLTimetable>();

            //load archive timetables

            List<string> paths = xmlFilePaths();
            foreach (string path in paths)
            {
                if(!path.EndsWith("-info.xml"))
                {
                    OneXMLTimetable newTT = new OneXMLTimetable();
                    if (newTT.Load(path))
                    {
                        newTT.m_timetableInfo = new TimetableInfo(path, TimetableArchive.Count.ToString());
                        TimetableArchive.Add(newTT);
                        result = true;
                    }
                }
            }

            //get most recent timetable accordint to creation date
            OneXMLTimetable mostRecent = TimetableArchive.OrderByDescending(t => t.m_timetableInfo.SemesterStart).OrderByDescending(t => t.m_timetableInfo.Created).First();
            this.Copy(mostRecent);

            return result;
        }