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); }
private void LogInstallEvent(string package, string eventType) { try { Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo(eventType + " " + package + ":", InstallerInfo.ManifestFile.Name.Replace(".dnn", ""))); foreach (LogEntry objLogEntry in InstallerInfo.Log.Logs) { objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("Info:", objLogEntry.Description)); } Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); objEventLog.AddLog(objEventLogInfo); } catch (Exception ex) { ex.ToString(); } }
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 void DeleteTabModule(int tabId, int moduleId, bool softDelete) { ModuleInfo objModule = GetModule(moduleId, tabId, false); if (objModule != null) { dataProvider.DeleteTabModule(tabId, moduleId, softDelete); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("tabId", tabId.ToString())); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("moduleId", moduleId.ToString())); objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.TABMODULE_DELETED.ToString(); objEventLog.AddLog(objEventLogInfo); UpdateTabModuleOrder(tabId); if (GetModule(moduleId, Null.NullInteger, true).TabID == Null.NullInteger) { DeleteModule(moduleId); } } ClearCache(tabId); }
public static string UploadLegacySkin(string RootPath, string SkinRoot, string SkinName, Stream objInputStream) { ZipInputStream objZipInputStream = new ZipInputStream(objInputStream); ZipEntry objZipEntry; string strExtension; string strFileName; FileStream objFileStream; int intSize = 2048; byte[] arrData = new byte[2048]; string strMessage = ""; ArrayList arrSkinFiles = new ArrayList(); PortalSettings ResourcePortalSettings = CommonLibrary.Common.Globals.GetPortalSettings(); string BEGIN_MESSAGE = Localization.GetString("BeginZip", ResourcePortalSettings); string CREATE_DIR = Localization.GetString("CreateDir", ResourcePortalSettings); string WRITE_FILE = Localization.GetString("WriteFile", ResourcePortalSettings); string FILE_ERROR = Localization.GetString("FileError", ResourcePortalSettings); string END_MESSAGE = Localization.GetString("EndZip", ResourcePortalSettings); string FILE_RESTICTED = Localization.GetString("FileRestricted", ResourcePortalSettings); strMessage += FormatMessage(BEGIN_MESSAGE, SkinName, -1, false); objZipEntry = objZipInputStream.GetNextEntry(); while (objZipEntry != null) { if (!objZipEntry.IsDirectory) { strExtension = objZipEntry.Name.Substring(objZipEntry.Name.LastIndexOf(".") + 1); if (("," + strExtension.ToUpper()).IndexOf(",ASCX,HTM,HTML,CSS,SWF,RESX,XAML,JS," + Host.FileExtensions.ToUpper()) != 0) { if (objZipEntry.Name.ToLower() == SkinController.RootSkin.ToLower() + ".zip") { MemoryStream objMemoryStream = new MemoryStream(); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); while (intSize > 0) { objMemoryStream.Write(arrData, 0, intSize); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); } objMemoryStream.Seek(0, SeekOrigin.Begin); strMessage += UploadLegacySkin(RootPath, SkinController.RootSkin, SkinName, (Stream)objMemoryStream); } else if (objZipEntry.Name.ToLower() == SkinController.RootContainer.ToLower() + ".zip") { MemoryStream objMemoryStream = new MemoryStream(); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); while (intSize > 0) { objMemoryStream.Write(arrData, 0, intSize); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); } objMemoryStream.Seek(0, SeekOrigin.Begin); strMessage += UploadLegacySkin(RootPath, SkinController.RootContainer, SkinName, (Stream)objMemoryStream); } else { strFileName = RootPath + SkinRoot + "\\" + SkinName + "\\" + objZipEntry.Name; if (!Directory.Exists(Path.GetDirectoryName(strFileName))) { strMessage += FormatMessage(CREATE_DIR, Path.GetDirectoryName(strFileName), 2, false); Directory.CreateDirectory(Path.GetDirectoryName(strFileName)); } if (File.Exists(strFileName)) { File.SetAttributes(strFileName, FileAttributes.Normal); File.Delete(strFileName); } objFileStream = File.Create(strFileName); strMessage += FormatMessage(WRITE_FILE, Path.GetFileName(strFileName), 2, false); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); while (intSize > 0) { objFileStream.Write(arrData, 0, intSize); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); } objFileStream.Close(); switch (Path.GetExtension(strFileName)) { case ".htm": case ".html": case ".ascx": case ".css": if (strFileName.ToLower().IndexOf(Globals.glbAboutPage.ToLower()) < 0) { arrSkinFiles.Add(strFileName); } break; } break; } } else { strMessage += string.Format(FILE_RESTICTED, objZipEntry.Name, Host.FileExtensions.ToString(), ",", ", *.").Replace("2", "true"); } } objZipEntry = objZipInputStream.GetNextEntry(); } strMessage += FormatMessage(END_MESSAGE, SkinName + ".zip", 1, false); objZipInputStream.Close(); UI.Skins.SkinFileProcessor NewSkin = new UI.Skins.SkinFileProcessor(RootPath, SkinRoot, SkinName); strMessage += NewSkin.ProcessList(arrSkinFiles, SkinParser.Portable); try { Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("Install Skin:", SkinName)); Array arrMessage = strMessage.Split(new string[] { "<br>" }, StringSplitOptions.None); foreach (string strRow in arrMessage) { objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("Info:", HtmlUtils.StripTags(strRow, true))); } Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); objEventLog.AddLog(objEventLogInfo); } catch (Exception ex) { ex.ToString(); } return(strMessage); }
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; }
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); }
/// ----------------------------------------------------------------------------- /// <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; }
/// ----------------------------------------------------------------------------- /// <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); } }
public static string UploadLegacySkin(string RootPath, string SkinRoot, string SkinName, Stream objInputStream) { ZipInputStream objZipInputStream = new ZipInputStream(objInputStream); ZipEntry objZipEntry; string strExtension; string strFileName; FileStream objFileStream; int intSize = 2048; byte[] arrData = new byte[2048]; string strMessage = ""; ArrayList arrSkinFiles = new ArrayList(); PortalSettings ResourcePortalSettings = CommonLibrary.Common.Globals.GetPortalSettings(); string BEGIN_MESSAGE = Localization.GetString("BeginZip", ResourcePortalSettings); string CREATE_DIR = Localization.GetString("CreateDir", ResourcePortalSettings); string WRITE_FILE = Localization.GetString("WriteFile", ResourcePortalSettings); string FILE_ERROR = Localization.GetString("FileError", ResourcePortalSettings); string END_MESSAGE = Localization.GetString("EndZip", ResourcePortalSettings); string FILE_RESTICTED = Localization.GetString("FileRestricted", ResourcePortalSettings); strMessage += FormatMessage(BEGIN_MESSAGE, SkinName, -1, false); objZipEntry = objZipInputStream.GetNextEntry(); while (objZipEntry != null) { if (!objZipEntry.IsDirectory) { strExtension = objZipEntry.Name.Substring(objZipEntry.Name.LastIndexOf(".") + 1); if (("," + strExtension.ToUpper()).IndexOf(",ASCX,HTM,HTML,CSS,SWF,RESX,XAML,JS," + Host.FileExtensions.ToUpper()) != 0) { if (objZipEntry.Name.ToLower() == SkinController.RootSkin.ToLower() + ".zip") { MemoryStream objMemoryStream = new MemoryStream(); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); while (intSize > 0) { objMemoryStream.Write(arrData, 0, intSize); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); } objMemoryStream.Seek(0, SeekOrigin.Begin); strMessage += UploadLegacySkin(RootPath, SkinController.RootSkin, SkinName, (Stream)objMemoryStream); } else if (objZipEntry.Name.ToLower() == SkinController.RootContainer.ToLower() + ".zip") { MemoryStream objMemoryStream = new MemoryStream(); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); while (intSize > 0) { objMemoryStream.Write(arrData, 0, intSize); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); } objMemoryStream.Seek(0, SeekOrigin.Begin); strMessage += UploadLegacySkin(RootPath, SkinController.RootContainer, SkinName, (Stream)objMemoryStream); } else { strFileName = RootPath + SkinRoot + "\\" + SkinName + "\\" + objZipEntry.Name; if (!Directory.Exists(Path.GetDirectoryName(strFileName))) { strMessage += FormatMessage(CREATE_DIR, Path.GetDirectoryName(strFileName), 2, false); Directory.CreateDirectory(Path.GetDirectoryName(strFileName)); } if (File.Exists(strFileName)) { File.SetAttributes(strFileName, FileAttributes.Normal); File.Delete(strFileName); } objFileStream = File.Create(strFileName); strMessage += FormatMessage(WRITE_FILE, Path.GetFileName(strFileName), 2, false); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); while (intSize > 0) { objFileStream.Write(arrData, 0, intSize); intSize = objZipInputStream.Read(arrData, 0, arrData.Length); } objFileStream.Close(); switch (Path.GetExtension(strFileName)) { case ".htm": case ".html": case ".ascx": case ".css": if (strFileName.ToLower().IndexOf(Globals.glbAboutPage.ToLower()) < 0) { arrSkinFiles.Add(strFileName); } break; } break; } } else { strMessage += string.Format(FILE_RESTICTED, objZipEntry.Name, Host.FileExtensions.ToString(), ",", ", *.").Replace("2", "true"); } } objZipEntry = objZipInputStream.GetNextEntry(); } strMessage += FormatMessage(END_MESSAGE, SkinName + ".zip", 1, false); objZipInputStream.Close(); UI.Skins.SkinFileProcessor NewSkin = new UI.Skins.SkinFileProcessor(RootPath, SkinRoot, SkinName); strMessage += NewSkin.ProcessList(arrSkinFiles, SkinParser.Portable); try { Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("Install Skin:", SkinName)); Array arrMessage = strMessage.Split(new string[] { "<br>" }, StringSplitOptions.None); foreach (string strRow in arrMessage) { objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("Info:", HtmlUtils.StripTags(strRow, true))); } Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); objEventLog.AddLog(objEventLogInfo); } catch (Exception ex) { ex.ToString(); } return strMessage; }
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; }
public int AddModule(ModuleInfo objModule) { Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); if (Null.IsNull(objModule.ModuleID)) { IContentTypeController typeController = new ContentTypeController(); ContentType contentType = (from t in typeController.GetContentTypes() where t.Type == "Module" select t) .SingleOrDefault(); IContentController contentController = new ContentController(); objModule.Content = objModule.ModuleTitle; objModule.ContentTypeId = contentType.ContentTypeId; objModule.Indexed = false; int contentItemID = contentController.AddContentItem(objModule); objModule.ModuleID = dataProvider.AddModule(contentItemID, objModule.PortalID, objModule.ModuleDefID, objModule.ModuleTitle, objModule.AllTabs, objModule.Header, objModule.Footer, objModule.StartDate, objModule.EndDate, objModule.InheritViewPermissions, objModule.IsDeleted, UserController.GetCurrentUserInfo().UserID); //Now we have the ModuleID - update the contentItem contentController.UpdateContentItem(objModule); objEventLog.AddLog(objModule, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", Services.Log.EventLog.EventLogController.EventLogType.MODULE_CREATED); ModulePermissionController.SaveModulePermissions(objModule); } ModuleInfo tmpModule = GetModule(objModule.ModuleID, objModule.TabID); if (tmpModule != null) { if (tmpModule.IsDeleted) { RestoreModule(objModule); } } else { dataProvider.AddTabModule(objModule.TabID, objModule.ModuleID, objModule.ModuleOrder, objModule.PaneName, objModule.CacheTime, objModule.CacheMethod, objModule.Alignment, objModule.Color, objModule.Border, objModule.IconFile, (int)objModule.Visibility, objModule.ContainerSrc, objModule.DisplayTitle, objModule.DisplayPrint, objModule.DisplaySyndicate, objModule.IsWebSlice, objModule.WebSliceTitle, objModule.WebSliceExpiryDate, objModule.WebSliceTTL, UserController.GetCurrentUserInfo().UserID); Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("TabId", objModule.TabID.ToString())); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("ModuleID", objModule.ModuleID.ToString())); objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.TABMODULE_CREATED.ToString(); objEventLog.AddLog(objEventLogInfo); if (objModule.ModuleOrder == -1) { UpdateModuleOrder(objModule.TabID, objModule.ModuleID, objModule.ModuleOrder, objModule.PaneName); } else { UpdateTabModuleOrder(objModule.TabID); } } UpdateModuleSettings(objModule); if (objModule.TabModuleID == -1) { if (tmpModule == null) tmpModule = GetModule(objModule.ModuleID, objModule.TabID); objModule.TabModuleID = tmpModule.TabModuleID; } UpdateTabModuleSettings(objModule); ClearCache(objModule.TabID); return objModule.ModuleID; }
public void DeleteTabModuleSetting(int TabModuleId, string SettingName) { dataProvider.DeleteTabModuleSetting(TabModuleId, SettingName); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("TabModuleId", TabModuleId.ToString())); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("SettingName", SettingName.ToString())); objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.TABMODULE_SETTING_DELETED.ToString(); objEventLog.AddLog(objEventLogInfo); DataCache.RemoveCache("GetTabModuleSettings" + TabModuleId.ToString()); }
public void DeleteTabSettings(int TabId) { provider.DeleteTabSettings(TabId); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("TabId", TabId.ToString())); objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.TAB_SETTING_DELETED.ToString(); objEventLog.AddLog(objEventLogInfo); DataCache.RemoveCache("GetTabSettings" + TabId.ToString()); }
public void UpdateTabSetting(int TabId, string SettingName, string SettingValue) { Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("TabId", TabId.ToString())); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("SettingName", SettingName.ToString())); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("SettingValue", SettingValue.ToString())); IDataReader dr = provider.GetTabSetting(TabId, SettingName); if (dr.Read()) { provider.UpdateTabSetting(TabId, SettingName, SettingValue, UserController.GetCurrentUserInfo().UserID); objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.TAB_SETTING_UPDATED.ToString(); objEventLog.AddLog(objEventLogInfo); } else { provider.AddTabSetting(TabId, SettingName, SettingValue, UserController.GetCurrentUserInfo().UserID); objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.TAB_SETTING_CREATED.ToString(); objEventLog.AddLog(objEventLogInfo); } dr.Close(); DataCache.RemoveCache("GetTabSettings" + TabId.ToString()); }
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); }
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 void DeleteModuleSettings(int ModuleId) { dataProvider.DeleteModuleSettings(ModuleId); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("ModuleId", ModuleId.ToString())); objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.MODULE_SETTING_DELETED.ToString(); objEventLog.AddLog(objEventLogInfo); DataCache.RemoveCache("GetModuleSettings" + ModuleId.ToString()); }
public void UpdateTabModuleSetting(int TabModuleId, string SettingName, string SettingValue) { Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("TabModuleId", TabModuleId.ToString())); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("SettingName", SettingName.ToString())); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("SettingValue", SettingValue.ToString())); IDataReader dr = null; try { dr = dataProvider.GetTabModuleSetting(TabModuleId, SettingName); if (dr.Read()) { dataProvider.UpdateTabModuleSetting(TabModuleId, SettingName, SettingValue, UserController.GetCurrentUserInfo().UserID); objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.TABMODULE_SETTING_UPDATED.ToString(); objEventLog.AddLog(objEventLogInfo); } else { dataProvider.AddTabModuleSetting(TabModuleId, SettingName, SettingValue, UserController.GetCurrentUserInfo().UserID); objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.TABMODULE_SETTING_CREATED.ToString(); objEventLog.AddLog(objEventLogInfo); } } catch (Exception ex) { CommonLibrary.Services.Exceptions.Exceptions.LogException(ex); } finally { CBO.CloseDataReader(dr, true); } DataCache.RemoveCache("GetTabModuleSettings" + TabModuleId.ToString()); }
public int CreatePortal(string PortalName, UserInfo objAdminUser, string Description, string KeyWords, string TemplatePath, string TemplateFile, string HomeDirectory, string PortalAlias, string ServerPath, string ChildPath, bool IsChildPortal) { Services.FileSystem.FolderController objFolderController = new Services.FileSystem.FolderController(); string strMessage = Null.NullString; int AdministratorId = Null.NullInteger; int intPortalId = CreatePortal(PortalName, HomeDirectory); if (intPortalId != -1) { if (String.IsNullOrEmpty(HomeDirectory)) { HomeDirectory = "Portals/" + intPortalId.ToString(); } string MappedHomeDirectory = objFolderController.GetMappedDirectory(Common.Globals.ApplicationPath + "/" + HomeDirectory + "/"); strMessage += CreateProfileDefinitions(intPortalId, TemplatePath, TemplateFile); if (strMessage == Null.NullString) { try { objAdminUser.PortalID = intPortalId; UserCreateStatus createStatus = UserController.CreateUser(ref objAdminUser); if (createStatus == UserCreateStatus.Success) { AdministratorId = objAdminUser.UserID; } else { strMessage += UserController.GetUserCreateStatus(createStatus); } } catch (Exception Exc) { strMessage += Localization.GetString("CreateAdminUser.Error") + Exc.Message + Exc.StackTrace; } } else { throw new Exception(strMessage); } if (String.IsNullOrEmpty(strMessage) && AdministratorId > 0) { try { if (Directory.Exists(MappedHomeDirectory)) { Globals.DeleteFolderRecursive(MappedHomeDirectory); } } catch (Exception Exc) { strMessage += Localization.GetString("DeleteUploadFolder.Error") + Exc.Message + Exc.StackTrace; } if (strMessage == Null.NullString) { try { if (IsChildPortal) { if (!Directory.Exists(ChildPath)) { System.IO.Directory.CreateDirectory(ChildPath); } if (!File.Exists(ChildPath + "\\" + Globals.glbDefaultPage)) { System.IO.File.Copy(Common.Globals.HostMapPath + "subhost.aspx", ChildPath + "\\" + Globals.glbDefaultPage); } } } catch (Exception Exc) { strMessage += Localization.GetString("ChildPortal.Error") + Exc.Message + Exc.StackTrace; } } else { throw new Exception(strMessage); } if (strMessage == Null.NullString) { try { System.IO.Directory.CreateDirectory(MappedHomeDirectory); //ensure that the Templates folder exists string templateFolder = String.Format("{0}Templates", MappedHomeDirectory); if (!Directory.Exists(templateFolder)) { System.IO.Directory.CreateDirectory(templateFolder); } //ensure that the Users folder exists string usersFolder = String.Format("{0}Users", MappedHomeDirectory); if (!Directory.Exists(usersFolder)) { System.IO.Directory.CreateDirectory(usersFolder); } //copy the default page template CopyPageTemplate("Default.page.template", MappedHomeDirectory); CopyPageTemplate("UserProfile.page.template", MappedHomeDirectory); // process zip resource file if present ProcessResourceFile(MappedHomeDirectory, TemplatePath + TemplateFile); } catch (Exception Exc) { strMessage += Localization.GetString("ChildPortal.Error") + Exc.Message + Exc.StackTrace; } } else { throw new Exception(strMessage); } if (strMessage == Null.NullString) { try { ParseTemplate(intPortalId, TemplatePath, TemplateFile, AdministratorId, PortalTemplateModuleAction.Replace, true); } catch (Exception Exc) { strMessage += Localization.GetString("PortalTemplate.Error") + Exc.Message + Exc.StackTrace; } } else { throw new Exception(strMessage); } if (strMessage == Null.NullString) { PortalInfo objportal = GetPortal(intPortalId); objportal.Description = Description; objportal.KeyWords = KeyWords; objportal.UserTabId = TabController.GetTabByTabPath(objportal.PortalID, "//UserProfile"); UpdatePortalInfo(objportal.PortalID, objportal.PortalName, objportal.LogoFile, objportal.FooterText, objportal.ExpiryDate, objportal.UserRegistration, objportal.BannerAdvertising, objportal.Currency, objportal.AdministratorId, objportal.HostFee, objportal.HostSpace, objportal.PageQuota, objportal.UserQuota, objportal.PaymentProcessor, objportal.ProcessorUserId, objportal.ProcessorPassword, objportal.Description, objportal.KeyWords, objportal.BackgroundFile, objportal.SiteLogHistory, objportal.SplashTabId, objportal.HomeTabId, objportal.LoginTabId, objportal.RegisterTabId, objportal.UserTabId, objportal.DefaultLanguage, objportal.TimeZoneOffset, objportal.HomeDirectory); objAdminUser.Profile.PreferredLocale = objportal.DefaultLanguage; objAdminUser.Profile.TimeZone = objportal.TimeZoneOffset; UserController.UpdateUser(objportal.PortalID, objAdminUser); DesktopModuleController.AddDesktopModulesToPortal(intPortalId); Localization.AddLanguagesToPortal(intPortalId); AddPortalAlias(intPortalId, PortalAlias); try { Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo(); objEventLogInfo.BypassBuffering = true; objEventLogInfo.LogTypeKey = CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString(); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("Install Portal:", PortalName)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("FirstName:", objAdminUser.FirstName)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("LastName:", objAdminUser.LastName)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("Username:"******"Email:", objAdminUser.Email)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("Description:", Description)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("Keywords:", KeyWords)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("TemplatePath:", TemplatePath)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("TemplateFile:", TemplateFile)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("HomeDirectory:", HomeDirectory)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("PortalAlias:", PortalAlias)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("ServerPath:", ServerPath)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("ChildPath:", ChildPath)); objEventLogInfo.LogProperties.Add(new CommonLibrary.Services.Log.EventLog.LogDetailInfo("IsChildPortal:", IsChildPortal.ToString())); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); objEventLog.AddLog(objEventLogInfo); } catch (Exception ex) { ex.ToString(); } } else { throw new Exception(strMessage); } } else { DeletePortalInfo(intPortalId); intPortalId = -1; throw new Exception(strMessage); } } else { strMessage += Localization.GetString("CreatePortal.Error"); throw new Exception(strMessage); } return intPortalId; }