private void UpgradeModule(EventMessage message)
 {
     try
     {
         string BusinessControllerClass = message.Attributes["BusinessControllerClass"];
         object objController = Framework.Reflection.CreateObject(BusinessControllerClass, "");
         Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
         Services.Log.EventLog.LogInfo objEventLogInfo;
         if (objController is IUpgradeable)
         {
             string[] UpgradeVersions = message.Attributes["UpgradeVersionsList"].ToString().Split(',');
             foreach (string Version in UpgradeVersions)
             {
                 string Results = ((IUpgradeable)objController).UpgradeModule(Version);
                 objEventLogInfo = new Services.Log.EventLog.LogInfo();
                 objEventLogInfo.AddProperty("Module Upgraded", BusinessControllerClass);
                 objEventLogInfo.AddProperty("Version", Version);
                 if (!string.IsNullOrEmpty(Results))
                 {
                     objEventLogInfo.AddProperty("Results", Results);
                 }
                 objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.MODULE_UPDATED.ToString();
                 objEventLog.AddLog(objEventLogInfo);
             }
         }
         UpdateSupportedFeatures(objController, Convert.ToInt32(message.Attributes["DesktopModuleId"]));
     }
     catch (Exception exc)
     {
         Exceptions.LogException(exc);
     }
 }
 private void UpgradeModule(EventMessage message)
 {
     try
     {
         string BusinessControllerClass = message.Attributes["BusinessControllerClass"];
         object objController           = Framework.Reflection.CreateObject(BusinessControllerClass, "");
         Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
         Services.Log.EventLog.LogInfo            objEventLogInfo;
         if (objController is IUpgradeable)
         {
             string[] UpgradeVersions = message.Attributes["UpgradeVersionsList"].ToString().Split(',');
             foreach (string Version in UpgradeVersions)
             {
                 string Results = ((IUpgradeable)objController).UpgradeModule(Version);
                 objEventLogInfo = new Services.Log.EventLog.LogInfo();
                 objEventLogInfo.AddProperty("Module Upgraded", BusinessControllerClass);
                 objEventLogInfo.AddProperty("Version", Version);
                 if (!string.IsNullOrEmpty(Results))
                 {
                     objEventLogInfo.AddProperty("Results", Results);
                 }
                 objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.MODULE_UPDATED.ToString();
                 objEventLog.AddLog(objEventLogInfo);
             }
         }
         UpdateSupportedFeatures(objController, Convert.ToInt32(message.Attributes["DesktopModuleId"]));
     }
     catch (Exception exc)
     {
         Exceptions.LogException(exc);
     }
 }
 private static void AddEventLog(int portalId, string username, int userId, string portalName, string Ip, UserLoginStatus loginStatus)
 {
     Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
     Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo();
     PortalSecurity objSecurity = new PortalSecurity();
     objEventLogInfo.AddProperty("IP", Ip);
     objEventLogInfo.LogPortalID = portalId;
     objEventLogInfo.LogPortalName = portalName;
     objEventLogInfo.LogUserName = objSecurity.InputFilter(username, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup);
     objEventLogInfo.LogUserID = userId;
     objEventLogInfo.LogTypeKey = loginStatus.ToString();
     objEventLog.AddLog(objEventLogInfo);
 }
        public static bool ProcessMessages(EventMessageCollection eventMessages)
        {
            EventMessage message;

            for (int messageNo = 0; messageNo <= eventMessages.Count - 1; messageNo++)
            {
                message = eventMessages[messageNo];
                try
                {
                    object oMessageProcessor = Framework.Reflection.CreateObject(message.ProcessorType, message.ProcessorType);
                    if (!((EventMessageProcessorBase)oMessageProcessor).ProcessMessage(message))
                    {
                        throw new Exception();
                    }
                    DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);
                }
                catch
                {
                    Services.Log.EventLog.EventLogController objEventLog     = new Services.Log.EventLog.EventLogController();
                    Services.Log.EventLog.LogInfo            objEventLogInfo = new Services.Log.EventLog.LogInfo();
                    objEventLogInfo.AddProperty("EventQueue.ProcessMessage", "Message Processing Failed");
                    objEventLogInfo.AddProperty("ProcessorType", message.ProcessorType);
                    objEventLogInfo.AddProperty("Body", message.Body);
                    objEventLogInfo.AddProperty("Sender", message.Sender);
                    foreach (string key in message.Attributes.Keys)
                    {
                        objEventLogInfo.AddProperty(key, message.Attributes[key]);
                    }
                    if (!String.IsNullOrEmpty(message.ExceptionMessage))
                    {
                        objEventLogInfo.AddProperty("ExceptionMessage", message.ExceptionMessage);
                    }
                    objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                    objEventLog.AddLog(objEventLogInfo);
                    if (message.ExpirationDate < DateTime.Now)
                    {
                        DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);
                    }
                }
            }
            return(true);
        }
 public static bool ProcessMessages(EventMessageCollection eventMessages)
 {
     EventMessage message;
     for (int messageNo = 0; messageNo <= eventMessages.Count - 1; messageNo++)
     {
         message = eventMessages[messageNo];
         try
         {
             object oMessageProcessor = Framework.Reflection.CreateObject(message.ProcessorType, message.ProcessorType);
             if (!((EventMessageProcessorBase)oMessageProcessor).ProcessMessage(message))
             {
                 throw new Exception();
             }
             DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);
         }
         catch
         {
             Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
             Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo();
             objEventLogInfo.AddProperty("EventQueue.ProcessMessage", "Message Processing Failed");
             objEventLogInfo.AddProperty("ProcessorType", message.ProcessorType);
             objEventLogInfo.AddProperty("Body", message.Body);
             objEventLogInfo.AddProperty("Sender", message.Sender);
             foreach (string key in message.Attributes.Keys)
             {
                 objEventLogInfo.AddProperty(key, message.Attributes[key]);
             }
             if (!String.IsNullOrEmpty(message.ExceptionMessage))
             {
                 objEventLogInfo.AddProperty("ExceptionMessage", message.ExceptionMessage);
             }
             objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
             objEventLog.AddLog(objEventLogInfo);
             if (message.ExpirationDate < DateTime.Now)
             {
                 DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);
             }
         }
     }
     return true;
 }
        public static RewriterConfiguration GetConfig()
        {
            RewriterConfiguration Config = new RewriterConfiguration();
            Config.Rules = new RewriterRuleCollection();
            FileStream fileReader = null;
            string filePath = "";
            try
            {
                Config = (RewriterConfiguration)(DataCache.GetCache("RewriterConfig"));

                if (Config == null)
                {
                    filePath = Globals.ApplicationMapPath + "\\SiteUrls.config";

                    if (!(File.Exists(filePath)))
                    {
                        //Copy from \Config
                        if (File.Exists(Globals.ApplicationMapPath + Globals.glbConfigFolder + "SiteUrls.config"))
                        {
                            File.Copy(Globals.ApplicationMapPath + Globals.glbConfigFolder + "SiteUrls.config", Globals.ApplicationMapPath + "\\SiteUrls.config", true);
                        }
                    }

                    //Create a FileStream for the Config file
                    fileReader = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);

                    XPathDocument doc = new XPathDocument(fileReader);
                    Config = new RewriterConfiguration();
                    Config.Rules = new RewriterRuleCollection();

                    foreach (XPathNavigator nav in doc.CreateNavigator().Select("RewriterConfig/Rules/RewriterRule"))
                    {
                        RewriterRule rule = new RewriterRule();
                        rule.LookFor = nav.SelectSingleNode("LookFor").Value;
                        rule.SendTo = nav.SelectSingleNode("SendTo").Value;
                        Config.Rules.Add(rule);
                    }


                    if (File.Exists(filePath))
                    {
                        // Create a dependancy on SiteUrls.config
                        CacheDependency dep = new CacheDependency(filePath);

                        // Set back into Cache
                        DataCache.SetCache("RewriterConfig", Config, dep);
                    }

                }
            }
            catch (Exception ex)
            {
                //log it
                Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
                Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo();
                objEventLogInfo.AddProperty("UrlRewriter.RewriterConfiguration", "GetConfig Failed");
                objEventLogInfo.AddProperty("FilePath", filePath);
                objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
                objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLog.AddLog(objEventLogInfo);

            }
            finally
            {
                if (fileReader != null)
                {
                    //Close the Reader
                    fileReader.Close();
                }

            }

            return Config;

        }
