コード例 #1
0
        public void grdEnrollment_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName)
                {
                case "Select":
                    var objEnroll          = default(EventSignupsInfo);
                    var objCtlEventSignups = new EventSignupsController();
                    objEnroll = objCtlEventSignups.EventsSignupsGet(
                        Convert.ToInt32(grdEnrollment.DataKeys[e.Item.ItemIndex]), ModuleId, false);
                    var iItemID = objEnroll.EventID;

                    var objEventInfoHelper =
                        new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
                    Response.Redirect(
                        objEventInfoHelper.GetDetailPageRealURL(
                            iItemID, GetUrlGroupId(), GetUrlUserId()));
                    break;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
            BindData();
        }
コード例 #2
0
        private void UpdateSubscriptions()
        {
            var objCtlEventSubscriptions = new EventSubscriptionController();
            var lstEventSubscriptions    = default(ArrayList);

            lstEventSubscriptions = objCtlEventSubscriptions.EventsSubscriptionGetModule(this.ModuleId);
            if (lstEventSubscriptions.Count == 0)
            {
                return;
            }

            var objEventInfo = new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, null);
            var lstusers     = objEventInfo.GetEventModuleViewers();

            var objEventSubscription = default(EventSubscriptionInfo);

            foreach (EventSubscriptionInfo tempLoopVar_objEventSubscription in lstEventSubscriptions)
            {
                objEventSubscription = tempLoopVar_objEventSubscription;
                if (!lstusers.Contains(objEventSubscription.UserID))
                {
                    var objCtlUser = new UserController();
                    var objUser    = objCtlUser.GetUser(this.PortalId, objEventSubscription.UserID);

                    if (ReferenceEquals(objUser, null) || !objUser.IsSuperUser)
                    {
                        objCtlEventSubscriptions.EventsSubscriptionDeleteUser(
                            objEventSubscription.UserID, this.ModuleId);
                    }
                }
            }
        }
コード例 #3
0
ファイル: EventRSS.aspx.cs プロジェクト: jspsoft/DNN.Events
        private bool HideFullEvent(EventInfo objevent)
        {
            var objEventInfoHelper = new EventInfoHelper(_moduleID, _tabID, _portalID, _settings);

            return(objEventInfoHelper.HideFullEvent(objevent, _settings.Eventhidefullenroll, _userinfo.UserID,
                                                    Request.IsAuthenticated));
        }
コード例 #4
0
        public void grdEnrollment_ItemCommand(object sender, DataGridCommandEventArgs e)
        {
            var objEnroll = default(EventSignupsInfo);

            objEnroll = _objCtlEventSignups.EventsSignupsGet(
                Convert.ToInt32(grdEnrollment.DataKeys[e.Item.ItemIndex]), ModuleId, false);

            try
            {
                switch (e.CommandName)
                {
                case "Select":
                    try
                    {
                        var itemID             = objEnroll.EventID;
                        var objEventInfoHelper =
                            new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
                        Response.Redirect(
                            objEventInfoHelper.AddSkinContainerControls(
                                EditUrl("ItemID", itemID.ToString(), "Edit"), "?"));
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    catch (Exception)
                    { }
                    break;

                case "User":
                    var objCtlEvent = new EventController();
                    var objEvent    = objCtlEvent.EventsGet(objEnroll.EventID, objEnroll.ModuleID);

                    var objEventEmailInfo = new EventEmailInfo();
                    var objEventEmail     = new EventEmails(PortalId, ModuleId, LocalResourceFile,
                                                            ((PageBase)Page).PageCulture.Name);
                    objEventEmailInfo.TxtEmailSubject = txtEmailSubject.Text;
                    objEventEmailInfo.TxtEmailBody    = txtEmailMessage.Text;
                    objEventEmailInfo.TxtEmailFrom    = txtEmailFrom.Text;
                    if (objEnroll.UserID > -1)
                    {
                        objEventEmailInfo.UserIDs.Add(objEnroll.UserID);
                    }
                    else
                    {
                        objEventEmailInfo.UserEmails.Add(objEnroll.AnonEmail);
                        objEventEmailInfo.UserLocales.Add(objEnroll.AnonCulture);
                        objEventEmailInfo.UserTimeZoneIds.Add(objEnroll.AnonTimeZoneId);
                    }
                    objEventEmail.SendEmails(objEventEmailInfo, objEvent, objEnroll);
                    break;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
            BindData();
        }
コード例 #5
0
 protected void gvEvents_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     switch (e.CommandName)
     {
     case "Edit":
         var iItemID = Convert.ToInt32(e.CommandArgument);
         //set selected row editable
         var objEventInfoHelper =
             new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings);
         this.Response.Redirect(
             objEventInfoHelper.GetEditURL(iItemID, this.GetUrlGroupId(), this.GetUrlUserId()));
         break;
     }
 }
コード例 #6
0
 public void grdEvents_ItemCommand(object sender, DataGridCommandEventArgs e)
 {
     switch (e.CommandName)
     {
     case "Select":
         var itemID             = Convert.ToInt32(grdEvents.DataKeys[e.Item.ItemIndex]);
         var objEventInfoHelper =
             new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
         Response.Redirect(
             objEventInfoHelper.AddSkinContainerControls(
                 Globals.NavigateURL(TabId, "Edit", "Mid=" + ModuleId, "ItemID=" + itemID,
                                     "EditRecur=Single"), "?"));
         break;
     }
 }
コード例 #7
0
 public void grdRecurEvents_ItemCommand(object sender, DataGridCommandEventArgs e)
 {
     switch (e.CommandName)
     {
     case "Select":
         var itemID             = Convert.ToInt32(e.Item.Cells[4].Text);
         var objEventInfoHelper =
             new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings);
         this.Response.Redirect(
             objEventInfoHelper.AddSkinContainerControls(
                 Globals.NavigateURL(this.TabId, "Edit", "Mid=" + this.ModuleId, "ItemID=" + itemID,
                                     "EditRecur=All"), "?"));
         break;
     }
 }
