Esempio n. 1
0
        public void Localize(Models.Page o, Models.Site targetSite)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();

            LocalizeWithChildPages(serviceContext, o, targetSite);
            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 2
0
 private IEnumerable <Page> QueryBySite(Site site)
 {
     return(CloudTableHelper.GetTableServiceContext().CreateQuery <PageEntity>(PageTable)
            .Where(it => it.PartitionKey == site.FullName && it.ParentPage == "")
            .ToArray()
            .Select(it => PageEntityHelper.ToPage(it)));
 }
Esempio n. 3
0
 private IEnumerable <HtmlBlock> QueryBySite(Site site)
 {
     return(CloudTableHelper.GetTableServiceContext().CreateQuery <HtmlBlockEntity>(HtmlBlockTable)
            .Where(it => it.PartitionKey == site.FullName)
            .ToArray()
            .Select(it => it.ToHtmlBlock()));
 }
Esempio n. 4
0
 public IQueryable <ElementCategory> Categories()
 {
     return(CloudTableHelper.GetTableServiceContext().CreateQuery <CategoryEntity>(LabelCategoryTable)
            .Where(it => it.PartitionKey == SiteName)
            .ToArray()
            .Select(it => it.ToElementCategory())
            .AsQueryable());
 }
Esempio n. 5
0
 public IQueryable <Models.Page> ChildPages(Models.Page parentPage)
 {
     return(CloudTableHelper.GetTableServiceContext().CreateQuery <PageEntity>(PageTable)
            .Where(it => it.PartitionKey == parentPage.Site.FullName && it.ParentPage == parentPage.FullName)
            .ToArray()
            .Select(it => PageEntityHelper.ToPage(it))
            .AsQueryable());
 }
Esempio n. 6
0
        public void AddCategory(string category, string culture)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entity         = new CategoryEntity(SiteName, category);

            serviceContext.AddObject(LabelCategoryTable, entity);
            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 7
0
        public Models.HtmlBlock Get(Models.HtmlBlock dummy)
        {
            var entity = CloudTableHelper.GetTableServiceContext().CreateQuery <HtmlBlockEntity>(HtmlBlockTable)
                         .Where(it => it.PartitionKey == dummy.Site.FullName && it.RowKey == dummy.Name)
                         .FirstOrDefault();

            return(entity == null ? null : entity.ToHtmlBlock());
        }
Esempio n. 8
0
        public void Move(Models.Site site, string pageFullName, string newParent)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();

            MovePageRecursively(site, pageFullName, newParent, serviceContext);

            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 9
0
        public Models.Page Get(Models.Page dummy)
        {
            var entity = CloudTableHelper.GetTableServiceContext().CreateQuery <PageEntity>(PageTable)
                         .Where(it => it.PartitionKey == dummy.Site.FullName && it.RowKey == dummy.FullName)
                         .FirstOrDefault();

            return(PageEntityHelper.ToPage(entity));
        }
Esempio n. 10
0
        public Models.User Get(Models.User dummy)
        {
            var entity = CloudTableHelper.GetTableServiceContext().CreateQuery <SiteUserEntity>(SiteUsersTable)
                         .Where(it => it.SiteName == dummy.Site.FullName && it.UserName == dummy.UserName)
                         .FirstOrDefault();

            return(entity == null ? null : SiteUserHelper.ToUser(entity));
        }
Esempio n. 11
0
 public IEnumerable <Models.User> All(Models.Site site)
 {
     return(CloudTableHelper.GetTableServiceContext().CreateQuery <SiteUserEntity>(SiteUsersTable)
            .Where(it => it.SiteName == site.FullName)
            .ToArray()
            .Select(it => SiteUserHelper.ToUser(it))
            .AsQueryable());
 }
Esempio n. 12
0
 private IQueryable <Page> AllPagesNested(Site site)
 {
     return(CloudTableHelper.GetTableServiceContext().CreateQuery <PageEntity>(PageTable)
            .Where(it => it.SiteName == site.FullName)
            .ToArray()
            .Select(it => PageEntityHelper.ToPage(it))
            .AsQueryable());
 }
