Esempio n. 1
0
 public object Clone()
 {
     WorkDay retVal = new WorkDay();
     retVal.Start = this.Start;
     retVal.End = this.End;
     retVal.WorkingHours = (WorkHours)this.WorkingHours.Clone();
     return retVal;
 }
Esempio n. 2
0
 /// <summary>
 /// Sets the week end days.
 /// </summary>
 /// <param name="day">The day.</param>
 public void SetWeekEndDays(WorkDay day)
 {
     for (int i = 0; i < CalendarSettings.DayInWeek; i++)
     {
         if (IsWeekEnd(i) == true)
         {
             WeekDays[i] = day;
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Loads the calendar.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        private void Initialize(string xmlCalendar)
        {
            XmlSerializer xmlsz = new XmlSerializer(typeof(CalendarType));
            using (MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(xmlCalendar)))
            {
                CalendarType calendarType = (CalendarType)xmlsz.Deserialize(ms);
                _MSPDIcalendar = calendarType;

                //Nothing todo
                if (calendarType.WeekDays == null)
                    return;

                foreach (CalendarWeekDay weekDay in calendarType.WeekDays)
                {
                    WorkDay workDay = new WorkDay();

                    int intervalNum = 0;
                    if (weekDay.DayWorking == true)
                    {
                        foreach (CalendarWeekDayWorkingTimesWorkingTime workingTimes in weekDay.WorkingTimes.Items)
                        {
                            workDay.WorkingHours.AddInterval(intervalNum++, CalendarHelper.Tick2Milis(workingTimes.FromTime.Ticks),
                                                  CalendarHelper.Tick2Milis(workingTimes.ToTime.Ticks));
                        }
                    }

                    if (weekDay.DayType == CalendarWeekDayDayType.Exception)
                    {
                        workDay.Start = CalendarHelper.Tick2Milis(weekDay.TimePeriod.FromDate.Ticks);
                        workDay.End = CalendarHelper.Tick2Milis(weekDay.TimePeriod.ToDate.Ticks);
                        this.DayException.Add(workDay);
                        continue;
                    }
                    //Set week work day
                    this.WorkingWeek.WeekDays[(int)weekDay.DayType - 1] = workDay;
                }

            }
        }