当前位置: 首页>>代码示例>>C#>>正文


C# Stream.DeserializeJson方法代码示例

本文整理汇总了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);

        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:28,代码来源:MarketingExportImport.cs

示例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"));
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:7,代码来源:InventoryExportImport.cs

示例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"));
		}
开发者ID:adwardliu,项目名称:vc-community,代码行数:7,代码来源:CoreExportImport.cs

示例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);
		}
开发者ID:nisarzahid,项目名称:vc-community,代码行数:58,代码来源:CatalogExportImport.cs

示例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());
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:9,代码来源:QuoteExportImport.cs

示例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);
        }
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:10,代码来源:StoreExportImport.cs

示例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);
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:11,代码来源:StoreExportImport.cs

示例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());

        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:11,代码来源:CustomerExportImport.cs

示例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);
        }
开发者ID:afandylamusu,项目名称:vc-community,代码行数:14,代码来源:CustomerExportImport.cs

示例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);
            }

        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:15,代码来源:CoreExportImport.cs

示例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);
                }
            }
        }
开发者ID:shenge321,项目名称:vc-community,代码行数:20,代码来源:ContentExportImport.cs

示例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);
			}
		}
开发者ID:nisarzahid,项目名称:vc-community,代码行数:23,代码来源:ContentExportImport.cs

示例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);
        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:71,代码来源:CatalogExportImport.cs

示例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);


		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:21,代码来源:CatalogExportImport.cs


注:本文中的Stream.DeserializeJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。