Ejemplo n.º 1
0
        /*! loads the holidays
         */
        private static void LoadHolidays()
        {
            string id = " ";
            try
            {

                XmlDocument doc = new XmlDocument();
                doc.Load(AppSettings.getDataPath() + "\\holidays.xml");
                XmlElement root = doc.DocumentElement;

                XmlNodeList holidaysList = root.SelectNodes("//holiday");

                foreach (XmlElement element in holidaysList)
                {

                    string uid = element.Attributes["uid"].Value;
                    string name = element.Attributes["name"].Value;

                    id = name;

                    Holiday.HolidayType type = (Holiday.HolidayType)Enum.Parse(typeof(Holiday.HolidayType), element.Attributes["type"].Value);
                    Holiday.TravelType traveltype = (Holiday.TravelType)Enum.Parse(typeof(Holiday.TravelType), element.Attributes["holidaytype"].Value);

                    List<Country> countries = new List<Country>();

                    XmlNodeList countriesList = element.SelectNodes("observers/observer");

                    foreach (XmlElement eCountry in countriesList)
                        countries.Add(Countries.GetCountry(eCountry.Attributes["country"].Value));

                    XmlElement dateElement = (XmlElement)element.SelectSingleNode("observationdate");

                    if (type == Holiday.HolidayType.Fixed_Date)
                    {

                        int month = Convert.ToInt16(dateElement.Attributes["month"].Value);
                        int day = Convert.ToInt16(dateElement.Attributes["day"].Value);

                        DateTime date = new DateTime(1900, month, day);

                        foreach (Country country in countries)
                        {
                            Holiday holiday = new Holiday(root.Name, uid, type, name, traveltype, country);
                            holiday.Date = date;

                            Holidays.AddHoliday(holiday);
                        }

                    }
                    if (type == Holiday.HolidayType.Fixed_Month)
                    {
                        int month = Convert.ToInt16(dateElement.Attributes["month"].Value);

                        foreach (Country country in countries)
                        {
                            Holiday holiday = new Holiday(root.Name, uid, type, name, traveltype, country);
                            holiday.Month = month;

                            Holidays.AddHoliday(holiday);
                        }
                    }
                    if (type == Holiday.HolidayType.Fixed_Week)
                    {
                        int week = Convert.ToInt16(dateElement.Attributes["week"].Value);

                        foreach (Country country in countries)
                        {
                            Holiday holiday = new Holiday(root.Name, uid, type, name, traveltype, country);
                            holiday.Week = week;

                            Holidays.AddHoliday(holiday);
                        }

                    }
                    if (type == Holiday.HolidayType.Non_Fixed_Date)
                    {
                        int month = Convert.ToInt16(dateElement.Attributes["month"].Value);
                        int week = Convert.ToInt16(dateElement.Attributes["week"].Value);
                        DayOfWeek day = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), dateElement.Attributes["dayofweek"].Value);

                        foreach (Country country in countries)
                        {
                            Holiday holiday = new Holiday(root.Name, uid, type, name, traveltype, country);
                            holiday.Month = month;
                            holiday.Week = week;
                            holiday.Day = day;

                            Holidays.AddHoliday(holiday);
                        }
                    }

                    if (element.SelectSingleNode("translations") != null)
                        Translator.GetInstance().addTranslation(root.Name, element.Attributes["uid"].Value, element.SelectSingleNode("translations"));

                }
            }
            catch (Exception e)
            {
                string s = e.ToString();
                s = id;
            }
        }
Ejemplo n.º 2
0
 public HolidayYearEvent(DateTime date, Holiday holiday, int length)
 {
     this.Date = date;
     this.Holiday = holiday;
     this.Length = length;
 }
Ejemplo n.º 3
0
 //adds a holiday to the list
 public static void AddHoliday(Holiday holiday)
 {
     holidays.Add(holiday);
 }
Ejemplo n.º 4
0
 //adds a holiday to the list
 public static void AddHoliday(Holiday holiday)
 {
     holidays.Add(holiday);
 }
Ejemplo n.º 5
0
 }                               //in days
 public HolidayYearEvent(DateTime date, Holiday holiday, int length)
 {
     this.Date    = date;
     this.Holiday = holiday;
     this.Length  = length;
 }