public ExtendedUserData(string UserName) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { vw_carrot_UserData rc = CompiledQueries.cqFindUserByName(_db, UserName); LoadUserData(rc); } }
public static int GetHistoryListCount(Guid siteID, bool showLatestOnly, DateTime?editDate, Guid?editUserID) { Guid userID = Guid.Empty; if (editUserID.HasValue) { userID = editUserID.Value; } DateTime dateStart = DateTime.UtcNow.Date.AddDays(-2); DateTime dateEnd = DateTime.UtcNow.Date.AddDays(1); if (editDate.HasValue) { dateStart = editDate.Value.Date.AddDays(-8); dateEnd = editDate.Value.Date.AddDays(1); } using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { return((from h in _db.vw_carrot_EditHistories where h.SiteID == siteID && (!showLatestOnly || h.IsLatestVersion == true) && (!editDate.HasValue || (h.EditDate.Date >= dateStart.Date && h.EditDate.Date <= dateEnd.Date)) && (!editUserID.HasValue || h.EditUserId == userID) select h).Count()); } }
public void Save() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { bool bNew = false; carrot_ContentTag s = CompiledQueries.cqGetContentTagByID(_db, this.ContentTagID); if (s == null || (s != null && s.ContentTagID == Guid.Empty)) { s = new carrot_ContentTag(); s.ContentTagID = Guid.NewGuid(); s.SiteID = this.SiteID; bNew = true; } s.TagSlug = ContentPageHelper.ScrubSlug(this.TagSlug); s.TagText = this.TagText; s.IsPublic = this.IsPublic; if (bNew) { _db.carrot_ContentTags.InsertOnSubmit(s); } _db.SubmitChanges(); this.ContentTagID = s.ContentTagID; } }
public static int GetCommentCountByContent(Guid siteID, Guid rootContentID, DateTime postDate, string postIP) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { return((from c in CannedQueries.FindCommentsByDate(_db, siteID, rootContentID, postDate, postIP) select c).Count()); } }
public static int GetAllCommentCountBySite(Guid siteID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { return((from c in CannedQueries.GetSiteContentComments(_db, siteID) select c).Count()); } }
public static int GetCommentCountByContent(Guid rootContentID, bool bActiveOnly) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { return((from c in CannedQueries.GetContentPageComments(_db, rootContentID, bActiveOnly) select c).Count()); } }
public static int GetCommentCountByContent(Guid rootContentID, bool?approved, bool?spam) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { return((from c in CannedQueries.GetContentPageComments(_db, rootContentID, approved, spam) select c).Count()); } }
public bool VerifyUserHasSiteAccess(Guid siteID, Guid userID) { //all admins have rights to all sites if (SecurityData.IsAdmin) { return(true); } // if user is neither admin nor editor, they should not be in the backend of the site if (!(SecurityData.IsSiteEditor || SecurityData.IsAdmin)) { return(false); } using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { // by this point, the user is probably an editor, make sure they have rights to this site IQueryable <Guid> lstSiteIDs = (from l in _db.carrot_UserSiteMappings where l.UserId == userID && l.SiteID == siteID select l.SiteID); if (lstSiteIDs.Count() > 0) { return(true); } } return(false); }
public static int GetCommentCountBySiteAndType(Guid siteID, ContentPageType.PageType pageType, bool?approved, bool?spam) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { return((from c in CannedQueries.GetSiteContentCommentsByPostType(_db, siteID, pageType, approved, spam) select c).Count()); } }
public void Save() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { bool bNew = false; carrot_UserData usr = CompiledQueries.cqFindUserTblByID(_db, this.UserId); if (usr == null) { usr = new carrot_UserData(); usr.UserId = this.UserId; bNew = true; } usr.UserNickName = this.UserNickName; usr.FirstName = this.FirstName; usr.LastName = this.LastName; usr.UserBio = this.UserBio; if (bNew) { _db.carrot_UserDatas.InsertOnSubmit(usr); } _db.SubmitChanges(); this.UserId = usr.UserId; } }
public bool AddToSite(Guid siteID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { carrot_UserSiteMapping map = (from m in _db.carrot_UserSiteMappings where m.UserId == this.UserId && m.SiteID == siteID select m).FirstOrDefault(); if (map == null) { _siteIDs = null; map = new carrot_UserSiteMapping(); map.UserSiteMappingID = Guid.NewGuid(); map.SiteID = siteID; map.UserId = this.UserId; _db.carrot_UserSiteMappings.InsertOnSubmit(map); _db.SubmitChanges(); return(true); } else { return(false); } } }
public int GetSitePageCount(ContentPageType.PageType entryType) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { int iCount = CannedQueries.GetAllByTypeList(_db, this.SiteID, false, entryType).Count(); return(iCount); } }
public ExtendedUserData(Guid UserID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { vw_carrot_UserData rc = CompiledQueries.cqFindUserByID(_db, UserID); LoadUserData(rc); } }
public void Save() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { bool bNew = false; carrot_TextWidget s = CompiledQueries.cqTextWidgetByID(_db, this.TextWidgetID); if (s == null) { bNew = true; s = new carrot_TextWidget(); s.TextWidgetID = Guid.NewGuid(); s.SiteID = this.SiteID; s.TextWidgetAssembly = this.TextWidgetAssembly; } s.ProcessBody = this.ProcessBody; s.ProcessPlainText = this.ProcessPlainText; s.ProcessHTMLText = this.ProcessHTMLText; s.ProcessComment = this.ProcessComment; s.ProcessSnippet = this.ProcessSnippet; if (bNew) { _db.carrot_TextWidgets.InsertOnSubmit(s); } _db.SubmitChanges(); this.TextWidgetID = s.TextWidgetID; } }
public static IQueryable <ExtendedUserData> GetUsers() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { IQueryable <ExtendedUserData> lstUsr = (from u in CompiledQueries.cqGetUserList(_db) select new ExtendedUserData(u)); return(lstUsr); } }
public static int GetSimilar(Guid SiteID, Guid TagID, string tagSlug) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { IQueryable <carrot_ContentTag> query = CompiledQueries.cqGetContentTagNoMatch(_db, SiteID, TagID, tagSlug); return(query.Count()); } }
public static int GetSimilar(Guid SiteID, Guid CategoryID, string categorySlug) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { IQueryable <carrot_ContentCategory> query = CompiledQueries.cqGetContentCategoryNoMatch(_db, SiteID, CategoryID, categorySlug); return(query.Count()); } }
public static int GetSimilar(Guid siteID, Guid rootSnippetID, string categorySlug) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { IQueryable <vw_carrot_ContentSnippet> query = CompiledQueries.cqGetContentSnippetNoMatch(_db, siteID, rootSnippetID, categorySlug); return(query.Count()); } }
public List <SiteData> GetSiteList() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { return((from m in _db.carrot_UserSiteMappings join s in _db.carrot_Sites on m.SiteID equals s.SiteID where m.UserId == this.UserId select new SiteData(s)).ToList()); } }
public static List <PostComment> GetCommentsByContentPage(Guid rootContentID, bool bActiveOnly) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { IQueryable <vw_carrot_Comment> lstComments = (from c in CannedQueries.GetContentPageComments(_db, rootContentID, bActiveOnly) select c); return(lstComments.Select(x => new PostComment(x)).ToList()); } }
public List <ExtendedUserData> GetMappedUsers() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { return((from l in _db.carrot_UserSiteMappings join u in _db.vw_carrot_UserDatas on l.UserId equals u.UserId where l.SiteID == this.SiteID select new ExtendedUserData(u)).ToList()); } }
public List <ContentSnippet> GetContentSnippetList() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { List <ContentSnippet> _types = (from d in CompiledQueries.cqGetSnippetsBySiteID(_db, this.SiteID) select new ContentSnippet(d)).ToList(); return(_types); } }
public static List <PostComment> GetAllCommentsBySite(Guid siteID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { IQueryable <PostComment> s = (from c in CannedQueries.GetSiteContentComments(_db, siteID) select new PostComment(c)); return(s.ToList()); } }
public static List <ContentSnippet> GetHistory(Guid rootSnippetID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { List <ContentSnippet> _types = (from d in CompiledQueries.cqGetSnippetVersionHistory(_db, rootSnippetID) select new ContentSnippet(d)).ToList(); return(_types); } }
public void ResetHeartbeatLock() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { carrot_RootContent rc = CompiledQueries.cqGetRootContentTbl(_db, this.SiteID, this.Root_ContentID); rc.EditHeartbeat = DateTime.UtcNow.AddHours(-2); rc.Heartbeat_UserId = null; _db.SubmitChanges(); } }
public void Save() { using (CarrotCMSDataContext db = CarrotCMSDataContext.GetDataContext()) { string xml = this.GetXml(); xml = xml.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", string.Empty); db.carrot_UpdateGoLiveLocal(this.SiteID, XElement.Parse(xml)); } }
public static int GetSiteCount(Guid siteID) { int iCt = -1; using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { iCt = CompiledQueries.cqGetContentTagCountBySiteID(_db, siteID); } return(iCt); }
public List <BasicContentData> GetFullSiteFileList() { List <BasicContentData> map = new List <BasicContentData>(); using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { IQueryable <vw_carrot_Content> queryAllFiles = CompiledQueries.cqGetAllContent(_db, this.SiteID); map = queryAllFiles.Select(x => new BasicContentData(x)).ToList(); } return(map); }
public void Save() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { carrot_Site s = CompiledQueries.cqGetSiteByID(_db, this.SiteID); bool bNew = false; if (s == null) { s = new carrot_Site(); if (this.SiteID == Guid.Empty) { this.SiteID = Guid.NewGuid(); } bNew = true; } // if updating the current site then blank out its cache if (CurrentSiteID == this.SiteID) { CurrentSite = null; } s.SiteID = this.SiteID; s.TimeZone = this.TimeZoneIdentifier; FixMeta(); s.MetaKeyword = this.MetaKeyword.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ").Replace(" ", " "); s.MetaDescription = this.MetaDescription.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ").Replace(" ", " "); s.SiteName = this.SiteName; s.SiteTagline = this.SiteTagline; s.SiteTitlebarPattern = this.SiteTitlebarPattern; s.MainURL = this.MainURL; s.BlockIndex = this.BlockIndex; s.SendTrackbacks = this.SendTrackbacks; s.AcceptTrackbacks = this.AcceptTrackbacks; s.Blog_FolderPath = ContentPageHelper.ScrubSlug(this.Blog_FolderPath); s.Blog_CategoryPath = ContentPageHelper.ScrubSlug(this.Blog_CategoryPath); s.Blog_TagPath = ContentPageHelper.ScrubSlug(this.Blog_TagPath); s.Blog_EditorPath = ContentPageHelper.ScrubSlug(this.Blog_EditorPath); s.Blog_DatePath = ContentPageHelper.ScrubSlug(this.Blog_DatePath); s.Blog_Root_ContentID = this.Blog_Root_ContentID; s.Blog_DatePattern = String.IsNullOrEmpty(this.Blog_DatePattern) ? "yyyy/MM/dd" : this.Blog_DatePattern; if (bNew) { _db.carrot_Sites.InsertOnSubmit(s); } _db.SubmitChanges(); } }
public void RecordHeartbeatLock(Guid currentUserID) { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { carrot_RootContent rc = CompiledQueries.cqGetRootContentTbl(_db, this.SiteID, this.Root_ContentID); rc.Heartbeat_UserId = currentUserID; rc.EditHeartbeat = DateTime.UtcNow; _db.SubmitChanges(); } }