コード例 #8
0
ファイル: EventDay.ascx.cs プロジェクト: MaiklT/DNN.Events
 protected void lstEvents_ItemCommand(object source, DataGridCommandEventArgs e)
 {
     try
     {
         switch (e.CommandName)
         {
         case "Edit":
             //set selected row editable
             var iItemID            = Convert.ToInt32(e.CommandArgument);
             var objEventInfoHelper =
                 new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
             Response.Redirect(
                 objEventInfoHelper.GetEditURL(iItemID, GetUrlGroupId(), GetUrlUserId()));
             break;
         }
     }
     catch (Exception exc) //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
コード例 #9
0
        protected void EventCalendar_SelectionChanged(object sender, EventArgs e)
        {
            EventCalendar.VisibleDate = EventCalendar.SelectedDate;
            SelectedDate = Convert.ToDateTime(EventCalendar.SelectedDate.Date);
            var urlDate = Convert.ToString(EventCalendar.SelectedDate.Date.ToShortDateString());

            dpGoToDate.SelectedDate = SelectedDate.Date;
            if (Settings.Monthcellnoevents)
            {
                try
                {
                    EventCalendar.SelectedDate = new DateTime();
                    if (Settings.Eventdaynewpage)
                    {
                        var objEventInfoHelper =
                            new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
                        Response.Redirect(
                            objEventInfoHelper.AddSkinContainerControls(
                                Globals.NavigateURL(TabId, "Day", "Mid=" + ModuleId,
                                                    "selecteddate=" + urlDate), "&"));
                    }
                    else
                    {
                        Response.Redirect(
                            Globals.NavigateURL(TabId, "", "ModuleID=" + ModuleId, "mctl=EventDay",
                                                "selecteddate=" + urlDate));
                    }
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch (Exception)
                { }
            }
            else
            {
                //fill grid with current selection's data
                BindDataGrid();
            }
        }
コード例 #10
0
ファイル: EventMonth.ascx.cs プロジェクト: thabaum/DNN.Events
        protected void EventCalendar_SelectionChanged(object sender, EventArgs e)
        {
            this.EventCalendar.VisibleDate = this.EventCalendar.SelectedDate;
            this.SelectedDate = Convert.ToDateTime(this.EventCalendar.SelectedDate.Date);
            var urlDate = Convert.ToString(this.EventCalendar.SelectedDate.Date.ToShortDateString());

            this.dpGoToDate.SelectedDate = this.SelectedDate.Date;
            if (this.Settings.Monthcellnoevents)
            {
                try
                {
                    this.EventCalendar.SelectedDate = new DateTime();
                    if (this.Settings.Eventdaynewpage)
                    {
                        var objEventInfoHelper =
                            new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings);
                        this.Response.Redirect(
                            objEventInfoHelper.AddSkinContainerControls(
                                Globals.NavigateURL(this.TabId, "Day", "Mid=" + this.ModuleId,
                                                    "selecteddate=" + urlDate), "&"));
                    }
                    else
                    {
                        this.Response.Redirect(
                            Globals.NavigateURL(this.TabId, "", "ModuleID=" + this.ModuleId, "mctl=EventDay",
                                                "selecteddate=" + urlDate));
                    }
                }
                catch (Exception)
                { }
            }
            else
            {
                //fill grid with current selection's data
                this.BindDataGrid();
            }
        }
コード例 #11
0
        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);
                        }
                    }
                }
            }
        }
