private Containers.Container LoadContainerByPath(string ContainerPath) { if (ContainerPath.ToLower().IndexOf("/skins/") != -1 || ContainerPath.ToLower().IndexOf("/skins\\") != -1 || ContainerPath.ToLower().IndexOf("\\skins\\") != -1 || ContainerPath.ToLower().IndexOf("\\skins/") != -1) { throw new System.Exception(); } Containers.Container ctlContainer = null; try { string ContainerSrc = ContainerPath; if (ContainerPath.IndexOf(Common.Globals.ApplicationPath, StringComparison.InvariantCultureIgnoreCase) != -1) { ContainerPath = ContainerPath.Remove(0, Common.Globals.ApplicationPath.Length); } ctlContainer = ControlUtilities.LoadControl <Containers.Container>(PaneControl.Page, ContainerPath); ctlContainer.ContainerSrc = ContainerSrc; ctlContainer.DataBind(); } catch (Exception exc) { ModuleLoadException lex = new ModuleLoadException(Skin.MODULELOAD_ERROR, exc); if (TabPermissionController.CanAdminPage()) { PaneControl.Controls.Add(new ErrorContainer(PortalSettings, string.Format(Skin.CONTAINERLOAD_ERROR, ContainerPath), lex).Container); } Exceptions.LogException(lex); } return(ctlContainer); }
private bool ProcessModule(ModuleInfo module) { var success = true; if (ModuleInjectionManager.CanInjectModule(module, this.PortalSettings)) { // We need to ensure that Content Item exists since in old versions Content Items are not needed for modules this.EnsureContentItemForModule(module); Pane pane = this.GetPane(module); if (pane != null) { success = this.InjectModule(pane, module); } else { var lex = new ModuleLoadException(Localization.GetString("PaneNotFound.Error")); this.Controls.Add(new ErrorContainer(this.PortalSettings, MODULELOAD_ERROR, lex).Container); Exceptions.LogException(lex); } } return(success); }
/// ----------------------------------------------------------------------------- /// <summary> /// LoadContainerByPath gets the Container from its Url(Path) /// </summary> /// <param name="containerPath">The Url to the Container control</param> /// <returns>A Container</returns> /// ----------------------------------------------------------------------------- private Containers.Container LoadContainerByPath(string containerPath) { if (containerPath.ToLower().IndexOf("/skins/") != -1 || containerPath.ToLower().IndexOf("/skins\\") != -1 || containerPath.ToLower().IndexOf("\\skins\\") != -1 || containerPath.ToLower().IndexOf("\\skins/") != -1) { throw new Exception(); } Containers.Container container = null; try { string containerSrc = containerPath; if (containerPath.IndexOf(Globals.ApplicationPath, StringComparison.InvariantCultureIgnoreCase) != -1) { containerPath = containerPath.Remove(0, Globals.ApplicationPath.Length); } container = ControlUtilities.LoadControl <Containers.Container>(PaneControl.Page, containerPath); container.ContainerSrc = containerSrc; //call databind so that any server logic in the container is executed container.DataBind(); } catch (Exception exc) { //could not load user control var lex = new ModuleLoadException(Skin.MODULELOAD_ERROR, exc); if (TabPermissionController.CanAdminPage()) { //only display the error to administrators _containerWrapperControl.Controls.Add(new ErrorContainer(PortalSettings, string.Format(Skin.CONTAINERLOAD_ERROR, containerPath), lex).Container); } Exceptions.LogException(lex); } return(container); }
public void InjectModule(ModuleInfo objModule) { bool bSuccess = true; try { if (!Common.Globals.IsAdminControl()) { PaneControl.Controls.Add(new LiteralControl("<a name=\"" + objModule.ModuleID.ToString() + "\"></a>")); } Containers.Container ctlContainer = LoadModuleContainer(objModule); Containers.Add(ctlContainer.ID, ctlContainer); if (Common.Globals.IsLayoutMode() && Common.Globals.IsAdminControl() == false) { Panel ctlDragDropContainer = new Panel(); System.Web.UI.Control ctlTitle = ctlContainer.FindControl("dnnTitle"); ctlDragDropContainer.ID = ctlContainer.ID + "_DD"; PaneControl.Controls.Add(ctlDragDropContainer); ctlDragDropContainer.Controls.Add(ctlContainer); if (ctlTitle != null) { if (ctlTitle.Controls.Count > 0) { ctlTitle = ctlTitle.Controls[0]; } } //if (ctlDragDropContainer != null && ctlTitle != null) //{ // ClientAPI.EnableContainerDragAndDrop(ctlTitle, ctlDragDropContainer, objModule.ModuleID); // ClientAPI.RegisterPostBackEventHandler(PaneControl, "MoveToPane", ModuleMoveToPanePostBack, false); //} } else { PaneControl.Controls.Add(ctlContainer); } ctlContainer.SetModuleConfiguration(objModule); if (PaneControl.Visible == false) { PaneControl.Visible = true; } } catch (Exception exc) { ModuleLoadException lex; lex = new ModuleLoadException(string.Format(Skin.MODULEADD_ERROR, PaneControl.ID.ToString()), exc); if (TabPermissionController.CanAdminPage()) { PaneControl.Controls.Add(new ErrorContainer(PortalSettings, Skin.MODULELOAD_ERROR, lex).Container); } Exceptions.LogException(exc); bSuccess = false; throw lex; } if (!bSuccess) { throw new ModuleLoadException(); } }
private bool ProcessMasterModules() { bool bSuccess = true; if (TabPermissionController.CanViewPage()) { if (!CheckExpired()) { if ((PortalSettings.ActiveTab.StartDate < DateTime.Now && PortalSettings.ActiveTab.EndDate > DateTime.Now) || Globals.IsLayoutMode()) { if (PortalSettings.ActiveTab.Modules.Count > 0) { foreach (ModuleInfo objModule in PortalSettings.ActiveTab.Modules) { if (ModulePermissionController.CanViewModule(objModule) && objModule.IsDeleted == false) { if ((objModule.StartDate < DateTime.Now && objModule.EndDate > DateTime.Now) || Common.Globals.IsLayoutMode() || Common.Globals.IsEditMode()) { Pane pane = null; bool bFound = Panes.TryGetValue(objModule.PaneName.ToLowerInvariant(), out pane); if (!bFound) { bFound = Panes.TryGetValue(Common.Globals.glbDefaultPane.ToLowerInvariant(), out pane); } if (bFound) { bSuccess = InjectModule(pane, objModule); } else { ModuleLoadException lex; lex = new ModuleLoadException(PANE_LOAD_ERROR); Controls.Add(new ErrorContainer(PortalSettings, MODULELOAD_ERROR, lex).Container); Exceptions.LogException(lex); } } } } } } else { AddPageMessage(this, "", TABACCESS_ERROR, UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning); } } else { AddPageMessage(this, "", string.Format(CONTRACTEXPIRED_ERROR, PortalSettings.PortalName, Common.Globals.GetMediumDate(PortalSettings.ExpiryDate.ToString()), PortalSettings.Email), UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError); } } else { Response.Redirect(Common.Globals.AccessDeniedURL(TABACCESS_ERROR), true); } return(bSuccess); }
public void AddLog(Exception objException, ExceptionLogType LogType) { LogController objLogController = new LogController(); LogInfo objLogInfo = new LogInfo(); objLogInfo.LogTypeKey = LogType.ToString(); if (LogType == ExceptionLogType.MODULE_LOAD_EXCEPTION) { //Add ModuleLoadException Properties ModuleLoadException objModuleLoadException = (ModuleLoadException)objException; objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleId", objModuleLoadException.ModuleId.ToString())); objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleDefId", objModuleLoadException.ModuleDefId.ToString())); objLogInfo.LogProperties.Add(new LogDetailInfo("FriendlyName", objModuleLoadException.FriendlyName)); objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleControlSource", objModuleLoadException.ModuleControlSource)); } if (LogType == ExceptionLogType.SECURITY_EXCEPTION) { //Add ModuleLoadException Properties ModuleLoadException objModuleLoadException = (ModuleLoadException)objException; objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleId", objModuleLoadException.ModuleId.ToString())); objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleDefId", objModuleLoadException.ModuleDefId.ToString())); objLogInfo.LogProperties.Add(new LogDetailInfo("FriendlyName", objModuleLoadException.FriendlyName)); objLogInfo.LogProperties.Add(new LogDetailInfo("ModuleControlSource", objModuleLoadException.ModuleControlSource)); } //Add BasePortalException Properties BasePortalException objBasePortalException = new BasePortalException(objException.ToString(), objException); objLogInfo.LogProperties.Add(new LogDetailInfo("AssemblyVersion", objBasePortalException.AssemblyVersion)); objLogInfo.LogProperties.Add(new LogDetailInfo("PortalID", objBasePortalException.PortalID.ToString())); objLogInfo.LogProperties.Add(new LogDetailInfo("PortalName", objBasePortalException.PortalName)); objLogInfo.LogProperties.Add(new LogDetailInfo("UserID", objBasePortalException.UserID.ToString())); objLogInfo.LogProperties.Add(new LogDetailInfo("UserName", objBasePortalException.UserName)); objLogInfo.LogProperties.Add(new LogDetailInfo("ActiveTabID", objBasePortalException.ActiveTabID.ToString())); objLogInfo.LogProperties.Add(new LogDetailInfo("ActiveTabName", objBasePortalException.ActiveTabName)); objLogInfo.LogProperties.Add(new LogDetailInfo("RawURL", objBasePortalException.RawURL)); objLogInfo.LogProperties.Add(new LogDetailInfo("AbsoluteURL", objBasePortalException.AbsoluteURL)); objLogInfo.LogProperties.Add(new LogDetailInfo("AbsoluteURLReferrer", objBasePortalException.AbsoluteURLReferrer)); objLogInfo.LogProperties.Add(new LogDetailInfo("UserAgent", objBasePortalException.UserAgent)); objLogInfo.LogProperties.Add(new LogDetailInfo("DefaultDataProvider", objBasePortalException.DefaultDataProvider)); objLogInfo.LogProperties.Add(new LogDetailInfo("ExceptionGUID", objBasePortalException.ExceptionGUID)); objLogInfo.LogProperties.Add(new LogDetailInfo("InnerException", objBasePortalException.InnerException.Message)); objLogInfo.LogProperties.Add(new LogDetailInfo("FileName", objBasePortalException.FileName)); objLogInfo.LogProperties.Add(new LogDetailInfo("FileLineNumber", objBasePortalException.FileLineNumber.ToString())); objLogInfo.LogProperties.Add(new LogDetailInfo("FileColumnNumber", objBasePortalException.FileColumnNumber.ToString())); objLogInfo.LogProperties.Add(new LogDetailInfo("Method", objBasePortalException.Method)); objLogInfo.LogProperties.Add(new LogDetailInfo("StackTrace", objBasePortalException.StackTrace)); objLogInfo.LogProperties.Add(new LogDetailInfo("Message", objBasePortalException.Message)); objLogInfo.LogProperties.Add(new LogDetailInfo("Source", objBasePortalException.Source)); objLogInfo.LogPortalID = objBasePortalException.PortalID; objLogController.AddLog(objLogInfo); }
private bool ProcessModule(ModuleInfo module) { bool success = true; if (ModuleInjectionManager.CanInjectModule(module, PortalSettings)) { Pane pane = GetPane(module); if (pane != null) { success = InjectModule(pane, module); } else { var lex = new ModuleLoadException(Localization.GetString("PaneNotFound.Error")); Controls.Add(new ErrorContainer(PortalSettings, MODULELOAD_ERROR, lex).Container); Exceptions.LogException(lex); } } return(success); }
private bool ProcessModule(ModuleInfo module) { bool success = true; if (ModulePermissionController.CanViewModule(module) && module.IsDeleted == false && ((module.StartDate < DateTime.Now && module.EndDate > DateTime.Now) || Globals.IsLayoutMode() || Globals.IsEditMode())) { Pane pane = GetPane(module); if (pane != null) { success = InjectModule(pane, module); } else { var lex = new ModuleLoadException(Localization.GetString("PaneNotFound.Error")); Controls.Add(new ErrorContainer(PortalSettings, MODULELOAD_ERROR, lex).Container); Exceptions.LogException(lex); } } return(success); }
/// ----------------------------------------------------------------------------- /// <summary> /// InjectModule injects a Module (and its container) into the Pane /// </summary> /// <param name="module">The Module</param> /// ----------------------------------------------------------------------------- public void InjectModule(ModuleInfo module) { _containerWrapperControl = new HtmlGenericControl("div"); PaneControl.Controls.Add(_containerWrapperControl); //inject module classes string classFormatString = "DnnModule DnnModule-{0} DnnModule-{1}"; string sanitizedModuleName = Null.NullString; if (!String.IsNullOrEmpty(module.DesktopModule.ModuleName)) { sanitizedModuleName = Globals.CreateValidClass(module.DesktopModule.ModuleName, false); } if (IsVesionableModule(module)) { classFormatString += " DnnVersionableControl"; } _containerWrapperControl.Attributes["class"] = String.Format(classFormatString, sanitizedModuleName, module.ModuleID); try { if (!Globals.IsAdminControl() && PortalSettings.InjectModuleHyperLink) { _containerWrapperControl.Controls.Add(new LiteralControl("<a name=\"" + module.ModuleID + "\"></a>")); } //Load container control Containers.Container container = LoadModuleContainer(module); //Add Container to Dictionary Containers.Add(container.ID, container); // hide anything of type ActionsMenu - as we're injecting our own menu now. container.InjectActionMenu = (container.Controls.OfType <ActionBase>().Count() == 0); if (!container.InjectActionMenu) { foreach (var actionControl in container.Controls.OfType <IActionControl>()) { if (actionControl is ActionsMenu) { Control control = actionControl as Control; if (control != null) { control.Visible = false; container.InjectActionMenu = true; } } } } if (Globals.IsLayoutMode() && Globals.IsAdminControl() == false) { //provide Drag-N-Drop capabilities var dragDropContainer = new Panel(); Control title = container.FindControl("dnnTitle"); //Assume that the title control is named dnnTitle. If this becomes an issue we could loop through the controls looking for the title type of skin object dragDropContainer.ID = container.ID + "_DD"; _containerWrapperControl.Controls.Add(dragDropContainer); //inject the container into the page pane - this triggers the Pre_Init() event for the user control dragDropContainer.Controls.Add(container); if (title != null) { if (title.Controls.Count > 0) { title = title.Controls[0]; } } //enable drag and drop if (title != null) { //The title ID is actually the first child so we need to make sure at least one child exists DNNClientAPI.EnableContainerDragAndDrop(title, dragDropContainer, module.ModuleID); ClientAPI.RegisterPostBackEventHandler(PaneControl, "MoveToPane", ModuleMoveToPanePostBack, false); } } else { _containerWrapperControl.Controls.Add(container); if (Globals.IsAdminControl()) { _containerWrapperControl.Attributes["class"] += " DnnModule-Admin"; } } //Attach Module to Container container.SetModuleConfiguration(module); //display collapsible page panes if (PaneControl.Visible == false) { PaneControl.Visible = true; } } catch (ThreadAbortException) { //Response.Redirect may called in module control's OnInit method, so it will cause ThreadAbortException, no need any action here. } catch (Exception exc) { var lex = new ModuleLoadException(string.Format(Skin.MODULEADD_ERROR, PaneControl.ID), exc); if (TabPermissionController.CanAdminPage()) { //only display the error to administrators _containerWrapperControl.Controls.Add(new ErrorContainer(PortalSettings, Skin.MODULELOAD_ERROR, lex).Container); } Exceptions.LogException(exc); throw lex; } }