示例#7
0
		public string LogDetailError(ErrorCodes errorCode, string virtualPath, bool logError)
		{
			string endUserPath = string.Empty;
			if (! (string.IsNullOrEmpty(virtualPath)))
			{
				endUserPath = (string)ToEndUserPath(virtualPath);
			}

			string returnValue = GetPermissionErrorText(endUserPath);
			string logMsg = string.Empty;

			switch (errorCode)
			{
				case ErrorCodes.AddFolder_NoPermission:
				case ErrorCodes.AddFolder_NotInsecureFolder:
				case ErrorCodes.CopyFolder_NoPermission:
				case ErrorCodes.CopyFolder_NotInsecureFolder:
				case ErrorCodes.DeleteFolder_NoPermission:
				case ErrorCodes.DeleteFolder_NotInsecureFolder:
				case ErrorCodes.DeleteFolder_Protected:
				case ErrorCodes.CannotMoveFolder_ChildrenVisible:
				case ErrorCodes.CannotDeleteFolder_ChildrenVisible:
				case ErrorCodes.CannotCopyFolder_ChildrenVisible:
					logMsg = GetString("ErrorCodes." + errorCode);
					break;
				case ErrorCodes.DeleteFolder_Root:
				case ErrorCodes.RenameFolder_Root:
					logMsg = GetString("ErrorCodes." + errorCode);
					returnValue = string.Format("{0} [{1}]", GetString("ErrorCodes." + errorCode), endUserPath);
					break;
				case ErrorCodes.FileDoesNotExist:
				case ErrorCodes.FolderDoesNotExist:
					logMsg = string.Empty;
					returnValue = string.Format("{0} [{1}]", GetString("ErrorCodes." + errorCode), endUserPath);
					break;
			}

			if (! (string.IsNullOrEmpty(logMsg)))
			{
				Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
				Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo();

				objEventLogInfo.AddProperty("From", "TelerikHtmlEditorProvider Message");

				if (PortalSettings.ActiveTab != null)
				{
					objEventLogInfo.AddProperty("TabID", PortalSettings.ActiveTab.TabID.ToString());
					objEventLogInfo.AddProperty("TabName", PortalSettings.ActiveTab.TabName);
				}

				Entities.Users.UserInfo user = Entities.Users.UserController.GetCurrentUserInfo();
				if (user != null)
				{
					objEventLogInfo.AddProperty("UserID", user.UserID.ToString());
					objEventLogInfo.AddProperty("UserName", user.Username);
				}

				objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT.ToString();
				objEventLogInfo.AddProperty("Message", logMsg);
				objEventLogInfo.AddProperty("Path", virtualPath);
				objEventLog.AddLog(objEventLogInfo);
			}

			return returnValue;
		}