コード例 #12
0
        private void BindData()
        {
            var objEventInfoHelper        = new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings);
            var objEventTimeZoneUtilities = new EventTimeZoneUtilities();

            this._eventModeration = new ArrayList();
            switch (this.rbModerate.SelectedValue)
            {
            case "Events":
                this._eventModeration =
                    objEventInfoHelper.ConvertEventListToDisplayTimeZone(
                        this._objCtlEvent.EventsModerateEvents(this.ModuleId, this.GetUrlGroupId()),
                        this.GetDisplayTimeZoneId());

                this._eventRecurModeration = new ArrayList();
                this._eventRecurModeration =
                    this._objCtlEventRecurMaster.EventsRecurMasterModerate(this.ModuleId, this.GetUrlGroupId());
                foreach (EventRecurMasterInfo objRecurMaster in this._eventRecurModeration)
                {
                    objRecurMaster.Dtstart = objEventTimeZoneUtilities
                                             .ConvertToDisplayTimeZone(objRecurMaster.Dtstart, objRecurMaster.EventTimeZoneId,
                                                                       this.PortalId, this.GetDisplayTimeZoneId()).EventDate;
                }

                //Get data for selected date and fill grid
                this.grdEvents.DataSource = this._eventModeration;
                this.grdEvents.DataBind();

                if (this._eventRecurModeration.Count > 0)
                {
                    this.grdRecurEvents.DataSource = this._eventRecurModeration;
                    this.grdRecurEvents.DataBind();
                    this.grdRecurEvents.Visible = true;
                }

                this.grdEvents.Visible     = true;
                this.grdEnrollment.Visible = false;
                break;

            case "Enrollment":
                this._eventModeration =
                    this._objCtlEventSignups.EventsModerateSignups(this.ModuleId, this.GetUrlGroupId());

                var objSignup = default(EventSignupsInfo);
                foreach (EventSignupsInfo tempLoopVar_objSignup in this._eventModeration)
                {
                    objSignup = tempLoopVar_objSignup;
                    if (objSignup.UserID != -1)
                    {
                        objSignup.UserName = objEventInfoHelper
                                             .UserDisplayNameProfile(objSignup.UserID, objSignup.UserName, this.LocalResourceFile)
                                             .DisplayNameURL;
                    }
                    else
                    {
                        objSignup.UserName = objSignup.AnonName;
                        objSignup.Email    = objSignup.AnonEmail;
                    }
                    if (objSignup.Email == "")
                    {
                        objSignup.EmailVisible = false;
                    }
                    else
                    {
                        objSignup.EmailVisible = true;
                    }
                    objSignup.EventTimeBegin = objEventTimeZoneUtilities
                                               .ConvertToDisplayTimeZone(objSignup.EventTimeBegin, objSignup.EventTimeZoneId,
                                                                         this.PortalId, this.GetDisplayTimeZoneId()).EventDate;
                }

                //Get data for selected date and fill grid
                this.grdEnrollment.DataSource = this._eventModeration;
                this.grdEnrollment.DataBind();
                //Add Remove Popup to grid
                var i = 0;
                if (this.grdEnrollment.Items.Count > 0)
                {
                    for (i = 0; i <= this.grdEnrollment.Items.Count - 1; i++)
                    {
                        //Are You Sure You Wish To Email the User?'
                        ((ImageButton)this.grdEnrollment.Items[i].FindControl("btnUserEmail")).Attributes.Add(
                            "onclick",
                            "javascript:return confirm('" +
                            Localization
                            .GetString(
                                "ConfirmModerateSendMailToUser",
                                this
                                .LocalResourceFile) +
                            "');");
                        ((ImageButton)this.grdEnrollment.Items[i].FindControl("btnUserEmail")).AlternateText =
                            Localization.GetString("EmailUser", this.LocalResourceFile);
                        ((ImageButton)this.grdEnrollment.Items[i].FindControl("btnUserEmail")).ToolTip =
                            Localization.GetString("EmailUser", this.LocalResourceFile);
                    }
                    this.grdEvents.Visible      = false;
                    this.grdRecurEvents.Visible = false;
                    this.grdEnrollment.Visible  = true;
                }
                break;
            }
            if (this._eventModeration.Count < 1)
            {
                //"No New Events/Enrollments to Moderate..."
                this.lblMessage.Text = Localization.GetString("MsgModerateNothingToModerate", this.LocalResourceFile);
                this.ShowButtonsGrid(false);
            }
            else
            {
                //Deny option will delete Event/Enrollment Entries from the Database!"
                this.lblMessage.Text = Localization.GetString("MsgModerateNoteDenyOption", this.LocalResourceFile);
                this.ShowButtonsGrid(true);
            }
        }
