//added to provide dynamic initialization for DateList in span rules.
 private void InitSpanDateList()
 {
     string[] parts = RecurrenceRule.Split(new char[] { RecurrenceSupport.RuleDelimiter });
     if (parts.GetLength(0) == 3)
     {
         dateList              = new RecurrenceList();
         dateList.BaseDate     = DateTime.Parse(parts[1], System.Globalization.CultureInfo.InstalledUICulture.DateTimeFormat);
         dateList.TerminalDate = DateTime.Parse(parts[2], System.Globalization.CultureInfo.InstalledUICulture.DateTimeFormat);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Used after the inital load to add additional recurring appointments to the dataprovider.
        /// </summary>
        /// <param name="date">The recurring appointment definition.</param>
        /// <returns>True if dates were added.</returns>
        /// <remarks>Dynamically provide appointments on demand as new dates are exposed.</remarks>
        public bool CheckAndAddIfNeededRecurringAppointments(DateTime date)
        {
            bool ret = false;

            foreach (IRecurringScheduleAppointment item in RecurringList)
            {
                if (item.DateList == null && item.RecurrenceRule != null && item.RecurrenceRule.Length > 0)
                {   //create initial DateList and add any appointments
                    CreateDateListFromItem(item);
                    AddNewRecurringAppointments(item, item.DateList.BaseDate);
                }
                RecurrenceList list = item.DateList;
                if (list != null)
                {
                    //now loop thru and add appointments if needed
                    DateTime date1 = date.CompareTo(list.TerminalDate) > 0 ? list.TerminalDate : date;
                    if (date1.CompareTo(list[list.Count - 1]) > 0)
                    {
                        //need to add
                        int start = list.Count;
                        list.IsValidRecurrence(date1);
                        bool needToSort = false;
                        while (start < list.Count)
                        {
                            date1 = list[start];
                            if (date1 >= item.DateList.BaseDate && date1 <= item.DateList.TerminalDate)
                            {
                                AddAppointmentFromItem(item, date1);
                                needToSort = true;
                            }
                            start++;
                        }
                        if (needToSort)
                        {
                            ResetBaseDate(item);
                            MasterList.SortStartTime();
                            ret = true;
                        }
                    }
                }
            }
            return(ret);
        }