Exemplo n.º 1
0
        }        //Count

        /// <summary>
        /// This class returns an array of holidays contained in the current list.
        /// Note: This array is a copy of what the list contains and thus any
        /// changes made in the array once retrieved will not be reflected in the
        /// list unless the modify holiday method is used when a holiday is changed.
        /// </summary>
        /// <returns>
        /// An array of Holidays that the current list contains.
        /// </returns>
        /// Revision History
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 06/02/06 ach N/A	 N/A	Creation of Class
        public CHoliday[] GetHolidays()
        {
            // Local Variables
            try
            {
                XmlNodeList holidayListNodes = m_xmlnodeCurrentList.ChildNodes;
                CHoliday[]  holidayList      = new CHoliday[holidayListNodes.Count - 2];
                int         intCount         = 0;

                // Convert each holiday from an xml node
                // to a CHoliday and add to holidayList
                foreach (XmlNode holiday in holidayListNodes)
                {
                    if (holiday.Name == "Holiday")
                    {
                        holidayList[intCount] = XmlToHoliday(holiday);
                        intCount++;
                    }
                }

                return(holidayList);
            }
            catch
            {
                return(null);
            }
        }//GetHolidays
Exemplo n.º 2
0
        }        //AddHoliday

        /// <summary>
        /// This method takes a Holiday Object and creates a
        /// corresponding xml node.
        /// </summary>
        /// <param name="Holiday">
        /// Represents the Holiday who information will be entered
        /// into a xml node.
        /// </param>
        /// <returns>
        /// An xml node representing the Holiday.
        /// </returns>
        /// Revision History
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 06/02/06 ach N/A	 N/A	Creation of Class
        private XmlNode HolidayToXml(CHoliday Holiday)
        {
            // XmlNode Representation of HolidayToAdd
            XmlNode newHol = m_xmldomColl.CreateElement("Holiday");

            // Add the Holiday ID
            newHol.AppendChild(m_xmldomColl.CreateElement("HolidayID"));
            newHol.LastChild.InnerText = Holiday.ID.ToString();

            // Add the Holiday Name
            newHol.AppendChild(m_xmldomColl.CreateElement("Name"));
            newHol.LastChild.InnerText = Holiday.Name;

            // Add the Holiday Day Type
            newHol.AppendChild(m_xmldomColl.CreateElement("HolidayDayTypeIndex"));
            newHol.LastChild.InnerText = Holiday.Index.ToString();

            // Add the Strategy
            newHol.AppendChild(m_xmldomColl.CreateElement("Strategy"));
            XmlNode strat = newHol.LastChild;

            // Add the Fixed Holiday to Strategy
            strat.AppendChild(m_xmldomColl.CreateElement("FixedHoliday"));
            XmlNode fixedHol = strat.LastChild;

            // Add the Month to Fixed Holiday
            fixedHol.AppendChild(m_xmldomColl.CreateElement("Month"));
            fixedHol.LastChild.InnerText = Holiday.Date.Month.ToString();

            // Add the Day to Fixed Holiday
            fixedHol.AppendChild(m_xmldomColl.CreateElement("Day"));
            fixedHol.LastChild.InnerText = Holiday.Date.Day.ToString();

            // Add the Frequency
            newHol.AppendChild(m_xmldomColl.CreateElement("Frequency"));
            XmlNode frequency = newHol.LastChild;

            // If the Holiday occurs in a single year add to Frequency
            if (eFrequency.SINGLE == Holiday.Frequency)
            {
                frequency.AppendChild(m_xmldomColl.CreateElement("SingleYear"));
                frequency.LastChild.InnerText = Holiday.Date.Year.ToString();
            }
            // Else the holiday occurs every year add it to Frequency
            else
            {
                frequency.AppendChild(m_xmldomColl.CreateElement("EveryYear"));
                XmlAttribute moveSat = m_xmldomColl.CreateAttribute("MoveSat");
                moveSat.Value = Holiday.MoveSaturday.ToString();
                XmlAttribute moveSun = m_xmldomColl.CreateAttribute("MoveSun");
                moveSun.Value = Holiday.MoveSunday.ToString();
                frequency.LastChild.Attributes.SetNamedItem(moveSat);
                frequency.LastChild.Attributes.SetNamedItem(moveSun);
            }

            return(newHol);
        }        //HolidayToXml
Exemplo n.º 3
0
        }//EmptyList

        /// <summary>
        /// This class adds the holiday to the currently accessed holiday
        /// list.
        /// </summary>
        /// <param name="HolidayToAdd">
        /// Represents a Holiday type to be added to the currently accessed list.
        /// </param>
        /// Revision History
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 06/02/06 ach N/A	 N/A	Creation of Class
        public void AddHoliday(CHoliday HolidayToAdd)
        {
            // Put the Holiday into an Xml Node
            XmlNode newHol = HolidayToXml(HolidayToAdd);

            // Use the AppendChild method to add the Holiday to current list
            m_xmlnodeCurrentList.AppendChild(newHol);

            m_xmlnodeCurrentHoliday = m_xmlnodeCurrentList.LastChild;

            // Increment the Next ID
            m_intNextID++;
        }        //AddHoliday