Пример #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (pageContents != null) {
                pageContents.TitleBar = txtTitle.Text;
                pageContents.NavMenuText = txtNav.Text;
                pageContents.PageHead = txtHead.Text;

                pageContents.MetaDescription = txtDescription.Text;
                pageContents.MetaKeyword = txtKey.Text;
                pageContents.Thumbnail = txtThumb.Text;

                pageContents.EditDate = SiteData.CurrentSite.Now;

                pageContents.GoLiveDate = ucReleaseDate.GetDate();
                pageContents.RetireDate = ucRetireDate.GetDate();

                pageContents.PageActive = chkActive.Checked;
                pageContents.ShowInSiteNav = chkNavigation.Checked;
                pageContents.ShowInSiteMap = chkSiteMap.Checked;
                pageContents.BlockIndex = chkHide.Checked;

                if (String.IsNullOrEmpty(hdnCreditUserID.Value)) {
                    pageContents.CreditUserId = null;
                } else {
                    var usr = new ExtendedUserData(hdnCreditUserID.Value);
                    pageContents.CreditUserId = usr.UserId;
                }

                cmsHelper.cmsAdminContent = pageContents;

                Master.ShowSave();

                Response.Redirect(SiteData.CurrentScriptName + "?pageid=" + pageContents.Root_ContentID.ToString() + Master.SavedSuffix);
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
 public ExtendedUserData GetCreditUserInfo()
 {
     if (_creditUser == null && this.CreditUserId.HasValue)
     {
         _creditUser = new ExtendedUserData(this.CreditUserId.Value);
     }
     return(_creditUser);
 }
		private Guid FindUser(Guid userId) {
			ExtendedUserData usr = new ExtendedUserData(userId);

			if (usr == null) {
				return SecurityData.CurrentUserGuid;
			} else {
				return userId;
			}
		}
		protected void btnAddUsers_Click(object sender, EventArgs e) {
			if (!String.IsNullOrEmpty(hdnUserID.Value)) {
				MembershipRole role = getCurrentGroup();

				ExtendedUserData exUsr = new ExtendedUserData(hdnUserID.Value);
				exUsr.AddToRole(role.RoleName);
			}

			Response.Redirect(SiteData.CurrentScriptName + "?id=" + groupID.ToString());
		}
Пример #6
0
		public SiteExportUser(ExtendedUserData user) {
			if (user != null) {
				this.ExportUserID = user.UserId;
				this.Email = user.Email;
				this.Login = user.UserName;
				this.FirstName = user.FirstName;
				this.LastName = user.LastName;
				this.UserNickname = user.UserNickName;
			}
		}
Пример #7
0
        public static ExtendedUserData FindByEmail(string Email)
        {
            ExtendedUserData usr = new ExtendedUserData();

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_UserData rc = CompiledQueries.cqFindUserByEmail(_db, Email);
                usr.LoadUserData(rc);
            }

            return(usr);
        }
Пример #8
0
        public static ExtendedUserData FindByUserID(Guid UserID)
        {
            ExtendedUserData usr = new ExtendedUserData();

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_UserData rc = CompiledQueries.cqFindUserByID(_db, UserID);
                usr.LoadUserData(rc);
            }

            return(usr);
        }
		protected void btnAddUsers_Click(object sender, EventArgs e) {
			if (!String.IsNullOrEmpty(hdnUserID.Value)) {
				ExtendedUserData exUsr = new ExtendedUserData(hdnUserID.Value);
				exUsr.AddToSite(guidSiteID);

				if (chkAddToEditor.Checked) {
					exUsr.AddToRole(SecurityData.CMSGroup_Editors);
				}
			}

			Response.Redirect(SiteData.CurrentScriptName + "?id=" + guidSiteID.ToString());
		}
Пример #10
0
 public SiteExportUser(ExtendedUserData user)
 {
     if (user != null)
     {
         this.ExportUserID = user.UserId;
         this.Email        = user.EmailAddress;
         this.Login        = user.UserName;
         this.FirstName    = user.FirstName;
         this.LastName     = user.LastName;
         this.UserNickname = user.UserNickName;
     }
 }
Пример #11
0
		protected override void OnPreRender(EventArgs e) {
			if (usr == null) {
				usr = ExtendedUserData.GetEditorFromURL();
			}
			if (usr == null) {
				ContentPage cp = cu.GetContainerContentPage(this);
				usr = cp.GetUserInfo();
			}

			AssignUser();

			base.OnPreRender(e);
		}
Пример #12
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (pageContents != null) {
                pageContents.TitleBar = txtTitle.Text;
                pageContents.NavMenuText = txtNav.Text;
                pageContents.PageHead = txtHead.Text;

                pageContents.MetaDescription = txtDescription.Text;
                pageContents.MetaKeyword = txtKey.Text;
                pageContents.Thumbnail = txtThumb.Text;

                pageContents.EditDate = SiteData.CurrentSite.Now;

                pageContents.GoLiveDate = Convert.ToDateTime(txtReleaseDate.Text + " " + txtReleaseTime.Text);
                pageContents.RetireDate = Convert.ToDateTime(txtRetireDate.Text + " " + txtRetireTime.Text);

                pageContents.PageActive = chkActive.Checked;
                pageContents.ShowInSiteNav = false;
                pageContents.ShowInSiteMap = false;
                pageContents.BlockIndex = chkHide.Checked;

                List<ContentCategory> lstCat = new List<ContentCategory>();
                List<ContentTag> lstTag = new List<ContentTag>();

                lstCat = (from cr in CollectCheckboxRepeater(rpCat)
                          join l in SiteData.CurrentSite.GetCategoryList() on cr equals l.ContentCategoryID
                          select l).ToList();

                lstTag = (from cr in CollectCheckboxRepeater(rpTag)
                          join l in SiteData.CurrentSite.GetTagList() on cr equals l.ContentTagID
                          select l).ToList();

                pageContents.ContentCategories = lstCat;
                pageContents.ContentTags = lstTag;

                if (string.IsNullOrEmpty(hdnCreditUserID.Value)) {
                    pageContents.CreditUserId = null;
                } else {
                    var usr = new ExtendedUserData(hdnCreditUserID.Value);
                    pageContents.CreditUserId = usr.UserId;
                }

                pageContents.FileName = ContentPageHelper.CreateFileNameFromSlug(pageContents.SiteID, pageContents.GoLiveDate, pageContents.PageSlug);

                cmsHelper.cmsAdminContent = pageContents;

                Master.ShowSave();

                Response.Redirect(SiteData.CurrentScriptName + "?pageid=" + pageContents.Root_ContentID.ToString() + Master.SavedSuffix);
            }
        }
Пример #13
0
 public static ExtendedUserData GetEditorFromURL()
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
         vw_carrot_EditorURL query = CompiledQueries.cqGetEditorByURL(_db, SiteData.CurrentSiteID, SiteData.CurrentScriptName);
         if (query != null)
         {
             ExtendedUserData usr = new ExtendedUserData(query.UserId);
             return(usr);
         }
         else
         {
             return(null);
         }
     }
 }
Пример #14
0
		protected override void OnDataBinding(EventArgs e) {
			RepeaterItem container = (RepeaterItem)this.NamingContainer;

			object contentData = DataBinder.GetDataItem(container);

			if (contentData is ISiteContent) {
				ISiteContent content = (ISiteContent)(contentData);

				usr = content.GetUserInfo();

				AssignUser();
			}

			base.OnDataBinding(e);
		}
