예제 #1
0
        public void SavePageEdit()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                SiteData site = SiteData.GetSiteFromCache(this.SiteID);

                if (this.Root_ContentID == Guid.Empty)
                {
                    this.Root_ContentID = Guid.NewGuid();
                }
                if (this.ContentID == Guid.Empty)
                {
                    this.ContentID = Guid.NewGuid();
                }
                if (this.Parent_ContentID == Guid.Empty)
                {
                    this.Parent_ContentID = null;
                }

                carrot_RootContent rc = CompiledQueries.cqGetRootContentTbl(_db, this.SiteID, this.Root_ContentID);

                carrot_Content oldC = CompiledQueries.cqGetLatestContentTbl(_db, this.SiteID, this.Root_ContentID);

                bool bNew = false;

                if (rc == null)
                {
                    rc = new carrot_RootContent();

                    PerformCommonSaveRoot(site, rc);

                    _db.carrot_RootContents.InsertOnSubmit(rc);
                    bNew = true;
                }

                carrot_Content c = new carrot_Content();
                c.ContentID = Guid.NewGuid();
                if (!bNew)
                {
                    oldC.IsLatestVersion = false;
                }

                PerformCommonSave(site, rc, c);

                _db.carrot_Contents.InsertOnSubmit(c);

                SaveKeywordsAndTags(_db);

                _db.SubmitChanges();

                SaveTrackbacks();
            }
        }
예제 #2
0
 internal static IQueryable <vw_carrot_Content> GetLatestContentByParent(CarrotCMSDataContext ctx, Guid siteID, string parentPage, bool bActiveOnly)
 {
     return(from ct in ctx.vw_carrot_Contents
            join cp in ctx.vw_carrot_ContentChilds on ct.Root_ContentID equals cp.Root_ContentID
            orderby ct.NavOrder, ct.NavMenuText
            where ct.SiteID == siteID &&
            cp.ParentFileName.ToLower() == parentPage.ToLower() &&
            ct.IsLatestVersion == true &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false)
            select ct);
 }
예제 #3
0
 internal static IQueryable <vw_carrot_Content> GetLatestBlogListDateRange(CarrotCMSDataContext ctx, Guid siteID, DateTime dateBegin, DateTime dateEnd, bool bActiveOnly)
 {
     return(from ct in ctx.vw_carrot_Contents
            where ct.SiteID == siteID &&
            ct.IsLatestVersion == true &&
            ct.GoLiveDate >= dateBegin &&
            ct.GoLiveDate <= dateEnd &&
            ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry) &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false)
            select ct);
 }
예제 #4
0
 internal static IQueryable <vw_carrot_Content> GetAllByTypeList(CarrotCMSDataContext ctx, Guid siteID, bool bActiveOnly, ContentPageType.PageType entryType)
 {
     return(from ct in ctx.vw_carrot_Contents
            orderby ct.NavOrder, ct.NavMenuText
            where ct.SiteID == siteID &&
            ct.IsLatestVersion == true &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false) &&
            ct.IsLatestVersion == true &&
            ct.ContentTypeID == ContentPageType.GetIDByType(entryType)
            select ct);
 }
예제 #5
0
 internal static IQueryable <vw_carrot_Content> GetLatestContentByParent(CarrotCMSDataContext ctx, Guid siteID, Guid?parentContentID, bool bActiveOnly)
 {
     return(from ct in ctx.vw_carrot_Contents
            orderby ct.NavOrder, ct.NavMenuText
            where ct.SiteID == siteID &&
            ct.Parent_ContentID == parentContentID &&
            ct.Parent_ContentID != null &&
            ct.IsLatestVersion == true &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false)
            select ct);
 }
        public static List <ContentCategory> BuildCategoryList(Guid rootContentID)
        {
            List <ContentCategory> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                IQueryable <vw_carrot_CategoryURL> query = CompiledQueries.cqGetContentCategoryByContentID(_db, rootContentID);

                _types = (from d in query.ToList()
                          select new ContentCategory(d)).ToList();
            }

            return(_types);
        }
예제 #7
0
        public static List <TrackBackEntry> GetPageTrackBackList(Guid rootContentID)
        {
            List <TrackBackEntry> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                IQueryable <vw_carrot_TrackbackQueue> query = CompiledQueries.cqGetTrackbackByRootID(_db, rootContentID);

                _types = (from d in query.ToList()
                          select new TrackBackEntry(d)).ToList();
            }

            return(_types);
        }
