Exemplo n.º 1
0
        //========================
        public static string GetGalleryExportXML(Guid siteID, List <Guid> GalleryIDs)
        {
            GalleryExportList lstGE = new GalleryExportList();

            lstGE.ExportDate        = SiteData.CurrentSite.Now;
            lstGE.CarrotCakeVersion = SiteData.CarrotCakeCMSVersion;
            lstGE.OriginalSite      = SiteData.GetSiteFromCache(siteID);

            GalleryHelper gh = new GalleryHelper(siteID);

            foreach (Guid galleryID in GalleryIDs)
            {
                GalleryExport ge  = new GalleryExport();
                GalleryGroup  gal = gh.GalleryGroupGetByID(galleryID);

                ge.TheGallery        = gal;
                ge.OriginalGalleryID = gal.GalleryID;
                ge.ExportDate        = SiteData.CurrentSite.Now;
                ge.CarrotCakeVersion = SiteData.CarrotCakeCMSVersion;

                lstGE.TheGalleries.Add(ge);
            }

            return(ContentImportExportUtils.GetExportXML <GalleryExportList>(lstGE));
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            guidContentID = GetGuidIDFromQuery();

            guidNodeID = GetGuidParameterFromQuery("node");

            if (!String.IsNullOrEmpty(Request.QueryString["comment"]))
            {
                bExportComments = true;
            }

            if (!String.IsNullOrEmpty(Request.QueryString["datebegin"]))
            {
                dateBegin = Convert.ToDateTime(Request.QueryString["datebegin"].ToString()).Date;
            }
            if (!String.IsNullOrEmpty(Request.QueryString["dateend"]))
            {
                dateEnd = Convert.ToDateTime(Request.QueryString["dateend"].ToString()).Date;
            }
            if (!String.IsNullOrEmpty(Request.QueryString["exportwhat"]))
            {
                ExportWhat = (SiteExport.ExportType)Enum.Parse(typeof(SiteExport.ExportType), Request.QueryString["exportwhat"].ToString(), true);;
            }

            string theXML   = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
            string fileName = "export.xml";

            if (guidContentID != Guid.Empty)
            {
                ContentPageExport content = ContentImportExportUtils.GetExportPage(SiteData.CurrentSiteID, guidContentID);
                theXML = ContentImportExportUtils.GetExportXML <ContentPageExport>(content);

                fileName = "page_" + content.ThePage.NavMenuText + "_" + guidContentID.ToString();
            }
            else
            {
                SiteExport site = ContentImportExportUtils.GetExportSite(SiteData.CurrentSiteID, ExportWhat);

                site.ThePages.RemoveAll(x => x.ThePage.GoLiveDate < dateBegin);
                site.ThePages.RemoveAll(x => x.ThePage.GoLiveDate > dateEnd);

                if (guidNodeID != Guid.Empty)
                {
                    List <Guid> lst = pageHelper.GetPageHierarchy(SiteData.CurrentSiteID, guidNodeID);
                    site.ThePages.RemoveAll(x => !lst.Contains(x.OriginalRootContentID) && x.ThePage.ContentType == ContentPageType.PageType.ContentEntry);
                }

                if (ExportWhat == SiteExport.ExportType.BlogData)
                {
                    site.ThePages.RemoveAll(x => x.ThePage.ContentType == ContentPageType.PageType.ContentEntry);
                }
                if (ExportWhat == SiteExport.ExportType.ContentData)
                {
                    site.ThePages.RemoveAll(x => x.ThePage.ContentType == ContentPageType.PageType.BlogEntry);
                }

                if (bExportComments)
                {
                    site.LoadComments();
                }

                theXML = ContentImportExportUtils.GetExportXML <SiteExport>(site);

                fileName = "site_" + site.TheSite.SiteName + "_" + site.TheSite.SiteID.ToString();
            }

            fileName = fileName + "-" + SiteData.CurrentSite.Now.ToString("yyyy-MM-dd") + ".xml";

            fileName = fileName.Replace(" ", "_");

            Response.Expires     = 5;
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName));

            Response.Write(theXML);

            Response.StatusCode        = 200;
            Response.StatusDescription = "OK";
            Response.End();
        }