Пример #15
0
        public string GetBlogHeadingFromURL(SiteData currentSite, string sFilterPath)
        {
            Guid siteID = currentSite.SiteID;

            string sTitle = String.Empty;

            if (currentSite.CheckIsBlogCategoryPath(sFilterPath))
            {
                vw_carrot_CategoryURL query = CompiledQueries.cqGetCategoryByURL(db, siteID, sFilterPath);
                sTitle = query.CategoryText;
            }
            if (currentSite.CheckIsBlogTagPath(sFilterPath))
            {
                vw_carrot_TagURL query = CompiledQueries.cqGetTagByURL(db, siteID, sFilterPath);
                sTitle = query.TagText;
            }
            if (currentSite.CheckIsBlogEditorFolderPath(sFilterPath))
            {
                vw_carrot_EditorURL query = CompiledQueries.cqGetEditorByURL(db, siteID, sFilterPath);
                ExtendedUserData    usr   = new ExtendedUserData(query.UserId);
                sTitle = usr.ToString();
            }
            if (currentSite.CheckIsBlogDateFolderPath(sFilterPath))
            {
                BlogDatePathParser p  = new BlogDatePathParser(currentSite, sFilterPath);
                TimeSpan           ts = p.DateEndUTC - p.DateBeginUTC;

                int daysDelta = ts.Days;
                if (daysDelta > 90)
                {
                    sTitle = "Year " + p.DateBegin.ToString("yyyy");
                }
                if (daysDelta < 36)
                {
                    sTitle = p.DateBegin.ToString("MMMM yyyy");
                }
                if (daysDelta < 5)
                {
                    sTitle = p.DateBegin.ToString("MMMM d, yyyy");
                }
            }
            if (currentSite.CheckIsSiteSearchPath(sFilterPath))
            {
                sTitle = "Search Results";
            }

            return(sTitle);
        }
Пример #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.ActivateTab(AdminBaseMasterPage.SectionID.UserFn);

            divInfoMsg.Visible = false;
            InfoMessage.Text = "";

            if (!IsPostBack) {
                txtEmail.Text = SecurityData.CurrentUser.Email;
                ExtendedUserData exUsr = new ExtendedUserData(SecurityData.CurrentUser.UserName);
                txtNickName.Text = exUsr.UserNickName;
                txtFirstName.Text = exUsr.FirstName;
                txtLastName.Text = exUsr.LastName;
                reBody.Text = exUsr.UserBio;
            }
        }
Пример #17
0
        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";
        }
		protected void Page_Load(object sender, EventArgs e) {
			Master.UsesSaved = true;
			Master.HideSave();

			guidContentID = GetGuidPageIDFromQuery();

			cmsHelper.OverrideKey(guidContentID);

			if (cmsHelper.cmsAdminContent != null) {
				pageContents = cmsHelper.cmsAdminContent;
				litPageName.Text = pageContents.FileName;

				if (!IsPostBack) {
					GeneralUtilities.BindList(listCats, SiteData.CurrentSite.GetCategoryList().OrderBy(x => x.CategoryText));
					GeneralUtilities.BindList(listTags, SiteData.CurrentSite.GetTagList().OrderBy(x => x.TagText));

					txtTitle.Text = pageContents.TitleBar;
					txtNav.Text = pageContents.NavMenuText;
					txtHead.Text = pageContents.PageHead;
					txtThumb.Text = pageContents.Thumbnail;

					txtDescription.Text = pageContents.MetaDescription;
					txtKey.Text = pageContents.MetaKeyword;

					txtReleaseDate.Text = pageContents.GoLiveDate.ToShortDateString();
					txtReleaseTime.Text = pageContents.GoLiveDate.ToShortTimeString();
					txtRetireDate.Text = pageContents.RetireDate.ToShortDateString();
					txtRetireTime.Text = pageContents.RetireDate.ToShortTimeString();

					lblUpdated.Text = pageContents.EditDate.ToString();

					chkActive.Checked = pageContents.PageActive;
					chkHide.Checked = pageContents.BlockIndex;

					if (pageContents.CreditUserId.HasValue) {
						var usr = new ExtendedUserData(pageContents.CreditUserId.Value);
						hdnCreditUserID.Value = usr.UserName;
						txtSearchUser.Text = string.Format("{0} ({1})", usr.UserName, usr.EmailAddress);
					}

					GeneralUtilities.SelectListValues(listTags, pageContents.ContentTags.Cast<IContentMetaInfo>().Select(x => x.ContentMetaInfoID.ToString()).ToList());
					GeneralUtilities.SelectListValues(listCats, pageContents.ContentCategories.Cast<IContentMetaInfo>().Select(x => x.ContentMetaInfoID.ToString()).ToList());
				}
			}
		}
Пример #19
0
        public bool RecordSnippetLock(Guid currentUserID)
        {
            bool bLock = IsSnippetLocked();
            bool bRet  = false;

            if (!bLock)
            {
                ExtendedUserData usr = new ExtendedUserData(currentUserID);

                //only allow admin/editors to record a lock
                if (usr.IsAdmin || usr.IsEditor)
                {
                    bRet = true;
                    RecordHeartbeatLock(currentUserID);
                }
            }

            return(bRet);
        }
Пример #20
0
		protected void Page_Load(object sender, EventArgs e) {
			Master.UsesSaved = true;
			Master.HideSave();

			guidContentID = GetGuidPageIDFromQuery();

			cmsHelper.OverrideKey(guidContentID);

			if (cmsHelper.cmsAdminContent != null) {
				pageContents = cmsHelper.cmsAdminContent;
				litPageName.Text = pageContents.FileName;

				if (!IsPostBack) {
					txtTitle.Text = pageContents.TitleBar;
					txtNav.Text = pageContents.NavMenuText;
					txtHead.Text = pageContents.PageHead;
					txtThumb.Text = pageContents.Thumbnail;

					txtDescription.Text = pageContents.MetaDescription;
					txtKey.Text = pageContents.MetaKeyword;

					txtReleaseDate.Text = pageContents.GoLiveDate.ToShortDateString();
					txtReleaseTime.Text = pageContents.GoLiveDate.ToShortTimeString();
					txtRetireDate.Text = pageContents.RetireDate.ToShortDateString();
					txtRetireTime.Text = pageContents.RetireDate.ToShortTimeString();

					lblUpdated.Text = pageContents.EditDate.ToString();

					chkActive.Checked = pageContents.PageActive;
					chkNavigation.Checked = pageContents.ShowInSiteNav;
					chkSiteMap.Checked = pageContents.ShowInSiteMap;
					chkHide.Checked = pageContents.BlockIndex;

					if (pageContents.CreditUserId.HasValue) {
						var usr = new ExtendedUserData(pageContents.CreditUserId.Value);
						hdnCreditUserID.Value = usr.UserName;
						txtSearchUser.Text = string.Format("{0} ({1})", usr.UserName, usr.EmailAddress);
					}
				}
			}
		}
Пример #21
0
		protected void btnRemove_Click(object sender, EventArgs e) {
			CheckBox chkSelected = null;
			HiddenField hdnUserId = null;

			foreach (GridViewRow dgItem in gvUsers.Rows) {
				hdnUserId = (HiddenField)dgItem.FindControl("hdnUserId");

				if (hdnUserId != null) {
					chkSelected = (CheckBox)dgItem.FindControl("chkSelected");

					Guid guidUsrID = new Guid(hdnUserId.Value);
					ExtendedUserData exUsr = new ExtendedUserData(guidUsrID);

					if (chkSelected.Checked) {
						exUsr.RemoveFromSite(guidSiteID);
					}
				}
			}

			Response.Redirect(SiteData.CurrentScriptName + "?id=" + guidSiteID.ToString());
		}
Пример #22
0
        public static bool GetIsSiteEditorFromCache()
        {
            bool keyVal = false;

            if (SiteData.IsWebView && IsAuthenticated)
            {
                string key = String.Format("{0}_{1}_{2}", keyIsSiteEditor, SecurityData.CurrentUserIdentityName, SiteData.CurrentSiteID);
                if (HttpContext.Current.Cache[key] != null)
                {
                    keyVal = Convert.ToBoolean(HttpContext.Current.Cache[key]);
                }
                else
                {
                    ExtendedUserData usrEx = SecurityData.CurrentExtendedUser;

                    keyVal = (IsEditor || usrEx.IsEditor) && usrEx.MemberSiteIDs.Contains(SiteData.CurrentSiteID);

                    HttpContext.Current.Cache.Insert(key, keyVal.ToString(), null, DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration);
                }
            }

            return(keyVal);
        }