예제 #8
0
        public static List <ContentTag> BuildTagList(Guid rootContentID)
        {
            List <ContentTag> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                IQueryable <carrot_ContentTag> query = CompiledQueries.cqGetContentTagByContentID(_db, rootContentID);

                _types = (from d in query.ToList()
                          select new ContentTag(d)).ToList();
            }

            return(_types);
        }
예제 #9
0
        public void ApplyTemplate()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_Content c = CompiledQueries.cqGetLatestContentTbl(_db, this.SiteID, this.Root_ContentID);

                if (c != null)
                {
                    c.TemplateFile = this.TemplateFile;

                    _db.SubmitChanges();
                }
            }
        }
예제 #10
0
        public static List <TextWidget> GetSiteTextWidgets(Guid siteID)
        {
            List <TextWidget> _lst = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                IQueryable <carrot_TextWidget> query = CompiledQueries.cqTextWidgetBySiteID(_db, siteID);

                _lst = (from d in query.ToList()
                        select new TextWidget(d)).ToList();
            }

            return(_lst);
        }
예제 #11
0
        public static List <TrackBackEntry> FindTrackbackByURL(Guid rootContentID, string sURL)
        {
            List <TrackBackEntry> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <vw_carrot_TrackbackQueue> query = CompiledQueries.cqGetTrackbackByRootIDAndUrl(_db, rootContentID, sURL);

                _types = (from d in query.ToList()
                          select new TrackBackEntry(d)).ToList();
            }

            return(_types);
        }
예제 #12
0
        public static List <TrackBackEntry> GetTrackBackSiteQueue(Guid siteID)
        {
            List <TrackBackEntry> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <vw_carrot_TrackbackQueue> query = CompiledQueries.cqGetTrackbackBySiteIDUnTracked(_db, siteID);

                _types = (from d in query.ToList()
                          select new TrackBackEntry(d)).ToList();
            }

            return(_types);
        }
예제 #13
0
        internal static List <string> GetSiteDirectoryPaths()
        {
            List <string> lstContent = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                lstContent = (from ct in _db.vw_carrot_Contents
                              where ct.IsLatestVersion == true &&
                              ct.FileName.ToLower().EndsWith(SiteData.DefaultDirectoryFilename)
                              select ct.FileName.ToLower()).Distinct().ToList();
            }

            return(lstContent);
        }
예제 #14
0
        public static ContentSnippet GetSnippetBySlug(Guid siteID, string categorySlug, bool bActiveOnly)
        {
            ContentSnippet _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                vw_carrot_ContentSnippet query = CompiledQueries.GetLatestContentSnippetBySlug(_db, siteID, bActiveOnly, categorySlug);
                if (query != null)
                {
                    _item = new ContentSnippet(query);
                }
            }

            return(_item);
        }
예제 #15
0
        public static ContentTag Get(Guid TagID)
        {
            ContentTag _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_ContentTag query = CompiledQueries.cqGetContentTagByID(_db, TagID);
                if (query != null)
                {
                    _item = new ContentTag(query);
                }
            }

            return(_item);
        }
예제 #16
0
        public static TextWidget Get(Guid textWidgetID)
        {
            TextWidget _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_TextWidget query = CompiledQueries.cqTextWidgetByID(_db, textWidgetID);
                if (query != null)
                {
                    _item = new TextWidget(query);
                }
            }

            return(_item);
        }
예제 #17
0
        public static ContentCategory Get(Guid CategoryID)
        {
            ContentCategory _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_ContentCategory query = CompiledQueries.cqGetContentCategoryByID(_db, CategoryID);
                if (query != null)
                {
                    _item = new ContentCategory(query);
                }
            }

            return(_item);
        }
예제 #18
0
        public static ContentSnippet Get(Guid rootSnippetID)
        {
            ContentSnippet _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_ContentSnippet query = CompiledQueries.cqGetLatestSnippetVersion(_db, rootSnippetID);
                if (query != null)
                {
                    _item = new ContentSnippet(query);
                }
            }

            return(_item);
        }
예제 #19
0
        public static ContentEditor Get(Guid SiteID, Guid UserID)
        {
            ContentEditor _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_EditorURL query = CompiledQueries.cqGetContentEditorByID(_db, SiteID, UserID);
                if (query != null)
                {
                    _item = new ContentEditor(query);
                }
            }

            return(_item);
        }
