示例#1
0
 public void SavePage(string storeId, TildaPage page)
 {
     using (var targetStream = _storageProvider.OpenWrite($"Pages/{storeId}/{page.FileName}"))
     {
         var sw = new StreamWriter(targetStream);
         sw.Write(page.Html);
     }
 }
        private void SavePages(VirtoData virtoData, ShopifyImportParams importParams, ShopifyImportNotification notification)
        {
            notification.Description = "Saving pages";
            _notifier.Upsert(notification);

            var pageBasePath = "/Pages/" + importParams.StoreId + "/";

            foreach (var page in virtoData.Pages)
            {
                var pageUrl = pageBasePath + page.Title + ".md";
                using (var targetStream = _contentStorageProvider.OpenWrite(pageUrl))
                {
                    // convert string to stream
                    byte[] byteArray = Encoding.UTF8.GetBytes(page.BodyHtml);
                    using (var sourceStream = new MemoryStream(byteArray))
                    {
                        sourceStream.CopyTo(targetStream);
                    }
                }
                notification.Progresses[PagesKey].ProcessedCount++;
                _notifier.Upsert(notification);
            }
        }
示例#3
0
 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);
             }
     }
 }