Пример #23
0
        public SiteExport(Guid siteID, ExportType exportWhat)
        {
            SiteData s = null;
            List <ContentPageExport> pages = new List <ContentPageExport>();

            s = SiteData.GetSiteByID(siteID);

            if (exportWhat == ExportType.AllData)
            {
                pages = ContentImportExportUtils.ExportAllSiteContent(siteID);
            }
            else
            {
                if (exportWhat == ExportType.ContentData)
                {
                    List <ContentPageExport> lst = ContentImportExportUtils.ExportPages(siteID);
                    pages = pages.Union(lst).ToList();
                }
                if (exportWhat == ExportType.BlogData)
                {
                    List <ContentPageExport> lst = ContentImportExportUtils.ExportPosts(siteID);
                    pages = pages.Union(lst).ToList();
                }
            }

            this.TheUsers = (from u in ExtendedUserData.GetUserList()
                             select new SiteExportUser {
                Email = u.Email,
                Login = u.UserName,
                FirstName = u.FirstName,
                LastName = u.LastName,
                UserNickname = u.UserNickName
            }).ToList();

            SetVals(s, pages);
        }
		private void SetVals(ContentPage cp, List<Widget> widgets) {
			CarrotCakeVersion = SiteData.CarrotCakeCMSVersion;
			ExportDate = DateTime.UtcNow;
			Guid siteID = cp.SiteID;

			NewRootContentID = Guid.NewGuid();

			cp.LoadAttributes();

			ThePage = cp;
			ThePageWidgets = widgets;

			if (ThePage == null) {
				ThePage = new ContentPage();
				ThePage.Root_ContentID = Guid.NewGuid();
				ThePage.ContentID = ThePage.Root_ContentID;
			}
			if (ThePageWidgets == null) {
				ThePageWidgets = new List<Widget>();
			}

			OriginalRootContentID = ThePage.Root_ContentID;
			OriginalSiteID = ThePage.SiteID;
			OriginalParentContentID = Guid.Empty;
			ParentFileName = "";

			if (ThePage.Parent_ContentID != null) {
				ContentPage parent = new ContentPage();
				using (ContentPageHelper cph = new ContentPageHelper()) {
					parent = cph.FindContentByID(siteID, ThePage.Parent_ContentID.Value);
				}
				ParentFileName = parent.FileName;
				OriginalParentContentID = parent.Root_ContentID;
			}

			ThePage.Root_ContentID = NewRootContentID;
			ThePage.ContentID = NewRootContentID;

			foreach (var w in ThePageWidgets) {
				w.Root_ContentID = NewRootContentID;
				w.Root_WidgetID = Guid.NewGuid();
				w.WidgetDataID = Guid.NewGuid();
			}

			Guid userID1 = Guid.Empty;

			if (!cp.EditUserId.HasValue) {
				userID1 = cp.CreateUserId;
			} else {
				userID1 = cp.EditUserId.Value;
			}

			ExtendedUserData u1 = new ExtendedUserData(userID1);
			this.TheUser = new SiteExportUser(u1);

			Guid userID2 = Guid.Empty;

			if (cp.CreditUserId.HasValue) {
				userID2 = cp.CreditUserId.Value;
			}

			ExtendedUserData u2 = new ExtendedUserData(userID2);
			if (u2 != null) {
				this.CreditUser = new SiteExportUser(u2);
			} else {
				this.CreditUser = null;
			}
		}
Пример #25
0
        protected override void OnPreRender(EventArgs e)
        {
            if (_usr == null) {
                _usr = ExtendedUserData.GetEditorFromURL();
            }
            if (_usr == null) {
                ContentPage cp = cu.GetContainerContentPage(this);
                if (this.SourceField == AuthorSource.Editor) {
                    _usr = cp.GetUserInfo();
                } else {
                    _usr = cp.GetCreditUserInfo();
                }
            }

            AssignUser();

            base.OnPreRender(e);
        }
Пример #26
0
 public ExtendedUserData GetUserInfo()
 {
     if (_user == null && this.EditUserId.HasValue) {
         _user = new ExtendedUserData(this.EditUserId.Value);
     }
     return _user;
 }
Пример #27
0
        public bool RecordSnippetLock(Guid currentUserID)
        {
            bool bLock = IsSnippetLocked();
            bool bRet = false;

            if (!bLock) {
                ExtendedUserData usr = new ExtendedUserData(currentUserID);

                //only allow admin/editors to record a lock
                if (usr.IsAdmin || usr.IsEditor) {
                    bRet = true;
                    RecordHeartbeatLock(currentUserID);
                }
            }

            return bRet;
        }
Пример #28
0
 public IdentityResult CreateApplicationUser(ApplicationUser user, string password, out ExtendedUserData newusr)
 {
     return(AttemptCreateApplicationUser(user, password, out newusr));
 }
		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);
		}
		public ActionResult SiteRemoveUsers(SiteModel model) {
			ModelState.Clear();

			SiteData site = model.Site;

			if (ModelState.IsValid) {
				List<UserModel> usrs = model.Users.Where(x => x.Selected).ToList();

				foreach (var u in usrs) {
					ExtendedUserData exUsr = new ExtendedUserData(u.User.UserId);
					exUsr.RemoveFromSite(site.SiteID);
				}

				return RedirectToAction("SiteDetail", new { @id = site.SiteID });
			}

			Helper.HandleErrorDict(ModelState);

			return View("SiteDetail", model);
		}