Esempio n. 13
0
        public Models.Page GetDefaultPage(Models.Site site)
        {
            var entity = CloudTableHelper.GetTableServiceContext().CreateQuery <PageEntity>(PageTable)
                         .Where(it => it.PartitionKey == site.FullName)
                         .Where(it => it.IsDefault == true)
                         .FirstOrDefault();

            return(PageEntityHelper.ToPage(entity));
        }
Esempio n. 14
0
        public Element Get(string name, string category, string culture)
        {
            var entity = new LabelEntity(SiteName, name, "", category);

            return(CloudTableHelper.GetTableServiceContext().CreateQuery <LabelEntity>(LabelTable)
                   .Where(it => it.PartitionKey == entity.SiteName && it.RowKey == entity.RowKey)
                   .ToArray()
                   .Select(it => it.ToElement())
                   .FirstOrDefault());
        }
Esempio n. 15
0
        public void Clear(Site site)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entities       = serviceContext.CreateQuery <HtmlBlockEntity>(HtmlBlockTable)
                                 .Where(it => it.PartitionKey == site.FullName);

            foreach (var item in entities)
            {
                serviceContext.DeleteObject(item);
            }
            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 16
0
        public void Localize(Models.HtmlBlock o, Models.Site targetSite)
        {
            var htmlBlock = Get(o);
            var entity    = new HtmlBlockEntity(htmlBlock);

            entity.SiteName = targetSite.FullName;

            var serviceContext = CloudTableHelper.GetTableServiceContext();

            serviceContext.AddObject(HtmlBlockTable, entity);
            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 17
0
        public void Clear()
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entities       = serviceContext.CreateQuery <LabelEntity>(LabelTable)
                                 .Where(it => it.SiteName == SiteName);

            foreach (var item in entities)
            {
                serviceContext.DeleteObject(item);
            }
            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 18
0
        public void Remove(Models.HtmlBlock item)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entity         = serviceContext.CreateQuery <HtmlBlockEntity>(HtmlBlockTable)
                                 .Where(it => it.PartitionKey == item.Site.FullName && it.RowKey == item.Name)
                                 .FirstOrDefault();

            if (entity != null)
            {
                serviceContext.DeleteObject(entity);
                serviceContext.SaveChangesWithRetries();
            }
        }
Esempio n. 19
0
        public void RemoveDraft(Models.Page page)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entity         = serviceContext.CreateQuery <PageEntity>(PageDraftTable)
                                 .Where(it => it.PartitionKey == page.Site.FullName && it.RowKey == page.FullName)
                                 .Select(it => PageEntityHelper.ToPage(it)).FirstOrDefault();

            if (entity != null)
            {
                serviceContext.DeleteObject(entity);
                serviceContext.SaveChangesWithRetries();
            }
        }
Esempio n. 20
0
        public void Remove(Models.Page item)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entity         = serviceContext.CreateQuery <PageEntity>(PageTable)
                                 .Where(it => it.PartitionKey == item.Site.FullName && it.RowKey == item.FullName)
                                 .FirstOrDefault();

            if (entity != null)
            {
                RemovePageWithChildPages(serviceContext, entity);

                serviceContext.SaveChangesWithRetries();
            }
        }
Esempio n. 21
0
        public bool Remove(Element element)
        {
            var entity         = new LabelEntity(SiteName, element);
            var serviceContext = CloudTableHelper.GetTableServiceContext();

            entity = serviceContext.CreateQuery <LabelEntity>(LabelTable)
                     .Where(it => it.PartitionKey == SiteName && it.RowKey == entity.RowKey)
                     .FirstOrDefault();
            if (entity != null)
            {
                serviceContext.DeleteObject(entity);
                serviceContext.SaveChangesWithRetries();
            }
            return(true);
        }