示例#8
0
        public string LogDetailError(ErrorCodes errorCode, string virtualPath, bool logError)
        {
            string endUserPath = string.Empty;

            if (!(string.IsNullOrEmpty(virtualPath)))
            {
                endUserPath = (string)ToEndUserPath(virtualPath);
            }

            string returnValue = GetPermissionErrorText(endUserPath);
            string logMsg      = string.Empty;

            switch (errorCode)
            {
            case ErrorCodes.AddFolder_NoPermission:
            case ErrorCodes.AddFolder_NotInsecureFolder:
            case ErrorCodes.CopyFolder_NoPermission:
            case ErrorCodes.CopyFolder_NotInsecureFolder:
            case ErrorCodes.DeleteFolder_NoPermission:
            case ErrorCodes.DeleteFolder_NotInsecureFolder:
            case ErrorCodes.DeleteFolder_Protected:
            case ErrorCodes.CannotMoveFolder_ChildrenVisible:
            case ErrorCodes.CannotDeleteFolder_ChildrenVisible:
            case ErrorCodes.CannotCopyFolder_ChildrenVisible:
                logMsg = GetString("ErrorCodes." + errorCode);
                break;

            case ErrorCodes.DeleteFolder_Root:
            case ErrorCodes.RenameFolder_Root:
                logMsg      = GetString("ErrorCodes." + errorCode);
                returnValue = string.Format("{0} [{1}]", GetString("ErrorCodes." + errorCode), endUserPath);
                break;

            case ErrorCodes.FileDoesNotExist:
            case ErrorCodes.FolderDoesNotExist:
                logMsg      = string.Empty;
                returnValue = string.Format("{0} [{1}]", GetString("ErrorCodes." + errorCode), endUserPath);
                break;
            }

            if (!(string.IsNullOrEmpty(logMsg)))
            {
                Services.Log.EventLog.EventLogController objEventLog     = new Services.Log.EventLog.EventLogController();
                Services.Log.EventLog.LogInfo            objEventLogInfo = new Services.Log.EventLog.LogInfo();

                objEventLogInfo.AddProperty("From", "TelerikHtmlEditorProvider Message");

                if (PortalSettings.ActiveTab != null)
                {
                    objEventLogInfo.AddProperty("TabID", PortalSettings.ActiveTab.TabID.ToString());
                    objEventLogInfo.AddProperty("TabName", PortalSettings.ActiveTab.TabName);
                }

                Entities.Users.UserInfo user = Entities.Users.UserController.GetCurrentUserInfo();
                if (user != null)
                {
                    objEventLogInfo.AddProperty("UserID", user.UserID.ToString());
                    objEventLogInfo.AddProperty("UserName", user.Username);
                }

                objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT.ToString();
                objEventLogInfo.AddProperty("Message", logMsg);
                objEventLogInfo.AddProperty("Path", virtualPath);
                objEventLog.AddLog(objEventLogInfo);
            }

            return(returnValue);
        }