Пример #31
0
        private void SetVals(ContentPage cp, List <Widget> widgets)
        {
            CarrotCakeVersion = SiteData.CarrotCakeCMSVersion;
            ExportDate        = DateTime.UtcNow;
            Guid siteID = cp.SiteID;

            NewRootContentID = Guid.NewGuid();

            cp.LoadAttributes();

            ThePage        = cp;
            ThePageWidgets = widgets;

            if (ThePage == null)
            {
                ThePage = new ContentPage();
                ThePage.Root_ContentID = Guid.NewGuid();
                ThePage.ContentID      = ThePage.Root_ContentID;
            }
            if (ThePageWidgets == null)
            {
                ThePageWidgets = new List <Widget>();
            }

            OriginalRootContentID   = ThePage.Root_ContentID;
            OriginalSiteID          = ThePage.SiteID;
            OriginalParentContentID = Guid.Empty;
            ParentFileName          = "";

            if (ThePage.Parent_ContentID != null)
            {
                ContentPage parent = new ContentPage();
                using (ContentPageHelper cph = new ContentPageHelper()) {
                    parent = cph.FindContentByID(siteID, ThePage.Parent_ContentID.Value);
                }
                ParentFileName          = parent.FileName;
                OriginalParentContentID = parent.Root_ContentID;
            }

            ThePage.Root_ContentID = NewRootContentID;
            ThePage.ContentID      = NewRootContentID;

            foreach (var w in ThePageWidgets)
            {
                w.Root_ContentID = NewRootContentID;
                w.Root_WidgetID  = Guid.NewGuid();
                w.WidgetDataID   = Guid.NewGuid();
            }

            Guid userID1 = Guid.Empty;

            if (!cp.EditUserId.HasValue)
            {
                userID1 = cp.CreateUserId;
            }
            else
            {
                userID1 = cp.EditUserId.Value;
            }

            ExtendedUserData u1 = new ExtendedUserData(userID1);

            this.TheUser = new SiteExportUser(u1);

            Guid userID2 = Guid.Empty;

            if (cp.CreditUserId.HasValue)
            {
                userID2 = cp.CreditUserId.Value;
            }

            ExtendedUserData u2 = new ExtendedUserData(userID2);

            if (u2 != null)
            {
                this.CreditUser = new SiteExportUser(u2);
            }
            else
            {
                this.CreditUser = null;
            }
        }
		protected void Page_Load(object sender, EventArgs e) {
			Master.ActivateTab(AdminBaseMasterPage.SectionID.ContentAdd);

			RedirectIfNoSite();

			lblUpdated.Text = SiteData.CurrentSite.Now.ToString();
			lblCreateDate.Text = SiteData.CurrentSite.Now.ToString();

			iPageCount = pageHelper.GetSitePageCount(SiteID, ContentPageType.PageType.ContentEntry);

			guidContentID = GetGuidIDFromQuery();
			guidVersionContentID = GetGuidParameterFromQuery("versionid");
			guidImportContentID = GetGuidParameterFromQuery("importid");

			if (!IsPostBack) {
				if (iPageCount < 1) {
					txtSort.Text = "0";
				} else {
					int iOrder = pageHelper.GetMaxNavOrder(SiteID) + 1;
					txtSort.Text = iOrder.ToString();
				}
			}

			sPageMode = GetStringParameterFromQuery("mode");
			if (sPageMode.ToLower() == "raw") {
				reBody.CssClass = "rawEditor";
				reLeftBody.CssClass = "rawEditor";
				reRightBody.CssClass = "rawEditor";
				divCenter.Visible = false;
				divRight.Visible = false;
				divLeft.Visible = false;
			}

			if (!IsPostBack) {
				DateTime dtSite = CalcNearestFiveMinTime(SiteData.CurrentSite.Now);
				txtReleaseDate.Text = dtSite.ToShortDateString();
				txtReleaseTime.Text = dtSite.ToShortTimeString();
				txtRetireDate.Text = dtSite.AddYears(200).ToShortDateString();
				txtRetireTime.Text = dtSite.AddYears(200).ToShortTimeString();

				hdnRootID.Value = Guid.Empty.ToString();
				ParentPagePicker.RootContentID = Guid.Empty;

				ContentPage pageContents = null;
				if (guidVersionContentID != Guid.Empty) {
					pageContents = pageHelper.GetVersion(SiteID, guidVersionContentID);
				}
				if (guidContentID != Guid.Empty && pageContents == null) {
					pageContents = pageHelper.FindContentByID(SiteID, guidContentID);
				}

				if (guidImportContentID != Guid.Empty) {
					ContentPageExport cpe = ContentImportExportUtils.GetSerializedContentPageExport(guidImportContentID);

					if (cpe != null) {
						pageContents = cpe.ThePage;
						pageContents.EditDate = SiteData.CurrentSite.Now;

						var rp = pageHelper.GetLatestContentByURL(SiteID, false, pageContents.FileName);
						if (rp != null) {
							pageContents.Root_ContentID = rp.Root_ContentID;
							pageContents.ContentID = rp.ContentID;
							pageContents.Parent_ContentID = rp.Parent_ContentID;
							pageContents.NavOrder = rp.NavOrder;
						} else {
							pageContents.Root_ContentID = Guid.Empty;
							pageContents.ContentID = Guid.Empty;
							pageContents.NavOrder = pageHelper.GetSitePageCount(SiteID, ContentPageType.PageType.ContentEntry);
						}
					}
				}

				//if (pageContents == null) {
				//    pageContents = new ContentPage(SiteData.CurrentSiteID, ContentPageType.PageType.ContentEntry);
				//}

				List<ContentPage> lstContent = pageHelper.GetAllLatestContentList(SiteID);

				GeneralUtilities.BindList(ddlTemplate, cmsHelper.Templates);

				chkDraft.Visible = false;
				divEditing.Visible = false;

				float iThird = (float)(iPageCount - 1) / (float)3;

				Dictionary<string, float> dictTemplates = pageHelper.GetPopularTemplateList(SiteID, ContentPageType.PageType.ContentEntry);
				if (dictTemplates.Any() && dictTemplates.First().Value >= iThird) {
					try {
						GeneralUtilities.SelectListValue(ddlTemplate, dictTemplates.First().Key);
					} catch { }
				}

				if (pageContents == null) {
					btnDeleteButton.Visible = false;
				}

				if (pageContents != null) {
					bool bRet = pageHelper.RecordPageLock(pageContents.Root_ContentID, SiteData.CurrentSite.SiteID, SecurityData.CurrentUserGuid);

					if (pageContents.ContentType != ContentPageType.PageType.ContentEntry) {
						Response.Redirect(SiteFilename.BlogPostAddEditURL + "?id=" + Request.QueryString.ToString());
					}

					cmsHelper.OverrideKey(pageContents.Root_ContentID);
					cmsHelper.cmsAdminContent = pageContents;
					cmsHelper.cmsAdminWidget = pageContents.GetWidgetList();

					BindTextDataGrid();

					guidRootContentID = pageContents.Root_ContentID;
					hdnRootID.Value = guidRootContentID.ToString();

					txtOldFile.Text = pageContents.FileName;

					if (guidImportContentID != Guid.Empty) {
						txtOldFile.Text = "";
					}

					Dictionary<string, string> dataVersions = (from v in pageHelper.GetVersionHistory(SiteID, pageContents.Root_ContentID)
															   join u in ExtendedUserData.GetUserList() on v.EditUserId equals u.UserId
															   orderby v.EditDate descending
															   select new KeyValuePair<string, string>(v.ContentID.ToString(), string.Format("{0} ({1}) {2}", v.EditDate, u.UserName, (v.IsLatestVersion ? " [**] " : " ")))
																).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

					GeneralUtilities.BindListDefaultText(ddlVersions, dataVersions, null, "Page Versions", "00000");

					bLocked = pageHelper.IsPageLocked(pageContents);

					pnlHB.Visible = !bLocked;
					pnlButtons.Visible = !bLocked;
					divEditing.Visible = bLocked;
					chkDraft.Visible = !bLocked;
					pnlHBEmpty.Visible = bLocked;

					if (bLocked && pageContents.Heartbeat_UserId != null) {
						MembershipUser usr = SecurityData.GetUserByGuid(pageContents.Heartbeat_UserId.Value);
						litUser.Text = "Read only mode. User '" + usr.UserName + "' is currently editing the page.";
					}

					txtTitle.Text = pageContents.TitleBar;
					txtNav.Text = pageContents.NavMenuText;
					txtHead.Text = pageContents.PageHead;
					txtFileName.Text = pageContents.FileName;
					txtThumb.Text = pageContents.Thumbnail;

					txtDescription.Text = pageContents.MetaDescription;
					txtKey.Text = pageContents.MetaKeyword;

					txtSort.Text = pageContents.NavOrder.ToString();

					lblUpdated.Text = pageContents.EditDate.ToString();
					lblCreateDate.Text = pageContents.CreateDate.ToString();

					reBody.Text = pageContents.PageText;
					reLeftBody.Text = pageContents.LeftPageText;
					reRightBody.Text = pageContents.RightPageText;

					chkActive.Checked = pageContents.PageActive;
					chkNavigation.Checked = pageContents.ShowInSiteNav;
					chkSiteMap.Checked = pageContents.ShowInSiteMap;
					chkHide.Checked = pageContents.BlockIndex;

					GeneralUtilities.BindDataBoundControl(gvTracks, pageContents.GetTrackbacks());

					txtReleaseDate.Text = pageContents.GoLiveDate.ToShortDateString();
					txtReleaseTime.Text = pageContents.GoLiveDate.ToShortTimeString();
					txtRetireDate.Text = pageContents.RetireDate.ToShortDateString();
					txtRetireTime.Text = pageContents.RetireDate.ToShortTimeString();

					if (pageContents.CreditUserId.HasValue) {
						var usr = new ExtendedUserData(pageContents.CreditUserId.Value);
						hdnCreditUserID.Value = usr.UserName;
						txtSearchUser.Text = string.Format("{0} ({1})", usr.UserName, usr.EmailAddress);
					}

					if (pageContents.Parent_ContentID.HasValue) {
						ParentPagePicker.SelectedPage = pageContents.Parent_ContentID.Value;
					}

					GeneralUtilities.SelectListValue(ddlTemplate, pageContents.TemplateFile.ToLower());
				}
			}

			ParentPagePicker.RootContentID = guidRootContentID;

			SetBlankText(reBody);
			SetBlankText(reLeftBody);
			SetBlankText(reRightBody);

			if (ddlVersions.Items.Count < 1) {
				pnlReview.Visible = false;
			}
		}