예제 #20
0
        public static List <MembershipUser> GetUserSearch(string searchTerm)
        {
            List <MembershipUser> usrs = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                usrs = (from u in _db.aspnet_Users
                        join m in _db.aspnet_Memberships on u.UserId equals m.UserId
                        where u.UserName.Contains(searchTerm) ||
                        m.Email.Contains(searchTerm)
                        select Membership.GetUser(u.UserName)).Take(50).ToList();
            }

            return(usrs);
        }
예제 #21
0
        public static ContentTag GetByURL(Guid SiteID, string requestedURL)
        {
            ContentTag _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                vw_carrot_TagURL query = CompiledQueries.cqGetContentTagByURL(_db, SiteID, requestedURL);
                if (query != null)
                {
                    _item = new ContentTag(query);
                }
            }

            return(_item);
        }
예제 #22
0
        public static ContentEditor GetByURL(Guid SiteID, string requestedURL)
        {
            ContentEditor _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_EditorURL query = CompiledQueries.cqGetContentEditorURL(_db, SiteID, requestedURL);
                if (query != null)
                {
                    _item = new ContentEditor(query);
                }
            }

            return(_item);
        }
예제 #23
0
        public static ContentSnippet GetVersion(Guid snippetDataID)
        {
            ContentSnippet _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                vw_carrot_ContentSnippet query = CompiledQueries.cqGetSnippetVersionByID(_db, snippetDataID);
                if (query != null)
                {
                    _item = new ContentSnippet(query);
                }
            }

            return(_item);
        }
예제 #24
0
        public static ContentSnippet GetSnippetByID(Guid siteID, Guid rootSnippetID, bool bActiveOnly)
        {
            ContentSnippet _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_ContentSnippet query = CompiledQueries.GetLatestContentSnippetByID(_db, siteID, bActiveOnly, rootSnippetID);
                if (query != null)
                {
                    _item = new ContentSnippet(query);
                }
            }

            return(_item);
        }
예제 #25
0
        public Guid GetCurrentEditUser()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_RootContentSnippet rc = CompiledQueries.cqGetSnippetDataTbl(_db, this.SiteID, this.Root_ContentSnippetID);

                if (rc != null)
                {
                    return((Guid)rc.Heartbeat_UserId);
                }
                else
                {
                    return(Guid.Empty);
                }
            }
        }
예제 #26
0
        public static string GetSerialized(Guid itemID, string sKey)
        {
            string sData = String.Empty;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_SerialCache itm = CompiledQueries.SearchSeriaCache(_db, itemID, sKey);

                if (itm != null)
                {
                    sData = itm.SerializedData;
                }
            }

            return(sData);
        }
예제 #27
0
 internal static IQueryable <vw_carrot_Content> GetContentByCategoryURL(CarrotCMSDataContext ctx, Guid siteID, bool bActiveOnly, string sCatURL)
 {
     return(from c in ctx.vw_carrot_CategoryURLs
            join m in ctx.carrot_CategoryContentMappings on c.ContentCategoryID equals m.ContentCategoryID
            join ct in ctx.vw_carrot_Contents on m.Root_ContentID equals ct.Root_ContentID
            where c.SiteID == siteID &&
            ct.SiteID == siteID &&
            c.CategoryUrl.ToLower() == sCatURL.ToLower() &&
            ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry) &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false) &&
            ct.IsLatestVersion == true
            select ct);
 }
예제 #28
0
		public void Delete() {
			using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
				carrot_ContentCategory s = CompiledQueries.cqGetContentCategoryByID(_db, this.ContentCategoryID);

				if (s != null) {
					IQueryable<carrot_CategoryContentMapping> lst = (from m in _db.carrot_CategoryContentMappings
																	 where m.ContentCategoryID == s.ContentCategoryID
																	 select m);

					_db.carrot_CategoryContentMappings.BatchDelete(lst);
					_db.carrot_ContentCategories.DeleteOnSubmit(s);
					_db.SubmitChanges();
				}
			}
		}
예제 #29
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);
         }
     }
 }
예제 #30
0
        public ExtendedUserData GetCurrentEditUserData()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                carrot_RootContentSnippet rc = CompiledQueries.cqGetSnippetDataTbl(_db, this.SiteID, this.Root_ContentSnippetID);

                if (rc != null)
                {
                    return(new ExtendedUserData((Guid)rc.Heartbeat_UserId));
                }
                else
                {
                    return(null);
                }
            }
        }