コード例 #1
0
    protected void DayPilotCalendar1_OnBeforeEventRecurrence(BeforeEventRecurrenceEventArgs ea)
    {
        List <DateTime> list = new List <DateTime>();

        for (int i = 1; i < 5; i++)
        {
            list.Add(ea.Start.AddHours(i));
        }
        ea.Rule = RecurrenceRule.FromList(list);
    }
コード例 #2
0
        protected override void PerformDataBinding(IEnumerable retrievedData)
        {
            Hashtable hashtable = new Hashtable();

            if (base.DesignMode)
            {
                return;
            }
            base.PerformDataBinding(retrievedData);
            if (retrievedData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(this.DataStartField))
            {
                throw new NullReferenceException("DataStartField property must be specified.");
            }
            if (string.IsNullOrEmpty(this.DataEndField))
            {
                throw new NullReferenceException("DataEndField property must be specified.");
            }
            List <RecurEx>    list  = new List <RecurEx>();
            List <RecurEvent> list2 = new List <RecurEvent>();

            foreach (object current in retrievedData)
            {
                string   propertyValue = DataBinder.GetPropertyValue(current, this.DataStartField, null);
                DateTime dateTime;
                if (!DateTime.TryParse(propertyValue, out dateTime))
                {
                    throw new FormatException(string.Format("Unable to convert '{0}' (from DataStartField column) to DateTime.", propertyValue));
                }
                string   propertyValue2 = DataBinder.GetPropertyValue(current, this.DataEndField, null);
                DateTime dateTime2;
                if (!DateTime.TryParse(propertyValue2, out dateTime2))
                {
                    throw new FormatException(string.Format("Unable to convert '{0}' (from DataEndField column) to DateTime.", propertyValue2));
                }
                DateTime t = dateTime.Date;
                while (t < dateTime2)
                {
                    hashtable[t.ToString("s")] = 1;
                    t = t.AddDays(1.0);
                }
                if (dateTime == dateTime2)
                {
                    hashtable[dateTime.ToString("s")] = 1;
                }
                string text = null;
                if (!string.IsNullOrEmpty(this.DataRecurrenceField))
                {
                    text = DataBinder.GetPropertyValue(current, this.DataRecurrenceField, null);
                }
                if (string.IsNullOrEmpty(text))
                {
                    if (this.BeforeEventRecurrence != null)
                    {
                        if (string.IsNullOrEmpty(this.DataIdField))
                        {
                            throw new ArgumentException("DataIdField is required for recurrent events.");
                        }
                        string   propertyValue3 = DataBinder.GetPropertyValue(current, this.DataIdField, null);
                        string[] array          = null;
                        if (this.ServerTagFields != null)
                        {
                            array = new string[this.ServerTagFields.Length];
                            for (int i = 0; i < this.ServerTagFields.Length; i++)
                            {
                                array[i] = Convert.ToString(DataBinder.GetPropertyValue(current, this.ServerTagFields[i], null));
                            }
                        }
                        BeforeEventRecurrenceEventArgs beforeEventRecurrenceEventArgs = new BeforeEventRecurrenceEventArgs(dateTime, dateTime2, propertyValue3, array, this.ServerTagFields);
                        this.BeforeEventRecurrence(beforeEventRecurrenceEventArgs);
                        if (beforeEventRecurrenceEventArgs.Rule != null)
                        {
                            RecurEvent recurEvent = RecurEvent.FromRule(beforeEventRecurrenceEventArgs.Rule, dateTime, dateTime2, propertyValue3, null);
                            recurEvent.FirstDayOfWeek = this.ResolvedWeekStart;
                            list2.Add(recurEvent);
                        }
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(this.DataIdField))
                    {
                        throw new ArgumentException("DataIdField is required for recurrent events.");
                    }
                    string    propertyValue4 = DataBinder.GetPropertyValue(current, this.DataIdField, null);
                    RecurInfo recurInfo      = RecurInfo.Parse(text, propertyValue4, dateTime, dateTime2, null);
                    switch (recurInfo.Type)
                    {
                    case RecurType.Deleted:
                        list.Add((RecurEx)recurInfo);
                        break;

                    case RecurType.Modified:
                        list.Add((RecurEx)recurInfo);
                        break;

                    case RecurType.Event:
                        list2.Add((RecurEvent)recurInfo);
                        break;
                    }
                    RecurType arg_2B4_0 = recurInfo.Type;
                }
            }
            foreach (RecurEvent current2 in list2)
            {
                foreach (RecurEx current3 in list)
                {
                    current2.AddRecurexSilent(current3);
                }
                foreach (Occurrence current4 in current2.Occurrences(this.VisibleEnd))
                {
                    DateTime t2 = current4.Start.Date;
                    while (t2 < current4.End)
                    {
                        hashtable[t2.ToString("s")] = 1;
                        t2 = t2.AddDays(1.0);
                    }
                    if (current4.Start == current4.End)
                    {
                        hashtable[current4.Start.ToString("s")] = 1;
                    }
                }
            }
            this.Items = hashtable;
        }