Пример #33
0
        public PageViewType GetBlogHeadingFromURL(SiteData currentSite, string sFilterPath)
        {
            Guid siteID = currentSite.SiteID;
            PageViewType pvt = new PageViewType { ExtraTitle = "", CurrentViewType = PageViewType.ViewType.SinglePage, RawValue = null };

            string sTitle = String.Empty;

            if (currentSite.CheckIsBlogCategoryPath(sFilterPath)) {
                pvt.CurrentViewType = PageViewType.ViewType.CategoryIndex;
                vw_carrot_CategoryURL query = CompiledQueries.cqGetCategoryByURL(db, siteID, sFilterPath);
                if (query != null) {
                    sTitle = query.CategoryText;
                    pvt.RawValue = query.CategoryText;
                }
            }
            if (currentSite.CheckIsBlogTagPath(sFilterPath)) {
                pvt.CurrentViewType = PageViewType.ViewType.TagIndex;
                vw_carrot_TagURL query = CompiledQueries.cqGetTagByURL(db, siteID, sFilterPath);
                if (query != null) {
                    sTitle = query.TagText;
                    pvt.RawValue = query.TagText;
                }
            }
            if (currentSite.CheckIsBlogEditorFolderPath(sFilterPath)) {
                pvt.CurrentViewType = PageViewType.ViewType.AuthorIndex;
                vw_carrot_EditorURL query = CompiledQueries.cqGetEditorByURL(db, siteID, sFilterPath);
                if (query != null) {
                    ExtendedUserData usr = new ExtendedUserData(query.UserId);
                    sTitle = usr.ToString();
                    pvt.RawValue = usr;
                }
            }
            if (currentSite.CheckIsBlogDateFolderPath(sFilterPath)) {
                pvt.CurrentViewType = PageViewType.ViewType.DateIndex;

                BlogDatePathParser p = new BlogDatePathParser(currentSite, sFilterPath);
                TimeSpan ts = p.DateEndUTC - p.DateBeginUTC;

                pvt.RawValue = p.DateBegin;

                int daysDelta = ts.Days;
                if (daysDelta < 400 && daysDelta > 90) {
                    sTitle = p.DateBegin.ToString("yyyy");
                    pvt.CurrentViewType = PageViewType.ViewType.DateYearIndex;
                }
                if (daysDelta < 36 && daysDelta > 3) {
                    sTitle = p.DateBegin.ToString("MMMM yyyy");
                    pvt.CurrentViewType = PageViewType.ViewType.DateMonthIndex;
                }
                if (daysDelta < 5) {
                    sTitle = p.DateBegin.ToString("MMMM d, yyyy");
                    pvt.CurrentViewType = PageViewType.ViewType.DateDayIndex;
                }
            }

            if (currentSite.CheckIsSiteSearchPath(sFilterPath)) {
                pvt.CurrentViewType = PageViewType.ViewType.SearchResults;
                string sSearchTerm = "";

                if (HttpContext.Current.Request.QueryString[SiteData.SearchQueryParameter] != null) {
                    sSearchTerm = HttpContext.Current.Request.QueryString[SiteData.SearchQueryParameter].ToString();
                }

                pvt.RawValue = sSearchTerm;
                sTitle = string.Format(" '{0}' ", sSearchTerm);
            }

            pvt.ExtraTitle = sTitle;

            return pvt;
        }
Пример #34
0
        public bool RecordPageLock(Guid rootContentID, Guid siteID, Guid currentUserID)
        {
            bool bLock = IsPageLocked(rootContentID, siteID, currentUserID);
            bool bRet = false;

            if (!bLock) {
                ExtendedUserData usr = new ExtendedUserData(currentUserID);

                //only allow admin/editors to record a lock
                if (usr.IsAdmin || usr.IsEditor) {
                    bRet = RecordHeartbeatLock(rootContentID, siteID, currentUserID);
                }
            }

            return bRet;
        }
		public ActionResult SiteAddUser(SiteModel model) {
			ModelState.Clear();

			if (String.IsNullOrEmpty(model.NewUserId)) {
				ModelState.AddModelError("NewUserId", "The New User field is required.");
			}

			SiteData site = model.Site;
			Helper.ForceValidation(ModelState, model);

			if (ModelState.IsValid) {
				if (!String.IsNullOrEmpty(model.NewUserId)) {
					ExtendedUserData exUsr = new ExtendedUserData(new Guid(model.NewUserId));
					exUsr.AddToSite(site.SiteID);

					if (model.NewUserAsEditor) {
						exUsr.AddToRole(SecurityData.CMSGroup_Editors);
					}
				}

				return RedirectToAction("SiteDetail", new { @id = site.SiteID });
			}

			Helper.HandleErrorDict(ModelState);

			model.LoadUsers();

			return View("SiteDetail", model);
		}
		public ActionResult UserProfile() {
			ExtendedUserData model = new ExtendedUserData(SecurityData.CurrentUserIdentityName);

			ShowSaved("Profile Updated");

			return View(model);
		}
Пример #37
0
        public string GetBlogHeadingFromURL(SiteData currentSite, string sFilterPath)
        {
            Guid siteID = currentSite.SiteID;

            string sTitle = String.Empty;

            if (currentSite.CheckIsBlogCategoryPath(sFilterPath)) {
                vw_carrot_CategoryURL query = CompiledQueries.cqGetCategoryByURL(db, siteID, sFilterPath);
                sTitle = query.CategoryText;
            }
            if (currentSite.CheckIsBlogTagPath(sFilterPath)) {
                vw_carrot_TagURL query = CompiledQueries.cqGetTagByURL(db, siteID, sFilterPath);
                sTitle = query.TagText;
            }
            if (currentSite.CheckIsBlogEditorFolderPath(sFilterPath)) {
                vw_carrot_EditorURL query = CompiledQueries.cqGetEditorByURL(db, siteID, sFilterPath);
                ExtendedUserData usr = new ExtendedUserData(query.UserId);
                sTitle = usr.ToString();
            }
            if (currentSite.CheckIsBlogDateFolderPath(sFilterPath)) {
                BlogDatePathParser p = new BlogDatePathParser(currentSite, sFilterPath);
                TimeSpan ts = p.DateEndUTC - p.DateBeginUTC;

                int daysDelta = ts.Days;
                if (daysDelta > 90) {
                    sTitle = "Year " + p.DateBegin.ToString("yyyy");
                }
                if (daysDelta < 36) {
                    sTitle = p.DateBegin.ToString("MMMM yyyy");
                }
                if (daysDelta < 5) {
                    sTitle = p.DateBegin.ToString("MMMM d, yyyy");
                }
            }
            if (currentSite.CheckIsSiteSearchPath(sFilterPath)) {
                sTitle = "Search Results";
            }

            return sTitle;
        }
		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);
		}
