Пример #1
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);
            }
        }