Beispiel #1
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();
        }
Beispiel #2
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();
        }