Пример #39
0
 public IdentityResult CreateApplicationUser(ApplicationUser user, out ExtendedUserData newusr)
 {
     return(AttemptCreateApplicationUser(user, SecurityData.GenerateSimplePassword(), out newusr));
 }
		protected void SavePage(bool bRedirect) {
			ContentPage pageContents = null;
			if (guidVersionContentID != Guid.Empty) {
				pageContents = pageHelper.GetVersion(SiteID, guidVersionContentID);
			}
			if (guidContentID != Guid.Empty && pageContents == null) {
				pageContents = pageHelper.FindContentByID(SiteID, guidContentID);
			}
			if (guidImportContentID != Guid.Empty) {
				pageContents = ContentImportExportUtils.GetSerializedContentPageExport(guidImportContentID).ThePage;

				if (pageContents != null) {
					pageContents.SiteID = SiteID;
					pageContents.EditDate = SiteData.CurrentSite.Now;
					pageContents.CreateUserId = SecurityData.CurrentUserGuid;
					pageContents.CreateDate = SiteData.CurrentSite.Now;

					var rp = pageHelper.GetLatestContentByURL(SiteID, false, pageContents.FileName);
					if (rp != null) {
						pageContents.Root_ContentID = rp.Root_ContentID;
						pageContents.ContentID = rp.ContentID;
					} else {
						pageContents.Root_ContentID = Guid.Empty;
						pageContents.ContentID = Guid.Empty;
					}
				}
			}

			if (pageContents == null) {
				pageContents = new ContentPage(SiteData.CurrentSiteID, ContentPageType.PageType.ContentEntry);
			}

			DateTime dtSite = CalcNearestFiveMinTime(SiteData.CurrentSite.Now);
			pageContents.GoLiveDate = dtSite.AddMinutes(-5);
			pageContents.RetireDate = dtSite.AddYears(200);

			pageContents.IsLatestVersion = true;
			pageContents.Thumbnail = txtThumb.Text;

			pageContents.TemplateFile = ddlTemplate.SelectedValue;

			pageContents.TitleBar = txtTitle.Text;
			pageContents.NavMenuText = txtNav.Text;
			pageContents.PageHead = txtHead.Text;
			pageContents.FileName = txtFileName.Text;

			pageContents.MetaDescription = txtDescription.Text;
			pageContents.MetaKeyword = txtKey.Text;

			pageContents.EditDate = SiteData.CurrentSite.Now;
			pageContents.NavOrder = int.Parse(txtSort.Text);

			pageContents.PageText = reBody.Text;
			pageContents.LeftPageText = reLeftBody.Text;
			pageContents.RightPageText = reRightBody.Text;

			pageContents.PageActive = chkActive.Checked;
			pageContents.ShowInSiteNav = chkNavigation.Checked;
			pageContents.ShowInSiteMap = chkSiteMap.Checked;
			pageContents.BlockIndex = chkHide.Checked;

			pageContents.ContentType = ContentPageType.PageType.ContentEntry;

			if (ParentPagePicker.SelectedPage.HasValue) {
				pageContents.Parent_ContentID = ParentPagePicker.SelectedPage.Value;
			} else {
				pageContents.Parent_ContentID = null;
			}

			if (String.IsNullOrEmpty(hdnCreditUserID.Value)) {
				pageContents.CreditUserId = null;
			} else {
				var usr = new ExtendedUserData(hdnCreditUserID.Value);
				pageContents.CreditUserId = usr.UserId;
			}

			pageContents.GoLiveDate = Convert.ToDateTime(txtReleaseDate.Text + " " + txtReleaseTime.Text);
			pageContents.RetireDate = Convert.ToDateTime(txtRetireDate.Text + " " + txtRetireTime.Text);
			pageContents.EditUserId = SecurityData.CurrentUserGuid;

			pageContents.NewTrackBackURLs = txtTrackback.Text;

			if (!chkDraft.Checked) {
				pageContents.SavePageEdit();
			} else {
				pageContents.SavePageAsDraft();
			}

			//if importing, copy in all meta data possible
			if (guidImportContentID != Guid.Empty) {
				List<Widget> widgets = ContentImportExportUtils.GetSerializedContentPageExport(guidImportContentID).ThePageWidgets;

				foreach (var wd in widgets) {
					wd.Root_ContentID = pageContents.Root_ContentID;
					wd.Root_WidgetID = Guid.NewGuid();
					wd.WidgetDataID = Guid.NewGuid();
					wd.IsPendingChange = true;
					wd.EditDate = SiteData.CurrentSite.Now;
					wd.Save();
				}

				ContentImportExportUtils.RemoveSerializedExportData(guidImportContentID);
			}

			cmsHelper.OverrideKey(pageContents.Root_ContentID);
			if (cmsHelper.cmsAdminWidget != null) {
				var ww = (from w in cmsHelper.cmsAdminWidget
						  where w.IsLatestVersion == true
						  && w.IsPendingChange == true
						  && (w.ControlPath.StartsWith("CLASS:Carrotware.CMS.UI.Controls.ContentRichText,")
						  || w.ControlPath.StartsWith("CLASS:Carrotware.CMS.UI.Controls.ContentPlainText,"))
						  select w);

				foreach (Widget w in ww) {
					w.Save();
				}
			}

			cmsHelper.cmsAdminContent = null;
			cmsHelper.cmsAdminWidget = null;

			if (pageContents.FileName.ToLower().EndsWith(SiteData.DefaultDirectoryFilename)) {
				VirtualDirectory.RegisterRoutes(true);
			}

			if (!bRedirect) {
				if (sPageMode.Length < 1) {
					Response.Redirect(SiteData.CurrentScriptName + "?id=" + pageContents.Root_ContentID.ToString());
				} else {
					Response.Redirect(SiteData.CurrentScriptName + "?mode=raw&id=" + pageContents.Root_ContentID.ToString());
				}
			} else {
				Response.Redirect(pageContents.FileName);
			}
		}
