private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Add the external Validation.js to the Page
                const string csname = "ExtValidationScriptFile";
                var          cstype = MethodBase.GetCurrentMethod().GetType();
                var          cstext = "<script src=\"" + ResolveUrl("~/DesktopModules/Events/Scripts/Validation.js") +
                                      "\" type=\"text/javascript\"></script>";
                if (!Page.ClientScript.IsClientScriptBlockRegistered(csname))
                {
                    Page.ClientScript.RegisterClientScriptBlock(cstype, csname, cstext, false);
                }

                ddlCategories.EmptyMessage = Localization.GetString("NoCategories", LocalResourceFile);
                ddlCategories.Localization.AllItemsCheckedString =
                    Localization.GetString("AllCategories", LocalResourceFile);
                ddlCategories.Localization.CheckAllString =
                    Localization.GetString("SelectAllCategories", LocalResourceFile);
                if (Settings.Enablecategories == EventModuleSettings.DisplayCategories.SingleSelect)
                {
                    ddlCategories.CheckBoxes = false;
                }

                if (!Page.IsPostBack)
                {
                    //Bind DDL
                    var ctrlEventCategories = new EventCategoryController();
                    var lstCategories       = ctrlEventCategories.EventsCategoryList(PortalId);

                    var arrCategories = new ArrayList();
                    if (Settings.Restrictcategories)
                    {
                        foreach (EventCategoryInfo dbCategory in lstCategories)
                        {
                            foreach (int category in Settings.ModuleCategoryIDs)
                            {
                                if (dbCategory.Category == category)
                                {
                                    arrCategories.Add(dbCategory);
                                }
                            }
                        }
                    }
                    else
                    {
                        arrCategories.AddRange(lstCategories);
                    }

                    if (lstCategories.Count == 0)
                    {
                        Visible = false;
                        SelectedCategory.Clear();
                        return;
                    }

                    //Restrict categories by events in time frame.
                    if (Settings.RestrictCategoriesToTimeFrame)
                    {
                        //Only for list view.
                        var whichView = string.Empty;
                        if (!(Request.QueryString["mctl"] == null) && ModuleId ==
                            Convert.ToInt32(Request.QueryString["ModuleID"]))
                        {
                            if (Request["mctl"].EndsWith(".ascx"))
                            {
                                whichView = Request["mctl"];
                            }
                            else
                            {
                                whichView = Request["mctl"] + ".ascx";
                            }
                        }
                        if (whichView.Length == 0)
                        {
                            if (!ReferenceEquals(
                                    Request.Cookies.Get("DNNEvents" + Convert.ToString(ModuleId)), null))
                            {
                                whichView = Request.Cookies.Get("DNNEvents" + Convert.ToString(ModuleId)).Value;
                            }
                            else
                            {
                                whichView = Settings.DefaultView;
                            }
                        }

                        if (whichView == "EventList.ascx" || whichView == "EventRpt.ascx")
                        {
                            var objEventInfoHelper =
                                new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
                            var lstEvents = default(ArrayList);

                            var getSubEvents = Settings.MasterEvent;
                            var numDays      = Settings.EventsListEventDays;
                            var displayDate  = default(DateTime);
                            var startDate    = default(DateTime);
                            var endDate      = default(DateTime);
                            if (Settings.ListViewUseTime)
                            {
                                displayDate = DisplayNow();
                            }
                            else
                            {
                                displayDate = DisplayNow().Date;
                            }
                            if (Settings.EventsListSelectType == "DAYS")
                            {
                                startDate = displayDate.AddDays(Settings.EventsListBeforeDays * -1);
                                endDate   = displayDate.AddDays(Settings.EventsListAfterDays * 1);
                            }
                            else
                            {
                                startDate = displayDate;
                                endDate   = displayDate.AddDays(numDays);
                            }

                            lstEvents = objEventInfoHelper.GetEvents(startDate, endDate, getSubEvents,
                                                                     new ArrayList(Convert.ToInt32(new[] { "-1" })),
                                                                     new ArrayList(Convert.ToInt32(new[] { "-1" })), -1,
                                                                     -1);

                            var eventCategoryIds = new ArrayList();
                            foreach (EventInfo lstEvent in lstEvents)
                            {
                                eventCategoryIds.Add(lstEvent.Category);
                            }
                            foreach (EventCategoryInfo lstCategory in lstCategories)
                            {
                                if (!eventCategoryIds.Contains(lstCategory.Category))
                                {
                                    arrCategories.Remove(lstCategory);
                                }
                            }
                        }
                    }

                    //Bind categories.
                    ddlCategories.DataSource = arrCategories;
                    ddlCategories.DataBind();

                    if (Settings.Enablecategories == EventModuleSettings.DisplayCategories.SingleSelect)
                    {
                        ddlCategories.Items.Insert(
                            0,
                            new RadComboBoxItem(Localization.GetString("AllCategories", LocalResourceFile),
                                                "-1"));
                        ddlCategories.SelectedIndex = 0;
                    }
                    ddlCategories.OnClientDropDownClosed =
                        "function() { btnUpdateClick('" + btnUpdate.UniqueID + "','" +
                        ddlCategories.ClientID + "');}";
                    ddlCategories.OnClientLoad = "function() { storeText('" + ddlCategories.ClientID + "');}";
                    if (Settings.Enablecategories == EventModuleSettings.DisplayCategories.SingleSelect)
                    {
                        foreach (int category in SelectedCategory)
                        {
                            ddlCategories.SelectedIndex =
                                ddlCategories.FindItemByValue(category.ToString()).Index;
                            break;
                        }
                    }
                    else
                    {
                        foreach (var category in SelectedCategory)
                        {
                            foreach (RadComboBoxItem item in ddlCategories.Items)
                            {
                                if (item.Value == category.ToString())
                                {
                                    item.Checked = true;
                                }
                            }
                        }

                        if (Convert.ToInt32(SelectedCategory[0]) == -1)
                        {
                            foreach (RadComboBoxItem item in ddlCategories.Items)
                            {
                                item.Checked = true;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                //ProcessModuleLoadException(Me, exc)
            }
        }
        public override List <SitemapUrl> GetUrls(int portalID, PortalSettings ps, string version)
        {
            var sitemapUrls = new List <SitemapUrl>();

            var objDesktopModule = default(DesktopModuleInfo);

            objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DNN_Events", portalID);

            var objModules          = new ModuleController();
            var objModule           = default(ModuleInfo);
            var lstModules          = objModules.GetModulesByDefinition(portalID, objDesktopModule.FriendlyName);
            var moduleIds           = new ArrayList();
            var visibleModuleIds    = new ArrayList();
            var visibleTabModuleIds = new ArrayList();

            foreach (ModuleInfo tempLoopVar_objModule in lstModules)
            {
                objModule = tempLoopVar_objModule;
                var objTabPermissions = TabPermissionController.GetTabPermissions(objModule.TabID, portalID);
                var objTabPermission  = default(TabPermissionInfo);

                foreach (TabPermissionInfo tempLoopVar_objTabPermission in objTabPermissions)
                {
                    objTabPermission = tempLoopVar_objTabPermission;

                    if (objTabPermission.PermissionKey == "VIEW" && objTabPermission.RoleName != "" &&
                        objTabPermission.AllowAccess && (objTabPermission.RoleID == -1) |
                        (objTabPermission.RoleID == -3))
                    {
                        if (objModule.InheritViewPermissions)
                        {
                            visibleTabModuleIds.Add("Tab" + objModule.TabID + "Mod" + objModule.ModuleID);
                            visibleModuleIds.Add(objModule.ModuleID);
                            break;
                        }

                        var objModulePermission = default(ModulePermissionInfo);
                        // ReSharper disable LoopCanBeConvertedToQuery
                        foreach (ModulePermissionInfo tempLoopVar_objModulePermission in objModule.ModulePermissions)
                        {
                            objModulePermission = tempLoopVar_objModulePermission;
                            // ReSharper restore LoopCanBeConvertedToQuery
                            if (objModulePermission.PermissionKey == "VIEW" && objModulePermission.RoleName != "" &&
                                objModulePermission.AllowAccess && (objModulePermission.RoleID == -1) |
                                (objModulePermission.RoleID == -3))
                            {
                                visibleTabModuleIds.Add("Tab" + objModule.TabID + "Mod" + objModule.ModuleID);
                                visibleModuleIds.Add(objModule.ModuleID);
                                break;
                            }
                        }
                    }
                }
            }
            foreach (ModuleInfo tempLoopVar_objModule in lstModules)
            {
                objModule = tempLoopVar_objModule;

                // This check for objModule = Nothing because of error in DNN 5.0.0 in GetModulesByDefinition
                if (ReferenceEquals(objModule, null))
                {
                    continue;
                }

                if (objModule.IsDeleted)
                {
                    continue;
                }

                if (moduleIds.Contains(objModule.ModuleID))
                {
                    continue;
                }

                if (!visibleTabModuleIds.Contains("Tab" + objModule.TabID + "Mod" + objModule.ModuleID))
                {
                    continue;
                }

                moduleIds.Add(objModule.ModuleID);
                var settings = EventModuleSettings.GetEventModuleSettings(objModule.ModuleID, null);
                if (!settings.EnableSitemap)
                {
                    continue;
                }

                if (settings.SocialGroupModule == EventModuleSettings.SocialModule.UserProfile)
                {
                    continue;
                }

                var iCategoryIDs = new ArrayList();
                if (settings.Enablecategories == EventModuleSettings.DisplayCategories.DoNotDisplay)
                {
                    iCategoryIDs = settings.ModuleCategoryIDs;
                }
                else
                {
                    iCategoryIDs.Add("-1");
                }

                var ilocationIDs = new ArrayList();
                if (settings.Enablelocations == EventModuleSettings.DisplayLocations.DoNotDisplay)
                {
                    ilocationIDs = settings.ModuleLocationIDs;
                }
                else
                {
                    ilocationIDs.Add("-1");
                }

                var objEventTimeZoneUtilities = new EventTimeZoneUtilities();
                var currDate    = objEventTimeZoneUtilities.ConvertFromUTCToModuleTimeZone(DateTime.UtcNow, settings.TimeZoneId);
                var dtStartDate = DateAndTime.DateAdd(DateInterval.Day, Convert.ToDouble(-settings.SiteMapDaysBefore), currDate);
                var dtEndDate   = DateAndTime.DateAdd(DateInterval.Day, settings.SiteMapDaysAfter, currDate);

                var objEventInfoHelper = new EventInfoHelper(objModule.ModuleID, objModule.TabID, portalID, settings);

                var lstevents = default(ArrayList);
                lstevents = objEventInfoHelper.GetEvents(dtStartDate, dtEndDate, settings.MasterEvent, iCategoryIDs, ilocationIDs, -1, -1);

                var objEvent = default(EventInfo);

                foreach (EventInfo tempLoopVar_objEvent in lstevents)
                {
                    objEvent = tempLoopVar_objEvent;
                    if (settings.Enforcesubcalperms && !visibleModuleIds.Contains(objEvent.ModuleID))
                    {
                        continue;
                    }
                    var pageUrl = new SitemapUrl();
                    pageUrl.Url             = objEventInfoHelper.DetailPageURL(objEvent, false);
                    pageUrl.Priority        = settings.SiteMapPriority;
                    pageUrl.LastModified    = objEvent.LastUpdatedAt;
                    pageUrl.ChangeFrequency = SitemapChangeFrequency.Daily;
                    sitemapUrls.Add(pageUrl);
                }
            }

            return(sitemapUrls);
        }
Exemple #3
0
        private void BindDataGrid()
        {
            var culture            = Thread.CurrentThread.CurrentCulture;
            var startDate          = default(DateTime); // Start View Date Events Range
            var endDate            = default(DateTime); // End View Date Events Range
            var objEvent           = default(EventInfo);
            var objEventInfoHelper = new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
            var editButtonVisible  = false;

            // Set Date Range
            var dDate = SelectedDate.Date;

            startDate = dDate.AddDays(-1);
            endDate   = dDate.AddDays(1);

            // Get Events/Sub-Calendar Events
            var getSubEvents = Settings.MasterEvent;

            _selectedEvents =
                objEventInfoHelper.GetEvents(startDate, endDate, getSubEvents, SelectCategory.SelectedCategory,
                                             SelectLocation.SelectedLocation, GetUrlGroupId(),
                                             GetUrlUserId());

            _selectedEvents =
                objEventInfoHelper.ConvertEventListToDisplayTimeZone(_selectedEvents, GetDisplayTimeZoneId());

            if (_selectedEvents.Count == 0)
            {
                lstEvents.Visible  = false;
                divMessage.Visible = true;
                return;
            }
            lstEvents.Visible  = true;
            divMessage.Visible = false;

            // Get Date Events (used for Multiday event)
            var dayEvents = default(ArrayList);

            dayEvents = objEventInfoHelper.GetDateEvents(_selectedEvents, dDate);

            var fmtEventTimeBegin = Settings.Templates.txtDayEventTimeBegin;

            if (string.IsNullOrEmpty(fmtEventTimeBegin))
            {
                fmtEventTimeBegin = "g";
            }

            var fmtEventTimeEnd = Settings.Templates.txtDayEventTimeEnd;

            if (string.IsNullOrEmpty(fmtEventTimeEnd))
            {
                fmtEventTimeEnd = "g";
            }

            var tmpDayDescription = Settings.Templates.txtDayEventDescription;
            var tmpDayLocation    = Settings.Templates.txtDayLocation;

            if (Settings.Eventtooltipday)
            {
                toolTipManager.TargetControls.Clear();
            }

            var colEvents = new ArrayList();
            var lstEvent  = default(EventListObject);

            foreach (EventInfo tempLoopVar_objEvent in dayEvents)
            {
                objEvent = tempLoopVar_objEvent;
                // If full enrollments should be hidden, ignore
                if (HideFullEvent(objEvent))
                {
                    continue;
                }

                var blAddEvent = true;
                if (Settings.Collapserecurring)
                {
                    foreach (EventListObject tempLoopVar_lstEvent in colEvents)
                    {
                        lstEvent = tempLoopVar_lstEvent;
                        if (lstEvent.RecurMasterID == objEvent.RecurMasterID)
                        {
                            blAddEvent = false;
                        }
                    }
                }
                if (blAddEvent)
                {
                    var objCtlEventRecurMaster = new EventRecurMasterController();
                    var tcc         = new TokenReplaceControllerClass(ModuleId, LocalResourceFile);
                    var fmtRowEnd   = "";
                    var fmtRowBegin = "";
                    fmtRowEnd   = tcc.TokenParameters(fmtEventTimeEnd, objEvent, Settings);
                    fmtRowBegin = tcc.TokenParameters(fmtEventTimeBegin, objEvent, Settings);

                    lstEvent                = new EventListObject();
                    lstEvent.EventID        = objEvent.EventID;
                    lstEvent.CreatedByID    = objEvent.CreatedByID;
                    lstEvent.OwnerID        = objEvent.OwnerID;
                    lstEvent.EventDateBegin = objEvent.EventTimeBegin;
                    lstEvent.EventDateEnd   = objEvent.EventTimeEnd;
                    if (objEvent.DisplayEndDate)
                    {
                        lstEvent.TxtEventDateEnd = string.Format("{0:" + fmtRowEnd + "}", lstEvent.EventDateEnd);
                    }
                    else
                    {
                        lstEvent.TxtEventDateEnd = "";
                    }
                    lstEvent.EventTimeBegin    = objEvent.EventTimeBegin;
                    lstEvent.TxtEventTimeBegin = string.Format("{0:" + fmtRowBegin + "}", lstEvent.EventTimeBegin);
                    lstEvent.Duration          = objEvent.Duration;

                    var isEvtEditor = IsEventEditor(objEvent, false);

                    var templatedescr = "";
                    var iconString    = "";

                    if (!IsPrivateNotModerator || UserId == objEvent.OwnerID)
                    {
                        templatedescr              = tcc.TokenReplaceEvent(objEvent, tmpDayDescription, null, false, isEvtEditor);
                        lstEvent.CategoryColor     = GetColor(objEvent.Color);
                        lstEvent.CategoryFontColor = GetColor(objEvent.FontColor);

                        iconString = CreateIconString(objEvent, Settings.IconListPrio,
                                                      Settings.IconListRec, Settings.IconListReminder,
                                                      Settings.IconListEnroll);
                    }

                    lstEvent.EventName = CreateEventName(objEvent, "[event:title]");
                    lstEvent.EventDesc = objEvent.EventDesc;
                    // RWJS - not sure why replace ' with \' - lstEvent.DecodedDesc = System.Web.HttpUtility.HtmlDecode(objEvent.EventDesc).Replace(Environment.NewLine, "").Trim.Replace("'", "\'")
                    lstEvent.DecodedDesc =
                        Convert.ToString(HttpUtility.HtmlDecode(templatedescr).Replace(Environment.NewLine, ""));
                    lstEvent.EventID  = objEvent.EventID;
                    lstEvent.ModuleID = objEvent.ModuleID;

                    var objEventRRULE = default(EventRRULEInfo);
                    objEventRRULE      = objCtlEventRecurMaster.DecomposeRRULE(objEvent.RRULE, objEvent.EventTimeBegin);
                    lstEvent.RecurText =
                        objCtlEventRecurMaster.RecurrenceText(objEventRRULE, LocalResourceFile, culture,
                                                              objEvent.EventTimeBegin);
                    if (objEvent.RRULE != "")
                    {
                        lstEvent.RecurUntil = objEvent.LastRecurrence.ToShortDateString();
                    }
                    else
                    {
                        lstEvent.RecurUntil = "";
                    }
                    lstEvent.EventID  = objEvent.EventID;
                    lstEvent.ModuleID = objEvent.ModuleID;

                    lstEvent.ImageURL = "";
                    if (Settings.Eventimage && objEvent.ImageURL != null && objEvent.ImageDisplay)
                    {
                        lstEvent.ImageURL =
                            ImageInfo(objEvent.ImageURL, objEvent.ImageHeight, objEvent.ImageWidth);
                    }

                    // Get detail page url
                    lstEvent.URL = objEventInfoHelper.DetailPageURL(objEvent);
                    if (objEvent.DetailPage && objEvent.DetailNewWin)
                    {
                        lstEvent.Target = "_blank";
                    }

                    lstEvent.Icons           = iconString;
                    lstEvent.DisplayDuration = Convert.ToInt32(Conversion.Int((double)objEvent.Duration / 1440 + 1));
                    lstEvent.CategoryName    = objEvent.CategoryName;
                    lstEvent.LocationName    = tcc.TokenReplaceEvent(objEvent, tmpDayLocation);
                    lstEvent.CustomField1    = objEvent.CustomField1;
                    lstEvent.CustomField2    = objEvent.CustomField2;
                    lstEvent.RecurMasterID   = objEvent.RecurMasterID;

                    if (Settings.Eventtooltipday)
                    {
                        lstEvent.Tooltip =
                            ToolTipCreate(objEvent, Settings.Templates.txtTooltipTemplateTitle,
                                          Settings.Templates.txtTooltipTemplateBody, isEvtEditor);
                    }

                    lstEvent.EditVisibility = false;
                    if (isEvtEditor)
                    {
                        lstEvent.EditVisibility = true;
                        editButtonVisible       = true;
                    }

                    colEvents.Add(lstEvent);
                }
            }

            //Determine which fields get displayed
            if (!IsPrivateNotModerator)
            {
                if (Settings.EventsListFields.LastIndexOf("EB", StringComparison.Ordinal) < 0 ||
                    editButtonVisible == false)
                {
                    lstEvents.Columns[0].Visible = false;
                }
                else
                {
                    lstEvents.Columns[0].Visible = true;
                }
                if (Settings.EventsListFields.LastIndexOf("BD", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[1].Visible = false;
                }
                if (Settings.EventsListFields.LastIndexOf("ED", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[2].Visible = false;
                }
                if (Settings.EventsListFields.LastIndexOf("EN", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[3].Visible = false;
                }
                if (Settings.EventsListFields.LastIndexOf("IM", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[4].Visible = false;
                }
                if (Settings.EventsListFields.LastIndexOf("DU", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[5].Visible = false;
                }
                if (Settings.EventsListFields.LastIndexOf("CA", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[6].Visible = false;
                }
                if (Settings.EventsListFields.LastIndexOf("LO", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[7].Visible = false;
                }
                if (!Settings.EventsCustomField1 ||
                    Settings.EventsListFields.LastIndexOf("C1", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[8].Visible = false;
                }
                if (!Settings.EventsCustomField2 ||
                    Settings.EventsListFields.LastIndexOf("C2", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[9].Visible = false;
                }
                if (Settings.EventsListFields.LastIndexOf("DE", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[10].Visible = false;
                }
                if (Settings.EventsListFields.LastIndexOf("RT", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[11].Visible = false;
                }
                if (Settings.EventsListFields.LastIndexOf("RU", StringComparison.Ordinal) < 0)
                {
                    lstEvents.Columns[12].Visible = false;
                }
            }
            else
            {
                // Set Defaults
                lstEvents.Columns[0].Visible  = false; // Edit Buttom
                lstEvents.Columns[1].Visible  = true;  // Begin Date
                lstEvents.Columns[2].Visible  = true;  // End Date
                lstEvents.Columns[3].Visible  = true;  // Title
                lstEvents.Columns[4].Visible  = false; // Image
                lstEvents.Columns[5].Visible  = false; // Duration
                lstEvents.Columns[6].Visible  = false; // Category
                lstEvents.Columns[7].Visible  = false; // Location
                lstEvents.Columns[8].Visible  = false; // Custom Field 1
                lstEvents.Columns[9].Visible  = false; // Custom Field 2
                lstEvents.Columns[10].Visible = false; // Description
                lstEvents.Columns[11].Visible = false; // Recurrence Pattern
                lstEvents.Columns[12].Visible = false; // Recur Until
            }

            lstEvents.DataSource = colEvents;
            lstEvents.DataBind();
        }
        private void BindDataGrid()
        {
            var startDate          = default(DateTime); // Start View Date Events Range
            var endDate            = default(DateTime); // End View Date Events Range
            var objEventInfoHelper = new EventInfoHelper(ModuleId, TabId, PortalId, Settings);

            _pageBound = true;
            //****DO NOT CHANGE THE NEXT SECTION FOR ML CODING ****
            // Used Only to select view dates on Event Month View...
            var useDate  = Convert.ToDateTime(dpGoToDate.SelectedDate);
            var initDate = new DateTime(useDate.Year, useDate.Month, 1);

            startDate = initDate.AddDays(-10); // Allow for Prev Month days in View
            // Load 2 months of events.  This used to load only the events for the current month,
            // but was changed so that events for multiple events can be displayed in the case when
            // the Event displays some days for the next month.
            endDate = Convert.ToDateTime(initDate.AddMonths(1).AddDays(10));

            var getSubEvents = Settings.MasterEvent;

            _selectedEvents =
                objEventInfoHelper.GetEvents(startDate, endDate, getSubEvents, SelectCategory.SelectedCategory,
                                             SelectLocation.SelectedLocation, GetUrlGroupId(),
                                             GetUrlUserId());

            _selectedEvents =
                objEventInfoHelper.ConvertEventListToDisplayTimeZone(_selectedEvents, GetDisplayTimeZoneId());

            //Write current date to UI
            SelectedDate = Convert.ToDateTime(EventCalendar.VisibleDate);

            // Setup the Tooltip TargetControls because it doesn't work in DayRender!
            if (Settings.Eventtooltipmonth)
            {
                toolTipManager.TargetControls.Clear();
                if (Settings.Monthcellnoevents)
                {
                    var calcDate = startDate;
                    while (calcDate <= endDate)
                    {
                        toolTipManager.TargetControls.Add(
                            "ctlEvents_Mod_" + ModuleId + "_EventDate_" + calcDate.Date.ToString("yyyyMMMdd"),
                            true);
                        calcDate = calcDate.AddDays(1);
                    }
                }
                else
                {
                    foreach (EventInfo objEvent in _selectedEvents)
                    {
                        var calcDate = objEvent.EventTimeBegin.Date;
                        while (calcDate <= objEvent.EventTimeEnd.Date)
                        {
                            toolTipManager.TargetControls.Add(
                                "ctlEvents_Mod_" + ModuleId + "_EventID_" + objEvent.EventID + "_EventDate_" +
                                calcDate.Date.ToString("yyyyMMMdd"), true);
                            calcDate = calcDate.AddDays(1);
                        }
                    }
                }
            }
        }
Exemple #5
0
        private string CleanupExpired()
        {
            var returnStr       = "Event Cleanup completed.";
            var noDeletedEvents = 0;

            Status = "Performing Event Cleanup";

            var objDesktopModule = default(DesktopModuleInfo);

            objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DNN_Events", 0);

            if (ReferenceEquals(objDesktopModule, null))
            {
                return("Module Definition 'DNN_Events' not found. Cleanup cannot be performed.");
            }

            Status = "Performing Event Cleanup: Dummy";
            Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName;

            var objPortals = new PortalController();
            var objPortal  = default(PortalInfo);
            var objModules = new ModuleController();
            var objModule  = default(ModuleInfo);

            var lstportals = objPortals.GetPortals();

            foreach (PortalInfo tempLoopVar_objPortal in lstportals)
            {
                objPortal = tempLoopVar_objPortal;
                Status    = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID: Dummy";
                Status    = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                            objPortal.PortalID;

                var lstModules = objModules.GetModulesByDefinition(objPortal.PortalID, objDesktopModule.FriendlyName);
                foreach (ModuleInfo tempLoopVar_objModule in lstModules)
                {
                    objModule = tempLoopVar_objModule;
                    // This check for objModule = Nothing because of error in DNN 5.0.0 in GetModulesByDefinition
                    if (ReferenceEquals(objModule, null))
                    {
                        continue;
                    }
                    Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                             objPortal.PortalID + " ModuleID: Dummy";
                    Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                             objPortal.PortalID + " ModuleID:" + objModule.ModuleID;

                    var settings = EventModuleSettings.GetEventModuleSettings(objModule.ModuleID, null);
                    if (settings.Expireevents != "")
                    {
                        Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                                 objPortal.PortalID + " ModuleID:" + objModule.ModuleID + " IN PROGRESS";

                        var objEventCtl = new EventController();
                        var expireDate  =
                            DateAndTime.DateAdd(DateInterval.Day, -Convert.ToInt32(settings.Expireevents),
                                                DateTime.UtcNow);
                        var startdate          = expireDate.AddYears(-10);
                        var endDate            = expireDate.AddDays(1);
                        var objEventInfoHelper = new EventInfoHelper(objModule.ModuleID, settings);
                        var categoryIDs        = new ArrayList();
                        categoryIDs.Add("-1");
                        var locationIDs = new ArrayList();
                        locationIDs.Add("-1");
                        var lstEvents =
                            objEventInfoHelper.GetEvents(startdate, endDate, false, categoryIDs, locationIDs, -1, -1);

                        var objEventTimeZoneUtilities = new EventTimeZoneUtilities();
                        foreach (EventInfo objEvent in lstEvents)
                        {
                            var eventTime =
                                objEventTimeZoneUtilities.ConvertToUTCTimeZone(
                                    objEvent.EventTimeEnd, objEvent.EventTimeZoneId);
                            if (eventTime < expireDate)
                            {
                                objEvent.Cancelled = true;
                                objEventCtl.EventsSave(objEvent, true, 0, true);
                                noDeletedEvents++;
                                returnStr = "Event Cleanup completed. " + noDeletedEvents + " Events deleted.";
                            }
                        }
                        objEventCtl.EventsCleanupExpired(objModule.PortalID, objModule.ModuleID);
                    }
                }
            }
            Status = "Cleanup complete";
            return(returnStr);
        }
Exemple #6
0
        private void BindPage(DateTime dDate)
        {
            var dBegin             = default(DateTime);
            var dEnd               = default(DateTime);
            var sBegin             = default(DateTime);
            var sEnd               = default(DateTime);
            var objEventInfoHelper = new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings);

            try
            {
                // Set Date Range
                if (this.Settings.WeekStart != FirstDayOfWeek.Default)
                {
                    this._dWeekStart =
                        dDate.AddDays(Convert.ToDouble(-(int)dDate.DayOfWeek + this.Settings.WeekStart));
                }
                else
                {
                    this._dWeekStart = dDate.AddDays(Convert.ToDouble(-(int)dDate.DayOfWeek));
                }
                if (((int)dDate.DayOfWeek < (int)this.Settings.WeekStart) &
                    (this.Settings.WeekStart != FirstDayOfWeek.Default))
                {
                    this._dWeekStart = this._dWeekStart.AddDays(-7);
                }
                this.lblWeekOf.Text = string.Format(Localization.GetString("capWeekEvent", this.LocalResourceFile),
                                                    DateAndTime.DatePart(
                                                        DateInterval.WeekOfYear, this._dWeekStart,
                                                        FirstWeekOfYearValue: FirstWeekOfYear.FirstFourDays),
                                                    this._dWeekStart.ToLongDateString());
                this.ViewState[this.ModuleId + "WeekOf"] = this._dWeekStart.ToShortDateString();

                // Allow 7 days for events that might start before beginning of week
                sBegin = this._dWeekStart;
                dBegin = DateAndTime.DateAdd(DateInterval.Day, -7, this._dWeekStart);
                sEnd   = DateAndTime.DateAdd(DateInterval.Day, Convert.ToDouble(+7), this._dWeekStart);
                dEnd   = sEnd;

                // Get Events/Sub-Calendar Events

                var getSubEvents = this.Settings.MasterEvent;
                this._selectedEvents =
                    objEventInfoHelper.GetEvents(dBegin, dEnd, getSubEvents, this.SelectCategory.SelectedCategory,
                                                 this.SelectLocation.SelectedLocation, this.GetUrlGroupId(),
                                                 this.GetUrlUserId());

                this._selectedEvents =
                    objEventInfoHelper.ConvertEventListToDisplayTimeZone(
                        this._selectedEvents, this.GetDisplayTimeZoneId());

                // Setup ScheduleGeneral
                // Create DataView
                var eventTable = new DataTable("Events");
                eventTable.Columns.Add("ID", Type.GetType("System.Int32"));
                eventTable.Columns.Add("CreatedByID", Type.GetType("System.Int32"));
                eventTable.Columns.Add("OwnerID", Type.GetType("System.Int32"));
                eventTable.Columns.Add("StartTime", Type.GetType("System.DateTime"));
                eventTable.Columns.Add("EndTime", Type.GetType("System.DateTime"));
                eventTable.Columns.Add("Icons", Type.GetType("System.String"));
                eventTable.Columns.Add("Task", Type.GetType("System.String"));
                eventTable.Columns.Add("Description", Type.GetType("System.String"));
                eventTable.Columns.Add("StartDateTime", Type.GetType("System.DateTime"));
                eventTable.Columns.Add("Duration", Type.GetType("System.Int32"));
                eventTable.Columns.Add("URL", Type.GetType("System.String"));
                eventTable.Columns.Add("Target", Type.GetType("System.String"));
                eventTable.Columns.Add("Tooltip", Type.GetType("System.String"));
                eventTable.Columns.Add("BackColor", Type.GetType("System.String"));

                if (this.Settings.Eventtooltipweek)
                {
                    this.toolTipManager.TargetControls.Clear();
                }

                var dgRow    = default(DataRow);
                var objEvent = default(EventInfo);
                foreach (EventInfo tempLoopVar_objEvent in this._selectedEvents)
                {
                    objEvent = tempLoopVar_objEvent;
                    // If full enrollments should be hidden, ignore
                    if (this.HideFullEvent(objEvent))
                    {
                        continue;
                    }

                    if (objEvent.EventTimeEnd > sBegin && objEvent.EventTimeBegin < sEnd)
                    {
                        dgRow                = eventTable.NewRow();
                        dgRow["ID"]          = objEvent.EventID;
                        dgRow["CreatedByID"] = objEvent.CreatedByID;
                        dgRow["OwnerID"]     = objEvent.OwnerID;
                        dgRow["StartTime"]   = objEvent.EventTimeBegin;
                        if (!objEvent.AllDayEvent)
                        {
                            dgRow["EndTime"] = objEvent.EventTimeEnd;
                        }
                        else
                        {
                            // all day events are recorded as 23:59
                            dgRow["EndTime"] = objEvent.EventTimeEnd.AddMinutes(1);
                        }
                        //**** Add ModuleName if SubCalendar
                        var imagestring = "";
                        if (this.Settings.Eventimage && this.Settings.EventImageWeek &&
                            objEvent.ImageURL != null && objEvent.ImageDisplay)
                        {
                            imagestring = this.ImageInfo(objEvent.ImageURL, objEvent.ImageHeight, objEvent.ImageWidth);
                        }

                        dgRow["BackColor"] = "";
                        var iconString = "";

                        var eventtext = this.CreateEventName(objEvent, this.Settings.Templates.txtWeekEventText);

                        if (!this.IsPrivateNotModerator || this.UserId == objEvent.OwnerID)
                        {
                            var forecolorstr = "";
                            var backcolorstr = "";
                            var blankstr     = "";
                            if (objEvent.Color != "")
                            {
                                backcolorstr       = "background-color: " + objEvent.Color + ";";
                                blankstr           = "&nbsp;";
                                dgRow["BackColor"] = objEvent.Color;
                            }
                            if (objEvent.FontColor != "")
                            {
                                forecolorstr = "color: " + objEvent.FontColor + ";";
                            }
                            dgRow["Task"] = "<span style=\"" + backcolorstr + forecolorstr + "\">" + imagestring +
                                            blankstr + eventtext + blankstr + "</span>";

                            iconString =
                                this.CreateIconString(objEvent, this.Settings.IconWeekPrio, this.Settings.IconWeekRec,
                                                      this.Settings.IconWeekReminder, this.Settings.IconWeekEnroll);

                            // Get detail page url
                            dgRow["URL"] = objEventInfoHelper.DetailPageURL(objEvent);
                            if (objEvent.DetailPage && objEvent.DetailNewWin)
                            {
                                dgRow["Target"] = "_blank";
                            }
                        }
                        else
                        {
                            dgRow["Task"] = imagestring + eventtext;
                        }

                        dgRow["Icons"]         = iconString;
                        dgRow["Description"]   = objEvent.EventDesc;
                        dgRow["StartDateTime"] = objEvent.EventTimeBegin;
                        dgRow["Duration"]      = objEvent.Duration;
                        if (this.Settings.Eventtooltipweek)
                        {
                            var isEvtEditor = this.IsEventEditor(objEvent, false);
                            dgRow["Tooltip"] =
                                this.ToolTipCreate(objEvent, this.Settings.Templates.txtTooltipTemplateTitle,
                                                   this.Settings.Templates.txtTooltipTemplateBody, isEvtEditor);
                        }


                        eventTable.Rows.Add(dgRow);
                    }
                }
                var dvEvent = new DataView(eventTable);

                this.schWeek.StartDate        = this._dWeekStart;
                this.schWeek.DateFormatString = this.Settings.Templates.txtWeekTitleDate;
                this.schWeek.Weeks            = 1;
                this.schWeek.DataSource       = dvEvent;
                this.schWeek.DataBind();
            }
            catch
            { }
        }
Exemple #7
0
        private void Page_Load(object sender, EventArgs e)
        {
            var iDaysBefore   = 0;
            var iDaysAfter    = 0;
            var iMax          = 0;
            var iOwnerID      = 0;
            var iLocationID   = 0;
            var iImportance   = 0;
            var categoryIDs   = new ArrayList();
            var locationIDs   = new ArrayList();
            var iGroupId      = -1;
            var iUserId       = -1;
            var iCategoryName = "";
            var iLocationName = "";
            var iOwnerName    = "";
            var txtPriority   = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["mid"]))
            {
                _moduleID = Convert.ToInt32(HttpContext.Current.Request.QueryString["mid"]);
            }
            else
            {
                Response.Redirect(Globals.NavigateURL(), true);
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["tabid"]))
            {
                _tabID = Convert.ToInt32(HttpContext.Current.Request.QueryString["tabid"]);
            }
            else
            {
                Response.Redirect(Globals.NavigateURL(), true);
            }

            var localResourceFile = TemplateSourceDirectory + "/" + Localization.LocalResourceDirectory +
                                    "/EventRSS.aspx.resx";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["CategoryName"]))
            {
                iCategoryName = HttpContext.Current.Request.QueryString["CategoryName"];
                var objSecurity = new PortalSecurity();
                iCategoryName = objSecurity.InputFilter(iCategoryName, PortalSecurity.FilterFlag.NoSQL);
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["CategoryID"]))
            {
                categoryIDs.Add(Convert.ToInt32(HttpContext.Current.Request.QueryString["CategoryID"]));
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["LocationName"]))
            {
                iLocationName = HttpContext.Current.Request.QueryString["LocationName"];
                var objSecurity = new PortalSecurity();
                iLocationName = objSecurity.InputFilter(iLocationName, PortalSecurity.FilterFlag.NoSQL);
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["LocationID"]))
            {
                locationIDs.Add(Convert.ToInt32(HttpContext.Current.Request.QueryString["LocationID"]));
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["groupid"]))
            {
                iGroupId = Convert.ToInt32(HttpContext.Current.Request.QueryString["groupid"]);
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["DaysBefore"]))
            {
                iDaysBefore = Convert.ToInt32(HttpContext.Current.Request.QueryString["DaysBefore"]);
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["DaysAfter"]))
            {
                iDaysAfter = Convert.ToInt32(HttpContext.Current.Request.QueryString["DaysAfter"]);
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["MaxNumber"]))
            {
                iMax = Convert.ToInt32(HttpContext.Current.Request.QueryString["MaxNumber"]);
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["OwnerName"]))
            {
                iOwnerName = HttpContext.Current.Request.QueryString["OwnerName"];
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["OwnerID"]))
            {
                iOwnerID = Convert.ToInt32(HttpContext.Current.Request.QueryString["OwnerID"]);
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["LocationName"]))
            {
                iLocationName = HttpContext.Current.Request.QueryString["LocationName"];
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["LocationID"]))
            {
                iLocationID = Convert.ToInt32(HttpContext.Current.Request.QueryString["LocationID"]);
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["Priority"]))
            {
                var iPriority = "";
                iPriority = HttpContext.Current.Request.QueryString["Priority"];
                var lHigh   = "";
                var lMedium = "";
                var lLow    = "";
                lHigh   = Localization.GetString("High", localResourceFile);
                lMedium = Localization.GetString("Normal", localResourceFile);
                lLow    = Localization.GetString("Low", localResourceFile);

                txtPriority = "Medium";
                if (iPriority == lHigh)
                {
                    txtPriority = "High";
                }
                else if (iPriority == lMedium)
                {
                    txtPriority = "Medium";
                }
                else if (iPriority == lLow)
                {
                    txtPriority = "Low";
                }
                else if (iPriority == "High")
                {
                    txtPriority = "High";
                }
                else if (iPriority == "Normal")
                {
                    txtPriority = "Medium";
                }
                else if (iPriority == "Low")
                {
                    txtPriority = "Low";
                }
            }

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["Importance"]))
            {
                iImportance = Convert.ToInt32(HttpContext.Current.Request.QueryString["Importance"]);
            }

            var portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            _portalID = portalSettings.PortalId;
            _userinfo = (UserInfo)HttpContext.Current.Items["UserInfo"];

            if (!string.IsNullOrEmpty(portalSettings.DefaultLanguage))
            {
                var userculture = new CultureInfo(portalSettings.DefaultLanguage, false);
                Thread.CurrentThread.CurrentCulture = userculture;
            }

            if (_userinfo.UserID > 0)
            {
                if (!string.IsNullOrEmpty(_userinfo.Profile.PreferredLocale))
                {
                    var userculture = new CultureInfo(_userinfo.Profile.PreferredLocale, false);
                    Thread.CurrentThread.CurrentCulture = userculture;
                }
            }

            _settings = EventModuleSettings.GetEventModuleSettings(_moduleID, localResourceFile);

            if (_settings.Enablecategories == EventModuleSettings.DisplayCategories.DoNotDisplay)
            {
                categoryIDs   = _settings.ModuleCategoryIDs;
                iCategoryName = "";
            }

            if (!string.IsNullOrEmpty(iCategoryName))
            {
                var oCntrlEventCategory = new EventCategoryController();
                var oEventCategory      = oCntrlEventCategory.EventCategoryGetByName(iCategoryName, _portalID);
                if (!ReferenceEquals(oEventCategory, null))
                {
                    categoryIDs.Add(oEventCategory.Category);
                }
            }

            if (_settings.Enablelocations == EventModuleSettings.DisplayLocations.DoNotDisplay)
            {
                locationIDs   = _settings.ModuleLocationIDs;
                iLocationName = "";
            }

            if (!string.IsNullOrEmpty(iLocationName))
            {
                var oCntrlEventLocation = new EventLocationController();
                var oEventLocation      = oCntrlEventLocation.EventsLocationGetByName(iLocationName, _portalID);
                if (!ReferenceEquals(oEventLocation, null))
                {
                    locationIDs.Add(oEventLocation.Location);
                }
            }

            if (!_settings.RSSEnable)
            {
                Response.Redirect(Globals.NavigateURL(), true);
            }

            if (_settings.SocialGroupModule == EventModuleSettings.SocialModule.UserProfile)
            {
                iUserId = _userinfo.UserID;
            }
            var getSubEvents = _settings.MasterEvent;

            // Define the range of dates that we have to select
            var dtEndDate = default(DateTime);

            if (iDaysBefore == 0 && iDaysAfter == 0)
            {
                iDaysAfter = _settings.RSSDays;
            }

            var objEventTimeZoneUtilities = new EventTimeZoneUtilities();
            var currDate = objEventTimeZoneUtilities.ConvertFromUTCToModuleTimeZone(DateTime.UtcNow, _settings.TimeZoneId);

            dtEndDate = DateAndTime.DateAdd(DateInterval.Day, iDaysAfter, currDate).Date;

            var dtStartDate = default(DateTime);

            dtStartDate = DateAndTime.DateAdd(DateInterval.Day, Convert.ToDouble(-iDaysBefore), currDate).Date;

            var txtFeedRootTitle       = "";
            var txtFeedRootDescription = "";
            var txtRSSDateField        = "";

            txtFeedRootTitle       = _settings.RSSTitle;
            txtFeedRootDescription = _settings.RSSDesc;
            txtRSSDateField        = _settings.RSSDateField;

            // Get ready for the RSS feed
            Response.ContentType     = "text/xml";
            Response.ContentEncoding = Encoding.UTF8;


            using (var sw = new StringWriter())
            {
                using (var writer = new XmlTextWriter(sw))
                {
                    //                Dim writer As XmlTextWriter = New XmlTextWriter(sw)
                    writer.Formatting  = Formatting.Indented;
                    writer.Indentation = 4;

                    writer.WriteStartElement("rss");
                    writer.WriteAttributeString("version", "2.0");
                    writer.WriteAttributeString("xmlns:wfw", "http://wellformedweb.org/CommentAPI/");
                    writer.WriteAttributeString("xmlns:slash", "http://purl.org/rss/1.0/modules/slash/");
                    writer.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/");
                    writer.WriteAttributeString("xmlns:trackback",
                                                "http://madskills.com/public/xml/rss/module/trackback/");
                    writer.WriteAttributeString("xmlns:atom", "http://www.w3.org/2005/Atom");
                    writer.WriteAttributeString("xmlns", NsPre, null, NsFull);

                    writer.WriteStartElement("channel");

                    writer.WriteStartElement("atom:link");
                    writer.WriteAttributeString("href", HttpContext.Current.Request.Url.AbsoluteUri);
                    writer.WriteAttributeString("rel", "self");
                    writer.WriteAttributeString("type", "application/rss+xml");
                    writer.WriteEndElement();

                    writer.WriteElementString("title", portalSettings.PortalName + " - " + txtFeedRootTitle);

                    if (portalSettings.PortalAlias.HTTPAlias.IndexOf("http://", StringComparison.Ordinal) == -1 &&
                        portalSettings.PortalAlias.HTTPAlias.IndexOf("https://", StringComparison.Ordinal) == -1)
                    {
                        writer.WriteElementString("link", Globals.AddHTTP(portalSettings.PortalAlias.HTTPAlias));
                    }
                    else
                    {
                        writer.WriteElementString("link", portalSettings.PortalAlias.HTTPAlias);
                    }

                    writer.WriteElementString("description", txtFeedRootDescription);
                    writer.WriteElementString("ttl", "60");

                    var objEventInfoHelper =
                        new EventInfoHelper(_moduleID, _tabID, _portalID, _settings);
                    var lstEvents      = default(ArrayList);
                    var tcc            = new TokenReplaceControllerClass(_moduleID, localResourceFile);
                    var tmpTitle       = _settings.Templates.txtRSSTitle;
                    var tmpDescription = _settings.Templates.txtRSSDescription;
                    if (categoryIDs.Count == 0)
                    {
                        categoryIDs.Add("-1");
                    }
                    if (locationIDs.Count == 0)
                    {
                        locationIDs.Add("-1");
                    }

                    lstEvents = objEventInfoHelper.GetEvents(dtStartDate, dtEndDate, getSubEvents, categoryIDs,
                                                             locationIDs, iGroupId, iUserId);

                    var objEventBase      = new EventBase();
                    var displayTimeZoneId = objEventBase.GetDisplayTimeZoneId(_settings, _portalID);

                    var rssCount = 0;
                    foreach (EventInfo eventInfo in lstEvents)
                    {
                        var objEvent = eventInfo;

                        if ((Convert.ToInt32(categoryIDs[0]) == 0) &
                            (objEvent.Category != Convert.ToInt32(categoryIDs[0])))
                        {
                            continue;
                        }
                        if ((Convert.ToInt32(locationIDs[0]) == 0) &
                            (objEvent.Location != Convert.ToInt32(locationIDs[0])))
                        {
                            continue;
                        }
                        if ((iOwnerID > 0) & (objEvent.OwnerID != iOwnerID))
                        {
                            continue;
                        }
                        if (!string.IsNullOrEmpty(iOwnerName) && objEvent.OwnerName != iOwnerName)
                        {
                            continue;
                        }
                        if ((iLocationID > 0) & (objEvent.Location != iLocationID))
                        {
                            continue;
                        }
                        if (!string.IsNullOrEmpty(iLocationName) && objEvent.LocationName != iLocationName)
                        {
                            continue;
                        }
                        if (iImportance > 0 && (int)objEvent.Importance != iImportance)
                        {
                            continue;
                        }
                        if (!string.IsNullOrEmpty(txtPriority) && objEvent.Importance.ToString() != txtPriority)
                        {
                            continue;
                        }

                        // If full enrollments should be hidden, ignore
                        if (HideFullEvent(objEvent))
                        {
                            continue;
                        }

                        var pubDate       = default(DateTime);
                        var pubTimeZoneId = "";
                        switch (txtRSSDateField)
                        {
                        case "UPDATEDDATE":
                            pubDate       = objEvent.LastUpdatedAt;
                            pubTimeZoneId = objEvent.OtherTimeZoneId;
                            break;

                        case "CREATIONDATE":
                            pubDate       = objEvent.CreatedDate;
                            pubTimeZoneId = objEvent.OtherTimeZoneId;
                            break;

                        case "EVENTDATE":
                            pubDate       = objEvent.EventTimeBegin;
                            pubTimeZoneId = objEvent.EventTimeZoneId;
                            break;
                        }

                        objEvent = objEventInfoHelper.ConvertEventToDisplayTimeZone(objEvent, displayTimeZoneId);

                        writer.WriteStartElement("item");
                        var eventTitle = tcc.TokenReplaceEvent(objEvent, tmpTitle);
                        writer.WriteElementString("title", eventTitle);

                        var eventDescription = tcc.TokenReplaceEvent(objEvent, tmpDescription);
                        var txtDescription   = HttpUtility.HtmlDecode(eventDescription);
                        writer.WriteElementString("description", txtDescription);

                        var txtURL = objEventInfoHelper.DetailPageURL(objEvent);
                        writer.WriteElementString("link", txtURL);
                        writer.WriteElementString("guid", txtURL);

                        writer.WriteElementString("pubDate", GetRFC822Date(pubDate, pubTimeZoneId));

                        writer.WriteElementString("dc:creator", objEvent.OwnerName);

                        if (objEvent.Category > 0)
                        {
                            writer.WriteElementString("category", objEvent.CategoryName);
                        }
                        if (objEvent.Location > 0)
                        {
                            writer.WriteElementString("category", objEvent.LocationName);
                        }
                        if ((int)objEvent.Importance != 2)
                        {
                            var strImportance = Localization.GetString(objEvent.Importance + "Prio", localResourceFile);
                            writer.WriteElementString("category", strImportance);
                        }

                        // specific event data
                        writer.WriteElementString(NsPre, "AllDayEvent", null, objEvent.AllDayEvent.ToString());
                        writer.WriteElementString(NsPre, "Approved", null, objEvent.Approved.ToString());
                        writer.WriteElementString(NsPre, "Cancelled", null, objEvent.Cancelled.ToString());
                        writer.WriteElementString(NsPre, "Category", null, objEvent.CategoryName);
                        //writer.WriteElementString(NsPre, "Location", Nothing, objEvent.LocationName)
                        writer.WriteElementString(NsPre, "DetailURL", null, objEvent.DetailURL);
                        writer.WriteElementString(NsPre, "EventTimeBegin", null,
                                                  objEvent.EventTimeBegin.ToString("yyyy-MM-dd HH:mm:ss"));
                        writer.WriteElementString(NsPre, "EventTimeZoneId", null, objEvent.EventTimeZoneId);
                        writer.WriteElementString(NsPre, "Duration", null, objEvent.Duration.ToString());
                        writer.WriteElementString(NsPre, "ImageURL", null, objEvent.ImageURL);
                        writer.WriteElementString(NsPre, "LocationName", null, objEvent.LocationName);
                        writer.WriteElementString(NsPre, "OriginalDateBegin", null,
                                                  objEvent.OriginalDateBegin.ToString("yyyy-MM-dd HH:mm:ss"));
                        writer.WriteElementString(NsPre, "Signups", null, objEvent.Signups.ToString());
                        writer.WriteElementString(NsPre, "OtherTimeZoneId", null, objEvent.OtherTimeZoneId);

                        writer.WriteEndElement();

                        rssCount++;
                        if ((iMax > 0) & (rssCount == iMax))
                        {
                            break;
                        }
                    }

                    writer.WriteEndElement();
                    writer.WriteEndElement();

                    Response.Write(sw.ToString());
                }
            }
        }