private void ImportEventsIntoExistingCalendar(IICalendarCollection collection, int calendar_id)
        {
            var cctrl = new CalendarApiController();
            var ectrl = new EventApiController();
            var rectrl = new REventApiController();

            //loop through calendar in collection
            foreach (var cal in collection)
            {
                //loop through events in calendar
                foreach (var e in cal.Events)
                {
                    //check if it is an reccuring event
                    if (e.RecurrenceRules.Count > 0)
                    {
                        var revent = new RecurringEvent(){ allDay = e.IsAllDay, title = e.Summary, start = e.Start.Date, end = e.Start.Date, calendarId = calendar_id, categories = String.Join(",", e.Categories), Id = 0};
                        revent.monthly_interval = (int)MonthlyIntervalEnum.First;
                        RecurrencePattern rp = (RecurrencePattern)e.RecurrenceRules[0];
                        switch (rp.Frequency)
                        {
                            case FrequencyType.Daily:
                                {
                                    revent.frequency = (int)FrequencyTypeEnum.Daily;
                                    break;
                                }
                            case FrequencyType.Monthly:
                                {
                                    revent.frequency = (int)FrequencyTypeEnum.Monthly;
                                    break;
                                }
                            case FrequencyType.Weekly:
                                {
                                    revent.frequency = (int)FrequencyTypeEnum.Weekly;
                                    break;
                                }
                            default:
                                {
                                    revent.frequency = (int)FrequencyTypeEnum.Monthly;
                                    break;
                                }
                        }
                        switch(e.Start.DayOfWeek) {
                            case DayOfWeek.Monday: {
                                revent.day = (int)DayOfWeekEnum.Mon;
                                break;
                            }
                            case DayOfWeek.Tuesday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Tue;
                                    break;
                                }
                            case DayOfWeek.Wednesday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Wed;
                                    break;
                                }
                            case DayOfWeek.Thursday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Thu;
                                    break;
                                }
                            case DayOfWeek.Friday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Fri;
                                    break;
                                }
                            case DayOfWeek.Saturday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Sat;
                                    break;
                                }
                            case DayOfWeek.Sunday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Sun;
                                    break;
                                }
                        }
                        rectrl.PostSave(revent);
                    }
                    else
                    {
                        ectrl.PostSave(new EventCalendar.Core.Models.Event() { allDay = e.IsAllDay, calendarId = calendar_id, title = e.Summary, start = e.Start.Date, end = e.End.Date, Id = 0, categories = String.Join(",", e.Categories) });
                    }
                }
            }
        }
