예제 #1
0
        public void RemoveObsoletePages(CmsPage page)
        {
            CmsPageDao dao = new CmsPageDao();

            IList<CmsPage> unapproved = dao.FindUnapprovedPages(Data.Guid.New(page.SubscriptionId),Data.Hash.New(page.UrlHash));
            IList<CmsPage> approved = dao.FindApprovedPages(Data.Guid.New(page.SubscriptionId), Data.Hash.New(page.UrlHash));

            IStorageClient client = StorageHelper.GetStorageClient();
            String container = SiteHelper.GetStorageKey(SiteHelper.PageContainerKey, page.SubscriptionId);

            //Loop through all of the unapproved pages and remove any old versions.
            //Start at the first one, since we always want to leave the latest unapproved version
            using (Transaction tx = new Transaction())
            {
                for (int i = 1; i < unapproved.Count; i++)
                {
                    client.Delete(container, StorageClientConst.RootFolder, unapproved[i].Guid);
                    dao.Delete<CmsPage>(unapproved[i]);
                }
                tx.Commit();
            }

            //Loop through all of the approved pages and remove any old versions.
            //Start at the first one, since we always want to leave the latest approved version
            using (Transaction tx = new Transaction())
            {
                for (int i = 1; i < approved.Count; i++)
                {
                    client.Delete(container, StorageClientConst.RootFolder, approved[i].Guid);
                    dao.Delete<CmsPage>(approved[i]);
                }
                tx.Commit();
            }
        }
예제 #2
0
        /// <summary>
        /// Removes all versions of the page
        /// </summary>
        /// <param name="page"></param>
        public void DeleteAll(CmsPage page)
        {
            if (page != null)
            {
                String container = SiteHelper.GetStorageKey(SiteHelper.PageContainerKey, page.SubscriptionId);

                IStorageClient client = StorageHelper.GetStorageClient();
                CmsPageDao dao = new CmsPageDao();

                IList<CmsPage> pages = dao.FindAllPages(Data.Guid.New(page.SubscriptionId), Data.Hash.New(page.UrlHash));
                using (Transaction tx = new Transaction())
                {
                    foreach (CmsPage temp in pages)
                    {
                        client.Delete(container, StorageClientConst.RootFolder, temp.Guid);
                        dao.Delete<CmsPage>(temp);
                    }
                    tx.Commit();
                }
            }

            CmsSitePath path = CmsSiteMap.Instance.GetPath(page.SubscriptionId,page.Url);
            if (path != null)
                CmsSiteMap.Instance.Remove(path);
        }
예제 #3
0
        public void Remove(CmsPage page)
        {
            if (page != null)
            {
                String container = SiteHelper.GetStorageKey(SiteHelper.PageContainerKey, page.SubscriptionId);

                IStorageClient client = StorageHelper.GetStorageClient();
                CmsPageDao dao = new CmsPageDao();
                using (Transaction tx = new Transaction())
                {
                    client.Delete(container, StorageClientConst.RootFolder, page.Guid);
                    dao.Delete<CmsPage>(page);
                    tx.Commit();
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Deletes a specific page from the system
        /// </summary>
        /// <param name="pageGuid"></param>
        public void Delete(Data.Guid siteGuid, Data.Guid pageGuid)
        {
            String container = SiteHelper.GetStorageKey(SiteHelper.PageContainerKey, siteGuid.Value);
            IStorageClient client = StorageHelper.GetStorageClient();
            CmsPageDao dao = new CmsPageDao();

            CmsPage page = GetPage(pageGuid, false);
            if (page != null)
            {
                if (!page.SubscriptionId.Equals(siteGuid.Value))
                    throw new ArgumentException("This page does not belong to the current subscription and can not be retrieved.");

                client.Delete(container, StorageClientConst.RootFolder, page.Guid);
                using (Transaction tx = new Transaction())
                {
                    dao.Delete<CmsPage>(page);
                    tx.Commit();
                }

                //Check if there are other versions of this page, if not, delete the sitepath as well
                IList<CmsPage> pages = GetPages(siteGuid, page.Url);
                if ((pages == null) || (pages.Count == 0))
                {
                    CmsSitePath path = CmsSiteMap.Instance.GetPath(page.Url);
                    if (path != null)
                        CmsSiteMap.Instance.Remove(path);
                }
            }
        }