예제 #1
0
        private static PersonalizationInfo LoadProfile()
        {
            HttpContext context = HttpContext.Current;

            //First try and load Personalization object from the Context
            PersonalizationInfo objPersonalization = (PersonalizationInfo)context.Items["Personalization"];

            //If the Personalization object is nothing load it and store it in the context for future calls
            if (objPersonalization == null)
            {
                // Obtain PortalSettings from Current Context
                PortalSettings _portalSettings = (PortalSettings)context.Items["PortalSettings"];

                // load the user info object
                UserInfo UserInfo = UserController.GetCurrentUserInfo();

                // get the personalization object
                PersonalizationController objPersonalizationController = new PersonalizationController();
                objPersonalization = objPersonalizationController.LoadProfile(UserInfo.UserID, _portalSettings.PortalId);

                //store it in the context
                context.Items.Add("Personalization", objPersonalization);
            }

            return objPersonalization;
        }
예제 #2
0
        private static PersonalizationInfo LoadProfile()
        {
            HttpContext context = HttpContext.Current;

            // First try and load Personalization object from the Context
            var personalization = (PersonalizationInfo)context.Items["Personalization"];

            // If the Personalization object is nothing load it and store it in the context for future calls
            if (personalization == null)
            {
                var _portalSettings = (PortalSettings)context.Items["PortalSettings"];

                // load the user info object
                UserInfo UserInfo = UserController.Instance.GetCurrentUserInfo();

                // get the personalization object
                var personalizationController = new PersonalizationController();
                personalization = personalizationController.LoadProfile(UserInfo.UserID, _portalSettings.PortalId);

                // store it in the context
                context.Items.Add("Personalization", personalization);
            }

            return(personalization);
        }
        public void OnEndRequest(object s, EventArgs e)
        {
            HttpContext Context = ((HttpApplication) s).Context;
            HttpRequest Request = Context.Request;
            //exit if a request for a .net mapping that isn't a content page is made i.e. axd
            if (Request.Url.LocalPath.ToLower().EndsWith(".aspx") == false && Request.Url.LocalPath.ToLower().EndsWith(".asmx") == false && Request.Url.LocalPath.ToLower().EndsWith(".ashx") == false)
            {
                return;
            }
			
            //Obtain PortalSettings from Current Context
            var _portalSettings = (PortalSettings) Context.Items["PortalSettings"];
            if (_portalSettings != null)
            {
                //load the user info object
                UserInfo UserInfo = UserController.Instance.GetCurrentUserInfo();
                var personalization = new PersonalizationController();
                personalization.SaveProfile(Context, UserInfo.UserID, _portalSettings.PortalId);
            }
        }
        public void OnEndRequest(object s, EventArgs e)
        {
            HttpContext context = ((HttpApplication) s).Context;
            HttpRequest request = context.Request;

            if (!Initialize.ProcessHttpModule(request, false, false))
            {
                return;
            }
			
            //Obtain PortalSettings from Current Context
            var _portalSettings = (PortalSettings)context.Items["PortalSettings"];
            if (_portalSettings != null)
            {
                //load the user info object
                UserInfo UserInfo = UserController.Instance.GetCurrentUserInfo();
                var personalization = new PersonalizationController();
                personalization.SaveProfile(context, UserInfo.UserID, _portalSettings.PortalId);
            }
        }
        public void OnEndRequest( object s, EventArgs e )
        {
            HttpContext Context = ( (HttpApplication)s ).Context;
            HttpRequest Request = Context.Request;

            if( Request.IsAuthenticated == true )
            {
                // Obtain PortalSettings from Current Context
                PortalSettings _portalSettings = (PortalSettings)Context.Items["PortalSettings"];

                if( !( _portalSettings == null ) )
                {
                    // load the user info object
                    UserInfo userInfo = UserController.GetCurrentUserInfo();

                    if (userInfo.UserID != -1)
                    {
                        PersonalizationController objPersonalization = new PersonalizationController();
                        objPersonalization.SaveProfile(Context, userInfo.UserID, _portalSettings.PortalId);
                    }
                }
            }
        }
        /// <summary>
        ///   Sets the current user so that checking authentication and roles works.
        /// </summary>
        /// <remarks>
        ///   Copies functionality from <c>DotNetNuke.HttpModules.Membership.MembershipModule.OnAuthenticateRequest</c>
        ///   to get the current user set as the "Current User"
        /// </remarks>
        private void SetCurrentUser()
        {
            // Obtain PortalSettings from Current Context
            var portalSettings = PortalController.GetCurrentPortalSettings();

            if (this.Context.Request.IsAuthenticated && portalSettings != null)
            {
                var roleController = new RoleController();
                var cachedUser = UserController.GetCachedUser(portalSettings.PortalId, this.Context.User.Identity.Name);

                if (this.Context.Request.Cookies["portalaliasid"] != null)
                {
            // ReSharper disable PossibleNullReferenceException
                    var portalCookie = FormsAuthentication.Decrypt(this.Context.Request.Cookies["portalaliasid"].Value);

                    // check if user has switched portals
                    if (portalSettings.PortalAlias.PortalAliasID != int.Parse(portalCookie.UserData))
                    {
                        // expire cookies if portal has changed
                        this.Context.Response.Cookies["portalaliasid"].Value = null;
                        this.Context.Response.Cookies["portalaliasid"].Path = "/";
                        this.Context.Response.Cookies["portalaliasid"].Expires = DateTime.Now.AddYears(-30);

                        this.Context.Response.Cookies["portalroles"].Value = null;
                        this.Context.Response.Cookies["portalroles"].Path = "/";
                        this.Context.Response.Cookies["portalroles"].Expires = DateTime.Now.AddYears(-30);

            // ReSharper restore PossibleNullReferenceException
                    }
                }

                // authenticate user and set last login ( this is necessary for users who have a permanent Auth cookie set )
                if (cachedUser == null || cachedUser.IsDeleted || cachedUser.Membership.LockedOut ||
                    cachedUser.Membership.Approved == false ||
                    cachedUser.Username.ToLower() != this.Context.User.Identity.Name.ToLower())
                {
                    var portalSecurity = new PortalSecurity();
                    portalSecurity.SignOut();

                    // Remove user from cache
                    if (cachedUser != null)
                    {
                        DataCache.ClearUserCache(portalSettings.PortalId, this.Context.User.Identity.Name);
                    }

                    // Redirect browser back to home page
                    this.Context.Response.Redirect(this.Context.Request.RawUrl, true);
                    return;
                }

                // valid Auth cookie
                // if users LastActivityDate is outside of the UsersOnlineTimeWindow then record user activity
                if (
                    DateTime.Compare(
                        cachedUser.Membership.LastActivityDate.AddMinutes(Host.UsersOnlineTimeWindow), DateTime.Now) < 0)
                {
                    // update LastActivityDate and IP Address for user
                    cachedUser.Membership.LastActivityDate = DateTime.Now;
                    cachedUser.LastIPAddress = this.Context.Request.UserHostAddress;
                    UserController.UpdateUser(portalSettings.PortalId, cachedUser);
                }

                // refreshroles is set when a role is added to a user by an administrator
                bool refreshCookies = cachedUser.RefreshRoles;

                // check for RSVP code
                if (!cachedUser.RefreshRoles && this.Context.Request.QueryString["rsvp"] != null &&
                    string.IsNullOrEmpty(this.Context.Request.QueryString["rsvp"]) == false)
                {
                    foreach (RoleInfo objRole in roleController.GetPortalRoles(portalSettings.PortalId))
                    {
                        if (objRole.RSVPCode == this.Context.Request.QueryString["rsvp"])
                        {
                            roleController.UpdateUserRole(portalSettings.PortalId, cachedUser.UserID, objRole.RoleID);

                            // clear portalroles so the new role is added to the cookie below
                            refreshCookies = true;
                        }
                    }
                }

                // create cookies if they do not exist yet for this session.
                if (this.Context.Request.Cookies["portalroles"] == null || refreshCookies)
                {
                    // keep cookies in sync
                    var currentDateTime = DateTime.Now;

                    // create a cookie authentication ticket ( version, user name, issue time, expires every hour, don't persist cookie, roles )
                    var portalTicket = new FormsAuthenticationTicket(
                        1,
                        this.Context.User.Identity.Name,
                        currentDateTime,
                        currentDateTime.AddHours(1),
                        false,
                        portalSettings.PortalAlias.PortalAliasID.ToString());

                    // encrypt the ticket
                    string portalAliasId = FormsAuthentication.Encrypt(portalTicket);

            // ReSharper disable PossibleNullReferenceException
                    // send portal cookie to client
                    this.Context.Response.Cookies["portalaliasid"].Value = portalAliasId;
                    this.Context.Response.Cookies["portalaliasid"].Path = "/";
                    this.Context.Response.Cookies["portalaliasid"].Expires = currentDateTime.AddMinutes(1);

            // ReSharper restore PossibleNullReferenceException
                    // get roles from UserRoles table
                    string[] arrPortalRoles = roleController.GetRolesByUser(cachedUser.UserID, portalSettings.PortalId);

                    // create a string to persist the roles, attach a portalID so that cross-portal impersonation cannot occur
                    string strPortalRoles = portalSettings.PortalId + "!!" + string.Join(";", arrPortalRoles);

                    // create a cookie authentication ticket ( version, user name, issue time, expires every hour, don't persist cookie, roles )
                    var rolesTicket = new FormsAuthenticationTicket(
                        1,
                        this.Context.User.Identity.Name,
                        currentDateTime,
                        currentDateTime.AddHours(1),
                        false,
                        strPortalRoles);

                    // encrypt the ticket
                    string strRoles = FormsAuthentication.Encrypt(rolesTicket);

            // ReSharper disable PossibleNullReferenceException
                    // send roles cookie to client
                    this.Context.Response.Cookies["portalroles"].Value = strRoles;
                    this.Context.Response.Cookies["portalroles"].Path = "/";
                    this.Context.Response.Cookies["portalroles"].Expires = currentDateTime.AddMinutes(1);

                    if (refreshCookies)
                    {
                        // if rsvp, update portalroles in context because it is being used later
                        this.Context.Request.Cookies["portalroles"].Value = strRoles;
                    }
                }

                if (this.Context.Request.Cookies["portalroles"] != null)
                {
                    // get roles from roles cookie
                    if (this.Context.Request.Cookies["portalroles"].Value != string.Empty)
                    {
                        var roleTicket = FormsAuthentication.Decrypt(this.Context.Request.Cookies["portalroles"].Value);

            // ReSharper restore PossibleNullReferenceException
                        if (roleTicket != null)
                        {
                            // get the role data and split it into portalid and a string array of role data
                            string rolesdata = roleTicket.UserData;
                            char[] separator = "!!".ToCharArray();

                            // need to use StringSplitOptions.None to preserve case where superuser has no roles
                            string[] rolesParts = rolesdata.Split(separator, StringSplitOptions.None);

                            // if cookie is for a different portal than current force a refresh of roles else used cookie cached version
                            if (Convert.ToInt32(rolesParts[0]) != portalSettings.PortalId)
                            {
                                cachedUser.Roles = roleController.GetRolesByUser(cachedUser.UserID, portalSettings.PortalId);
                            }
                            else
                            {
                                cachedUser.Roles = rolesParts[2].Split(';');
                            }
                        }
                        else
                        {
                            cachedUser.Roles = roleController.GetRolesByUser(cachedUser.UserID, portalSettings.PortalId);
                        }

                        // Clear RefreshRoles flag
                        if (cachedUser.RefreshRoles)
                        {
                            cachedUser.RefreshRoles = false;
                            UserController.UpdateUser(portalSettings.PortalId, cachedUser);
                        }
                    }

                    // save userinfo object in context
                    this.Context.Items.Add("UserInfo", cachedUser);

                    // load the personalization object
                    var personalizationController = new PersonalizationController();
                    personalizationController.LoadProfile(this.Context, cachedUser.UserID, cachedUser.PortalID);

                    // Localization.SetLanguage also updates the user profile, so this needs to go after the profile is loaded
                    Localization.SetLanguage(cachedUser.Profile.PreferredLocale);
                }
            }

            if (HttpContext.Current.Items["UserInfo"] == null)
            {
                this.Context.Items.Add("UserInfo", new UserInfo());
            }
        }
