Esempio n. 1
0
        }//end method

        //Overload AddScheduleEvent
        public void AddScheduleEvent(DateTime startTime, DateTime endTime, string title,
                                     string location, string description, ScheduleEvent.Period howOften,
                                     DateTime endReapetedEvent)
        {
            List <ScheduleEvent> temp;
            ScheduleEvent        se = new ScheduleEvent(startTime, endTime, title, location, description, howOften, endReapetedEvent, out temp);

            AddScheduleEvents(temp);
        }//end method
Esempio n. 2
0
        }//end method

        //Remove the following events in the series method
        public void RemoveFollowingScheduleEventsInSeries(ScheduleEvent scheduleEvent)
        {
            ScheduleEvent nextScheduleEvent;

            while (scheduleEvent != null)
            {
                nextScheduleEvent = scheduleEvent.Next;
                RemoveScheduleEvent(scheduleEvent);
                scheduleEvent = nextScheduleEvent;
            }
        }//end method
Esempio n. 3
0
        }//end method

        //Service method
        private void AddToDictionary(ScheduleEvent scheduleEvent)
        {
            if (days.ContainsKey(scheduleEvent.StartTime.Date))
            {
                this.days[scheduleEvent.StartTime.Date].Add(scheduleEvent);
                this.days[scheduleEvent.StartTime.Date].Sort();
            }
            else
            {
                List <ScheduleEvent> day = new List <ScheduleEvent>();
                day.Add(scheduleEvent);
                day.Sort();
                days.Add(scheduleEvent.StartTime.Date, day);
            }
        }//end method
Esempio n. 4
0
        }//end method

        //AddScheduleEvent method
        public void AddScheduleEvent(ScheduleEvent scheduleEvent)
        {
            if (scheduleEvent.EndTime - scheduleEvent.StartTime < TimeSpan.FromMinutes(25))
            {
                throw new DateMissMatchException();
            }
            else if (scheduleEvent.StartTime.Date == scheduleEvent.EndTime.Date)
            {
                AddToDictionary(scheduleEvent);
            }
            else
            {
                List <ScheduleEvent> dailyReapetedEvents;
                DateTime             endTime = new DateTime(scheduleEvent.StartTime.Year, scheduleEvent.StartTime.Month, scheduleEvent.StartTime.Day, 23, 59, 59);
                ScheduleEvent        se      = new ScheduleEvent(scheduleEvent.StartTime, endTime,
                                                                 scheduleEvent.Title, scheduleEvent.Location,
                                                                 scheduleEvent.Description, ScheduleEvent.Period.Daily, scheduleEvent.EndTime.Date, out dailyReapetedEvents);
                ScheduleEvent nextScheduleEvent = dailyReapetedEvents[0];

                ScheduleEvent lasScheduleEvent = dailyReapetedEvents[dailyReapetedEvents.Count - 1];

                lasScheduleEvent.EndTime = scheduleEvent.EndTime;

                ScheduleEvent firstScheduleEvent = nextScheduleEvent;

                DateTime firstScheduleEventStartTime = nextScheduleEvent.StartTime.Date;

                while (nextScheduleEvent != null)
                {
                    //An event that spreads over more than one day is not a recurring event
                    nextScheduleEvent.HowOften         = ScheduleEvent.Period.None;
                    nextScheduleEvent.EndReapetedEvent = firstScheduleEventStartTime;

                    if (nextScheduleEvent != firstScheduleEvent)
                    {
                        DateTime startTime = nextScheduleEvent.StartTime;
                        nextScheduleEvent.StartTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, 00, 00, 0);
                    }
                    AddToDictionary(nextScheduleEvent);
                    nextScheduleEvent = nextScheduleEvent.Next;
                }
            }
        }//end method
Esempio n. 5
0
        }//end method

        //Remove Schedule Event method
        public void RemoveScheduleEvent(ScheduleEvent scheduleEvent)
        {
            if (!days.ContainsKey(scheduleEvent.StartTime.Date))
            {
                throw new KeyNotFoundException();
            }

            //fix references
            if (scheduleEvent.Previous != null)
            {
                scheduleEvent.Previous.Next = scheduleEvent.Next;
            }

            if (scheduleEvent.Next != null)
            {
                scheduleEvent.Next.Previous = scheduleEvent.Previous;
            }

            //remove from dictionary
            this.days[scheduleEvent.StartTime.Date].Remove(scheduleEvent);
            days[scheduleEvent.StartTime.Date].Sort();
        }//end method
Esempio n. 6
0
        }//end method

        //Remove the all schedule events in the Series
        public void RemoveAllScheduleEventsInSeries(ScheduleEvent scheduleEvent)
        {
            //remove all subsequent events starting with the first event, i.e all series
            RemoveFollowingScheduleEventsInSeries(scheduleEvent.First);
        }//end method