public static void SyncEvents(Event pattern, IEnumerable<Event> events, EventList list, EventListManager manager)
 {
     Message message = Message.Parse(pattern, "event:sync");
      var deleteContext = new SyncEventContext(pattern, events, list,
                                           manager);
      Dispatcher.Dispatch(message, deleteContext);
 }
        public EventList GetCalendar(string eventID, Options options)
        {
            EventList calendar;

             Item item = StaticSettings.EventSourceDatabase.GetItem(ID.Parse(eventID));
             if (item == null)
             {
            return null;
             }

             if (item.TemplateID != StaticSettings.EventTemplate.ID)
             {
            throw new EventCalendarException(
               String.Format(String.Format(ResourceManager.Localize("UNSUPPORT_TEMPLATE"), item.Name,
                                           item.TemplateName, StaticSettings.EventTemplate.Name)));
             }

             Item settingsItem = StaticSettings.EventSourceDatabase.GetItem(options.ControlSettingsPath);
             Item[] eventList = Utilities.GetEventListForView(settingsItem, options.SiteSettingsPath);
             var EventListMgr = new EventListManager(eventList, options.SiteSettingsPath);

             calendar = EventListMgr.GetCalendar(item);

             return calendar;
        }
        public ArrayList GetCalendarsList(bool canWrite, Options options)
        {
            var list = new ArrayList();
             Item settingsItem = StaticSettings.EventSourceDatabase.GetItem(options.ControlSettingsPath);
             Item[] eventList = Utilities.GetEventListForView(settingsItem, options.SiteSettingsPath);
             var EventListMgr = new EventListManager(eventList, options.SiteSettingsPath);

             foreach (var cal in EventListMgr.ActiveEventLists)
             {
            if (cal.Value.Selected && (!canWrite || cal.Value.CanWrite))
            {
               list.Add(cal.Value.Title);
               list.Add(cal.Value.ID.ToString());
            }
             }

             return list;
        }
        private void initList()
        {
            var module = new ModuleSettings(SiteSettingsPath);
             SiteSettingsPath = module.ModuleSettingsItemPath;

             Item settings_item = null;
             if (!string.IsNullOrEmpty(SelectorSettingsPath))
             {
            settings_item = module.GetActiveDatabase().GetItem(SelectorSettingsPath);
             }

             var settings =
            new CalendarSelectorSettings(settings_item ?? module.CalendarSelectorSettings,
                                         SiteSettingsPath);

             EventListMgr = new EventListManager(settings.EventLists, SiteSettingsPath);
             Format = settings.Format;
             LinkText = settings.LinkText;
             Margin = settings.Margin;
             Title = settings.Title;

             if (ShowAsDropDownList)
             {
            _calsCtrl = new DropDownList();
             }
             else
             {
            _calsCtrl = new CheckBoxList();
             }

             _calsCtrl.EnableViewState = false;
        }
        public static void CreateEvents()
        {
            var module = new ModuleSettings(null);

             var eventManager = new EventListManager(new Item[1] {module.CalendarEventsRoot}, null);

             using (new SecurityDisabler())
             {
            CreateDeveloperTrainingEvents(eventManager);
            CreateEndUserTrainingEvents(eventManager);
            CreatePartiesEvents(eventManager);
            CreateLunchEvents(eventManager);
             }
        }
        private static void CreatePartiesEvents(EventListManager eventManager)
        {
            var details = new EventDetails();
             details.List = eventManager.GetCalendar(PartyList);

             details.Title = PartyResourceTitle;
             details.TitleCount = PartyResourceTitleCount;
             details.Location = PartyResourceLocation;
             details.LocationCount = PartyResourceLocationCount;
             details.Description = PartyResourceDescription;
             details.DescriptionCount = PartyResourceDescriptionCount;
             details.DefaultDescription = PartyDefaultTitle;
             details.DefaultLocation = DescriptionDefault;
             details.DefaultDescription = DescriptionDefault;
             details.Branch = StaticSettings.EventBranch;

             for (int i = 0; i < PartyResourceTitleCount; ++i)
             {
            details.StartTime = GetResourceString(PartyResourceStartTime, i, "13:00", false);
            details.EndTime = GetResourceString(PartyResourceEndTime, i, "14:00", false);

            string[] date = GetResourceString(PartyResourceStartDate, i, "", false).Split('|');
            var day = (DayOfWeek) Enum.Parse(typeof (DayOfWeek), date[0], true);
            int skipDays = 7 * (int.Parse(date[1]) - 1);
            details.Date = FindNextDayOfWeek(DateTime.Today, day).AddDays(skipDays);

            NewEvent(details, true, i);
             }
             ++offsetHours;
        }
        private static void CreateEndUserTrainingEvents(EventListManager eventManager)
        {
            DateTime start = FindNextDayOfWeek(DateTime.Today, DeveloperDay);

             var evt = new Event
                      {
                         Description = string.Empty, StartDate = Utilities.NormalizeDate(start),
                         EndDate = Utilities.NormalizeDate(start.AddMonths(2)), StartTime = "09:00",
                         EndTime = "17:00", Location = EndUserLocationDefault,
                         Title = EndUserDefaultTitle
                      };

             var scheduler = new Schedule
                            {
                               DaysOfWeek = (Utils.DaysOfWeek.Monday | Utils.DaysOfWeek.Friday),
                               StartDate = Utilities.NormalizeDate(start),
                               EndDate = Utilities.NormalizeDate(start.AddMonths(2)),
                               Recurrence = Recurrence.Weekly,
                               Frequency = 1
                            };

             var options = new Options
                          {
                             CalendarID = EndUserTrainingList,
                             ControlSettingsPath = DeveloperViewSettings,
                             SiteSettingsPath = DefaultModuleSettings
                          };

             CalendarActions.CreateEvent(evt, scheduler, options);
        }
        private void Initialize()
        {
            initAjax();

                if ((HttpContext.Current.Request.UserLanguages != null) &&
                     (!String.IsNullOrEmpty(HttpContext.Current.Request.UserLanguages[0])))
                {
                    Utilities.SetCurrentCulture(HttpContext.Current.Request.UserLanguages[0]);
                }
                ModuleSettings module = new ModuleSettings(SiteSettingsPath);
                SiteSettingsPath = module.ModuleSettingsItemPath;
                Item settings_item = module.MiniCalendarSettings;
                MiniCalendarSettings settings = new MiniCalendarSettings(settings_item, SiteSettingsPath);

                EventListMgr = new EventListManager(settings.EventLists, SiteSettingsPath);
                LinkBehavior = settings.LinkBehavior;
                RedirectTo = settings.RedirectTo;
                Margin = settings.Margin;
                Title = settings.Title;

                navCalendar.Width = Unit.Pixel(152);
                navCalendar.Height = Unit.Pixel(89);
                navCalendar.DayNameFormat = DayNameFormat.FirstTwoLetters;

                navCalendar.BorderStyle = BorderStyle.Solid;
                navCalendar.BorderWidth = Unit.Pixel(1);
                navCalendar.CellPadding = 0;
                navCalendar.EnableTheming = true;
                navCalendar.EnableViewState = false;
                navCalendar.CssClass = "navCalendar";
                navCalendar.ID = "calendar" + ID;

                navCalendar.DayRender += navCalendar_DayRender;
                navCalendar.SelectionChanged += navCalendar_SelectionChanged;

                navCalendar.SelectedDayStyle.CssClass = "navDaySelected";

                navCalendar.DayStyle.CssClass = "navCalendarText";

                navCalendar.WeekendDayStyle.CssClass = "navWeekdays";

                navCalendar.OtherMonthDayStyle.CssClass = "navOtherMonth";

                navCalendar.NextPrevStyle.CssClass = "navNextPrev";
                navCalendar.NextPrevStyle.ForeColor = Color.White;

                navCalendar.DayHeaderStyle.CssClass = "navDayHeader";
                navCalendar.TitleStyle.CssClass = "navHeader";
                navCalendar.TitleStyle.BackColor = Color.White;

                updatePanel.ID = "UpdatePanel" + ID;

            if (!VirtualPreviewUtil.IsVirtualPreview(this.Page))
            {
              Controls.Add(updatePanel);
              updatePanel.ContentTemplateContainer.Controls.Add(navCalendar);
            }
            else
            {
              Controls.Add(navCalendar);
            }
        }
 protected void init(StandardViewSettings view_settings, string site_settings_path)
 {
     _viewSetting = view_settings;
      RecurrentEventPrefix = view_settings.RecurrentEventPrefix;
      RecurrentEventSuffix = view_settings.RecurrentEventSuffix;
      ShowHeader = view_settings.ShowHeader;
      EventListMgr = new EventListManager(view_settings.EventLists, site_settings_path);
 }
        private void init(string idCalendar, Item agenda_settings, string site_settings_path)
        {
            settings = new AgendaViewSettings(agenda_settings, site_settings_path);
             siteSettings = site_settings_path;
             IdCalendar = idCalendar;

             Attributes["startHour"] = "-1";
             Attributes["numHours"] = "24";

             AgendaTitle = settings.Title;
             switch (settings.StartDate)
             {
            case StartDateOption.Today:
               AgendaStartDate = DateTime.Now;
               break;

            case StartDateOption.SelectedDate:
               if (HttpContext.Current.Session[StaticSettings.SessionStateCurrentDate] == null)
               {
                  AgendaStartDate = DateTime.Now;
               }
               else
               {
                  AgendaStartDate = (DateTime)HttpContext.Current.Session[StaticSettings.SessionStateCurrentDate];
               }
               break;
             }
             EventLimit = settings.EventLimit;
             ShowEventDate = settings.ShowEventDate;
             ShowEventTime = settings.ShowEventTime;
             Margin = settings.Margin;
             EventListMgr = new EventListManager(settings.EventLists, site_settings_path);
        }