Пример #41
0
        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());
                    }
                }

                if (chkAuthors.Checked) {
                    if (seu.ImportUserID == Guid.Empty) {
                        usr = Membership.CreateUser(seu.Login, ProfileManager.GenerateSimplePassword(), seu.Email);
                        Roles.AddUserToRole(seu.Login, SecurityData.CMSGroup_Users);
                        seu.ImportUserID = new Guid(usr.ProviderUserKey.ToString());
                    }

                    if (seu.ImportUserID != Guid.Empty) {
                        ExtendedUserData ud = new ExtendedUserData(seu.ImportUserID);
                        if (!string.IsNullOrEmpty(seu.FirstName) || !string.IsNullOrEmpty(seu.LastName)) {
                            ud.FirstName = seu.FirstName;
                            ud.LastName = seu.LastName;
                            ud.Save();
                        }
                    }
                }
            }

            if (chkPages.Checked) {
                sMsg += "<p>Imported Pages</p>";
                sitePageList = site.GetFullSiteFileList();

                int iOrder = 0;

                SiteNav navHome = GetHomePage(site);

                if (navHome != null) {
                    iOrder = 2;
                }

                foreach (var impCP in (from c in exSite.ThePages
                                       where c.ThePage.ContentType == ContentPageType.PageType.ContentEntry
                                       orderby c.ThePage.NavOrder, c.ThePage.NavMenuText
                                       select c).ToList()) {
                    ContentPage cp = impCP.ThePage;
                    cp.Root_ContentID = impCP.NewRootContentID;
                    cp.ContentID = Guid.NewGuid();
                    cp.SiteID = site.SiteID;
                    cp.ContentType = ContentPageType.PageType.ContentEntry;
                    cp.EditDate = SiteData.CurrentSite.Now;
                    cp.EditUserId = exSite.FindImportUser(impCP.TheUser);
                    cp.CreateUserId = exSite.FindImportUser(impCP.TheUser);
                    if (impCP.CreditUser != null) {
                        cp.CreditUserId = exSite.FindImportUser(impCP.CreditUser);
                    }
                    cp.NavOrder = iOrder;
                    cp.TemplateFile = ddlTemplatePage.SelectedValue;

                    ContentPageExport parent = (from c in exSite.ThePages
                                                where c.ThePage.ContentType == ContentPageType.PageType.ContentEntry
                                                  && c.ThePage.FileName.ToLower() == impCP.ParentFileName.ToLower()
                                                select c).FirstOrDefault();

                    BasicContentData navParent = null;
                    BasicContentData navData = GetFileInfoFromList(site, cp.FileName);

                    if (parent != null) {
                        cp.Parent_ContentID = parent.NewRootContentID;
                        navParent = GetFileInfoFromList(site, parent.ThePage.FileName);
                    }

                    //if URL exists already, make this become a new version in the current series
                    if (navData != null) {
                        cp.Root_ContentID = navData.Root_ContentID;

                        impCP.ThePage.RetireDate = navData.RetireDate;
                        impCP.ThePage.GoLiveDate = navData.GoLiveDate;

                        if (navData.NavOrder == 0) {
                            cp.NavOrder = 0;
                        }
                    }
                    //preserve homepage
                    if (navHome != null && navHome.FileName.ToLower() == cp.FileName.ToLower()) {
                        cp.NavOrder = 0;
                    }
                    //if the file url in the upload has an existing ID, use that, not the ID from the queue
                    if (navParent != null) {
                        cp.Parent_ContentID = navParent.Root_ContentID;
                    }

                    cp.RetireDate = impCP.ThePage.RetireDate;
                    cp.GoLiveDate = impCP.ThePage.GoLiveDate;

                    cp.SavePageEdit();

                    iOrder++;
                }
            }
            SetMsg(sMsg);

            if (chkPosts.Checked) {
                sMsg += "<p>Imported Posts</p>";
                sitePageList = site.GetFullSiteFileList();

                List<ContentTag> lstTags = site.GetTagList();
                List<ContentCategory> lstCategories = site.GetCategoryList();

                foreach (var impCP in (from c in exSite.ThePages
                                       where c.ThePage.ContentType == ContentPageType.PageType.BlogEntry
                                       orderby c.ThePage.CreateDate
                                       select c).ToList()) {
                    ContentPage cp = impCP.ThePage;
                    cp.Root_ContentID = impCP.NewRootContentID;
                    cp.ContentID = Guid.NewGuid();
                    cp.SiteID = site.SiteID;
                    cp.Parent_ContentID = null;
                    cp.ContentType = ContentPageType.PageType.BlogEntry;
                    cp.EditDate = SiteData.CurrentSite.Now;
                    cp.EditUserId = exSite.FindImportUser(impCP.TheUser);
                    cp.CreateUserId = exSite.FindImportUser(impCP.TheUser);
                    if (impCP.CreditUser != null) {
                        cp.CreditUserId = exSite.FindImportUser(impCP.CreditUser);
                    }
                    cp.NavOrder = SiteData.BlogSortOrderNumber;
                    cp.TemplateFile = ddlTemplatePost.SelectedValue;

                    cp.ContentCategories = (from l in lstCategories
                                            join o in impCP.ThePage.ContentCategories on l.CategorySlug.ToLower() equals o.CategorySlug.ToLower()
                                            select l).Distinct().ToList();

                    cp.ContentTags = (from l in lstTags
                                      join o in impCP.ThePage.ContentTags on l.TagSlug.ToLower() equals o.TagSlug.ToLower()
                                      select l).Distinct().ToList();

                    BasicContentData navData = GetFileInfoFromList(site, cp.FileName);

                    //if URL exists already, make this become a new version in the current series
                    if (navData != null) {
                        cp.Root_ContentID = navData.Root_ContentID;

                        impCP.ThePage.RetireDate = navData.RetireDate;
                        impCP.ThePage.GoLiveDate = navData.GoLiveDate;
                    }

                    cp.RetireDate = impCP.ThePage.RetireDate;
                    cp.GoLiveDate = impCP.ThePage.GoLiveDate;

                    cp.SavePageEdit();
                }

                using (ContentPageHelper cph = new ContentPageHelper()) {
                    //cph.BulkBlogFileNameUpdateFromDate(site.SiteID);
                    cph.ResolveDuplicateBlogURLs(site.SiteID);
                    cph.FixBlogNavOrder(site.SiteID);
                }
            }
            SetMsg(sMsg);

            if (chkComments.Checked) {
                sMsg += "<p>Imported Comments</p>";
                sitePageList = site.GetFullSiteFileList();

                foreach (var impCP in (from c in exSite.TheComments
                                       orderby c.TheComment.CreateDate
                                       select c).ToList()) {
                    int iCommentCount = -1;
                    PostComment pc = impCP.TheComment;
                    BasicContentData navData = GetFileInfoFromList(site, pc.FileName);
                    if (navData != null) {
                        pc.Root_ContentID = navData.Root_ContentID;
                        pc.ContentCommentID = Guid.NewGuid();

                        iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, pc.Root_ContentID, pc.CreateDate, pc.CommenterIP, pc.PostCommentText);
                        if (iCommentCount < 1) {
                            iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, pc.Root_ContentID, pc.CreateDate, pc.CommenterIP);
                        }

                        if (iCommentCount < 1) {
                            pc.Save();
                        }
                    }
                }
            }
            SetMsg(sMsg);

            BindData();
        }
        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);
                if (usr != null) {
                    seu.ImportUserID = usr.UserId;
                } else {
                    usr = ExtendedUserData.FindByUsername(seu.Login);
                    if (usr != null) {
                        seu.ImportUserID = usr.UserId;
                    }
                }

                if (this.CreateUsers) {
                    if (seu.ImportUserID == Guid.Empty) {
                        ApplicationUser user = new ApplicationUser { UserName = seu.Login, Email = seu.Email };
                        var result = sd.CreateApplicationUser(user, out usr);
                        if (result.Succeeded) {
                            usr = ExtendedUserData.FindByUsername(seu.Login);
                        }
                        seu.ImportUserID = usr.UserId;
                    }

                    if (seu.ImportUserID != Guid.Empty) {
                        ExtendedUserData ud = new ExtendedUserData(seu.ImportUserID);
                        if (!String.IsNullOrEmpty(seu.FirstName) || !String.IsNullOrEmpty(seu.LastName)) {
                            ud.FirstName = seu.FirstName;
                            ud.LastName = seu.LastName;
                            ud.Save();
                        }
                    }
                }
            }

            if (this.ImportPages) {
                sMsg += "<li>Imported Pages</li>";
                this.Content = site.GetFullSiteFileList();

                int iOrder = 0;

                SiteNav navHome = GetHomePage(site);

                if (navHome != null) {
                    iOrder = 2;
                }

                foreach (var impCP in (from c in this.Site.ThePages
                                       where c.ThePage.ContentType == ContentPageType.PageType.ContentEntry
                                       orderby c.ThePage.NavOrder, c.ThePage.NavMenuText
                                       select c).ToList()) {
                    ContentPage cp = impCP.ThePage;
                    cp.Root_ContentID = impCP.NewRootContentID;
                    cp.ContentID = Guid.NewGuid();
                    cp.SiteID = site.SiteID;
                    cp.ContentType = ContentPageType.PageType.ContentEntry;
                    cp.EditDate = SiteData.CurrentSite.Now;
                    cp.EditUserId = this.Site.FindImportUser(impCP.TheUser);
                    cp.CreateUserId = this.Site.FindImportUser(impCP.TheUser);
                    if (impCP.CreditUser != null) {
                        cp.CreditUserId = this.Site.FindImportUser(impCP.CreditUser);
                    }
                    cp.NavOrder = iOrder;
                    cp.TemplateFile = this.PageTemplate;

                    ContentPageExport parent = (from c in this.Site.ThePages
                                                where c.ThePage.ContentType == ContentPageType.PageType.ContentEntry
                                                  && c.ThePage.FileName.ToLower() == impCP.ParentFileName.ToLower()
                                                select c).FirstOrDefault();

                    BasicContentData navParent = null;
                    BasicContentData navData = GetFileInfoFromList(site, cp.FileName);

                    if (parent != null) {
                        cp.Parent_ContentID = parent.NewRootContentID;
                        navParent = GetFileInfoFromList(site, parent.ThePage.FileName);
                    }

                    //if URL exists already, make this become a new version in the current series
                    if (navData != null) {
                        cp.Root_ContentID = navData.Root_ContentID;

                        impCP.ThePage.RetireDate = navData.RetireDate;
                        impCP.ThePage.GoLiveDate = navData.GoLiveDate;

                        if (navData.NavOrder == 0) {
                            cp.NavOrder = 0;
                        }
                    }
                    //preserve homepage
                    if (navHome != null && navHome.FileName.ToLower() == cp.FileName.ToLower()) {
                        cp.NavOrder = 0;
                    }
                    //if the file url in the upload has an existing ID, use that, not the ID from the queue
                    if (navParent != null) {
                        cp.Parent_ContentID = navParent.Root_ContentID;
                    }

                    cp.RetireDate = impCP.ThePage.RetireDate;
                    cp.GoLiveDate = impCP.ThePage.GoLiveDate;

                    cp.SavePageEdit();

                    iOrder++;
                }
            }
            SetMsg(sMsg);

            if (this.ImportPosts) {
                sMsg += "<li>Imported Posts</li>";
                this.Content = site.GetFullSiteFileList();

                List<ContentTag> lstTags = site.GetTagList();
                List<ContentCategory> lstCategories = site.GetCategoryList();

                foreach (var impCP in (from c in this.Site.ThePages
                                       where c.ThePage.ContentType == ContentPageType.PageType.BlogEntry
                                       orderby c.ThePage.CreateDate
                                       select c).ToList()) {
                    ContentPage cp = impCP.ThePage;
                    cp.Root_ContentID = impCP.NewRootContentID;
                    cp.ContentID = Guid.NewGuid();
                    cp.SiteID = site.SiteID;
                    cp.Parent_ContentID = null;
                    cp.ContentType = ContentPageType.PageType.BlogEntry;
                    cp.EditDate = SiteData.CurrentSite.Now;
                    cp.EditUserId = this.Site.FindImportUser(impCP.TheUser);
                    cp.CreateUserId = this.Site.FindImportUser(impCP.TheUser);
                    if (impCP.CreditUser != null) {
                        cp.CreditUserId = this.Site.FindImportUser(impCP.CreditUser);
                    }
                    cp.NavOrder = SiteData.BlogSortOrderNumber;
                    cp.TemplateFile = this.PostTemplate;

                    cp.ContentCategories = (from l in lstCategories
                                            join o in impCP.ThePage.ContentCategories on l.CategorySlug.ToLower() equals o.CategorySlug.ToLower()
                                            select l).Distinct().ToList();

                    cp.ContentTags = (from l in lstTags
                                      join o in impCP.ThePage.ContentTags on l.TagSlug.ToLower() equals o.TagSlug.ToLower()
                                      select l).Distinct().ToList();

                    BasicContentData navData = GetFileInfoFromList(site, cp.FileName);

                    //if URL exists already, make this become a new version in the current series
                    if (navData != null) {
                        cp.Root_ContentID = navData.Root_ContentID;

                        impCP.ThePage.RetireDate = navData.RetireDate;
                        impCP.ThePage.GoLiveDate = navData.GoLiveDate;
                    }

                    cp.RetireDate = impCP.ThePage.RetireDate;
                    cp.GoLiveDate = impCP.ThePage.GoLiveDate;

                    cp.SavePageEdit();
                }

                using (ContentPageHelper cph = new ContentPageHelper()) {
                    //cph.BulkBlogFileNameUpdateFromDate(site.SiteID);
                    cph.ResolveDuplicateBlogURLs(site.SiteID);
                    cph.FixBlogNavOrder(site.SiteID);
                }
            }
            SetMsg(sMsg);

            if (this.ImportComments) {
                sMsg += "<li>Imported Comments</li>";
                this.Content = site.GetFullSiteFileList();

                foreach (var impCP in (from c in this.Site.TheComments
                                       orderby c.TheComment.CreateDate
                                       select c).ToList()) {
                    int iCommentCount = -1;
                    PostComment pc = impCP.TheComment;
                    BasicContentData navData = GetFileInfoFromList(site, pc.FileName);
                    if (navData != null) {
                        pc.Root_ContentID = navData.Root_ContentID;
                        pc.ContentCommentID = Guid.NewGuid();

                        iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, pc.Root_ContentID, pc.CreateDate, pc.CommenterIP, pc.PostCommentText);
                        if (iCommentCount < 1) {
                            iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, pc.Root_ContentID, pc.CreateDate, pc.CommenterIP);
                        }

                        if (iCommentCount < 1) {
                            pc.Save();
                        }
                    }
                }
            }

            SetMsg(sMsg);
        }
        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();
                        }
                    }
                }
            }

            this.Site.Comments.ForEach(r => r.ImportRootID = Guid.Empty);

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                if (this.ImportPages) {
                    sMsg += "<li>Imported Pages</li>";

                    int iOrder = 0;
                    SiteNav navHome = navHelper.FindHome(site.SiteID, false);
                    if (navHome != null) {
                        iOrder = 2;
                    }

                    foreach (var wpp in (from c in this.Site.Content
                                         where c.PostType == WordPressPost.WPPostType.Page
                                         orderby c.PostOrder, c.PostTitle
                                         select c).ToList()) {
                        GrabAttachments(wpp);
                        RepairBody(wpp);

                        ContentPage cp = ContentImportExportUtils.CreateWPContentPage(this.Site, wpp, site);
                        cp.SiteID = site.SiteID;
                        cp.ContentType = ContentPageType.PageType.ContentEntry;
                        cp.EditDate = SiteData.CurrentSite.Now;
                        cp.NavOrder = iOrder;
                        cp.TemplateFile = this.PageTemplate;

                        WordPressPost parent = (from c in this.Site.Content
                                                where c.PostType == WordPressPost.WPPostType.Page
                                                  && c.PostID == wpp.ParentPostID
                                                select c).FirstOrDefault();

                        SiteNav navParent = null;

                        SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLowerInvariant());
                        if (parent != null) {
                            navParent = navHelper.GetLatestVersion(site.SiteID, false, parent.ImportFileName.ToLowerInvariant());
                        }

                        //if URL exists already, make this become a new version in the current series
                        if (navData != null) {
                            cp.Root_ContentID = navData.Root_ContentID;
                            if (navData.NavOrder == 0) {
                                cp.NavOrder = 0;
                            }
                        }

                        if (navParent != null) {
                            cp.Parent_ContentID = navParent.Root_ContentID;
                        } else {
                            if (parent != null) {
                                cp.Parent_ContentID = parent.ImportRootID;
                            }
                        }
                        //preserve homepage
                        if (navHome != null && navHome.FileName.ToLowerInvariant() == cp.FileName.ToLowerInvariant()) {
                            cp.NavOrder = 0;
                        }

                        cp.RetireDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddYears(200);
                        cp.GoLiveDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5);

                        //if URL exists already, make this become a new version in the current series
                        if (navData != null) {
                            cp.Root_ContentID = navData.Root_ContentID;
                            cp.RetireDate = navData.RetireDate;
                            cp.GoLiveDate = navData.GoLiveDate;
                        }

                        cp.SavePageEdit();

                        this.Site.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID);

                        iOrder++;
                    }
                }

                if (this.ImportPosts) {
                    sMsg += "<li>Imported Posts</li>";

                    foreach (var wpp in (from c in this.Site.Content
                                         where c.PostType == WordPressPost.WPPostType.BlogPost
                                         orderby c.PostOrder
                                         select c).ToList()) {
                        GrabAttachments(wpp);
                        RepairBody(wpp);

                        ContentPage cp = ContentImportExportUtils.CreateWPContentPage(this.Site, wpp, site);
                        cp.SiteID = site.SiteID;
                        cp.Parent_ContentID = null;
                        cp.ContentType = ContentPageType.PageType.BlogEntry;
                        cp.EditDate = SiteData.CurrentSite.Now;
                        cp.NavOrder = SiteData.BlogSortOrderNumber;
                        cp.TemplateFile = this.PostTemplate;

                        SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLowerInvariant());

                        cp.RetireDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddYears(200);
                        cp.GoLiveDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5);

                        //if URL exists already, make this become a new version in the current series
                        if (navData != null) {
                            cp.Root_ContentID = navData.Root_ContentID;
                            cp.RetireDate = navData.RetireDate;
                            cp.GoLiveDate = navData.GoLiveDate;
                        }

                        cp.SavePageEdit();

                        this.Site.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID);
                    }

                    using (ContentPageHelper cph = new ContentPageHelper()) {
                        //cph.BulkBlogFileNameUpdateFromDate(site.SiteID);
                        cph.ResolveDuplicateBlogURLs(site.SiteID);
                        cph.FixBlogNavOrder(site.SiteID);
                    }
                }
            }
            SetMsg(sMsg);

            this.Site.Comments.RemoveAll(r => r.ImportRootID == Guid.Empty);

            if (this.Site.Comments.Any()) {
                sMsg += "<li>Imported Comments</li>";
            }

            foreach (WordPressComment wpc in this.Site.Comments) {
                int iCommentCount = -1;

                iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP, wpc.CommentContent);
                if (iCommentCount < 1) {
                    iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP);
                }

                if (iCommentCount < 1) {
                    PostComment pc = new PostComment();
                    pc.ContentCommentID = Guid.NewGuid();
                    pc.Root_ContentID = wpc.ImportRootID;
                    pc.CreateDate = site.ConvertUTCToSiteTime(wpc.CommentDateUTC);
                    pc.IsApproved = false;
                    pc.IsSpam = false;

                    pc.CommenterIP = wpc.AuthorIP;
                    pc.CommenterName = wpc.Author;
                    pc.CommenterEmail = wpc.AuthorEmail;
                    pc.PostCommentText = wpc.CommentContent;
                    pc.CommenterURL = wpc.AuthorURL;

                    if (wpc.Approved == "1") {
                        pc.IsApproved = true;
                    }
                    if (wpc.Approved.ToLowerInvariant() == "trash") {
                        pc.IsSpam = true;
                    }
                    if (wpc.Type.ToLowerInvariant() == "trackback" || wpc.Type.ToLowerInvariant() == "pingback") {
                        pc.CommenterEmail = wpc.Type;
                    }

                    pc.Save();
                }
            }
            SetMsg(sMsg);
        }