Beispiel #1
0
        public void ExportSite()
        {
            SiteDto siteDto = CMSContext.Current.GetSitesDto(CmsConfiguration.Instance.ApplicationId);

            foreach (SiteDto.SiteRow siteRow in siteDto.Site)
            {
                FileStream         stream             = File.Create(String.Format(ResultsPath + "{0}.site", siteRow.Name));
                ImportExportHelper importExportHelper = new ImportExportHelper();
                importExportHelper.ExportSite(siteRow.SiteId, stream);
                stream.Close();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Does the export.
        /// </summary>
        private void DoExport(Guid appId)
        {
            AppContext.Current.ApplicationId = appId;

            try
            {
                string result = String.Empty;

                if (SiteId != Guid.Empty)
                {
                    // export site

                    StringBuilder filePath = new StringBuilder(Server.MapPath(ManagementHelper.GetImportExportFolderPath("site")));
                    filePath.AppendFormat("\\SiteExport_{0}_{1}_{2}.xml", SiteName.Replace(' ', '-'), DateTime.Now.ToString("yyyyMMdd_HHmmss"), System.Environment.MachineName);
                    FileStream fs = new FileStream(filePath.ToString(), FileMode.Create, FileAccess.ReadWrite);

                    try
                    {
                        PageDocument.Init(new SqlPageDocumentStorageProvider(), new SqlTemporaryStorageProvider());
                        _ImportExport = new Mediachase.Cms.ImportExport.ImportExportHelper();
                        _ImportExport.ImportExportProgressMessage += new SiteImportExportProgressMessageHandler(ImportExport_ImportExportProgressMessage);
                        _ImportExport.ExportSite(SiteId, fs);
                    }
                    catch (SiteImportExportException ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (fs != null)
                        {
                            fs.Close();
                        }

                        // refresh files grid
                        //FilesControl.DataBind();
                        //FilesPanel.Update();
                    }
                }
                else
                {
                    throw new Exception("SiteId is empty!");
                }
            }
            catch (Exception ex)
            {
                ProgressControl1.AddProgressMessageText(ex.Message, true, -1);
            }
            finally
            {
            }
        }
Beispiel #3
0
        public void ContentSystem_ImportExportSite()
        {
            Guid[] siteIDs;
            Guid   applicationId = AppContext.Current.ApplicationId;

            ImportExportHelper importExportHelper = new ImportExportHelper();

            //import data
            using (FileStream stream = File.Open("SiteExport-B2C.xml", FileMode.Open))
            {
                siteIDs = importExportHelper.ImportSite(stream, applicationId, Guid.Empty, false);
            }

            Guid siteId = siteIDs[0];

            FileStream fs = new FileStream("Content_SiteExport.xml", FileMode.Create, FileAccess.ReadWrite);

            importExportHelper.ExportSite(siteId, fs);

            SiteDto siteDto = CMSContext.Current.GetSiteDto(siteId);

            // delete menus
            MenuDto menuDto = MenuManager.GetMenuDto(siteId);

            if (menuDto.Menu.Rows.Count > 0)
            {
                foreach (MenuDto.MenuRow menuRow in menuDto.Menu.Rows)
                {
                    menuRow.Delete();
                }
            }

            if (menuDto.HasChanges())
            {
                MenuManager.SaveMenuDto(menuDto);
            }

            // delete folders and pages
            int rootId = FileTreeItem.GetRoot(siteId);

            FileTreeItem.DeleteFileItem(rootId);

            //delete site
            siteDto.Site[0].Delete();
            CMSContext.Current.SaveSite(siteDto);
        }