Exemplo n.º 1
0
        private void BindDataGrid()
        {
            //Default sort from settings
            var sortDirection = default(SortDirection);

            if (this.Settings.EventsListSortDirection == "ASC")
            {
                sortDirection = SortDirection.Ascending;
            }
            else
            {
                sortDirection = SortDirection.Descending;
            }

            var sortExpression = (EventInfo.SortFilter) this.GetListSortExpression(this.Settings.EventsListSortColumn);

            // Get Events/Sub-Calendar Events
            this._selectedEvents = this.Get_ListView_Events(this.SelectCategory.SelectedCategory,
                                                            this.SelectLocation.SelectedLocation);

            EventInfo.SortExpression = sortExpression;
            EventInfo.SortDirection  = sortDirection;
            this._selectedEvents.Sort();

            var tcc        = new TokenReplaceControllerClass(this.ModuleId, this.LocalResourceFile);
            var eventTable = new DataTable("Events");

            eventTable.Columns.Add("EventText", Type.GetType("System.String"));
            eventTable.Columns.Add("Tooltip", Type.GetType("System.String"));

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

            var dgRow         = default(DataRow);
            var clientIdCount = 1;

            foreach (EventInfo objEvent in this._selectedEvents)
            {
                dgRow = eventTable.NewRow();
                var blAddSubModuleName = false;
                if (objEvent.ModuleID != this.ModuleId && objEvent.ModuleTitle != null &&
                    this.Settings.Addsubmodulename)
                {
                    blAddSubModuleName = true;
                }
                var isEvtEditor = this.IsEventEditor(objEvent, false);
                var tmpText     = this.Settings.Templates.txtListRptBody;
                var tmpTooltip  = "";
                if (this.Settings.Eventtooltiplist)
                {
                    tmpTooltip = this.ToolTipCreate(objEvent, this.Settings.Templates.txtTooltipTemplateTitle,
                                                    this.Settings.Templates.txtTooltipTemplateBody, isEvtEditor);
                    dgRow["Tooltip"] = tmpTooltip;
                }
                if (!this.Settings.ListViewTable)
                {
                    var tooltip = HttpUtility.HtmlEncode(tmpTooltip);
                    tmpText = this.AddTooltip(clientIdCount, tooltip, tmpText);
                    clientIdCount++;
                }

                dgRow["EventText"] = tcc.TokenReplaceEvent(objEvent, tmpText, null, blAddSubModuleName, isEvtEditor);

                eventTable.Rows.Add(dgRow);
            }

            var pgEvents = new PagedDataSource();
            var dvEvents = new DataView(eventTable);

            pgEvents.DataSource       = dvEvents;
            pgEvents.AllowPaging      = true;
            pgEvents.PageSize         = this.Settings.RptColumns * this.Settings.RptRows;
            pgEvents.CurrentPageIndex = this.PageNumber;
            if (pgEvents.PageCount > 1)
            {
                this.rptTRPager.Visible = true;
                var pages = new ArrayList();
                for (var i = 0; i <= pgEvents.PageCount - 1; i++)
                {
                    pages.Add(i + 1);
                }
                this.rptPager.DataSource = pages;
                this.rptPager.DataBind();
            }
            else
            {
                this.rptTRPager.Visible = false;
            }

            if (pgEvents.CurrentPageIndex + 1 < pgEvents.PageCount)
            {
                this._rptItemCount = pgEvents.PageSize;
            }
            else
            {
                this._rptItemCount = eventTable.Rows.Count - pgEvents.CurrentPageIndex * pgEvents.PageSize;
            }

            this.rptEvents.DataSource = pgEvents;
            this.rptEvents.DataBind();
        }
