Example #1
0
        /* public void LoadData(string fileName)
         * create XmlReaderSettings settings
         * set settings.IgnoreComments to true
         * set settings.IgnoreWhiteSpace to true
         * try
         *    create XmlReader reader(fileName,settings)
         *    if(reader.ReadToDescendent("PayPeriod")
         *       do
         *           PayPeriod newPayPeriod
         *           DateTime start = reader.ReadElementContentAsDateTime
         *           DateTime end = reader.ReadElementContentAsDateTime
         *           newPayPeriod = new PayPeriod(start,end)
         *
         *           if(reader.ReadToDescendent("Shift")
         *             do
         *                DateTime start = reader.ReadElementContentAsDateTime
         *                DateTime end = reader.ReadElementContentAsDateTime
         *
         *             while reader.ReadToSibling("Shift")
         *
         *       while reader.ReadToSibling("PayPeriod")
         */
        public void LoadData(string fileName)
        {
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreComments = true;
            settings.IgnoreWhitespace = true;
            try
            {
                XmlReader reader = XmlReader.Create(fileName, settings);
                try
                {
                    List.Clear();
                    if (reader.ReadToDescendant("PayPeriod"))
                    {
                        do
                        {
                            reader.ReadStartElement("PayPeriod");
                            DateTime start = DateTime.Parse(reader.ReadElementContentAsString());
                            DateTime end = DateTime.Parse(reader.ReadElementContentAsString());
                            PayPeriod newPayPeriod = new PayPeriod(start, end);
                            Add(newPayPeriod);
                            if (reader.Name == "Shift")
                            {
                                do
                                {
                                    reader.ReadStartElement("Shift");
                                    DateTime sStart = DateTime.Parse(reader.ReadElementContentAsString());
                                    DateTime sEnd = DateTime.Parse(reader.ReadElementContentAsString());
                                    Shift newShift = new Shift(sStart, sEnd);
                                    newPayPeriod.Add(newShift);
                                    reader.ReadEndElement();
                                }
                                while (reader.Name =="Shift");
                            }
                            reader.ReadEndElement();
                        }
                        while (reader.Name == "PayPeriod");
                    }
                }
                catch
                {
                    throw new ApplicationException("Error reading file");
                }
                finally
                {
                    reader.Close();
                }

            }
            catch
            {

            }
        }
Example #2
0
 public void Insert(int index,Shift shift)
 {
     List.Insert(index, shift);
 }
Example #3
0
 public void Remove(Shift rShift)
 {
     List.Remove(rShift);
 }
Example #4
0
 public void Add(Shift newShift)
 {
     List.Add(newShift);
 }