Esempio n. 22
0
        private void InsertOrUpdate(Models.User @new, Models.User old)
        {
            var entity         = SiteUserHelper.ToEntity(@new);
            var serviceContext = CloudTableHelper.GetTableServiceContext();

            if (Get(old) == null)
            {
                serviceContext.AddObject(SiteUsersTable, entity);
            }
            else
            {
                serviceContext.AttachTo(SiteUsersTable, entity, "*");
                serviceContext.UpdateObject(entity);
            }
            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 23
0
        private void InsertOrUpdate(Models.HtmlBlock @new, Models.HtmlBlock old)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entity         = new HtmlBlockEntity(@new);

            if (Get(old) == null)
            {
                serviceContext.AddObject(HtmlBlockTable, entity);
            }
            else
            {
                serviceContext.AttachTo(HtmlBlockTable, entity, "*");
                serviceContext.UpdateObject(entity);
            }
            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 24
0
        public void SaveAsDraft(Models.Page page)
        {
            var entity         = PageEntityHelper.ToPageEntity(page);
            var serviceContext = CloudTableHelper.GetTableServiceContext();

            if (GetDraft(page) != null)
            {
                serviceContext.AttachTo(PageDraftTable, entity);
                serviceContext.UpdateObject(entity);
            }
            else
            {
                serviceContext.AddObject(PageDraftTable, entity);
            }

            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 25
0
        private void InsertOrUpdate(Models.Page @new, Models.Page old)
        {
            @new.OnSaving();

            var entity         = PageEntityHelper.ToPageEntity(@new);
            var serviceContext = CloudTableHelper.GetTableServiceContext();

            if (Get(old) == null)
            {
                serviceContext.AddObject(PageTable, entity);
            }
            else
            {
                serviceContext.AttachTo(PageTable, entity, "*");
                serviceContext.UpdateObject(entity);
            }
            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 26
0
        public Models.Page Copy(Models.Site site, string sourcePageFullName, string newPageFullName)
        {
            var page    = Get(new Page(site, sourcePageFullName));
            var newPage = new Page(site, newPageFullName);
            var entity  = PageEntityHelper.ToPageEntity(page);

            entity.FullName = newPageFullName;
            if (newPage.Parent != null)
            {
                entity.ParentPage = newPage.Parent.FullName;
            }

            var serviceContext = CloudTableHelper.GetTableServiceContext();

            serviceContext.AddObject(PageTable, entity);
            serviceContext.SaveChangesWithRetries();

            return(PageEntityHelper.ToPage(entity));
        }
Esempio n. 27
0
        private void LocalizeWithChildPages(TableServiceContext serviceContext, Page page, Site targetSite)
        {
            var entity = CloudTableHelper.GetTableServiceContext().CreateQuery <PageEntity>(PageTable)
                         .Where(it => it.PartitionKey == targetSite.FullName && it.RowKey == page.FullName)
                         .FirstOrDefault();

            if (entity == null)
            {
                page            = Get(page);
                entity          = PageEntityHelper.ToPageEntity(page);
                entity.SiteName = targetSite.FullName;
                serviceContext.AddObject(PageTable, entity);

                foreach (var item in ChildPages(page))
                {
                    LocalizeWithChildPages(serviceContext, item, targetSite);
                }
            }
        }
Esempio n. 28
0
        private void InsertOrUpdateLabel(Element @new, Element old)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entity         = new LabelEntity(SiteName, @new);

            if (Get(old.Name, old.Category, old.Culture) == null)
            {
                if (!string.IsNullOrEmpty(@new.Category))
                {
                    AddCategory(@new.Category, @new.Culture);
                }
                serviceContext.AddObject(LabelTable, entity);
            }
            else
            {
                serviceContext.AttachTo(LabelTable, entity, "*");
                serviceContext.UpdateObject(entity);
            }
            serviceContext.SaveChangesWithRetries();
        }
Esempio n. 29
0
        public bool RemoveCategory(string category, string culture)
        {
            var serviceContext = CloudTableHelper.GetTableServiceContext();
            var entity         = serviceContext.CreateQuery <CategoryEntity>(LabelCategoryTable)
                                 .Where(it => it.PartitionKey == SiteName && it.RowKey == category)
                                 .FirstOrDefault();

            if (entity != null)
            {
                serviceContext.DeleteObject(entity);

                var labels = serviceContext.CreateQuery <LabelEntity>(LabelTable)
                             .Where(it => it.PartitionKey == SiteName && it.Category == category);
                foreach (var item in labels)
                {
                    serviceContext.DeleteObject(item);
                }

                serviceContext.SaveChangesWithRetries();
            }
            return(true);
        }