本文整理汇总了C#中DotNetNuke.Entities.Portals.PortalController.CreatePortal方法的典型用法代码示例。如果您正苦于以下问题:C# PortalController.CreatePortal方法的具体用法?C# PortalController.CreatePortal怎么用?C# PortalController.CreatePortal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Portals.PortalController
的用法示例。
在下文中一共展示了PortalController.CreatePortal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdUpdate_Click
//.........这里部分代码省略.........
if (!string.IsNullOrEmpty(strPortalAlias))
{
PortalAliasInfo portalAlias = PortalAliasController.GetPortalAliasLookup(strPortalAlias.ToLower());
if (portalAlias != null)
{
message = Localization.GetString("DuplicatePortalAlias", LocalResourceFile);
}
}
//Create Portal
if (String.IsNullOrEmpty(message))
{
string strTemplateFile = cboTemplate.SelectedItem.Text + ".template";
//Attempt to create the portal
var objAdminUser = new UserInfo();
int intPortalId;
try
{
objAdminUser.FirstName = txtFirstName.Text;
objAdminUser.LastName = txtLastName.Text;
objAdminUser.Username = txtUsername.Text;
objAdminUser.DisplayName = txtFirstName.Text + " " + txtLastName.Text;
objAdminUser.Email = txtEmail.Text;
objAdminUser.IsSuperUser = false;
objAdminUser.Membership.Approved = true;
objAdminUser.Membership.Password = txtPassword.Text;
objAdminUser.Membership.PasswordQuestion = txtQuestion.Text;
objAdminUser.Membership.PasswordAnswer = txtAnswer.Text;
objAdminUser.Profile.FirstName = txtFirstName.Text;
objAdminUser.Profile.LastName = txtLastName.Text;
intPortalId = objPortalController.CreatePortal(txtTitle.Text,
objAdminUser,
txtDescription.Text,
txtKeyWords.Text,
Globals.HostMapPath,
strTemplateFile,
homeDir,
strPortalAlias,
strServerPath,
strChildPath,
blnChild);
}
catch (Exception ex)
{
intPortalId = Null.NullInteger;
message = ex.Message;
}
if (intPortalId != -1)
{
//Create a Portal Settings object for the new Portal
PortalInfo objPortal = objPortalController.GetPortal(intPortalId);
var newSettings = new PortalSettings { PortalAlias = new PortalAliasInfo { HTTPAlias = strPortalAlias }, PortalId = intPortalId, DefaultLanguage = objPortal.DefaultLanguage };
string webUrl = Globals.AddHTTP(strPortalAlias);
try
{
if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
{
message = Mail.SendMail(PortalSettings.Email,
txtEmail.Text,
PortalSettings.Email + ";" + Host.HostEmail,
Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objAdminUser),
Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objAdminUser),
"",
示例2: AddPortal
/// -----------------------------------------------------------------------------
/// <summary>
/// AddPortal manages the Installation of a new DotNetNuke Portal
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// [cnurse] 11/06/2004 created
/// </history>
/// -----------------------------------------------------------------------------
public static int AddPortal(XmlNode node, bool status, int indent)
{
int portalId = -1;
try
{
string hostMapPath = Globals.HostMapPath;
string childPath = "";
string domain = "";
if ((HttpContext.Current != null))
{
domain = Globals.GetDomainName(HttpContext.Current.Request, true).ToLowerInvariant().Replace("/install", "");
}
DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddPortal:" + domain);
string portalName = XmlUtils.GetNodeValue(node.CreateNavigator(), "portalname");
if (status)
{
if (HttpContext.Current != null)
{
HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Site: " + portalName + "<br>");
}
}
var portalController = new PortalController();
XmlNode adminNode = node.SelectSingleNode("administrator");
if (adminNode != null)
{
string firstName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "firstname");
string lastName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "lastname");
string username = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "username");
string password = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "password");
string email = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "email");
string description = XmlUtils.GetNodeValue(node.CreateNavigator(), "description");
string keyWords = XmlUtils.GetNodeValue(node.CreateNavigator(), "keywords");
string templateFileName = XmlUtils.GetNodeValue(node.CreateNavigator(), "templatefile");
string serverPath = Globals.ApplicationMapPath + "\\";
bool isChild = bool.Parse(XmlUtils.GetNodeValue(node.CreateNavigator(), "ischild"));
string homeDirectory = XmlUtils.GetNodeValue(node.CreateNavigator(), "homedirectory");
//Get the Portal Alias
XmlNodeList portalAliases = node.SelectNodes("portalaliases/portalalias");
string strPortalAlias = domain;
if (portalAliases != null)
{
if (portalAliases.Count > 0)
{
if (!string.IsNullOrEmpty(portalAliases[0].InnerText))
{
strPortalAlias = portalAliases[0].InnerText;
}
}
}
//Create default email
if (string.IsNullOrEmpty(email))
{
email = "[email protected]" + domain.Replace("www.", "");
//Remove any domain subfolder information ( if it exists )
if (email.IndexOf("/") != -1)
{
email = email.Substring(0, email.IndexOf("/"));
}
}
if (isChild)
{
childPath = PortalController.GetPortalFolder(strPortalAlias);
}
var template = FindBestTemplate(templateFileName);
var userInfo = CreateUserInfo(firstName, lastName, username, password, email);
//Create Portal
portalId = portalController.CreatePortal(portalName,
userInfo,
description,
keyWords,
template,
homeDirectory,
strPortalAlias,
serverPath,
serverPath + childPath,
isChild);
if (portalId > -1)
{
//Add Extra Aliases
if (portalAliases != null)
{
//.........这里部分代码省略.........
示例3: CreateSite
private void CreateSite(PortalConfig portal, InstallConfig installConfig)
{
var domain = "";
if ((HttpContext.Current != null))
{
domain = Globals.GetDomainName(HttpContext.Current.Request, true).ToLowerInvariant().Replace("/install/launchautoinstall", "").Replace("/install", "").Replace("/runinstall", "");
}
var portalController = new PortalController();
var serverPath = Globals.ApplicationMapPath + "\\";
//Get the Portal Alias
var portalAlias = domain;
if (portal.PortAliases.Count > 0) portalAlias = portal.PortAliases[0];
//Verify that portal alias is not present
if (PortalAliasController.GetPortalAliasLookup(portalAlias.ToLower()) != null)
{
string description = Localization.Localization.GetString("SkipCreatingSite", LocalInstallResourceFile);
Details = string.Format(description, portalAlias);
return;
}
//Create default email
var email = portal.AdminEmail;
if (string.IsNullOrEmpty(email))
{
email = "[email protected]" + domain.Replace("www.", "");
//Remove any domain subfolder information ( if it exists )
if (email.IndexOf("/") != -1)
{
email = email.Substring(0, email.IndexOf("/"));
}
}
//install LP if installing in a different language
string culture = installConfig.InstallCulture;
if (!culture.Equals("en-us", StringComparison.InvariantCultureIgnoreCase))
{
string installFolder = HttpContext.Current.Server.MapPath("~/Install/language");
Upgrade.InstallPackage(installFolder + "\\installlanguage.resources", "Language", false);
}
var template = Upgrade.FindBestTemplate(portal.TemplateFileName);
UserInfo userInfo;
if (!String.IsNullOrEmpty(portal.AdminUserName))
userInfo = Upgrade.CreateUserInfo(portal.AdminFirstName, portal.AdminLastName, portal.AdminUserName, portal.AdminPassword, email);
else
userInfo = Upgrade.CreateUserInfo(installConfig.SuperUser.FirstName, installConfig.SuperUser.LastName, installConfig.SuperUser.UserName, installConfig.SuperUser.Password, installConfig.SuperUser.Email);
var childPath = string.Empty;
if (portal.IsChild)
childPath = portalAlias.Substring(portalAlias.LastIndexOf("/") + 1);
//Create Portal
var portalId = portalController.CreatePortal(portal.PortalName,
userInfo,
portal.Description,
portal.Keywords,
template,
portal.HomeDirectory,
portalAlias,
serverPath,
serverPath + childPath,
portal.IsChild);
if (portalId > -1)
{
foreach (var alias in portal.PortAliases)
{
portalController.AddPortalAlias(portalId, alias);
}
}
//remove en-US from portal if installing in a different language
if (!culture.Equals("en-us", StringComparison.InvariantCultureIgnoreCase))
{
var locale = LocaleController.Instance.GetLocale("en-US");
Localization.Localization.RemoveLanguageFromPortal(portalId, locale.LanguageId);
}
//Log user in to site
var loginStatus = UserLoginStatus.LOGIN_FAILURE;
UserController.UserLogin(portalId, userInfo.Username, installConfig.SuperUser.Password, "", "", "", ref loginStatus, false);
InstallController.Instance.RemoveFromInstallConfig("//dotnetnuke/superuser/password");
}
示例4: InstallPortal
/// -----------------------------------------------------------------------------
/// <summary>
/// InstallPortal installs the Host Portal
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// [cnurse] 02/19/2007 Created
/// </history>
/// -----------------------------------------------------------------------------
private bool InstallPortal()
{
bool success = false;
string strErrorMessage = usrAdmin.Validate();
if (!string.IsNullOrEmpty(strErrorMessage))
{
string strError = LocalizeString(strErrorMessage);
if (strErrorMessage == "PasswordLength")
{
strError = string.Format(strError, MembershipProviderConfig.MinPasswordLength);
}
lblPortalError.Text = string.Format(LocalizeString("AdminUserError"), strError);
}
else
{
try
{
var objPortalController = new PortalController();
string strServerPath = Globals.ApplicationMapPath + "\\";
string strPortalAlias = Globals.GetDomainName(HttpContext.Current.Request, true).Replace("/Install", "");
string strTemplate = cboPortalTemplate.SelectedValue + ".template";
//Create Portal
PortalId = objPortalController.CreatePortal(txtPortalTitle.Text,
usrAdmin.FirstName,
usrAdmin.LastName,
usrAdmin.UserName,
usrAdmin.Password,
usrAdmin.Email,
"",
"",
Globals.HostMapPath,
strTemplate,
"",
strPortalAlias,
strServerPath,
"",
false);
success = (PortalId > Null.NullInteger);
Config.Touch();
Response.Redirect("~/Default.aspx", true);
}
catch (ThreadAbortException)
{
//do nothing - we swallow this exception - becuase of redirect
}
catch (Exception ex)
{
Instrumentation.DnnLog.Error(ex);
success = false;
strErrorMessage = ex.Message;
}
if (!success)
{
lblPortalError.Text = string.Format(LocalizeString("InstallPortalError"), strErrorMessage);
}
}
return success;
}
示例5: AddPortal
/// <summary>
/// AddPortal manages the Installation of a new DotNetNuke Portal
/// </summary>
/// <remarks>
/// </remarks>
public static int AddPortal(XmlNode node, bool status, int indent)
{
try
{
int intPortalId;
string strHostPath = Globals.HostMapPath;
string strChildPath = "";
string strDomain = "";
if (HttpContext.Current != null)
{
strDomain = Globals.GetDomainName(HttpContext.Current.Request, true).Replace("/Install", "");
}
string strPortalName = XmlUtils.GetNodeValue(node, "portalname", "");
if (status)
{
HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal: " + strPortalName + "<br>");
}
PortalController objPortalController = new PortalController();
PortalSecurity objSecurity = new PortalSecurity();
XmlNode adminNode = node.SelectSingleNode("administrator");
string strFirstName = XmlUtils.GetNodeValue(adminNode, "firstname", "");
string strLastName = XmlUtils.GetNodeValue(adminNode, "lastname", "");
string strUserName = XmlUtils.GetNodeValue(adminNode, "username", "");
string strPassword = XmlUtils.GetNodeValue(adminNode, "password", "");
string strEmail = XmlUtils.GetNodeValue(adminNode, "email", "");
string strDescription = XmlUtils.GetNodeValue(node, "description", "");
string strKeyWords = XmlUtils.GetNodeValue(node, "keywords", "");
string strTemplate = XmlUtils.GetNodeValue(node, "templatefile", "");
string strServerPath = Globals.ApplicationMapPath + "\\";
bool isChild = bool.Parse(XmlUtils.GetNodeValue(node, "ischild", ""));
string strHomeDirectory = XmlUtils.GetNodeValue(node, "homedirectory", "");
//Get the Portal Alias
XmlNodeList portalAliases = node.SelectNodes("portalaliases/portalalias");
string strPortalAlias = strDomain;
if (portalAliases.Count > 0)
{
if (portalAliases[0].InnerText != "")
{
strPortalAlias = portalAliases[0].InnerText;
}
}
//Create default email
if (strEmail == "")
{
strEmail = "[email protected]" + strDomain.Replace("www.", "");
//Remove any domain subfolder information ( if it exists )
if (strEmail.IndexOf("/") != -1)
{
strEmail = strEmail.Substring(0, strEmail.IndexOf("/"));
}
}
if (isChild)
{
strChildPath = strPortalAlias.Substring(strPortalAlias.LastIndexOf("/") + 1 - 1);
}
//Create Portal
intPortalId = objPortalController.CreatePortal(strPortalName, strFirstName, strLastName, strUserName, objSecurity.Encrypt(Convert.ToString(Globals.HostSettings["EncryptionKey"]), strPassword), strEmail, strDescription, strKeyWords, strHostPath, strTemplate, strHomeDirectory, strPortalAlias, strServerPath, strServerPath + strChildPath, isChild);
if (intPortalId > -1)
{
//Add Extra Aliases
foreach (XmlNode portalAlias in portalAliases)
{
if (!String.IsNullOrEmpty(portalAlias.InnerText))
{
if (status)
{
HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal Alias: " + portalAlias.InnerText + "<br>");
}
objPortalController.AddPortalAlias(intPortalId, portalAlias.InnerText);
}
}
}
return intPortalId;
}
catch (Exception ex)
{
HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "<font color='red'>Error: " + ex.Message + "</font><br>");
return -1; // failure
}
}
示例6: cmdUpdate_Click
//.........这里部分代码省略.........
//Set Portal Alias for Child Portals
if( strMessage == "" )
{
if( blnChild )
{
strChildPath = strServerPath + strPortalAlias;
if( Directory.Exists( strChildPath ) )
{
strMessage = Localization.GetString( "ChildExists", this.LocalResourceFile );
}
else
{
if( PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId )
{
strPortalAlias = Globals.GetDomainName( Request ) + "/" + strPortalAlias;
}
else
{
strPortalAlias = txtPortalName.Text;
}
}
}
}
//Get Home Directory
string HomeDir;
if( txtHomeDirectory.Text != "Portals/[PortalID]" )
{
HomeDir = txtHomeDirectory.Text;
}
else
{
HomeDir = "";
}
//Create Portal
if( strMessage == "" )
{
string strTemplateFile = cboTemplate.SelectedItem.Text + ".template";
//Attempt to create the portal
int intPortalId;
try
{
intPortalId = objPortalController.CreatePortal( txtTitle.Text, txtFirstName.Text, txtLastName.Text, txtUsername.Text, objSecurity.Encrypt( Convert.ToString( Globals.HostSettings["EncryptionKey"] ), txtPassword.Text ), txtEmail.Text, txtDescription.Text, txtKeyWords.Text, Globals.HostMapPath, strTemplateFile, HomeDir, strPortalAlias, strServerPath, strChildPath, blnChild );
}
catch( Exception ex )
{
intPortalId = Null.NullInteger;
strMessage = ex.Message;
}
if( intPortalId != - 1 )
{
// notification
UserInfo objUser = UserController.GetUserByName( intPortalId, txtUsername.Text, false );
//Create a Portal Settings object for the new Portal
PortalSettings newSettings = new PortalSettings();
newSettings.PortalAlias = new PortalAliasInfo();
newSettings.PortalAlias.HTTPAlias = strPortalAlias;
newSettings.PortalId = intPortalId;
string webUrl = Globals.AddHTTP( strPortalAlias );
try
{
if( PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId )
{
Mail.SendMail( PortalSettings.Email, txtEmail.Text, PortalSettings.Email + ";" + Convert.ToString( PortalSettings.HostSettings["HostEmail"] ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objUser ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objUser ), "", "", "", "", "", "" );
}
else
{
Mail.SendMail( Convert.ToString( PortalSettings.HostSettings["HostEmail"] ), txtEmail.Text, Convert.ToString( PortalSettings.HostSettings["HostEmail"] ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objUser ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objUser ), "", "", "", "", "", "" );
}
}
catch( Exception )
{
strMessage = string.Format( Localization.GetString( "SendMail.Error", this.LocalResourceFile ), webUrl, null );
}
EventLogController objEventLog = new EventLogController();
objEventLog.AddLog( objPortalController.GetPortal( intPortalId ), PortalSettings, UserId, "", EventLogController.EventLogType.PORTAL_CREATED );
// Redirect to this new site
if( strMessage == Null.NullString )
{
Response.Redirect( webUrl, true );
}
}
}
lblMessage.Text = "<br>" + strMessage + "<br><br>";
}
catch( Exception exc ) //Module failed to load
{
Exceptions.ProcessModuleLoadException( this, exc );
}
}
}