Exemple #2
0
        private void ImportEventsIntoExistingCalendar(IICalendarCollection collection, int calendar_id)
        {
            var cctrl  = new CalendarApiController();
            var ectrl  = new EventApiController();
            var rectrl = new REventApiController();

            //loop through calendar in collection
            foreach (var cal in collection)
            {
                //loop through events in calendar
                foreach (var e in cal.Events)
                {
                    //check if it is an reccuring event
                    if (e.RecurrenceRules.Count > 0)
                    {
                        var revent = new RecurringEvent()
                        {
                            allDay = e.IsAllDay, title = e.Summary, start = e.Start.Date, end = e.Start.Date, calendarId = calendar_id, categories = String.Join(",", e.Categories), Id = 0
                        };
                        revent.monthly_interval = (int)MonthlyIntervalEnum.First;
                        RecurrencePattern rp = (RecurrencePattern)e.RecurrenceRules[0];
                        switch (rp.Frequency)
                        {
                        case FrequencyType.Daily:
                        {
                            revent.frequency = (int)FrequencyTypeEnum.Daily;
                            break;
                        }

                        case FrequencyType.Monthly:
                        {
                            revent.frequency = (int)FrequencyTypeEnum.Monthly;
                            break;
                        }

                        case FrequencyType.Weekly:
                        {
                            revent.frequency = (int)FrequencyTypeEnum.Weekly;
                            break;
                        }

                        default:
                        {
                            revent.frequency = (int)FrequencyTypeEnum.Monthly;
                            break;
                        }
                        }
                        switch (e.Start.DayOfWeek)
                        {
                        case DayOfWeek.Monday: {
                            revent.day = (int)DayOfWeekEnum.Mon;
                            break;
                        }

                        case DayOfWeek.Tuesday:
                        {
                            revent.day = (int)DayOfWeekEnum.Tue;
                            break;
                        }

                        case DayOfWeek.Wednesday:
                        {
                            revent.day = (int)DayOfWeekEnum.Wed;
                            break;
                        }

                        case DayOfWeek.Thursday:
                        {
                            revent.day = (int)DayOfWeekEnum.Thu;
                            break;
                        }

                        case DayOfWeek.Friday:
                        {
                            revent.day = (int)DayOfWeekEnum.Fri;
                            break;
                        }

                        case DayOfWeek.Saturday:
                        {
                            revent.day = (int)DayOfWeekEnum.Sat;
                            break;
                        }

                        case DayOfWeek.Sunday:
                        {
                            revent.day = (int)DayOfWeekEnum.Sun;
                            break;
                        }
                        }
                        rectrl.PostSave(revent);
                    }
                    else
                    {
                        ectrl.PostSave(new EventCalendar.Core.Models.Event()
                        {
                            allDay = e.IsAllDay, calendarId = calendar_id, title = e.Summary, start = e.Start.Date, end = e.End.Date, Id = 0, categories = String.Join(",", e.Categories)
                        });
                    }
                }
            }
        }
        private void ImportEventsToNewCalendar(IICalendarCollection collection)
        {
            var cctrl = new CalendarApiController();
            var ectrl = new EventApiController();
            var rectrl = new REventApiController();            

            //loop through calendar in collection
            foreach (var cal in collection)
            {
                //Create the new calendar
                string name = "New Imported Calendar";
                if(cal.Properties["X-WR-CALNAME"] != null) {
                    if(!String.IsNullOrEmpty(cal.Properties["X-WR-CALNAME"].Value.ToString())) {
                        name = cal.Properties["X-WR-CALNAME"].Value.ToString();
                    }
                }
                var calendar = cctrl.PostSave(new ECalendar() { Id = 0, Calendarname = name, DisplayOnSite = false, IsGCal = false, GCalFeedUrl = "", ViewMode = "month", Color = "#000000", TextColor = "#FFFFFF" });
                //loop through events in calendar
                foreach (var e in cal.Events)
                {
                    //check if it is an reccuring event
                    if (e.RecurrenceRules.Count > 0)
                    {
                        var revent = new RecurringEvent() { allDay = e.IsAllDay, title = e.Summary, start = e.Start.Date, end = e.Start.Date, calendarId = calendar.Id, categories = String.Join(",", e.Categories), Id = 0 };
                        revent.monthly_interval = (int)MonthlyIntervalEnum.First;
                        RecurrencePattern rp = (RecurrencePattern)e.RecurrenceRules[0];
                        switch (rp.Frequency)
                        {
                            case FrequencyType.Daily:
                                {
                                    revent.frequency = (int)FrequencyTypeEnum.Daily;
                                    break;
                                }
                            case FrequencyType.Monthly:
                                {
                                    revent.frequency = (int)FrequencyTypeEnum.Monthly;
                                    break;
                                }
                            case FrequencyType.Weekly:
                                {
                                    revent.frequency = (int)FrequencyTypeEnum.Weekly;
                                    break;
                                }
                            default:
                                {
                                    revent.frequency = (int)FrequencyTypeEnum.Monthly;
                                    break;
                                }
                        }
                        switch (rp.ByDay[0].DayOfWeek)
                        {
                            case DayOfWeek.Monday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Mon;
                                    break;
                                }
                            case DayOfWeek.Tuesday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Tue;
                                    break;
                                }
                            case DayOfWeek.Wednesday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Wed;
                                    break;
                                }
                            case DayOfWeek.Thursday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Thu;
                                    break;
                                }
                            case DayOfWeek.Friday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Fri;
                                    break;
                                }
                            case DayOfWeek.Saturday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Sat;
                                    break;
                                }
                            case DayOfWeek.Sunday:
                                {
                                    revent.day = (int)DayOfWeekEnum.Sun;
                                    break;
                                }
                        }
                        rectrl.PostSave(revent);
                    }
                    else
                    {
                        ectrl.PostSave(new EventCalendar.Core.Models.Event() { allDay = e.IsAllDay, calendarId = calendar.Id, title = e.Summary, start = e.Start.Date, end = e.End.Date, Id = 0, categories = String.Join(",", e.Categories) });
                    }
                }
            }
        }
