本文整理汇总了C#中Stream.DeserializeJson方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.DeserializeJson方法的具体用法?C# Stream.DeserializeJson怎么用?C# Stream.DeserializeJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.DeserializeJson方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
var originalObject = GetBackupObject(progressCallback);
var progressInfo = new ExportImportProgressInfo();
progressInfo.Description = String.Format("{0} promotions importing...", backupObject.Promotions.Count());
progressCallback(progressInfo);
UpdatePromotions(originalObject.Promotions, backupObject.Promotions);
progressInfo.Description = String.Format("{0} folders importing...", backupObject.ContentFolders.Count());
progressCallback(progressInfo);
UpdateContentFolders(originalObject.ContentFolders, backupObject.ContentFolders);
progressInfo.Description = String.Format("{0} places importing...", backupObject.ContentPlaces.Count());
progressCallback(progressInfo);
UpdateContentPlaces(originalObject.ContentPlaces, backupObject.ContentPlaces);
progressInfo.Description = String.Format("{0} contents importing...", backupObject.ContentItems.Count());
progressCallback(progressInfo);
UpdateContentItems(originalObject.ContentItems, backupObject.ContentItems);
progressInfo.Description = String.Format("{0} publications importing...", backupObject.ContentPublications.Count());
progressCallback(progressInfo);
UpdateContentPublications(originalObject.ContentPublications, backupObject.ContentPublications);
}
示例2: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
_inventoryService.UpsertInventories(backupObject.InventoryInfos);
progressCallback(new ExportImportProgressInfo("update inventory done"));
}
示例3: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
backupObject.FulfillmentCenters.ForEach(x => _commerceService.UpsertFulfillmentCenter(x));
progressCallback(new ExportImportProgressInfo("update fulfillmentCenters done"));
}
示例4: DoImport
public void DoImport(Stream backupStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var progressInfo = new ExportImportProgressInfo();
var backupObject = backupStream.DeserializeJson<BackupObject>();
var originalObject = GetBackupObject(progressCallback, false);
progressInfo.Description = String.Format("{0} catalogs importing...", backupObject.Catalogs.Count());
progressCallback(progressInfo);
UpdateCatalogs(originalObject.Catalogs, backupObject.Catalogs);
progressInfo.Description = String.Format("{0} categories importing...", backupObject.Categories.Count());
progressCallback(progressInfo);
//Categories should be sorted right way
//first need to create virtual categories
var orderedCategories = backupObject.Categories.Where(x=>x.Catalog.Virtual)
.OrderBy(x => x.Parents != null ? x.Parents.Count() : 0)
.ToList();
//second need to create physical categories
orderedCategories.AddRange(backupObject.Categories.Where(x => !x.Catalog.Virtual)
.OrderBy(x => x.Parents != null ? x.Parents.Count() : 0));
backupObject.Products = backupObject.Products.OrderBy(x => x.MainProductId).ToList();
UpdateCategories(originalObject.Categories, orderedCategories);
UpdateProperties(originalObject.Properties, backupObject.Properties);
//Binary data
if (manifest.HandleBinaryData)
{
var allBackupImages = backupObject.Products.SelectMany(x => x.Images);
allBackupImages = allBackupImages.Concat(backupObject.Categories.SelectMany(x => x.Images));
allBackupImages = allBackupImages.Concat(backupObject.Products.SelectMany(x => x.Variations).SelectMany(x => x.Images));
var allOrigImages = originalObject.Products.SelectMany(x => x.Images);
allOrigImages = allOrigImages.Concat(originalObject.Categories.SelectMany(x => x.Images));
allOrigImages = allOrigImages.Concat(originalObject.Products.SelectMany(x => x.Variations).SelectMany(x => x.Images));
var allNewImages = allBackupImages.Where(x => !allOrigImages.Contains(x)).Where(x=>x.BinaryData != null);
var index = 0;
var progressTemplate = "{0} of " + allNewImages.Count() + " images uploading";
foreach (var image in allNewImages)
{
progressInfo.Description = String.Format(progressTemplate, index);
progressCallback(progressInfo);
using (var stream = new MemoryStream(image.BinaryData))
{
image.Url = _blobStorageProvider.Upload(new UploadStreamInfo { FileByteStream = stream, FileName = image.Name, FolderName = "catalog" });
}
index++;
}
}
progressInfo.Description = String.Format("{0} products importing...", backupObject.Products.Count());
progressCallback(progressInfo);
UpdateCatalogProducts(originalObject.Products, backupObject.Products);
}
示例5: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
var progressInfo = new ExportImportProgressInfo();
progressInfo.Description = String.Format("{0} RFQs importing", backupObject.QuoteRequests.Count());
progressCallback(progressInfo);
_quoteRequestService.SaveChanges(backupObject.QuoteRequests.ToArray());
}
示例6: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var prodgressInfo = new ExportImportProgressInfo { Description = "loading data..." };
progressCallback(prodgressInfo);
var backupObject = backupStream.DeserializeJson<BackupObject>();
var originalObject = GetBackupObject();
UpdateStores(originalObject.Stores, backupObject.Stores);
}
示例7: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
var originalObject = GetBackupObject(progressCallback);
var progressInfo = new ExportImportProgressInfo();
progressInfo.Description = String.Format("{0} stores importing...", backupObject.Stores.Count());
progressCallback(progressInfo);
UpdateStores(originalObject.Stores, backupObject.Stores);
}
示例8: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
var originalObject = GetBackupObject(progressCallback);
var progressInfo = new ExportImportProgressInfo();
progressInfo.Description = String.Format("{0} members importing...", backupObject.Members.Count());
progressCallback(progressInfo);
_memberService.CreateOrUpdate(backupObject.Members.OrderByDescending(x => x.MemberType).ToArray());
}
示例9: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
var originalObject = GetBackupObject(progressCallback);
var progressInfo = new ExportImportProgressInfo();
progressInfo.Description = String.Format("{0} organizations importing...", backupObject.Organizations.Count());
progressCallback(progressInfo);
UpdateOrganizations(originalObject.Organizations, backupObject.Organizations);
progressInfo.Description = String.Format("{0} contacts importing...", backupObject.Contacts.Count());
progressCallback(progressInfo);
UpdateContacts(originalObject.Contacts, backupObject.Contacts);
}
示例10: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
progressCallback(new ExportImportProgressInfo("importing fulfillmentCenters"));
if (backupObject.FulfillmentCenters != null)
{
backupObject.FulfillmentCenters.ForEach(x => _commerceService.UpsertFulfillmentCenter(x));
}
progressCallback(new ExportImportProgressInfo("imporing currencies"));
if (backupObject.Currencies != null)
{
_commerceService.UpsertCurrencies(backupObject.Currencies);
}
}
示例11: DoImport
public void DoImport(Stream backupStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
var originalObject = GetBackupObject(progressCallback, false);
var progressInfo = new ExportImportProgressInfo();
progressInfo.Description = String.Format("{0} menu link lists importing...", backupObject.MenuLinkLists.Count());
progressCallback(progressInfo);
UpdateMenuLinkLists(backupObject.MenuLinkLists);
if (manifest.HandleBinaryData)
{
progressInfo.Description = String.Format("importing binary data: themes and pages importing...");
progressCallback(progressInfo);
foreach (var folder in backupObject.ContentFolders)
{
SaveContentFolderRecursive(folder);
}
}
}
示例12: DoImport
public void DoImport(Stream backupStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = backupStream.DeserializeJson<BackupObject>();
var originalObject = GetBackupObject(progressCallback, manifest.HandleBinaryData);
var progressInfo = new ExportImportProgressInfo();
progressInfo.Description = String.Format("{0} menu link lists importing...", backupObject.MenuLinkLists.Count());
progressCallback(progressInfo);
UpdateMenuLinkLists(originalObject.MenuLinkLists, backupObject.MenuLinkLists);
if (manifest.HandleBinaryData)
{
progressInfo.Description = String.Format("importing binary data: {0} pages importing...", backupObject.Pages.Count());
progressCallback(progressInfo);
UpdatePages(originalObject.Pages, backupObject.Pages);
progressInfo.Description = String.Format("importing binary data: {0} theme assets importing...", backupObject.ThemeAssets.Count());
progressCallback(progressInfo);
UpdateThemeAssets(originalObject.ThemeAssets, backupObject.ThemeAssets);
}
}
示例13: DoImport
public void DoImport(Stream backupStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var progressInfo = new ExportImportProgressInfo();
var backupObject = backupStream.DeserializeJson<BackupObject>();
foreach(var category in backupObject.Categories)
{
category.Catalog = backupObject.Catalogs.FirstOrDefault(x => x.Id == category.CatalogId);
if(category.Parents != null)
{
category.Level = category.Parents.Count();
}
}
var originalObject = GetBackupObject(progressCallback, false);
progressInfo.Description = String.Format("{0} catalogs importing...", backupObject.Catalogs.Count());
progressCallback(progressInfo);
UpdateCatalogs(originalObject.Catalogs, backupObject.Catalogs);
progressInfo.Description = String.Format("{0} categories importing...", backupObject.Categories.Count());
progressCallback(progressInfo);
backupObject.Products = backupObject.Products.OrderBy(x => x.MainProductId).ToList();
UpdateCategories(originalObject.Categories, backupObject.Categories);
UpdateProperties(originalObject.Properties, backupObject.Properties);
//Binary data
if (manifest.HandleBinaryData)
{
var allBackupImages = backupObject.Products.SelectMany(x => x.Images);
allBackupImages = allBackupImages.Concat(backupObject.Categories.SelectMany(x => x.Images));
allBackupImages = allBackupImages.Concat(backupObject.Products.SelectMany(x => x.Variations).SelectMany(x => x.Images));
var allOrigImages = originalObject.Products.SelectMany(x => x.Images);
allOrigImages = allOrigImages.Concat(originalObject.Categories.SelectMany(x => x.Images));
allOrigImages = allOrigImages.Concat(originalObject.Products.SelectMany(x => x.Variations).SelectMany(x => x.Images));
//Import only new images
var allNewImages = allBackupImages.Where(x => !allOrigImages.Contains(x));
var index = 0;
var progressTemplate = "{0} of " + allNewImages.Count() + " images uploading";
foreach (var image in allNewImages)
{
progressInfo.Description = String.Format(progressTemplate, index);
progressCallback(progressInfo);
try
{
//do not save images with external url
if (image.Url != null && !image.Url.IsAbsoluteUrl())
{
using (var sourceStream = new MemoryStream(image.BinaryData))
using (var targetStream = _blobStorageProvider.OpenWrite(image.Url))
{
sourceStream.CopyTo(targetStream);
}
}
}
catch (Exception ex)
{
progressInfo.Errors.Add(String.Format("{0}: {1}", "CatalogModule", ex.ExpandExceptionMessage()));
progressCallback(progressInfo);
}
index++;
}
}
progressInfo.Description = String.Format("{0} products importing...", backupObject.Products.Count());
progressCallback(progressInfo);
UpdateCatalogProducts(originalObject.Products, backupObject.Products);
}
示例14: DoImport
public void DoImport(Stream backupStream, Action<ExportImportProgressInfo> progressCallback)
{
var prodgressInfo = new ExportImportProgressInfo { Description = "loading data..." };
progressCallback(prodgressInfo);
var backupObject = backupStream.DeserializeJson<BackupObject>();
var originalObject = GetBackupObject(progressCallback);
UpdateCatalogs(originalObject.Catalogs, backupObject.Catalogs);
//Categories should be sorted right way (because it have a hierarchy structure and links to virtual categories)
backupObject.Categories = backupObject.Categories.Where(x => x.Links == null || !x.Links.Any())
.OrderBy(x => x.Parents != null ? x.Parents.Count() : 0)
.Concat(backupObject.Categories.Where(x => x.Links != null && x.Links.Any()))
.ToList();
UpdateCategories(originalObject.Categories, backupObject.Categories);
UpdateProperties(originalObject.Properties, backupObject.Properties);
UpdateCatalogProducts(originalObject.Products, backupObject.Products);
}