示例#9
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// UpgradeVersion upgrades a single version
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="strScriptFile">The upgrade script file</param>
        /// <history>
        /// [cnurse]	02/14/2007	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static string UpgradeVersion(string strScriptFile, bool writeFeedback)
        {
            System.Version version = new System.Version(Path.GetFileNameWithoutExtension(strScriptFile));
            string strExceptions = Null.NullString;

            // verify script has not already been run
            if (!Globals.FindDatabaseVersion(version.Major, version.Minor, version.Build))
            {
                // upgrade database schema
                DataProvider.Instance().UpgradeDatabaseSchema(version.Major, version.Minor, version.Build);

                // execute script file (and version upgrades) for version
                strExceptions = ExecuteScript(strScriptFile, writeFeedback);

                // update the version
                Globals.UpdateDataBaseVersion(version);

                Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
                Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo();
                objEventLogInfo.AddProperty("Upgraded DotNetNuke", "Version: " + Globals.FormatVersion(version));
                if (strExceptions.Length > 0)
                {
                    objEventLogInfo.AddProperty("Warnings", strExceptions);
                }
                else
                {
                    objEventLogInfo.AddProperty("No Warnings", "");
                }
                objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLogInfo.BypassBuffering = true;
                objEventLog.AddLog(objEventLogInfo);
            }

            return strExceptions;
        }
