本文整理汇总了C#中Carrotware.CMS.Core.ExtendedUserData.Save方法的典型用法代码示例。如果您正苦于以下问题:C# ExtendedUserData.Save方法的具体用法?C# ExtendedUserData.Save怎么用?C# ExtendedUserData.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carrotware.CMS.Core.ExtendedUserData
的用法示例。
在下文中一共展示了ExtendedUserData.Save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSaveEmail_Click
protected void btnSaveEmail_Click(object sender, EventArgs e)
{
MembershipUser usr = SecurityData.CurrentUser;
usr.Email = txtEmail.Text;
Membership.UpdateUser(usr);
ExtendedUserData exUsr = new ExtendedUserData(SecurityData.CurrentUser.UserName);
exUsr.UserNickName = txtNickName.Text;
exUsr.FirstName = txtFirstName.Text;
exUsr.LastName = txtLastName.Text;
exUsr.UserBio = reBody.Text;
exUsr.Save();
divInfoMsg.Visible = true;
InfoMessage.Text = "Profile Updated";
}
示例2: ImportStuff
public void ImportStuff()
{
this.HasLoaded = false;
this.Site = ContentImportExportUtils.GetSerializedSiteExport(this.ImportID);
SiteData.CurrentSite = null;
SiteData site = SiteData.CurrentSite;
this.Message = String.Empty;
string sMsg = String.Empty;
if (this.ImportSite || this.ImportPages || this.ImportPosts) {
List<string> tags = site.GetTagList().Select(x => x.TagSlug.ToLower()).ToList();
List<string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLower()).ToList();
this.Site.TheTags.RemoveAll(x => tags.Contains(x.TagSlug.ToLower()));
this.Site.TheCategories.RemoveAll(x => cats.Contains(x.CategorySlug.ToLower()));
sMsg += "<li>Imported Tags and Categories</li>";
List<ContentTag> lstTag = (from l in this.Site.TheTags.Distinct()
select new ContentTag {
ContentTagID = Guid.NewGuid(),
SiteID = site.SiteID,
IsPublic = l.IsPublic,
TagSlug = l.TagSlug,
TagText = l.TagText
}).ToList();
List<ContentCategory> lstCat = (from l in this.Site.TheCategories.Distinct()
select new ContentCategory {
ContentCategoryID = Guid.NewGuid(),
SiteID = site.SiteID,
IsPublic = l.IsPublic,
CategorySlug = l.CategorySlug,
CategoryText = l.CategoryText
}).ToList();
foreach (var v in lstTag) {
v.Save();
}
foreach (var v in lstCat) {
v.Save();
}
}
SetMsg(sMsg);
if (this.ImportSnippets) {
List<string> snippets = site.GetContentSnippetList().Select(x => x.ContentSnippetSlug.ToLower()).ToList();
this.Site.TheSnippets.RemoveAll(x => snippets.Contains(x.ContentSnippetSlug.ToLower()));
sMsg += "<li>Imported Content Snippets</li>";
List<ContentSnippet> lstSnip = (from l in this.Site.TheSnippets.Distinct()
select new ContentSnippet {
SiteID = site.SiteID,
Root_ContentSnippetID = Guid.NewGuid(),
ContentSnippetID = Guid.NewGuid(),
CreateUserId = SecurityData.CurrentUserGuid,
CreateDate = site.Now,
EditUserId = SecurityData.CurrentUserGuid,
EditDate = site.Now,
RetireDate = l.RetireDate,
GoLiveDate = l.GoLiveDate,
ContentSnippetActive = l.ContentSnippetActive,
ContentBody = l.ContentBody,
ContentSnippetSlug = l.ContentSnippetSlug,
ContentSnippetName = l.ContentSnippetName
}).ToList();
foreach (var v in lstSnip) {
v.Save();
}
}
SetMsg(sMsg);
if (this.ImportSite) {
sMsg += "<li>Updated Site Name</li>";
site.SiteName = this.Site.TheSite.SiteName;
site.SiteTagline = this.Site.TheSite.SiteTagline;
site.BlockIndex = this.Site.TheSite.BlockIndex;
site.Save();
}
SetMsg(sMsg);
if (!this.MapUsers) {
this.Site.TheUsers = new List<SiteExportUser>();
}
//iterate author collection and find if in the system
foreach (SiteExportUser seu in this.Site.TheUsers) {
SecurityData sd = new SecurityData();
ExtendedUserData usr = null;
seu.ImportUserID = Guid.Empty;
//attempt to find the user in the userbase
usr = ExtendedUserData.FindByEmail(seu.Email);
//.........这里部分代码省略.........
示例3: UserEdit
public ActionResult UserEdit(UserModel model) {
ExtendedUserData userExt = model.User;
if (ModelState.IsValid) {
var user = securityHelper.UserManager.FindByName(model.User.UserName);
IdentityResult result = securityHelper.UserManager.SetEmail(userExt.UserKey, userExt.Email);
result = securityHelper.UserManager.SetPhoneNumber(userExt.UserKey, userExt.PhoneNumber);
if (userExt.LockoutEndDateUtc.HasValue) {
//DateTime utcDateTime = DateTime.SpecifyKind(userExt.LockoutEndDateUtc.Value, DateTimeKind.Utc);
//DateTimeOffset utcOffset = utcDateTime;
//result = manage.UserManager.SetLockoutEnabled(userExt.UserKey, true);
//result = manage.UserManager.SetLockoutEndDate(userExt.UserKey, utcOffset);
if (!user.LockoutEndDateUtc.HasValue) {
// set lockout
user.LockoutEndDateUtc = userExt.LockoutEndDateUtc.Value;
user.AccessFailedCount = 20;
securityHelper.UserManager.Update(user);
}
} else {
if (user.LockoutEndDateUtc.HasValue) {
// unset lockout
user.LockoutEndDateUtc = null;
user.AccessFailedCount = 0;
securityHelper.UserManager.Update(user);
}
}
ExtendedUserData exUsr = new ExtendedUserData(userExt.UserId);
exUsr.UserNickName = userExt.UserNickName;
exUsr.FirstName = userExt.FirstName;
exUsr.LastName = userExt.LastName;
exUsr.UserBio = userExt.UserBio;
exUsr.Save();
model.SaveOptions();
return RedirectToAction("UserEdit", new { @id = userExt.UserId });
}
Helper.HandleErrorDict(ModelState);
return View(model);
}
示例4: UserProfile
public ActionResult UserProfile(ExtendedUserData model) {
if (ModelState.IsValid) {
IdentityResult result = securityHelper.UserManager.SetEmail(model.UserKey, model.Email);
ExtendedUserData exUsr = new ExtendedUserData(SecurityData.CurrentUserIdentityName);
exUsr.UserNickName = model.UserNickName;
exUsr.FirstName = model.FirstName;
exUsr.LastName = model.LastName;
exUsr.UserBio = model.UserBio;
exUsr.Save();
if (result.Succeeded) {
SetSaved();
return RedirectToAction("UserProfile");
}
}
Helper.HandleErrorDict(ModelState);
return View(model);
}
示例5: ImportStuff
public void ImportStuff()
{
this.HasLoaded = false;
this.Site = ContentImportExportUtils.GetSerializedWPExport(this.ImportID);
SiteData.CurrentSite = null;
SiteData site = SiteData.CurrentSite;
this.Message = String.Empty;
string sMsg = String.Empty;
if (this.ImportSite || this.ImportPages || this.ImportPosts) {
List<string> tags = site.GetTagList().Select(x => x.TagSlug.ToLowerInvariant()).ToList();
List<string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLowerInvariant()).ToList();
this.Site.Tags.RemoveAll(x => tags.Contains(x.InfoKey.ToLowerInvariant()));
this.Site.Categories.RemoveAll(x => cats.Contains(x.InfoKey.ToLowerInvariant()));
sMsg += "<li>Imported Tags and Categories</li>";
List<ContentTag> lstTag = (from l in this.Site.Tags.Distinct()
select new ContentTag {
ContentTagID = Guid.NewGuid(),
IsPublic = true,
SiteID = site.SiteID,
TagSlug = l.InfoKey,
TagText = l.InfoLabel
}).Distinct().ToList();
List<ContentCategory> lstCat = (from l in this.Site.Categories.Distinct()
select new ContentCategory {
ContentCategoryID = Guid.NewGuid(),
IsPublic = true,
SiteID = site.SiteID,
CategorySlug = l.InfoKey,
CategoryText = l.InfoLabel
}).Distinct().ToList();
foreach (var v in lstTag) {
v.Save();
}
foreach (var v in lstCat) {
v.Save();
}
}
SetMsg(sMsg);
if (this.ImportSite) {
sMsg += "<li>Updated Site Name</li>";
site.SiteName = this.Site.SiteTitle;
site.SiteTagline = this.Site.SiteDescription;
site.Save();
}
SetMsg(sMsg);
if (!this.MapUsers) {
this.Site.Authors = new List<WordPressUser>();
}
//iterate author collection and find if in the system
foreach (WordPressUser wpu in this.Site.Authors) {
SecurityData sd = new SecurityData();
ExtendedUserData usr = null;
wpu.ImportUserID = Guid.Empty;
//attempt to find the user in the userbase
usr = ExtendedUserData.FindByEmail(wpu.Email);
if (usr != null && usr.UserId != Guid.Empty) {
wpu.ImportUserID = usr.UserId;
} else {
usr = ExtendedUserData.FindByUsername(wpu.Login);
if (usr != null && usr.UserId != Guid.Empty) {
wpu.ImportUserID = usr.UserId;
}
}
if (this.CreateUsers) {
if (wpu.ImportUserID == Guid.Empty) {
ApplicationUser user = new ApplicationUser { UserName = wpu.Login, Email = wpu.Email };
var result = sd.CreateApplicationUser(user, out usr);
if (result.Succeeded) {
usr = ExtendedUserData.FindByUsername(wpu.Login);
} else {
throw new Exception(String.Format("Could not create user: {0} ({1}) \r\n{2}", wpu.Login, wpu.Email, String.Join("\r\n", result.Errors)));
}
wpu.ImportUserID = usr.UserId;
}
if (wpu.ImportUserID != Guid.Empty) {
ExtendedUserData ud = new ExtendedUserData(wpu.ImportUserID);
if (!String.IsNullOrEmpty(wpu.FirstName) || !String.IsNullOrEmpty(wpu.LastName)) {
ud.FirstName = wpu.FirstName;
ud.LastName = wpu.LastName;
ud.Save();
}
}
}
}
//.........这里部分代码省略.........
示例6: ImportStuff
private void ImportStuff()
{
SiteData.CurrentSite = null;
SiteData site = SiteData.CurrentSite;
litMessage.Text = "<p>No Items Selected For Import</p>";
string sMsg = "";
if (chkSite.Checked || chkPages.Checked || chkPosts.Checked) {
List<string> tags = site.GetTagList().Select(x => x.TagSlug.ToLower()).ToList();
List<string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLower()).ToList();
exSite.TheTags.RemoveAll(x => tags.Contains(x.TagSlug.ToLower()));
exSite.TheCategories.RemoveAll(x => cats.Contains(x.CategorySlug.ToLower()));
sMsg += "<p>Imported Tags and Categories</p>";
List<ContentTag> lstTag = (from l in exSite.TheTags.Distinct()
select new ContentTag {
ContentTagID = Guid.NewGuid(),
SiteID = site.SiteID,
IsPublic = l.IsPublic,
TagSlug = l.TagSlug,
TagText = l.TagText
}).ToList();
List<ContentCategory> lstCat = (from l in exSite.TheCategories.Distinct()
select new ContentCategory {
ContentCategoryID = Guid.NewGuid(),
SiteID = site.SiteID,
IsPublic = l.IsPublic,
CategorySlug = l.CategorySlug,
CategoryText = l.CategoryText
}).ToList();
foreach (var v in lstTag) {
v.Save();
}
foreach (var v in lstCat) {
v.Save();
}
}
SetMsg(sMsg);
if (chkSnippet.Checked) {
List<string> snippets = site.GetContentSnippetList().Select(x => x.ContentSnippetSlug.ToLower()).ToList();
exSite.TheSnippets.RemoveAll(x => snippets.Contains(x.ContentSnippetSlug.ToLower()));
sMsg += "<p>Imported Content Snippets</p>";
List<ContentSnippet> lstSnip = (from l in exSite.TheSnippets.Distinct()
select new ContentSnippet {
SiteID = site.SiteID,
Root_ContentSnippetID = Guid.NewGuid(),
ContentSnippetID = Guid.NewGuid(),
CreateUserId = SecurityData.CurrentUserGuid,
CreateDate = site.Now,
EditUserId = SecurityData.CurrentUserGuid,
EditDate = site.Now,
RetireDate = l.RetireDate,
GoLiveDate = l.GoLiveDate,
ContentSnippetActive = l.ContentSnippetActive,
ContentBody = l.ContentBody,
ContentSnippetSlug = l.ContentSnippetSlug,
ContentSnippetName = l.ContentSnippetName
}).ToList();
foreach (var v in lstSnip) {
v.Save();
}
}
SetMsg(sMsg);
if (chkSite.Checked) {
sMsg += "<p>Updated Site Name</p>";
site.SiteName = exSite.TheSite.SiteName;
site.SiteTagline = exSite.TheSite.SiteTagline;
site.Save();
}
SetMsg(sMsg);
if (!chkMapAuthor.Checked) {
exSite.TheUsers = new List<SiteExportUser>();
}
//itterate author collection and find if in the system
foreach (SiteExportUser seu in exSite.TheUsers) {
seu.ImportUserID = Guid.Empty;
MembershipUser usr = null;
//attempt to find the user in the userbase
usr = SecurityData.GetUserListByEmail(seu.Email).FirstOrDefault();
if (usr != null) {
seu.ImportUserID = new Guid(usr.ProviderUserKey.ToString());
} else {
usr = SecurityData.GetUserListByName(seu.Login).FirstOrDefault();
if (usr != null) {
seu.ImportUserID = new Guid(usr.ProviderUserKey.ToString());
//.........这里部分代码省略.........
示例7: ImportStuff
private void ImportStuff()
{
SiteData.CurrentSite = null;
SiteData site = SiteData.CurrentSite;
litMessage.Text = "<p>No Items Selected For Import</p>";
string sMsg = "";
if (chkSite.Checked || chkPages.Checked || chkPosts.Checked) {
List<string> tags = site.GetTagList().Select(x => x.TagSlug.ToLower()).ToList();
List<string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLower()).ToList();
wpSite.Tags.RemoveAll(x => tags.Contains(x.InfoKey.ToLower()));
wpSite.Categories.RemoveAll(x => cats.Contains(x.InfoKey.ToLower()));
sMsg += "<p>Imported Tags and Categories</p>";
List<ContentTag> lstTag = (from l in wpSite.Tags.Distinct()
select new ContentTag {
ContentTagID = Guid.NewGuid(),
IsPublic = true,
SiteID = site.SiteID,
TagSlug = l.InfoKey,
TagText = l.InfoLabel
}).Distinct().ToList();
List<ContentCategory> lstCat = (from l in wpSite.Categories.Distinct()
select new ContentCategory {
ContentCategoryID = Guid.NewGuid(),
IsPublic = true,
SiteID = site.SiteID,
CategorySlug = l.InfoKey,
CategoryText = l.InfoLabel
}).Distinct().ToList();
foreach (var v in lstTag) {
v.Save();
}
foreach (var v in lstCat) {
v.Save();
}
}
SetMsg(sMsg);
if (chkSite.Checked) {
sMsg += "<p>Updated Site Name</p>";
site.SiteName = wpSite.SiteTitle;
site.SiteTagline = wpSite.SiteDescription;
site.Save();
}
SetMsg(sMsg);
if (!chkMapAuthor.Checked) {
wpSite.Authors = new List<WordPressUser>();
}
//itterate author collection and find if in the system
foreach (WordPressUser wpu in wpSite.Authors) {
wpu.ImportUserID = Guid.Empty;
MembershipUser usr = null;
//attempt to find the user in the userbase
usr = SecurityData.GetUserListByEmail(wpu.Email).FirstOrDefault();
if (usr != null) {
wpu.ImportUserID = new Guid(usr.ProviderUserKey.ToString());
} else {
usr = SecurityData.GetUserListByName(wpu.Login).FirstOrDefault();
if (usr != null) {
wpu.ImportUserID = new Guid(usr.ProviderUserKey.ToString());
}
}
if (chkAuthors.Checked) {
if (wpu.ImportUserID == Guid.Empty) {
usr = Membership.CreateUser(wpu.Login, ProfileManager.GenerateSimplePassword(), wpu.Email);
Roles.AddUserToRole(wpu.Login, SecurityData.CMSGroup_Users);
wpu.ImportUserID = new Guid(usr.ProviderUserKey.ToString());
}
if (wpu.ImportUserID != Guid.Empty) {
ExtendedUserData ud = new ExtendedUserData(wpu.ImportUserID);
if (!string.IsNullOrEmpty(wpu.FirstName) || !string.IsNullOrEmpty(wpu.LastName)) {
ud.FirstName = wpu.FirstName;
ud.LastName = wpu.LastName;
ud.Save();
}
}
}
}
wpSite.Comments.ForEach(r => r.ImportRootID = Guid.Empty);
using (SiteNavHelper navHelper = new SiteNavHelper()) {
if (chkPages.Checked) {
sMsg += "<p>Imported Pages</p>";
int iOrder = 0;
SiteNav navHome = navHelper.FindHome(site.SiteID, false);
if (navHome != null) {
//.........这里部分代码省略.........
示例8: AttemptCreateApplicationUser
private IdentityResult AttemptCreateApplicationUser(ApplicationUser user, string password, out ExtendedUserData newusr) {
newusr = null;
var result = new IdentityResult();
lock (newUsrLock) {
if (user != null && !String.IsNullOrEmpty(user.Id)) {
using (var securityHelper = new SecurityHelper()) {
result = securityHelper.UserManager.Create(user, password);
if (result.Succeeded) {
user = securityHelper.UserManager.FindByName(user.UserName);
newusr = new ExtendedUserData();
newusr.UserKey = user.Id;
newusr.Id = user.Id;
newusr.Save();
newusr = ExtendedUserData.FindByUserID(newusr.UserId);
}
}
}
}
return result;
}
示例9: btnApply_Click
protected void btnApply_Click(object sender, EventArgs e)
{
if (userID != Guid.Empty) {
MembershipUser usr = Membership.GetUser(userID);
usr.Email = Email.Text;
Membership.UpdateUser(usr);
ExtendedUserData exUsr = new ExtendedUserData(userID);
exUsr.UserNickName = txtNickName.Text;
exUsr.FirstName = txtFirstName.Text;
exUsr.LastName = txtLastName.Text;
exUsr.UserBio = reBody.Text;
exUsr.Save();
if (!chkLocked.Checked) {
usr.UnlockUser();
Membership.UpdateUser(usr);
} else {
if (!usr.IsLockedOut) {
int iCount = 0;
while (iCount < 10) {
Membership.ValidateUser(usr.UserName, "zzBadPassWord123a" + iCount.ToString());
Membership.ValidateUser(usr.UserName, "zzBadPassWord123b" + iCount.ToString());
iCount++;
}
}
}
exUsr.AddToRole(SecurityData.CMSGroup_Users);
CheckBox chkSelected = null;
HiddenField hdnSiteID = null;
foreach (GridViewRow dgItem in gvSites.Rows) {
hdnSiteID = (HiddenField)dgItem.FindControl("hdnSiteID");
if (hdnSiteID != null) {
Guid guidSiteID = new Guid(hdnSiteID.Value);
chkSelected = (CheckBox)dgItem.FindControl("chkSelected");
if (chkSelected.Checked) {
exUsr.AddToSite(guidSiteID);
} else {
exUsr.RemoveFromSite(guidSiteID);
}
}
}
HiddenField hdnRoleId = null;
foreach (GridViewRow dgItem in gvRoles.Rows) {
hdnRoleId = (HiddenField)dgItem.FindControl("hdnRoleId");
if (hdnRoleId != null) {
chkSelected = (CheckBox)dgItem.FindControl("chkSelected");
if (chkSelected.Checked) {
exUsr.AddToRole(hdnRoleId.Value);
} else {
exUsr.RemoveFromRole(hdnRoleId.Value);
}
}
}
}
}