Example #1
0
        public Appointment Parse(IList <string> stringValue, DateTime start, DateTime end)
        {
            iCalendarEntryParser    parser         = new iCalendarEntryParser();
            iCalendarEntryContainer entryContainer = parser.ParseString(String.Join("\n", stringValue.ToArray()));

            this.rule = entryContainer.GetPropertyValue <VRecurrenceRule>(RecurrenceRuleProperty.TokenName);
            if (this.rule == null)
            {
                return(null);
            }

            Appointment pattern = Storage.CreateAppointment(AppointmentType.Pattern);

            pattern.Start = start;
            pattern.End   = end;
            iCalendarHelper.ApplyRecurrenceInfo(pattern.RecurrenceInfo, start, rule);
            ExceptionDateTimesProperty exceptionProperty = entryContainer.GetProperty(ExceptionDateTimesProperty.TokenName) as ExceptionDateTimesProperty;

            if (exceptionProperty != null)
            {
                exceptionProperty.ApplyTimeZone();
                OccurrenceCalculator calculator = OccurrenceCalculator.CreateInstance(pattern.RecurrenceInfo);
                foreach (var item in exceptionProperty.Values)
                {
                    int indx = calculator.FindOccurrenceIndex(item, pattern);
                    if (indx < 0)
                    {
                        continue;
                    }
                    pattern.CreateException(AppointmentType.DeletedOccurrence, indx);
                }
            }
            return(pattern);
        }
Example #2
0
 public RecurrencePatternParser(SchedulerStorage storage)
 {
     this.storage = storage;
     this.rule    = null;
 }