Exemple #4
0
        private void ImportEventsToNewCalendar(IICalendarCollection collection)
        {
            var cctrl  = new CalendarApiController();
            var ectrl  = new EventApiController();
            var rectrl = new REventApiController();

            //loop through calendar in collection
            foreach (var cal in collection)
            {
                //Create the new calendar
                string name = "New Imported Calendar";
                if (cal.Properties["X-WR-CALNAME"] != null)
                {
                    if (!String.IsNullOrEmpty(cal.Properties["X-WR-CALNAME"].Value.ToString()))
                    {
                        name = cal.Properties["X-WR-CALNAME"].Value.ToString();
                    }
                }
                var calendar = cctrl.PostSave(new ECalendar()
                {
                    Id = 0, Calendarname = name, DisplayOnSite = false, IsGCal = false, GCalFeedUrl = "", ViewMode = "month", Color = "#000000", TextColor = "#FFFFFF"
                });
                //loop through events in calendar
                foreach (var e in cal.Events)
                {
                    //check if it is an reccuring event
                    if (e.RecurrenceRules.Count > 0)
                    {
                        var revent = new RecurringEvent()
                        {
                            allDay = e.IsAllDay, title = e.Summary, start = e.Start.Date, end = e.Start.Date, calendarId = calendar.Id, categories = String.Join(",", e.Categories), Id = 0
                        };
                        revent.monthly_interval = (int)MonthlyIntervalEnum.First;
                        RecurrencePattern rp = (RecurrencePattern)e.RecurrenceRules[0];
                        switch (rp.Frequency)
                        {
                        case FrequencyType.Daily:
                        {
                            revent.frequency = (int)FrequencyTypeEnum.Daily;
                            break;
                        }

                        case FrequencyType.Monthly:
                        {
                            revent.frequency = (int)FrequencyTypeEnum.Monthly;
                            break;
                        }

                        case FrequencyType.Weekly:
                        {
                            revent.frequency = (int)FrequencyTypeEnum.Weekly;
                            break;
                        }

                        default:
                        {
                            revent.frequency = (int)FrequencyTypeEnum.Monthly;
                            break;
                        }
                        }
                        switch (rp.ByDay[0].DayOfWeek)
                        {
                        case DayOfWeek.Monday:
                        {
                            revent.day = (int)DayOfWeekEnum.Mon;
                            break;
                        }

                        case DayOfWeek.Tuesday:
                        {
                            revent.day = (int)DayOfWeekEnum.Tue;
                            break;
                        }

                        case DayOfWeek.Wednesday:
                        {
                            revent.day = (int)DayOfWeekEnum.Wed;
                            break;
                        }

                        case DayOfWeek.Thursday:
                        {
                            revent.day = (int)DayOfWeekEnum.Thu;
                            break;
                        }

                        case DayOfWeek.Friday:
                        {
                            revent.day = (int)DayOfWeekEnum.Fri;
                            break;
                        }

                        case DayOfWeek.Saturday:
                        {
                            revent.day = (int)DayOfWeekEnum.Sat;
                            break;
                        }

                        case DayOfWeek.Sunday:
                        {
                            revent.day = (int)DayOfWeekEnum.Sun;
                            break;
                        }
                        }
                        rectrl.PostSave(revent);
                    }
                    else
                    {
                        ectrl.PostSave(new EventCalendar.Core.Models.Event()
                        {
                            allDay = e.IsAllDay, calendarId = calendar.Id, title = e.Summary, start = e.Start.Date, end = e.End.Date, Id = 0, categories = String.Join(",", e.Categories)
                        });
                    }
                }
            }
        }