コード例 #13
0
        private void LoadModuleControl()
        {
            try
            {
                _socialGroupId = GetUrlGroupId();
                _socialUserId  = GetUrlUserId();
                var objModules       = new ModuleController();
                var objModule        = objModules.GetModule(ModuleId, TabId);
                var objDesktopModule =
                    DesktopModuleController.GetDesktopModule(objModule.DesktopModuleID, PortalId);
                var objEventInfoHelper = new EventInfoHelper(ModuleId, TabId, PortalId, Settings);

                // Force Module Default Settings on new Version or New Module Instance
                if (objDesktopModule.Version != Settings.Version)
                {
                    CreateThemeDirectory();
                    //                    objEventInfoHelper.SetDefaultModuleSettings(ModuleId, TabId, Page, LocalResourceFile)
                }

                if (!(Request.QueryString["mctl"] == null) &&
                    (ModuleId == Convert.ToInt32(Request.QueryString["ModuleID"]) ||
                     ModuleId == Convert.ToInt32(Request.QueryString["mid"])))
                {
                    if (Request["mctl"].EndsWith(".ascx"))
                    {
                        _mcontrolToLoad = Request["mctl"];
                    }
                    else
                    {
                        _mcontrolToLoad = Request["mctl"] + ".ascx";
                    }
                }

                // Set Default, if none selected
                if (_mcontrolToLoad.Length == 0)
                {
                    if (!ReferenceEquals(Request.Cookies.Get("DNNEvents" + Convert.ToString(ModuleId)), null))
                    {
                        _mcontrolToLoad = Request.Cookies.Get("DNNEvents" + Convert.ToString(ModuleId)).Value;
                    }
                    else
                    {
                        // See if Default View Set
                        _mcontrolToLoad = Settings.DefaultView;
                    }
                }

                // Check for Valid Module to Load
                _mcontrolToLoad = Path.GetFileNameWithoutExtension(_mcontrolToLoad) + ".ascx";
                switch (_mcontrolToLoad.ToLower())
                {
                case "eventdetails.ascx":
                    // Search and RSS feed may direct detail page url to base module -
                    // should be put in new page
                    if (Settings.Eventdetailnewpage)
                    {
                        //Get the item id of the selected event
                        if (!ReferenceEquals(Request.Params["ItemId"], null))
                        {
                            _itemId = int.Parse(Request.Params["ItemId"]);
                            var objCtlEvents = new EventController();
                            var objEvent     = objCtlEvents.EventsGet(_itemId, ModuleId);
                            if (!ReferenceEquals(objEvent, null))
                            {
                                Response.Redirect(
                                    objEventInfoHelper.GetDetailPageRealURL(
                                        objEvent.EventID, _socialGroupId, _socialUserId));
                            }
                        }
                    }
                    break;

                case "eventday.ascx":
                    break;

                case "eventmonth.ascx":
                    break;

                case "eventweek.ascx":
                    break;

                case "eventrpt.ascx":
                    if (Settings.ListViewGrid)
                    {
                        _mcontrolToLoad = "EventList.ascx";
                    }
                    break;

                case "eventlist.ascx":
                    if (!Settings.ListViewGrid)
                    {
                        _mcontrolToLoad = "EventRpt.ascx";
                    }
                    break;

                case "eventmoderate.ascx":
                    Response.Redirect(
                        objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(TabId, "Moderate", "Mid=" + ModuleId),
                            "?"));
                    break;

                case "eventmyenrollments.ascx":
                    break;

                default:
                    lblModuleSettings.Text    = Localization.GetString("lblBadControl", LocalResourceFile);
                    lblModuleSettings.Visible = true;
                    return;
                }

                var objPortalModuleBase = (PortalModuleBase)LoadControl(_mcontrolToLoad);
                objPortalModuleBase.ModuleConfiguration = ModuleConfiguration.Clone();
                objPortalModuleBase.ID = Path.GetFileNameWithoutExtension(_mcontrolToLoad);
                phMain.Controls.Add(objPortalModuleBase);

                //EVT-4499 Exlude the EventMyEnrollment.ascx to be set as cookie
                if (_mcontrolToLoad.ToLower() != "eventdetails.ascx" &&
                    _mcontrolToLoad.ToLower() != "eventday.ascx" &&
                    _mcontrolToLoad.ToLower() != "eventmyenrollments.ascx")
                {
                    var objCookie = new HttpCookie("DNNEvents" + Convert.ToString(ModuleId));
                    objCookie.Value = _mcontrolToLoad;
                    if (ReferenceEquals(Request.Cookies.Get("DNNEvents" + Convert.ToString(ModuleId)), null))
                    {
                        Response.Cookies.Add(objCookie);
                    }
                    else
                    {
                        Response.Cookies.Set(objCookie);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #14
0
        private void BindData()
        {
            try
            {
                var moduleStartDate = DateAndTime.DateAdd(DateInterval.Day,
                                                          Convert.ToDouble(-Settings.EnrolListDaysBefore),
                                                          ModuleNow());
                var moduleEndDate =
                    DateAndTime.DateAdd(DateInterval.Day, Settings.EnrolListDaysAfter, ModuleNow());
                var displayStartDate = DateAndTime.DateAdd(DateInterval.Day,
                                                           Convert.ToDouble(-Settings.EnrolListDaysBefore),
                                                           DisplayNow());
                var displayEndDate =
                    DateAndTime.DateAdd(DateInterval.Day, Settings.EnrolListDaysAfter, DisplayNow());

                //Default sort from settings
                var sortDirection  = Settings.EnrolListSortDirection;
                var sortExpression = GetSignupsSortExpression("EventTimeBegin");

                var inCategoryIDs = new ArrayList();
                inCategoryIDs.Add("-1");
                var objEventInfoHelper = new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
                var categoryIDs        = objEventInfoHelper.CreateCategoryFilter(inCategoryIDs);

                var eventSignups       = default(ArrayList);
                var objCtlEventSignups = new EventSignupsController();

                eventSignups =
                    objCtlEventSignups.EventsSignupsMyEnrollments(ModuleId, UserId, GetUrlGroupId(),
                                                                  categoryIDs, moduleStartDate, moduleEndDate);

                var objEventTimeZoneUtilities = new EventTimeZoneUtilities();
                var displayEventSignups       = new ArrayList();
                foreach (EventSignupsInfo eventSignup in eventSignups)
                {
                    var displayTimeZoneId = GetDisplayTimeZoneId();
                    eventSignup.EventTimeBegin = objEventTimeZoneUtilities
                                                 .ConvertToDisplayTimeZone(eventSignup.EventTimeBegin, eventSignup.EventTimeZoneId,
                                                                           PortalId, displayTimeZoneId).EventDate;
                    eventSignup.EventTimeEnd = objEventTimeZoneUtilities
                                               .ConvertToDisplayTimeZone(eventSignup.EventTimeEnd, eventSignup.EventTimeZoneId, PortalId,
                                                                         displayTimeZoneId).EventDate;
                    if (eventSignup.EventTimeBegin > displayEndDate || eventSignup.EventTimeEnd < displayStartDate)
                    {
                        continue;
                    }
                    displayEventSignups.Add(eventSignup);
                }

                EventSignupsInfo.SortExpression = sortExpression;
                EventSignupsInfo.SortDirection  = sortDirection;
                displayEventSignups.Sort();

                //Get data for selected date and fill grid
                grdEnrollment.DataSource = displayEventSignups;
                grdEnrollment.DataBind();
                if (eventSignups.Count < 1)
                {
                    divMessage.Visible    = true;
                    grdEnrollment.Visible = false;
                    //"No Events/Enrollments found..."
                    lblMessage.Text = Localization.GetString("MsgNoMyEventsOrEnrollment", LocalResourceFile);
                }
                else
                {
                    for (var i = 0; i <= eventSignups.Count - 1; i++)
                    {
                        var decTotal = Convert.ToDecimal(grdEnrollment.Items[i].Cells[7].Text) /
                                       Convert.ToDecimal(grdEnrollment.Items[i].Cells[8].Text);
                        var dtStartTime = Convert.ToDateTime(grdEnrollment.Items[i].Cells[1].Text);
                        // ReSharper disable LocalizableElement
                        ((Label)grdEnrollment.Items[i].FindControl("lblAmount")).Text =
                            string.Format("{0:F2}", decTotal) + " " + PortalSettings.Currency;
                        ((Label)grdEnrollment.Items[i].FindControl("lblTotal")).Text =
                            string.Format("{0:F2}", Convert.ToDecimal(grdEnrollment.Items[i].Cells[7].Text)) +
                            " " + PortalSettings.Currency;
                        // ReSharper restore LocalizableElement
                        if (decTotal > 0 || dtStartTime < ModuleNow().AddDays(Settings.Enrolcanceldays))
                        {
                            ((CheckBox)grdEnrollment.Items[i].FindControl("chkSelect")).Enabled = false;
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #15
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();
        }
コード例 #16
0
        protected void cmdPurchase_Click(object sender, EventArgs e)
        {
            var objEvent = default(EventInfo);

            try
            {
                if (this.Page.IsValid)
                {
                    objEvent = this._objCtlEvent.EventsGet(this._itemID, this.ModuleId);
                    // User wants to purchase event, create Event Signup Record
                    this._objEventSignups = new EventSignupsInfo();

                    //Just in case the user has clicked back and has now clicked Purchase again!!
                    var objEventSignupsChk = default(EventSignupsInfo);
                    if (string.IsNullOrEmpty(this._anonEmail))
                    {
                        objEventSignupsChk =
                            this._objCtlEventSignups.EventsSignupsGetUser(
                                objEvent.EventID, this.UserId, objEvent.ModuleID);
                    }
                    else
                    {
                        objEventSignupsChk =
                            this._objCtlEventSignups.EventsSignupsGetAnonUser(
                                objEvent.EventID, this._anonEmail, objEvent.ModuleID);
                    }
                    if (!ReferenceEquals(objEventSignupsChk, null))
                    {
                        this._objEventSignups.SignupID = objEventSignupsChk.SignupID;
                    }
                    this._objEventSignups.EventID  = objEvent.EventID;
                    this._objEventSignups.ModuleID = objEvent.ModuleID;
                    if (string.IsNullOrEmpty(this._anonEmail))
                    {
                        this._objEventSignups.UserID         = this.UserId;
                        this._objEventSignups.AnonEmail      = null;
                        this._objEventSignups.AnonName       = null;
                        this._objEventSignups.AnonTelephone  = null;
                        this._objEventSignups.AnonCulture    = null;
                        this._objEventSignups.AnonTimeZoneId = null;
                    }
                    else
                    {
                        var objSecurity = new PortalSecurity();
                        this._objEventSignups.UserID    = -1;
                        this._objEventSignups.AnonEmail =
                            objSecurity.InputFilter(this._anonEmail, PortalSecurity.FilterFlag.NoScripting);
                        this._objEventSignups.AnonName =
                            objSecurity.InputFilter(this._anonName, PortalSecurity.FilterFlag.NoScripting);
                        this._objEventSignups.AnonTelephone =
                            objSecurity.InputFilter(this._anonTelephone, PortalSecurity.FilterFlag.NoScripting);
                        this._objEventSignups.AnonCulture    = Thread.CurrentThread.CurrentCulture.Name;
                        this._objEventSignups.AnonTimeZoneId = this.GetDisplayTimeZoneId();
                    }
                    this._objEventSignups.PayPalStatus      = "none";
                    this._objEventSignups.PayPalReason      = "PayPal call initiated...";
                    this._objEventSignups.PayPalPaymentDate = DateTime.UtcNow;
                    this._objEventSignups.Approved          = false;
                    this._objEventSignups.NoEnrolees        = int.Parse(this.lblNoEnrolees.Text);

                    this._objEventSignups = this.CreateEnrollment(this._objEventSignups, objEvent);

                    if (!ReferenceEquals(objEventSignupsChk, null))
                    {
                        this._objEventSignups =
                            this._objCtlEventSignups.EventsSignupsGet(objEventSignupsChk.SignupID,
                                                                      objEventSignupsChk.ModuleID, false);
                    }

                    // Mail users
                    if (this.Settings.SendEnrollMessagePaying)
                    {
                        var objEventEmailInfo = new EventEmailInfo();
                        var objEventEmail     = new EventEmails(this.PortalId, this.ModuleId, this.LocalResourceFile,
                                                                ((PageBase)this.Page).PageCulture.Name);
                        objEventEmailInfo.TxtEmailSubject = this.Settings.Templates.txtEnrollMessageSubject;
                        objEventEmailInfo.TxtEmailBody    = this.Settings.Templates.txtEnrollMessagePaying;
                        objEventEmailInfo.TxtEmailFrom    = this.Settings.StandardEmail;
                        if (string.IsNullOrEmpty(this._anonEmail))
                        {
                            objEventEmailInfo.UserEmails.Add(this.PortalSettings.UserInfo.Email);
                            objEventEmailInfo.UserLocales.Add(this.PortalSettings.UserInfo.Profile.PreferredLocale);
                            objEventEmailInfo.UserTimeZoneIds.Add(this.PortalSettings.UserInfo.Profile.PreferredTimeZone
                                                                  .Id);
                        }
                        else
                        {
                            objEventEmailInfo.UserEmails.Add(this._objEventSignups.AnonEmail);
                            objEventEmailInfo.UserLocales.Add(this._objEventSignups.AnonCulture);
                            objEventEmailInfo.UserTimeZoneIds.Add(this._objEventSignups.AnonTimeZoneId);
                        }
                        objEventEmailInfo.UserIDs.Add(objEvent.OwnerID);
                        objEventEmail.SendEmails(objEventEmailInfo, objEvent, this._objEventSignups);
                    }

                    // build PayPal URL
                    var ppurl = this.Settings.Paypalurl + "/cgi-bin/webscr?cmd=_xclick&business=";

                    var socialGroupId = this.GetUrlGroupId();

                    var objEventInfoHelper =
                        new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings);
                    var returnURL = "";
                    if (socialGroupId > 0)
                    {
                        returnURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=enrolled", "groupid=" + socialGroupId), "?");
                    }
                    else
                    {
                        returnURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=enrolled"), "?");
                    }
                    if (returnURL.IndexOf("://") + 1 == 0)
                    {
                        returnURL = Globals.AddHTTP(Globals.GetDomainName(this.Request)) + returnURL;
                    }
                    var cancelURL = "";
                    if (socialGroupId > 0)
                    {
                        cancelURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=cancelled", "groupid=" + socialGroupId), "?");
                    }
                    else
                    {
                        cancelURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=cancelled"), "?");
                    }
                    if (cancelURL.IndexOf("://") + 1 == 0)
                    {
                        cancelURL = Globals.AddHTTP(Globals.GetDomainName(this.Request)) + cancelURL;
                    }
                    var strPayPalURL = "";
                    strPayPalURL = ppurl + Globals.HTTPPOSTEncode(objEvent.PayPalAccount);
                    strPayPalURL = strPayPalURL + "&item_name=" +
                                   Globals.HTTPPOSTEncode(objEvent.ModuleTitle + " - " + this.lblEventName.Text +
                                                          " ( " + this.lblFee.Text + " " + this.lblFeeCurrency.Text +
                                                          " )");
                    strPayPalURL = strPayPalURL + "&item_number=" +
                                   Globals.HTTPPOSTEncode(Convert.ToString(this._objEventSignups.SignupID));
                    strPayPalURL = strPayPalURL + "&quantity=" +
                                   Globals.HTTPPOSTEncode(Convert.ToString(this._objEventSignups.NoEnrolees));
                    strPayPalURL = strPayPalURL + "&custom=" +
                                   Globals.HTTPPOSTEncode(
                        Convert.ToDateTime(this.lblStartDate.Text).ToShortDateString());

                    // Make sure currency is in correct format
                    var dblFee    = double.Parse(this.lblFee.Text);
                    var uiculture = Thread.CurrentThread.CurrentCulture;
                    Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                    strPayPalURL = strPayPalURL + "&amount=" +
                                   Globals.HTTPPOSTEncode(Strings.Format(dblFee, "#,##0.00"));
                    Thread.CurrentThread.CurrentCulture = uiculture;

                    strPayPalURL = strPayPalURL + "&currency_code=" +
                                   Globals.HTTPPOSTEncode(this.lblTotalCurrency.Text);
                    strPayPalURL = strPayPalURL + "&return=" + returnURL;
                    strPayPalURL = strPayPalURL + "&cancel_return=" + cancelURL;
                    strPayPalURL = strPayPalURL + "&notify_url=" +
                                   Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(this.Request)) +
                                                          "/DesktopModules/Events/EventIPN.aspx");
                    strPayPalURL = strPayPalURL + "&undefined_quantity=&no_note=1&no_shipping=1";
                    //strPayPalURL = strPayPalURL & "&undefined_quantity=&no_note=1&no_shipping=1&rm=2"

                    // redirect to PayPal
                    this.Response.Redirect(strPayPalURL, true);
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #17
0
ファイル: EventDay.ascx.cs プロジェクト: MaiklT/DNN.Events
        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();
        }
コード例 #18
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
            { }
        }
コード例 #19
0
        /// <summary>
        ///     Render each day in the event (i.e. Cells)
        /// </summary>
        protected void EventCalendar_DayRender(object sender, DayRenderEventArgs e)
        {
            var objEvent    = default(EventInfo);
            var cellcontrol = new LiteralControl();

            _objEventInfoHelper = new EventInfoHelper(ModuleId, TabId, PortalId, Settings);

            // Get Events/Sub-Calendar Events
            var dayEvents    = new ArrayList();
            var allDayEvents = default(ArrayList);

            allDayEvents = _objEventInfoHelper.GetDateEvents(_selectedEvents, e.Day.Date);
            allDayEvents.Sort(new EventInfoHelper.EventDateSort());

            foreach (EventInfo tempLoopVar_objEvent in allDayEvents)
            {
                objEvent = tempLoopVar_objEvent;
                //if day not in current (selected) Event month OR full enrollments should be hidden, ignore
                if ((Settings.ShowEventsAlways || e.Day.Date.Month == SelectedDate.Month) &&
                    !HideFullEvent(objEvent))
                {
                    dayEvents.Add(objEvent);
                }
            }

            // If No Cell Event Display...
            if (Settings.Monthcellnoevents)
            {
                if (Settings.ShowEventsAlways == false && e.Day.IsOtherMonth)
                {
                    e.Cell.Text = "";
                    return;
                }

                if (dayEvents.Count > 0)
                {
                    e.Day.IsSelectable = true;

                    if (e.Day.Date == SelectedDate)
                    {
                        e.Cell.CssClass = "EventSelectedDay";
                    }
                    else
                    {
                        if (e.Day.IsWeekend)
                        {
                            e.Cell.CssClass = "EventWeekendDayEvents";
                        }
                        else
                        {
                            e.Cell.CssClass = "EventDayEvents";
                        }
                    }

                    if (Settings.Eventtooltipmonth)
                    {
                        var themeCss = GetThemeSettings().CssClass;

                        var tmpToolTipTitle = Settings.Templates.txtTooltipTemplateTitleNT;
                        if (tmpToolTipTitle.IndexOf("{0}") + 1 > 0)
                        {
                            tmpToolTipTitle = tmpToolTipTitle.Replace("{0}", "{0:d}");
                        }
                        var tooltipTitle =
                            Convert.ToString(HttpUtility.HtmlDecode(string.Format(tmpToolTipTitle, e.Day.Date))
                                             .Replace(Environment.NewLine, ""));
                        var cellToolTip = ""; //Holds control generated tooltip

                        foreach (EventInfo tempLoopVar_objEvent in dayEvents)
                        {
                            objEvent = tempLoopVar_objEvent;
                            //Add horizontal row to seperate the eventdescriptions
                            if (!string.IsNullOrEmpty(cellToolTip))
                            {
                                cellToolTip = cellToolTip + "<hr/>";
                            }

                            cellToolTip +=
                                CreateEventName(
                                    objEvent,
                                    Convert.ToString(Settings.Templates.txtTooltipTemplateBodyNT
                                                     .Replace(Constants.vbLf, "").Replace(Constants.vbCr, "")));
                        }
                        e.Cell.Attributes.Add(
                            "title",
                            "<table class=\"" + themeCss + " Eventtooltiptable\"><tr><td class=\"" + themeCss +
                            " Eventtooltipheader\">" + tooltipTitle + "</td></tr><tr><td class=\"" + themeCss +
                            " Eventtooltipbody\">" + cellToolTip + "</td></tr></table>");
                        e.Cell.ID = "ctlEvents_Mod_" + ModuleId + "_EventDate_" + e.Day.Date.ToString("yyyyMMMdd");
                    }

                    var dailyLink = new HyperLink();
                    dailyLink.Text = string.Format(Settings.Templates.txtMonthDayEventCount, dayEvents.Count);
                    var socialGroupId = GetUrlGroupId();
                    var socialUserId  = GetUrlUserId();
                    if (dayEvents.Count > 1)
                    {
                        if (Settings.Eventdaynewpage)
                        {
                            if (socialGroupId > 0)
                            {
                                dailyLink.NavigateUrl =
                                    _objEventInfoHelper.AddSkinContainerControls(
                                        Globals.NavigateURL(TabId, "Day", "Mid=" + ModuleId,
                                                            "selecteddate=" +
                                                            Strings.Format(e.Day.Date, "yyyyMMdd"),
                                                            "groupid=" + socialGroupId), "?");
                            }
                            else if (socialUserId > 0)
                            {
                                dailyLink.NavigateUrl =
                                    _objEventInfoHelper.AddSkinContainerControls(
                                        Globals.NavigateURL(TabId, "Day", "Mid=" + ModuleId,
                                                            "selecteddate=" +
                                                            Strings.Format(e.Day.Date, "yyyyMMdd"),
                                                            "userid=" + socialUserId), "?");
                            }
                            else
                            {
                                dailyLink.NavigateUrl =
                                    _objEventInfoHelper.AddSkinContainerControls(
                                        Globals.NavigateURL(TabId, "Day", "Mid=" + ModuleId,
                                                            "selecteddate=" +
                                                            Strings.Format(e.Day.Date, "yyyyMMdd")), "?");
                            }
                        }
                        else
                        {
                            if (socialGroupId > 0)
                            {
                                dailyLink.NavigateUrl =
                                    Globals.NavigateURL(TabId, "", "ModuleID=" + ModuleId, "mctl=EventDay",
                                                        "selecteddate=" + Strings.Format(e.Day.Date, "yyyyMMdd"),
                                                        "groupid=" + socialGroupId);
                            }
                            else if (socialUserId > 0)
                            {
                                dailyLink.NavigateUrl =
                                    Globals.NavigateURL(TabId, "", "ModuleID=" + ModuleId, "mctl=EventDay",
                                                        "selecteddate=" + Strings.Format(e.Day.Date, "yyyyMMdd"),
                                                        "userid=" + socialUserId);
                            }
                            else
                            {
                                dailyLink.NavigateUrl =
                                    Globals.NavigateURL(TabId, "", "ModuleID=" + ModuleId, "mctl=EventDay",
                                                        "selecteddate=" + Strings.Format(e.Day.Date, "yyyyMMdd"));
                            }
                        }
                    }
                    else
                    {
                        // Get detail page url
                        dailyLink = GetDetailPageUrl((EventInfo)dayEvents[0], dailyLink);
                    }
                    using (var stringWrite = new StringWriter())
                    {
                        using (var eventoutput = new HtmlTextWriter(stringWrite))
                        {
                            dailyLink.RenderControl(eventoutput);
                            cellcontrol.Text = "<div class='EventDayScroll'>" + stringWrite + "</div>";
                            e.Cell.Controls.Add(cellcontrol);
                        }
                    }
                }
                else
                {
                    e.Day.IsSelectable = false;
                }
                return;
            }

            //Make day unselectable
            if (!Settings.Monthdayselect)
            {
                e.Day.IsSelectable = false;
            }

            //loop through records and render if startDate = current day and is not null
            var celldata = ""; // Holds Control Generated HTML

            foreach (EventInfo tempLoopVar_objEvent in dayEvents)
            {
                objEvent = tempLoopVar_objEvent;
                var dailyLink  = new HyperLink();
                var iconString = "";

                // See if an Image is to be displayed for the Event
                if (Settings.Eventimage && Settings.EventImageMonth && objEvent.ImageURL != null &&
                    objEvent.ImageDisplay)
                {
                    dailyLink.Text = ImageInfo(objEvent.ImageURL, objEvent.ImageHeight, objEvent.ImageWidth);
                }

                if (Settings.Timeintitle)
                {
                    dailyLink.Text = dailyLink.Text + objEvent.EventTimeBegin.ToString("t") + " - ";
                }

                var eventtext = CreateEventName(objEvent, Settings.Templates.txtMonthEventText);
                dailyLink.Text = dailyLink.Text + eventtext.Trim();

                if (!IsPrivateNotModerator || UserId == objEvent.OwnerID)
                {
                    dailyLink.ForeColor = GetColor(objEvent.FontColor);
                    iconString          = CreateIconString(objEvent, Settings.IconMonthPrio,
                                                           Settings.IconMonthRec, Settings.IconMonthReminder,
                                                           Settings.IconMonthEnroll);

                    // Get detail page url
                    dailyLink = GetDetailPageUrl(objEvent, dailyLink);
                }
                else
                {
                    dailyLink.Style.Add("cursor", "text");
                    dailyLink.Style.Add("text-decoration", "none");
                    dailyLink.Attributes.Add("onclick", "javascript:return false;");
                }

                // See If Description Tooltip to be added
                if (Settings.Eventtooltipmonth)
                {
                    var isEvtEditor = IsEventEditor(objEvent, false);
                    dailyLink.Attributes.Add(
                        "title",
                        ToolTipCreate(objEvent, Settings.Templates.txtTooltipTemplateTitle,
                                      Settings.Templates.txtTooltipTemplateBody, isEvtEditor));
                }

                // Capture Control Info & save
                using (var stringWrite = new StringWriter())
                {
                    using (var eventoutput = new HtmlTextWriter(stringWrite))
                    {
                        dailyLink.ID = "ctlEvents_Mod_" + ModuleId + "_EventID_" + objEvent.EventID +
                                       "_EventDate_" + e.Day.Date.ToString("yyyyMMMdd");
                        dailyLink.RenderControl(eventoutput);
                        if (objEvent.Color != null && (!IsPrivateNotModerator || UserId == objEvent.OwnerID))
                        {
                            celldata = celldata + "<div style=\"background-color: " + objEvent.Color + ";\">" +
                                       iconString + stringWrite + "</div>";
                        }
                        else
                        {
                            celldata = celldata + "<div>" + iconString + stringWrite + "</div>";
                        }
                    }
                }
            }

            // Add Literal Control Data to Cell w/DIV tag (in order to support scrolling in cell)
            cellcontrol.Text = "<div class='EventDayScroll'>" + celldata + "</div>";
            e.Cell.Controls.Add(cellcontrol);
        }
コード例 #20
0
ファイル: EventRSS.aspx.cs プロジェクト: jspsoft/DNN.Events
        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());
                }
            }
        }
コード例 #21
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);
        }