예제 #7
0
        /// <summary>
        /// UpgradeApplication - This overload is used for version specific application upgrade operations.
        /// </summary>
        /// <remarks>
        ///	This should be used for file system modifications or upgrade operations which
        ///	should only happen once. Database references are not recommended because future
        ///	versions of the application may result in code incompatibilties.
        /// </remarks>
        ///	<param name="Version">The Version being Upgraded</param>
        private static string UpgradeApplication(string Version)
        {
            string strExceptions = "";

            try
            {
                switch (Version)
                {
                    case "02.00.00":

                        IDataReader dr;

                        // change portal upload directory from GUID to ID - this only executes for version 2.0.0
                        string strServerPath = HttpContext.Current.Request.MapPath(Globals.ApplicationPath);
                        string strPortalsDirMapPath = Globals.ApplicationMapPath + "/Portals/";

                        dr = DataProvider.Instance().GetPortals();
                        while (dr.Read())
                        {
                            // if GUID folder exists
                            if (Directory.Exists(strPortalsDirMapPath + dr["GUID"]))
                            {
                                // if ID folder exists ( this may happen because the 2.x release contains a default ID=0 folder )
                                if (Directory.Exists(strPortalsDirMapPath + dr["PortalID"]))
                                {
                                    // rename the ID folder
                                    try
                                    {
                                        Directory.Move(strPortalsDirMapPath + dr["PortalID"], strServerPath + "\\Portals\\" + dr["PortalID"] + "_old");
                                    }
                                    catch (Exception ex)
                                    {
                                        // error moving the directory - security issue?
                                        strExceptions += "Could Not Move Folder " + strPortalsDirMapPath + dr["GUID"] + " To " + strPortalsDirMapPath + dr["PortalID"] + ". Error: " + ex.Message + "\r\n";
                                    }
                                }

                                // move GUID folder to ID folder
                                try
                                {
                                    Directory.Move(strPortalsDirMapPath + dr["GUID"], strPortalsDirMapPath + dr["PortalID"]);
                                }
                                catch (Exception ex)
                                {
                                    // error moving the directory - security issue?
                                    strExceptions += "Could Not Move Folder " + strPortalsDirMapPath + dr["GUID"] + " To " + strPortalsDirMapPath + dr["PortalID"] + ". Error: " + ex.Message + "\r\n";
                                }
                            }
                        }
                        dr.Close();

                        // copy the default style sheet to the default portal ( if it does not already exist )
                        if (File.Exists(strPortalsDirMapPath + "0\\portal.css") == false)
                        {
                            if (File.Exists(Globals.HostMapPath + "portal.css"))
                            {
                                File.Copy(Globals.HostMapPath + "portal.css", strPortalsDirMapPath + "0\\portal.css");
                            }
                        }
                        break;

                    case "02.02.00":

                        string strProviderPath = PortalSettings.GetProviderPath();
                        if (strProviderPath.StartsWith("ERROR:"))
                        {
                            strExceptions += strProviderPath;
                            break;
                        }

                        //Optionally Install the memberRoleProvider
                        bool installMemberRole = true;
                        if (Config.GetSetting("InstallMemberRole") != null)
                        {
                            installMemberRole = bool.Parse(Config.GetSetting("InstallMemberRole"));
                        }
                        if (installMemberRole)
                        {
                            HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Installing MemberRole Provider:<br>");
                            strExceptions += InstallMemberRoleProvider(strProviderPath);
                        }

                        PortalController objPortalController = new PortalController();
                        ArrayList arrPortals;
                        arrPortals = objPortalController.GetPortals();

                        int intViewModulePermissionID;
                        int intEditModulePermissionID;

                        int intViewTabPermissionID;
                        int intEditTabPermissionID;

                        int intReadFolderPermissionID;
                        int intWriteFolderPermissionID;

                        PermissionController objPermissionController = new PermissionController();
                        PermissionInfo objPermission = new PermissionInfo();
                        objPermission.PermissionCode = "SYSTEM_MODULE_DEFINITION";
                        objPermission.PermissionKey = "VIEW";
                        objPermission.PermissionName = "View";
                        objPermission.ModuleDefID = Null.NullInteger;
                        objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionKey = "EDIT";
                        objPermission.PermissionName = "Edit";
                        objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionCode = "SYSTEM_TAB";
                        objPermission.PermissionKey = "VIEW";
                        objPermission.PermissionName = "View Tab";
                        objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionKey = "EDIT";
                        objPermission.PermissionName = "Edit Tab";
                        objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionCode = "SYSTEM_FOLDER";
                        objPermission.PermissionKey = "READ";
                        objPermission.PermissionName = "View Folder";
                        intReadFolderPermissionID = objPermissionController.AddPermission(objPermission);

                        objPermission.PermissionKey = "WRITE";
                        objPermission.PermissionName = "Write to Folder";
                        intWriteFolderPermissionID = objPermissionController.AddPermission(objPermission);

                        FolderController objFolderController = new FolderController();

                        FolderPermissionController objFolderPermissionController = new FolderPermissionController();
                        int PortalCount;
                        for (PortalCount = 0; PortalCount <= arrPortals.Count - 1; PortalCount++)
                        {
                            PortalInfo objPortal = (PortalInfo)arrPortals[PortalCount];
                            int FolderID = objFolderController.AddFolder(objPortal.PortalID, "", (int)FolderController.StorageLocationTypes.InsecureFileSystem, true, false);

                            FolderPermissionInfo objFolderPermission = new FolderPermissionInfo();
                            objFolderPermission.FolderID = FolderID;
                            objFolderPermission.PermissionID = intReadFolderPermissionID;
                            objFolderPermission.AllowAccess = true;
                            objFolderPermission.RoleID = objPortal.AdministratorRoleId;
                            objFolderPermissionController.AddFolderPermission(objFolderPermission);

                            objFolderPermission.PermissionID = intWriteFolderPermissionID;
                            objFolderPermissionController.AddFolderPermission(objFolderPermission);

                            //TODO: loop through folders recursively here
                            //in case they created any nested folders
                            //and assign priveledges accordingly
                        }

                        //Transfer Users to the Membership Provider
                        MembershipProvider provider = MembershipProvider.Instance();
                        provider.TransferUsersToMembershipProvider();

                        ModuleController objModuleController = new ModuleController();
                        ArrayList arrModules = objModuleController.GetAllModules();

                        ModulePermissionController objModulePermissionController = new ModulePermissionController();
                        int ModCount;
                        for (ModCount = 0; ModCount <= arrModules.Count - 1; ModCount++)
                        {
                            ModuleInfo objModule = (ModuleInfo)arrModules[ModCount];
                            ModulePermissionInfo objModulePermission = new ModulePermissionInfo();
                            objModulePermission.ModuleID = objModule.ModuleID;
                            int k;
                            string[] roles;
                            if (objModule.AuthorizedViewRoles.IndexOf(";") > 0)
                            {
                                roles = objModule.AuthorizedViewRoles.Split(';');
                                for (k = 0; k <= roles.Length - 1; k++)
                                {

                                    if (Int32.TryParse(roles[k], out intViewModulePermissionID))
                                    {
                                        objModulePermission.PermissionID = intViewModulePermissionID;
                                        objModulePermission.AllowAccess = true;
                                        objModulePermission.RoleID = Convert.ToInt32(roles[k]);
                                        objModulePermissionController.AddModulePermission(objModulePermission);
                                    }
                                }
                            }
                            if (objModule.AuthorizedEditRoles.IndexOf(";") > 0)
                            {
                                roles = objModule.AuthorizedEditRoles.Split(';');
                                for (k = 0; k <= roles.Length - 1; k++)
                                {
                                    if (Int32.TryParse(roles[k], out intEditModulePermissionID))
                                    {
                                        objModulePermission.PermissionID = intEditModulePermissionID;
                                        objModulePermission.AllowAccess = true;
                                        objModulePermission.RoleID = Convert.ToInt32(roles[k]);
                                        objModulePermissionController.AddModulePermission(objModulePermission);
                                    }
                                }
                            }
                        }

                        ArrayList arrTabs;
                        TabController objTabController = new TabController();
                        arrTabs = objTabController.GetAllTabs();

                        TabPermissionController objTabPermissionController = new TabPermissionController();
                        for (ModCount = 0; ModCount <= arrTabs.Count - 1; ModCount++)
                        {
                            TabInfo objTab = (TabInfo)arrTabs[ModCount];
                            TabPermissionInfo objTabPermission = new TabPermissionInfo();
                            objTabPermission.TabID = objTab.TabID;
                            int k;
                            string[] roles;
                            if (objTab.AuthorizedRoles.IndexOf(";") > 0)
                            {
                                roles = objTab.AuthorizedRoles.Split(';');
                                for (k = 0; k <= roles.Length - 1; k++)
                                {
                                    if (Int32.TryParse(roles[k], out intViewTabPermissionID))
                                    {
                                        objTabPermission.PermissionID = intViewTabPermissionID;
                                        objTabPermission.AllowAccess = true;
                                        objTabPermission.RoleID = Convert.ToInt32(roles[k]);
                                        objTabPermissionController.AddTabPermission(objTabPermission);
                                    }
                                }
                            }
                            if (objTab.AdministratorRoles.IndexOf(";") > 0)
                            {
                                roles = objTab.AdministratorRoles.Split(';');
                                for (k = 0; k <= roles.Length - 1; k++)
                                {
                                    if (Int32.TryParse(roles[k], out intEditTabPermissionID))
                                    {
                                        objTabPermission.PermissionID = intEditTabPermissionID;
                                        objTabPermission.AllowAccess = true;
                                        objTabPermission.RoleID = Convert.ToInt32(roles[k]);
                                        objTabPermissionController.AddTabPermission(objTabPermission);
                                    }
                                }
                            }
                        }
                        break;
                    case "03.00.01":

                        objTabController = new TabController();
                        arrTabs = objTabController.GetAllTabs();

                        int TabCount;
                        for (TabCount = 0; TabCount <= arrTabs.Count - 1; TabCount++)
                        {
                            TabInfo objTab = (TabInfo)arrTabs[TabCount];
                            if (objTab != null)
                            {
                                objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
                                DataProvider.Instance().UpdateTab(objTab.TabID, objTab.TabName, objTab.IsVisible, objTab.DisableLink, objTab.ParentId, objTab.IconFile, objTab.Title, objTab.Description, objTab.KeyWords, objTab.IsDeleted, objTab.Url, objTab.SkinSrc, objTab.ContainerSrc, objTab.TabPath, objTab.StartDate, objTab.EndDate);
                            }
                        }
                        break;
                    case "03.00.06":

                        //Need to clear the cache to pick up new HostSettings from the SQLDataProvider script
                        DataCache.RemoveCache("GetHostSettings");
                        break;
                    case "03.00.11":

                        //Need to convert any Profile Data to use XmlSerialization as Binary Formatting
                        //is not supported under Medium Trust

                        //Get all the Profiles
                        PersonalizationController objPersonalizationController = new PersonalizationController();

                        dr = DataProvider.Instance().GetAllProfiles();

                        while (dr.Read())
                        {
                            //Load Profile Data (using Binary Formatter method)
                            PersonalizationInfo objPersonalization = new PersonalizationInfo();
                            try
                            {
                                objPersonalization.UserId = Convert.ToInt32(Null.SetNull(dr["UserID"], objPersonalization.UserId));
                            }
                            catch
                            {
                            }
                            try
                            {
                                objPersonalization.PortalId = Convert.ToInt32(Null.SetNull(dr["PortalId"], objPersonalization.PortalId));
                            }
                            catch
                            {
                            }
                            objPersonalization.Profile = Globals.DeserializeHashTableBase64(dr["ProfileData"].ToString());
                            objPersonalization.IsModified = true;

                            //Save Profile Data (using XML Serializer)
                            objPersonalizationController.SaveProfile(objPersonalization);
                        }
                        dr.Close();
                        break;
                    case "03.00.12":

                        //If we are upgrading from a 3.0.x version then we need to upgrade the MembershipProvider
                        if (upgradeMemberShipProvider)
                        {
                            strProviderPath = PortalSettings.GetProviderPath();
                            StreamReader objStreamReader;
                            string strScript;

                            //Upgrade provider
                            HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Executing UpgradeMembershipProvider.sql<br>");
                            objStreamReader = File.OpenText(strProviderPath + "UpgradeMembershipProvider.sql");
                            strScript = objStreamReader.ReadToEnd();
                            objStreamReader.Close();
                            strExceptions += PortalSettings.ExecuteScript(strScript);
                        }
                        break;
                    case "03.01.00":

                        LogController objLogController = new LogController();
                        XmlDocument xmlDoc = new XmlDocument();
                        string xmlConfigFile = Globals.HostMapPath + "Logs\\LogConfig\\LogConfig.xml.resources";
                        try
                        {
                            xmlDoc.Load(xmlConfigFile);
                        }
                        catch (FileNotFoundException)
                        {
                            xmlConfigFile = Globals.HostMapPath + "Logs\\LogConfig\\LogConfigTemplate.xml.resources";
                            xmlDoc.Load(xmlConfigFile);
                        }
                        XmlNodeList LogType = xmlDoc.SelectNodes("/LogConfig/LogTypes/LogType");
                        foreach (XmlNode LogTypeInfo in LogType)
                        {
                            LogTypeInfo objLogTypeInfo = new LogTypeInfo();
                            objLogTypeInfo.LogTypeKey = LogTypeInfo.Attributes["LogTypeKey"].Value;
                            objLogTypeInfo.LogTypeFriendlyName = LogTypeInfo.Attributes["LogTypeFriendlyName"].Value;
                            objLogTypeInfo.LogTypeDescription = LogTypeInfo.Attributes["LogTypeDescription"].Value;
                            objLogTypeInfo.LogTypeCSSClass = LogTypeInfo.Attributes["LogTypeCSSClass"].Value;
                            objLogTypeInfo.LogTypeOwner = LogTypeInfo.Attributes["LogTypeOwner"].Value;
                            objLogController.AddLogType(objLogTypeInfo);
                        }

                        XmlNodeList LogTypeConfig = xmlDoc.SelectNodes("/LogConfig/LogTypeConfig");
                        foreach (XmlNode LogTypeConfigInfo in LogTypeConfig)
                        {
                            LogTypeConfigInfo objLogTypeConfig = new LogTypeConfigInfo();
                            objLogTypeConfig.EmailNotificationIsActive = Convert.ToBoolean((LogTypeConfigInfo.Attributes["EmailNotificationStatus"].Value == "On") ? true : false);
                            objLogTypeConfig.KeepMostRecent = LogTypeConfigInfo.Attributes["KeepMostRecent"].Value;
                            objLogTypeConfig.LoggingIsActive = Convert.ToBoolean((LogTypeConfigInfo.Attributes["LoggingStatus"].Value == "On") ? true : false);
                            objLogTypeConfig.LogTypeKey = LogTypeConfigInfo.Attributes["LogTypeKey"].Value;
                            objLogTypeConfig.LogTypePortalID = LogTypeConfigInfo.Attributes["LogTypePortalID"].Value;
                            objLogTypeConfig.MailFromAddress = LogTypeConfigInfo.Attributes["MailFromAddress"].Value;
                            objLogTypeConfig.MailToAddress = LogTypeConfigInfo.Attributes["MailToAddress"].Value;
                            objLogTypeConfig.NotificationThreshold = Convert.ToInt32(LogTypeConfigInfo.Attributes["NotificationThreshold"].Value);
                            objLogTypeConfig.NotificationThresholdTime = Convert.ToInt32(LogTypeConfigInfo.Attributes["NotificationThresholdTime"].Value);
                            objLogTypeConfig.NotificationThresholdTimeType = (LogTypeConfigInfo.NotificationThresholdTimeTypes)Enum.Parse(typeof(LogTypeConfigInfo.NotificationThresholdTimeTypes), LogTypeConfigInfo.Attributes["NotificationThresholdTimeType"].Value);
                            objLogController.AddLogTypeConfigInfo(objLogTypeConfig);
                        }

                        ScheduleItem objScheduleItem = new ScheduleItem();
                        objScheduleItem.TypeFullName = "DotNetNuke.Services.Cache.PurgeCache, DOTNETNUKE";
                        objScheduleItem.AttachToEvent = "";
                        objScheduleItem.CatchUpEnabled = false;
                        if (Globals.WebFarmEnabled)
                        {
                            objScheduleItem.Enabled = true;
                        }
                        else
                        {
                            objScheduleItem.Enabled = false;
                        }
                        objScheduleItem.ObjectDependencies = "";
                        objScheduleItem.RetainHistoryNum = 10;
                        objScheduleItem.Servers = "";
                        objScheduleItem.TimeLapse = 2;
                        objScheduleItem.TimeLapseMeasurement = "hz";
                        objScheduleItem.RetryTimeLapse = 30;
                        objScheduleItem.RetryTimeLapseMeasurement = "m";
                        SchedulingProvider.Instance().AddSchedule(objScheduleItem);
                        break;
                    case "03.02.03":

                        //add new SecurityException
                        LogController objSecLogController = new LogController();
                        XmlDocument xmlSecDoc = new XmlDocument();
                        string xmlSecConfigFile = Globals.HostMapPath + "Logs\\LogConfig\\SecurityExceptionTemplate.xml.resources";
                        try
                        {
                            xmlSecDoc.Load(xmlSecConfigFile);
                        }
                        catch (FileNotFoundException)
                        {
                            //  xmlConfigFile = Common.Globals.HostMapPath + "Logs\LogConfig\LogConfigTemplate.xml.resources"
                            // xmlDoc.Load(xmlConfigFile)
                        }
                        LogType = xmlSecDoc.SelectNodes("/LogConfig/LogTypes/LogType");

                        foreach (XmlNode LogTypeInfo in LogType)
                        {
                            LogTypeInfo objLogTypeInfo = new LogTypeInfo();
                            objLogTypeInfo.LogTypeKey = LogTypeInfo.Attributes["LogTypeKey"].Value;
                            objLogTypeInfo.LogTypeFriendlyName = LogTypeInfo.Attributes["LogTypeFriendlyName"].Value;
                            objLogTypeInfo.LogTypeDescription = LogTypeInfo.Attributes["LogTypeDescription"].Value;
                            objLogTypeInfo.LogTypeCSSClass = LogTypeInfo.Attributes["LogTypeCSSClass"].Value;
                            objLogTypeInfo.LogTypeOwner = LogTypeInfo.Attributes["LogTypeOwner"].Value;
                            objSecLogController.AddLogType(objLogTypeInfo);
                        }

                        LogTypeConfig = xmlSecDoc.SelectNodes("/LogConfig/LogTypeConfig");

                        foreach (XmlNode LogTypeConfigInfo in LogTypeConfig)
                        {
                            LogTypeConfigInfo objLogTypeConfig = new LogTypeConfigInfo();
                            objLogTypeConfig.EmailNotificationIsActive = Convert.ToBoolean((LogTypeConfigInfo.Attributes["EmailNotificationStatus"].Value == "On") ? true : false);
                            objLogTypeConfig.KeepMostRecent = LogTypeConfigInfo.Attributes["KeepMostRecent"].Value;
                            objLogTypeConfig.LoggingIsActive = Convert.ToBoolean((LogTypeConfigInfo.Attributes["LoggingStatus"].Value == "On") ? true : false);
                            objLogTypeConfig.LogTypeKey = LogTypeConfigInfo.Attributes["LogTypeKey"].Value;
                            objLogTypeConfig.LogTypePortalID = LogTypeConfigInfo.Attributes["LogTypePortalID"].Value;
                            objLogTypeConfig.MailFromAddress = LogTypeConfigInfo.Attributes["MailFromAddress"].Value;
                            objLogTypeConfig.MailToAddress = LogTypeConfigInfo.Attributes["MailToAddress"].Value;
                            objLogTypeConfig.NotificationThreshold = Convert.ToInt32(LogTypeConfigInfo.Attributes["NotificationThreshold"].Value);
                            objLogTypeConfig.NotificationThresholdTime = Convert.ToInt32(LogTypeConfigInfo.Attributes["NotificationThresholdTime"].Value);
                            objLogTypeConfig.NotificationThresholdTimeType = (LogTypeConfigInfo.NotificationThresholdTimeTypes)Enum.Parse(typeof(LogTypeConfigInfo.NotificationThresholdTimeTypes), LogTypeConfigInfo.Attributes["NotificationThresholdTimeType"].Value);
                            objSecLogController.AddLogTypeConfigInfo(objLogTypeConfig);
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                strExceptions += "Error: " + ex.Message + "\r\n";
                try
                {
                    Exceptions.Exceptions.LogException(ex);
                }
                catch
                {
                    // ignore
                }
            }

            return strExceptions;
        }