Exemplo n.º 2
0
        protected void rptEvents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var rptColumns  = this.Settings.RptColumns;
            var columnWidth = "\"" + Convert.ToInt32((double)100 / this.Settings.RptColumns) + "%\"";

            switch (e.Item.ItemType)
            {
            case ListItemType.Header:
                const string rptHeaderTable = "<table class=\"RptRepeater\">";
                var          rptHeaderStart =
                    "<tr id=\"rptTRHeader\" ><th id=\"rptTDHeader\" class=\"RptHeader\" colspan=\"" +
                    this.Settings.RptColumns + "\">";
                const string rptHeaderEnd = "</th></tr>";

                var rptHeaderBody =
                    this.Settings.Templates.txtListRptHeader.Replace(
                        "[event:repeaterheadertext]",
                        Localization.GetString("TokenListRptHeader", this.LocalResourceFile));
                rptHeaderBody = rptHeaderBody.Replace("[event:repeaterzeroeventstext]",
                                                      Localization.GetString(
                                                          "TokenListRptHeaderZeroEvents", this.LocalResourceFile));
                var tcc = new TokenReplaceControllerClass(this.ModuleId, this.LocalResourceFile);
                if (this._rptItemCount == 0)
                {
                    rptHeaderBody = tcc.TokenOneParameter(rptHeaderBody, "IFZEROEVENTS", true);
                }
                else
                {
                    rptHeaderBody = tcc.TokenOneParameter(rptHeaderBody, "IFZEROEVENTS", false);
                }

                var rptHeader = (Literal)e.Item.FindControl("rptHeader");
                if (this.Settings.ListViewTable)
                {
                    rptHeader.Text = rptHeaderTable;
                    if (!string.IsNullOrEmpty(rptHeaderBody))
                    {
                        rptHeader.Text = rptHeader.Text + rptHeaderStart + rptHeaderBody + rptHeaderEnd;
                    }
                }
                else
                {
                    rptHeader.Text = rptHeaderBody;
                }
                break;

            case ListItemType.Footer:
                var rptFooterStart =
                    "<tr id=\"rptTRFooter\"><td id=\"rptTDFooter\" class=\"RptFooter\" colspan=\"" +
                    this.Settings.RptColumns + "\">";
                const string rptFooterEnd   = "</td></tr>";
                const string rptFooterTable = "</table>";
                var          rptFooterBody  =
                    this.Settings.Templates.txtListRptFooter.Replace(
                        "[event:repeaterfootertext]",
                        Localization.GetString("TokenListRptFooter", this.LocalResourceFile));
                var rptFooter = (Literal)e.Item.FindControl("rptFooter");
                if (this.Settings.ListViewTable)
                {
                    if (!string.IsNullOrEmpty(rptFooterBody))
                    {
                        rptFooter.Text = rptFooterStart + rptFooterBody + rptFooterEnd;
                    }
                    rptFooter.Text = rptFooter.Text + rptFooterTable;
                }
                else
                {
                    rptFooter.Text = rptFooterBody;
                }
                break;

            default:
                var rptBody    = (Literal)e.Item.FindControl("rptBody");
                var rptRowBody = Convert.ToString(DataBinder.Eval(e.Item.DataItem, "EventText"));
                this._rptCurrentItemCount++;
                if (this.Settings.ListViewTable)
                {
                    var rptBodyStart = "<td [event:repeatertooltip] width=" + columnWidth + ">";

                    const string rptBodyEnd  = "</td>";
                    var          rptRowStart = "";
                    if ((this._rptCurrentItemCount - 1) % rptColumns == 0)
                    {
                        this._rptAlternate = !this._rptAlternate;
                        var rptCellClass = "RptNormal";
                        if (this._rptAlternate)
                        {
                            rptCellClass = "RptAlternate";
                        }
                        rptRowStart = "<tr class=\"" + rptCellClass + "\" >" + rptBodyStart;
                    }
                    else
                    {
                        rptRowStart = rptBodyStart;
                    }

                    var rptRowEnd = "";
                    if (this._rptCurrentItemCount % rptColumns == 0)
                    {
                        rptRowEnd = rptBodyEnd + "</tr>";
                    }
                    else if (this._rptItemCount == this._rptCurrentItemCount)
                    {
                        // ReSharper disable RedundantAssignment
                        for (var i = 1; i <= rptColumns - this._rptCurrentItemCount % rptColumns; i++)
                        {
                            // ReSharper restore RedundantAssignment
                            rptRowEnd += "<td width=" + columnWidth + " ></td>";
                        }
                        rptRowEnd += "</tr>";
                    }
                    else
                    {
                        rptRowEnd = rptBodyEnd;
                    }
                    var tooltip = "";
                    if (this.Settings.Eventtooltiplist)
                    {
                        tooltip = HttpUtility.HtmlEncode(
                            Convert.ToString(DataBinder.Eval(e.Item.DataItem, "Tooltip")));
                    }
                    rptBody.Text = this.AddTooltip(this._rptCurrentItemCount, tooltip, rptRowStart) + rptRowBody +
                                   rptRowEnd;
                }
                else
                {
                    rptBody.Text = rptRowBody;
                }
                break;
            }
        }
