本文整理汇总了C#中DotNetNuke.Entities.Users.UserInfo.UpdateDisplayName方法的典型用法代码示例。如果您正苦于以下问题:C# UserInfo.UpdateDisplayName方法的具体用法?C# UserInfo.UpdateDisplayName怎么用?C# UserInfo.UpdateDisplayName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Entities.Users.UserInfo
的用法示例。
在下文中一共展示了UserInfo.UpdateDisplayName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterUser
public UserInfo RegisterUser()
{
NameValueCollection profileProperties = AuthResult.Profile;
UserInfo userToRegister = new UserInfo();
userToRegister.PortalID = PortalSettings.PortalId;
foreach (string key in profileProperties)
{
switch (key)
{
case "FirstName":
userToRegister.FirstName = profileProperties[key];
break;
case "LastName":
userToRegister.LastName = profileProperties[key];
break;
case "Email":
userToRegister.Email = profileProperties[key];
break;
case "DisplayName":
userToRegister.DisplayName = profileProperties[key];
break;
default:
userToRegister.Profile.SetProfileProperty(key, profileProperties[key]);
break;
}
}
// we cannot add a user without an email address
if (String.IsNullOrEmpty(userToRegister.Email))
{
return null;
}
// let's check if we already have a user with this email address
int total = 0;
var existingUsers = UserController.GetUsersByEmail(PortalSettings.PortalId, userToRegister.Email, 0, 1, ref total);
if (existingUsers.Count > 0)
{
userToRegister = (UserInfo)existingUsers[0];
}
else
{
if (!String.IsNullOrEmpty(PortalSettings.Registration.DisplayNameFormat))
{
userToRegister.UpdateDisplayName(PortalSettings.Registration.DisplayNameFormat);
}
userToRegister.Membership.Password = UserController.GeneratePassword();
userToRegister.Membership.Approved = PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PublicRegistration;
var CreateStatus = UserController.CreateUser(ref userToRegister);
DataCache.ClearPortalCache(PortalSettings.PortalId, true);
if (CreateStatus != UserCreateStatus.Success)
{
throw new Exception(CreateStatus.ToString());
}
CompleteUserCreation(CreateStatus, userToRegister, true, true);
if (PortalSettings.Registration.UseEmailAsUserName)
{
UserController.ChangeUsername(userToRegister.UserID, userToRegister.Email);
}
}
if (!String.IsNullOrEmpty(AuthResult.AuthenticationType))
{
//string token = Service + "-" + AuthResult.Id;
string token = AuthResult.UserToken;
DotNetNuke.Services.Authentication.AuthenticationController.AddUserAuthentication(userToRegister.UserID, AuthResult.AuthenticationType, token);
}
return userToRegister;
}