Example #1
0
        private SiteExport ExportObject(int SiteID)
        {
            var _Model = new SiteExport();

            _Model.Site     = Get(SiteID);
            _Model.Cultures = new CultureBLL().Get(SiteID);
            _Model.Pages    = new PageBLL().GetWithCultures(SiteID);
            _Model.Content  = new ContentBLL().Export(SiteID);
            return(_Model);
        }
Example #2
0
        private int ImportObject(SiteExport SiteContent)
        {
            var _Site = new SiteAllBinding(SiteContent.Site, SiteContent.Cultures);

            _Site.SiteID = 0;
            var _SiteID = Save(_Site);

            ImportSavePages(SiteContent.Pages, _SiteID, 0);
            ImportSaveContent(SiteContent.Content, _SiteID, 0);
            return(_SiteID);
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            guidImportID = GetGuidParameterFromQuery("importid");

            litMessage.Text = "";

            iPageCount = pageHelper.GetSitePageCount(SiteID, ContentPageType.PageType.ContentEntry);

            if (guidImportID != Guid.Empty)
            {
                exSite = ContentImportExportUtils.GetSerializedSiteExport(guidImportID);

                litName.Text         = exSite.TheSite.SiteName;
                litDescription.Text  = exSite.TheSite.SiteTagline;
                litImportSource.Text = exSite.CarrotCakeVersion;
                litDate.Text         = exSite.ExportDate.ToString();

                if (!IsPostBack)
                {
                    BindData();
                }
            }
        }
Example #4
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();
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            string sXML = "";

            if (upFile.HasFile)
            {
                using (StreamReader sr = new StreamReader(upFile.FileContent)) {
                    sXML = sr.ReadToEnd();
                }
            }
            string sTest = "";

            if (!String.IsNullOrEmpty(sXML) && sXML.Length > 500)
            {
                sTest = sXML.Substring(0, 250).ToLower();

                try {
                    if (sTest.Contains("<contentpageexport xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/xmlschema\">"))
                    {
                        ContentPageExport cph = ContentImportExportUtils.DeserializeContentPageExport(sXML);
                        ContentImportExportUtils.AssignContentPageExportNewIDs(cph);
                        ContentImportExportUtils.SaveSerializedDataExport <ContentPageExport>(cph.NewRootContentID, cph);

                        if (cph.ThePage.ContentType == ContentPageType.PageType.ContentEntry)
                        {
                            Response.Redirect(SiteFilename.PageAddEditURL + "?importid=" + cph.NewRootContentID.ToString());
                        }
                        else
                        {
                            Response.Redirect(SiteFilename.BlogPostAddEditURL + "?importid=" + cph.NewRootContentID.ToString());
                        }
                    }

                    if (sTest.Contains("<siteexport xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/xmlschema\">"))
                    {
                        SiteExport site = ContentImportExportUtils.DeserializeSiteExport(sXML);
                        ContentImportExportUtils.AssignSiteExportNewIDs(site);
                        ContentImportExportUtils.SaveSerializedDataExport <SiteExport>(site.NewSiteID, site);

                        Response.Redirect(SiteFilename.SiteImportURL + "?importid=" + site.NewSiteID.ToString());
                    }

                    if (sXML.Contains("<channel>") && sXML.Contains("<rss"))
                    {
                        int iChnl = sXML.IndexOf("<channel>");
                        sTest = sXML.Substring(0, iChnl).ToLower();
                    }

                    if (sTest.Contains("<!-- this is a wordpress extended rss file generated by wordpress as an export of your") &&
                        sTest.Contains("http://purl.org/rss") &&
                        sTest.Contains("http://wordpress.org/export"))
                    {
                        WordPressSite wps = ContentImportExportUtils.DeserializeWPExport(sXML);
                        ContentImportExportUtils.AssignWPExportNewIDs(SiteData.CurrentSite, wps);
                        ContentImportExportUtils.SaveSerializedDataExport <WordPressSite>(wps.NewSiteID, wps);

                        Response.Redirect(SiteFilename.WPSiteImportURL + "?importid=" + wps.NewSiteID.ToString());
                    }

                    lblWarning.Text = "File did not appear to match an expected format.";
                    lblWarning.Attributes["style"] = "color: #990000;";
                } catch (Exception ex) {
                    lblWarning.Text = ex.ToString();
                    lblWarning.Attributes["style"] = "color: #990000;";
                }
            }
            else
            {
                lblWarning.Text = "No file appeared in the upload queue.";
                lblWarning.Attributes["style"] = "color: #990000;";
            }
        }