Exemplo n.º 3
0
        private void BindDataGrid(EventListObject.SortFilter sortExpression, SortDirection sortDirection)
        {
            var culture            = Thread.CurrentThread.CurrentCulture;
            var objEvent           = default(EventInfo);
            var objEventInfoHelper = new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings);
            var editColumnVisible  = false;

            // Get Events/Sub-Calendar Events
            this._selectedEvents = this.Get_ListView_Events(this.SelectCategory.SelectedCategory,
                                                            this.SelectLocation.SelectedLocation);

            var fmtEventTimeBegin = this.Settings.Templates.txtListEventTimeBegin;

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

            var fmtEventTimeEnd = this.Settings.Templates.txtListEventTimeEnd;

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

            var tmpListDescription = this.Settings.Templates.txtListEventDescription;
            var tmpListLocation    = this.Settings.Templates.txtListLocation;

            if (this._selectedEvents.Count == 0)
            {
                this.gvEvents.Visible    = false;
                this.divNoEvents.Visible = true;
                return;
            }
            this.gvEvents.Visible    = true;
            this.divNoEvents.Visible = false;

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

            // if Events Selection Type only get the 1st N Events
            var colEvents = new ArrayList();
            var lstEvent  = default(EventListObject);
            var indexID   = 0;

            foreach (EventInfo tempLoopVar_objEvent in this._selectedEvents)
            {
                objEvent = tempLoopVar_objEvent;
                var tcc = new TokenReplaceControllerClass(this.ModuleId, this.LocalResourceFile);
                var objCtlEventRecurMaster = new EventRecurMasterController();
                var fmtRowEnd   = "";
                var fmtRowBegin = "";
                fmtRowEnd   = tcc.TokenParameters(fmtEventTimeEnd, objEvent, this.Settings);
                fmtRowBegin = tcc.TokenParameters(fmtEventTimeBegin, objEvent, this.Settings);

                lstEvent             = new EventListObject();
                lstEvent.EventID     = objEvent.EventID;
                lstEvent.CreatedByID = objEvent.CreatedByID;
                lstEvent.OwnerID     = objEvent.OwnerID;
                lstEvent.IndexId     = indexID;
                // Get Dates (automatically converted to User's Timezone)
                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 = this.IsEventEditor(objEvent, false);

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

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

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

                lstEvent.EventName = this.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, ""));

                var objEventRRULE = default(EventRRULEInfo);
                objEventRRULE      = objCtlEventRecurMaster.DecomposeRRULE(objEvent.RRULE, objEvent.EventTimeBegin);
                lstEvent.RecurText =
                    objCtlEventRecurMaster.RecurrenceText(objEventRRULE, this.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 (this.Settings.Eventimage && objEvent.ImageURL != null && objEvent.ImageDisplay)
                {
                    lstEvent.ImageURL = this.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, tmpListLocation);
                lstEvent.CustomField1    = objEvent.CustomField1;
                lstEvent.CustomField2    = objEvent.CustomField2;
                lstEvent.RecurMasterID   = objEvent.RecurMasterID;

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

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

                colEvents.Add(lstEvent);
                indexID++;
            }

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

            EventListObject.SortExpression = sortExpression;
            EventListObject.SortDirection  = sortDirection;
            colEvents.Sort();

            this.gvEvents.DataKeyNames = new[] { "IndexId", "EventID", "EventDateBegin" };
            this.gvEvents.DataSource   = colEvents;
            this.gvEvents.DataBind();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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());
                }
            }
        }