private BackupObject GetBackupObject(Action<ExportImportProgressInfo> progressCallback, bool handleBynaryData) { var retVal = new BackupObject(); var progressInfo = new ExportImportProgressInfo(); progressInfo.Description = "cms content loading..."; progressCallback(progressInfo); retVal.MenuLinkLists = _menuService.GetAllLinkLists().Select(x => x.ToWebModel()).ToList(); if (handleBynaryData) { var result = _contentStorageProvider.Search("/", null); foreach (var blobFolder in result.Folders.Where(x => _exportedFolders.Contains(x.Name))) { var contentFolder = new ContentFolder { Url = blobFolder.Url }; ReadContentFoldersRecurive(contentFolder); retVal.ContentFolders.Add(contentFolder); } } return retVal; }
private void ReadContentFoldersRecurive(ContentFolder folder) { var result = _contentStorageProvider.Search(folder.Url, null); foreach (var blobFolder in result.Folders) { //Do not export default theme its will distributed with code if (blobFolder.Url != "/Themes/default") { var contentFolder = new ContentFolder() { Url = blobFolder.Url }; ReadContentFoldersRecurive(contentFolder); folder.Folders.Add(contentFolder); } } foreach (var blobItem in result.Items) { var contentFile = new ContentFile { Url = blobItem.Url }; using (var stream = _contentStorageProvider.OpenRead(blobItem.Url)) { contentFile.Data = stream.ReadFully(); } folder.Files.Add(contentFile); } }
private void ReadContentFoldersRecurive(ContentFolder folder, Action<ExportImportProgressInfo> progressCallback) { var result = _contentStorageProvider.Search(folder.Url, null); foreach (var blobFolder in result.Folders) { //Do not export default theme its will distributed with code if (blobFolder.Url != "/Themes/default") { var contentFolder = new ContentFolder() { Url = blobFolder.Url }; ReadContentFoldersRecurive(contentFolder, progressCallback); folder.Folders.Add(contentFolder); } } foreach (var blobItem in result.Items) { var progressInfo = new ExportImportProgressInfo(); progressInfo.Description = String.Format("Read {0}", blobItem.Url); progressCallback(progressInfo); var contentFile = new ContentFile { Url = blobItem.Url }; using (var stream = _contentStorageProvider.OpenRead(blobItem.Url)) { contentFile.Data = stream.ReadFully(); } folder.Files.Add(contentFile); } }
private void SaveContentFolderRecursive(ContentFolder folder) { foreach (var childFolder in folder.Folders) { SaveContentFolderRecursive(childFolder); } foreach (var folderFile in folder.Files) { using (var stream = _contentStorageProvider.OpenWrite(folderFile.Url)) using (var memStream = new MemoryStream(folderFile.Data)) { memStream.CopyTo(stream); } } }
private void SaveContentFolderRecursive(ContentFolder folder, Action<ExportImportProgressInfo> progressCallback) { foreach (var childFolder in folder.Folders) { SaveContentFolderRecursive(childFolder, progressCallback); } foreach (var folderFile in folder.Files) { using (var stream = _contentStorageProvider.OpenWrite(folderFile.Url)) using (var memStream = new MemoryStream(folderFile.Data)) { var progressInfo = new ExportImportProgressInfo(); progressInfo.Description = String.Format("Saving {0}", folderFile.Url); progressCallback(progressInfo); memStream.CopyTo(stream); } } }