示例#10
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// UpgradeApplication - This overload is used for general application upgrade operations.
        /// </summary>
        /// <remarks>
        ///	Since it is not version specific and is invoked whenever the application is
        ///	restarted, the operations must be re-executable.
        /// </remarks>
        /// <history>
        /// [cnurse]	11/6/2004	documented
        /// [cnurse] 02/27/2007 made public so it can be called from Wizard
        /// </history>
        /// -----------------------------------------------------------------------------
        public static void UpgradeApplication()
        {

            TabController objTabController = new TabController();
            TabInfo HostPage = objTabController.GetTabByName("Host", Null.NullInteger);
            TabInfo newPage = default(TabInfo);

            int ModuleDefID = 0;

            try
            {
                // remove the system message module from the admin tab
                // System Messages are now managed through Localization
                if (CoreModuleExists("System Messages"))
                {
                    RemoveCoreModule("System Messages", "Admin", "Site Settings", false);
                }

                // remove portal alias module
                if (CoreModuleExists("PortalAliases"))
                {
                    RemoveCoreModule("PortalAliases", "Admin", "Site Settings", false);
                }

                // add the log viewer module to the admin tab
                if (CoreModuleExists("LogViewer") == false)
                {
                    ModuleDefID = AddModuleDefinition("LogViewer", "Allows you to view log entries for portal events.", "Log Viewer");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/LogViewer/LogViewer.ascx", "", SecurityAccessLevel.Admin, 0);
                    AddModuleControl(ModuleDefID, "Edit", "Edit Log Settings", "DesktopModules/Admin/LogViewer/EditLogTypes.ascx", "", SecurityAccessLevel.Host, 0);

                    //Add the Module/Page to all configured portals
                    AddAdminPages("Log Viewer", "View a historical log of database events such as event schedules, exceptions, account logins, module and page changes, user account activities, security role activities, etc.", "icon_viewstats_16px.gif", "icon_viewstats_32px.gif", true, ModuleDefID, "Log Viewer", "icon_viewstats_16px.gif");
                }

                // add the schedule module to the host tab
                if (CoreModuleExists("Scheduler") == false)
                {
                    ModuleDefID = AddModuleDefinition("Scheduler", "Allows you to schedule tasks to be run at specified intervals.", "Scheduler");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Scheduler/ViewSchedule.ascx", "", SecurityAccessLevel.Admin, 0);
                    AddModuleControl(ModuleDefID, "Edit", "Edit Schedule", "DesktopModules/Admin/Scheduler/EditSchedule.ascx", "", SecurityAccessLevel.Host, 0);
                    AddModuleControl(ModuleDefID, "History", "Schedule History", "DesktopModules/Admin/Scheduler/ViewScheduleHistory.ascx", "", SecurityAccessLevel.Host, 0);
                    AddModuleControl(ModuleDefID, "Status", "Schedule Status", "DesktopModules/Admin/Scheduler/ViewScheduleStatus.ascx", "", SecurityAccessLevel.Host, 0);

                    //Create New Host Page (or get existing one)
                    newPage = AddHostPage("Schedule", "Add, modify and delete scheduled tasks to be run at specified intervals.", "icon_scheduler_16px.gif", "icon_scheduler_32px.gif", true);

                    //Add Module To Page
                    AddModuleToPage(newPage, ModuleDefID, "Schedule", "icon_scheduler_16px.gif");
                }

                // add the Search Admin module to the host tab
                if (CoreModuleExists("SearchAdmin") == false)
                {
                    ModuleDefID = AddModuleDefinition("SearchAdmin", "The Search Admininstrator provides the ability to manage search settings.", "Search Admin");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/SearchAdmin/SearchAdmin.ascx", "", SecurityAccessLevel.Host, 0);

                    //Create New Host Page (or get existing one)
                    newPage = AddHostPage("Search Admin", "Manage search settings associated with DotNetNuke's search capability.", "icon_search_16px.gif", "icon_search_32px.gif", true);

                    //Add Module To Page
                    AddModuleToPage(newPage, ModuleDefID, "Search Admin", "icon_search_16px.gif");
                }

                // add the Search Input module
                if (CoreModuleExists("SearchInput") == false)
                {
                    ModuleDefID = AddModuleDefinition("SearchInput", "The Search Input module provides the ability to submit a search to a given search results module.", "Search Input", false, false);
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/SearchInput/SearchInput.ascx", "", SecurityAccessLevel.Anonymous, 0);
                    AddModuleControl(ModuleDefID, "Settings", "Search Input Settings", "DesktopModules/Admin/SearchInput/Settings.ascx", "", SecurityAccessLevel.Edit, 0);
                }

                // add the Search Results module
                if (CoreModuleExists("SearchResults") == false)
                {
                    ModuleDefID = AddModuleDefinition("SearchResults", "The Search Reasults module provides the ability to display search results.", "Search Results", false, false);
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/SearchResults/SearchResults.ascx", "", SecurityAccessLevel.Anonymous, 0);
                    AddModuleControl(ModuleDefID, "Settings", "Search Results Settings", "DesktopModules/Admin/SearchResults/Settings.ascx", "", SecurityAccessLevel.Edit, 0);

                    //Add the Search Module/Page to all configured portals
                    AddSearchResults(ModuleDefID);
                }

                // add the site wizard module to the admin tab
                if (CoreModuleExists("SiteWizard") == false)
                {
                    ModuleDefID = AddModuleDefinition("SiteWizard", "The Administrator can use this user-friendly wizard to set up the common Extensions of the Portal/Site.", "Site Wizard");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/SiteWizard/Sitewizard.ascx", "", SecurityAccessLevel.Admin, 0);
                    AddAdminPages("Site Wizard", "Configure portal settings, page design and apply a site template using a step-by-step wizard.", "icon_wizard_16px.gif", "icon_wizard_32px.gif", true, ModuleDefID, "Site Wizard", "icon_wizard_16px.gif");
                }

                //add Lists module and tab
                if (HostTabExists("Lists") == false)
                {
                    ModuleDefID = AddModuleDefinition("Lists", "Allows you to edit common lists.", "Lists");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Lists/ListEditor.ascx", "", SecurityAccessLevel.Host, 0);

                    //Create New Host Page (or get existing one)
                    newPage = AddHostPage("Lists", "Manage common lists.", "icon_lists_16px.gif", "icon_lists_32px.gif", true);

                    //Add Module To Page
                    AddModuleToPage(newPage, ModuleDefID, "Lists", "icon_lists_16px.gif");
                }

                if (HostTabExists("Superuser Accounts") == false)
                {
                    //add SuperUser Accounts module and tab
                    DesktopModuleInfo objDesktopModuleInfo = DesktopModuleController.GetDesktopModuleByModuleName("DNN_Security", Null.NullInteger);
                    ModuleDefID = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("User Accounts", objDesktopModuleInfo.DesktopModuleID).ModuleDefID;

                    //Create New Host Page (or get existing one)
                    newPage = AddHostPage("Superuser Accounts", "Manage host user accounts.", "icon_users_16px.gif", "icon_users_32px.gif", true);

                    //Add Module To Page
                    AddModuleToPage(newPage, ModuleDefID, "Superuser Accounts", "icon_users_32px.gif");
                }

                //Add Edit Role Groups
                ModuleDefID = GetModuleDefinition("Security", "Security Roles");
                AddModuleControl(ModuleDefID, "EditGroup", "Edit Role Groups", "DesktopModules/Admin/Security/EditGroups.ascx", "icon_securityroles_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger);
                AddModuleControl(ModuleDefID, "UserSettings", "Manage User Settings", "DesktopModules/Admin/Security/UserSettings.ascx", "~/images/settings.gif", SecurityAccessLevel.Edit, Null.NullInteger);

                //Add User Accounts Controls
                ModuleDefID = GetModuleDefinition("Security", "User Accounts");
                AddModuleControl(ModuleDefID, "ManageProfile", "Manage Profile Definition", "DesktopModules/Admin/Security/ProfileDefinitions.ascx", "icon_users_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger);
                AddModuleControl(ModuleDefID, "EditProfileProperty", "Edit Profile Property Definition", "DesktopModules/Admin/Security/EditProfileDefinition.ascx", "icon_users_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger);
                AddModuleControl(ModuleDefID, "UserSettings", "Manage User Settings", "DesktopModules/Admin/Security/UserSettings.ascx", "~/images/settings.gif", SecurityAccessLevel.Edit, Null.NullInteger);
                AddModuleControl(Null.NullInteger, "Profile", "Profile", "DesktopModules/Admin/Security/ManageUsers.ascx", "icon_users_32px.gif", SecurityAccessLevel.Anonymous, Null.NullInteger);
                AddModuleControl(Null.NullInteger, "SendPassword", "Send Password", "DesktopModules/Admin/Security/SendPassword.ascx", "", SecurityAccessLevel.Anonymous, Null.NullInteger);
                AddModuleControl(Null.NullInteger, "ViewProfile", "View Profile", "DesktopModules/Admin/Security/ViewProfile.ascx", "icon_users_32px.gif", SecurityAccessLevel.Anonymous, Null.NullInteger);

                //Update Child Portal subHost.aspx
                PortalAliasController objAliasController = new PortalAliasController();
                ArrayList arrAliases = objAliasController.GetPortalAliasArrayByPortalID(Null.NullInteger);
                string childPath = null;

                foreach (PortalAliasInfo objAlias in arrAliases)
                {
                    //For the alias to be for a child it must be of the form ...../child
                    int intChild = objAlias.HTTPAlias.IndexOf("/");
                    if (intChild != -1 & intChild != (objAlias.HTTPAlias.Length - 1))
                    {
                        childPath = Globals.ApplicationMapPath + "\\" + objAlias.HTTPAlias.Substring(intChild + 1);
                        // check if Folder exists
                        if (Directory.Exists(childPath))
                        {
                            System.IO.FileInfo objDefault = new System.IO.FileInfo(childPath + "\\" + Globals.glbDefaultPage);
                            System.IO.FileInfo objSubHost = new System.IO.FileInfo(Common.Globals.HostMapPath + "subhost.aspx");
                            // check if upgrade is necessary
                            if (objDefault.Length != objSubHost.Length)
                            {
                                //Rename existing file
                                System.IO.File.Copy(childPath + "\\" + Globals.glbDefaultPage, childPath + "\\old_" + Globals.glbDefaultPage, true);
                                // create the subhost default.aspx file
                                System.IO.File.Copy(Common.Globals.HostMapPath + "subhost.aspx", childPath + "\\" + Globals.glbDefaultPage, true);
                            }
                        }
                    }
                }

                // add the solutions explorer module to the admin tab
                if (CoreModuleExists("Solutions") == false)
                {
                    ModuleDefID = AddModuleDefinition("Solutions", "Browse additional solutions for your application.", "Solutions", false, false);
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Solutions/Solutions.ascx", "", SecurityAccessLevel.Admin, 0);
                    AddAdminPages("Solutions", "DotNetNuke Solutions Explorer page provides easy access to locate free and commercial DotNetNuke modules, skin and more.", "icon_solutions_16px.gif", "icon_solutions_32px.gif", true, ModuleDefID, "Solutions Explorer", "icon_solutions_32px.gif");
                }


                //Add Search Skin Object
                AddSkinControl("SEARCH", "DotNetNuke.SearchSkinObject", "Admin/Skins/Search.ascx");

                //Add TreeView Skin Object
                AddSkinControl("TREEVIEW", "DotNetNuke.TreeViewSkinObject", "Admin/Skins/TreeViewMenu.ascx");

                //Add Text Skin Object
                AddSkinControl("TEXT", "DotNetNuke.TextSkinObject", "Admin/Skins/Text.ascx");

                //Add Styles Skin Object

                AddSkinControl("STYLES", "DotNetNuke.StylesSkinObject", "Admin/Skins/Styles.ascx");
            }
            catch (Exception ex)
            {
                Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
                Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo();
                objEventLogInfo.AddProperty("Upgraded DotNetNuke", "General");
                objEventLogInfo.AddProperty("Warnings", "Error: " + ex.Message + Environment.NewLine);
                objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLogInfo.BypassBuffering = true;
                objEventLog.AddLog(objEventLogInfo);
                try
                {
                    Exceptions.Exceptions.LogException(ex);
                }
                catch
                {
                }

                // ignore
            }

            //Remove any .txt and .config files that may exist in the Install folder
            foreach (string strFile in Directory.GetFiles(Globals.InstallMapPath + "Cleanup\\", "??.??.??.txt"))
            {
                FileSystemUtils.DeleteFile(strFile);
            }
            foreach (string strFile in Directory.GetFiles(Globals.InstallMapPath + "Config\\", "??.??.??.config"))
            {
                FileSystemUtils.DeleteFile(strFile);

            }
        }
示例#11
0
        public static RewriterConfiguration GetConfig()
        {
            RewriterConfiguration Config = new RewriterConfiguration();

            Config.Rules = new RewriterRuleCollection();
            FileStream fileReader = null;
            string     filePath   = "";

            try
            {
                Config = (RewriterConfiguration)(DataCache.GetCache("RewriterConfig"));

                if (Config == null)
                {
                    filePath = Globals.ApplicationMapPath + "\\SiteUrls.config";

                    if (!(File.Exists(filePath)))
                    {
                        //Copy from \Config
                        if (File.Exists(Globals.ApplicationMapPath + Globals.glbConfigFolder + "SiteUrls.config"))
                        {
                            File.Copy(Globals.ApplicationMapPath + Globals.glbConfigFolder + "SiteUrls.config", Globals.ApplicationMapPath + "\\SiteUrls.config", true);
                        }
                    }

                    //Create a FileStream for the Config file
                    fileReader = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);

                    XPathDocument doc = new XPathDocument(fileReader);
                    Config       = new RewriterConfiguration();
                    Config.Rules = new RewriterRuleCollection();

                    foreach (XPathNavigator nav in doc.CreateNavigator().Select("RewriterConfig/Rules/RewriterRule"))
                    {
                        RewriterRule rule = new RewriterRule();
                        rule.LookFor = nav.SelectSingleNode("LookFor").Value;
                        rule.SendTo  = nav.SelectSingleNode("SendTo").Value;
                        Config.Rules.Add(rule);
                    }


                    if (File.Exists(filePath))
                    {
                        // Create a dependancy on SiteUrls.config
                        CacheDependency dep = new CacheDependency(filePath);

                        // Set back into Cache
                        DataCache.SetCache("RewriterConfig", Config, dep);
                    }
                }
            }
            catch (Exception ex)
            {
                //log it
                Services.Log.EventLog.EventLogController objEventLog     = new Services.Log.EventLog.EventLogController();
                Services.Log.EventLog.LogInfo            objEventLogInfo = new Services.Log.EventLog.LogInfo();
                objEventLogInfo.AddProperty("UrlRewriter.RewriterConfiguration", "GetConfig Failed");
                objEventLogInfo.AddProperty("FilePath", filePath);
                objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
                objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLog.AddLog(objEventLogInfo);
            }
            finally
            {
                if (fileReader != null)
                {
                    //Close the Reader
                    fileReader.Close();
                }
            }

            return(Config);
        }