本文整理汇总了C#中VirtoCommerce.Platform.Core.ExportImport.PlatformExportManifest类的典型用法代码示例。如果您正苦于以下问题:C# PlatformExportManifest类的具体用法?C# PlatformExportManifest怎么用?C# PlatformExportManifest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlatformExportManifest类属于VirtoCommerce.Platform.Core.ExportImport命名空间,在下文中一共展示了PlatformExportManifest类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
示例2: GetNewExportManifest
public PlatformExportManifest GetNewExportManifest()
{
var retVal = new PlatformExportManifest
{
Author = CurrentPrincipal.GetCurrentUserName(),
PlatformVersion = PlatformVersion.CurrentVersion.ToString(),
Modules = InnerGetModulesWithInterface(typeof(ISupportExportImportModule)).Select(x => new ExportModuleInfo
{
Id = x.Id,
Dependencies = x.Dependencies != null ? x.Dependencies.ToArray() : null,
Version = x.Version,
Description = ((ISupportExportImportModule)x.ModuleInfo.ModuleInstance).ExportDescription
}).ToArray()
};
return retVal;
}
开发者ID:alexsandrocruz,项目名称:vc-community,代码行数:17,代码来源:PlatformExportImportManager.cs
示例3: 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
示例4: 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
示例5: Export
public void Export(Stream outStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
if (manifest == null)
{
throw new ArgumentNullException("manifest");
}
using (var package = ZipPackage.Open(outStream, FileMode.Create))
{
//Export all selected platform entries
ExportPlatformEntriesInternal(package, manifest, progressCallback);
//Export all selected modules
ExportModulesInternal(package, manifest, progressCallback);
//Write system information about exported modules
var manifestPart = package.CreatePart(_manifestPartUri, "application/javascript");
//After all modules exported need write export manifest part
using (var stream = manifestPart.GetStream())
{
manifest.SerializeJson<PlatformExportManifest>(stream);
}
}
}
开发者ID:alexsandrocruz,项目名称:vc-community,代码行数:24,代码来源:PlatformExportImportManager.cs
示例6: ExportModulesInternal
private void ExportModulesInternal(Package package, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var progressInfo = new ExportImportProgressInfo();
foreach (var module in manifest.Modules)
{
var moduleDescriptor = InnerGetModulesWithInterface(typeof(ISupportExportImportModule)).FirstOrDefault(x => x.Id == module.Id);
if (moduleDescriptor != null)
{
//Create part for module
var modulePartUri = PackUriHelper.CreatePartUri(new Uri(module.Id + ".json", UriKind.Relative));
var modulePart = package.CreatePart(modulePartUri, System.Net.Mime.MediaTypeNames.Application.Octet, CompressionOption.Normal);
Action<ExportImportProgressInfo> modulePorgressCallback = (x) =>
{
progressInfo.Description = String.Format("{0}: {1}", module.Id, x.Description);
progressCallback(progressInfo);
};
progressInfo.Description = String.Format("{0}: exporting...", module.Id);
progressCallback(progressInfo);
try
{
((ISupportExportImportModule)moduleDescriptor.ModuleInfo.ModuleInstance).DoExport(modulePart.GetStream(), manifest, modulePorgressCallback);
}
catch (Exception ex)
{
progressInfo.Errors.Add(ex.ExpandExceptionMessage());
progressCallback(progressInfo);
}
module.PartUri = modulePartUri.ToString();
}
}
}
开发者ID:alexsandrocruz,项目名称:vc-community,代码行数:37,代码来源:PlatformExportImportManager.cs
示例7: ImportModulesInternal
private void ImportModulesInternal(Package package, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var progressInfo = new ExportImportProgressInfo();
foreach (var moduleInfo in manifest.Modules)
{
var moduleDescriptor = InnerGetModulesWithInterface(typeof(ISupportExportImportModule)).FirstOrDefault(x => x.Id == moduleInfo.Id);
if (moduleDescriptor != null)
{
var modulePart = package.GetPart(new Uri(moduleInfo.PartUri, UriKind.Relative));
using (var modulePartStream = modulePart.GetStream())
{
Action<ExportImportProgressInfo> modulePorgressCallback = (x) =>
{
progressInfo.Description = String.Format("{0}: {1}", moduleInfo.Id, x.Description);
progressCallback(progressInfo);
};
try
{
((ISupportExportImportModule)moduleDescriptor.ModuleInfo.ModuleInstance).DoImport(modulePartStream, manifest, modulePorgressCallback);
}
catch (Exception ex)
{
progressInfo.Errors.Add(ex.ExpandExceptionMessage());
progressCallback(progressInfo);
}
}
}
}
}
开发者ID:alexsandrocruz,项目名称:vc-community,代码行数:29,代码来源:PlatformExportImportManager.cs
示例8: Export
public void Export(Stream outStream, PlatformExportImportOptions exportOptions, Action<ExportImportProgressInfo> progressCallback)
{
if (exportOptions == null)
{
throw new ArgumentNullException("exportOptions");
}
var progressInfo = new ExportImportProgressInfo
{
Description = "Start platform export...",
TotalCount = exportOptions.Modules.Count(),
ProcessedCount = 0
};
progressCallback(progressInfo);
using (var package = ZipPackage.Open(outStream, FileMode.Create))
{
var exportModulesInfo = new List<ExportModuleInfo>();
foreach (var module in exportOptions.Modules)
{
//Create part for module
var modulePartUri = PackUriHelper.CreatePartUri(new Uri(module.Id, UriKind.Relative));
var modulePart = package.CreatePart(modulePartUri, System.Net.Mime.MediaTypeNames.Application.Octet, CompressionOption.Normal);
progressInfo.Description = String.Format("{0}: export started.", module.Id);
progressCallback(progressInfo);
Action<ExportImportProgressInfo> modulePorgressCallback = (x) =>
{
progressInfo.Description = String.Format("{0}: {1}", module.Id, x.Description);
progressCallback(progressInfo);
};
((ISupportExportModule)module.ModuleInfo.ModuleInstance).DoExport(modulePart.GetStream(), modulePorgressCallback);
//Register in manifest
var moduleManifestPart = new ExportModuleInfo
{
ModuleId = module.Id,
ModuleVersion = module.Version,
PartUri = modulePartUri.ToString()
};
exportModulesInfo.Add(moduleManifestPart);
progressInfo.Description = String.Format("{0}: export finished.", module.Id);
progressInfo.ProcessedCount++;
progressCallback(progressInfo);
}
//Write system information about exported modules
var manifestPart = package.CreatePart(_manifestPartUri, System.Net.Mime.MediaTypeNames.Text.Xml);
var manifest = new PlatformExportManifest
{
Author = exportOptions.Author,
Created = DateTime.UtcNow,
PlatformVersion = exportOptions.PlatformVersion.ToString(),
Modules = exportModulesInfo.ToArray(),
};
//After all modules exported need write export manifest part
using (var streamWriter = new StreamWriter(manifestPart.GetStream()))
{
streamWriter.Write(manifest.SerializeXML());
}
}
}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:64,代码来源:PlatformExportImportManager.cs
示例9: DoExport
public void DoExport(Stream backupStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = GetBackupObject(progressCallback, manifest.HandleBinaryData);
backupObject.SerializeJson(backupStream);
}
开发者ID:nisarzahid,项目名称:vc-community,代码行数:6,代码来源:ContentExportImport.cs
示例10: Import
public void Import(Stream stream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
if (manifest == null)
{
throw new ArgumentNullException("manifest");
}
var progressInfo = new ExportImportProgressInfo();
progressInfo.Description = "Starting platform import...";
progressCallback(progressInfo);
using (var package = ZipPackage.Open(stream, FileMode.Open))
{
//Import selected platform entries
ImportPlatformEntriesInternal(package, manifest, progressCallback);
//Import selected modules
ImportModulesInternal(package, manifest, progressCallback);
}
}
开发者ID:alexsandrocruz,项目名称:vc-community,代码行数:20,代码来源:PlatformExportImportManager.cs
示例11: DoImport
public void DoImport(Stream inputStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
//Nothing todo
//Is needed only for settings import
}
开发者ID:nisarzahid,项目名称:vc-community,代码行数:5,代码来源:Module.cs
示例12: GetNewExportManifest
public PlatformExportManifest GetNewExportManifest(string author)
{
var retVal = new PlatformExportManifest
{
Author = author,
PlatformVersion = PlatformVersion.CurrentVersion.ToString(),
Modules = InnerGetModulesWithInterface(typeof(ISupportExportImportModule)).Select(x => new ExportModuleInfo
{
Id = x.Id,
Version = x.Version.ToString(),
Description = ((ISupportExportImportModule)x.ModuleInstance).ExportDescription
}).ToArray()
};
return retVal;
}
开发者ID:lorenzonet,项目名称:vc-community,代码行数:16,代码来源:PlatformExportImportManager.cs
示例13: DoExport
public void DoExport(Stream outStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var job = _container.Resolve<QuoteExportImport>();
job.DoExport(outStream, progressCallback);
}
开发者ID:sameerkattel,项目名称:vc-community,代码行数:5,代码来源:Module.cs
示例14: DoImport
public void DoImport(Stream inputStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var exportJob = _container.Resolve<CatalogExportImport>();
exportJob.DoImport(inputStream, manifest, progressCallback);
}
开发者ID:adwardliu,项目名称:vc-community,代码行数:5,代码来源:Module.cs
示例15: DoExport
public void DoExport(System.IO.Stream outStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var exportJob = _container.Resolve<PricingExportImport>();
exportJob.DoExport(outStream, progressCallback);
}
开发者ID:alexsandrocruz,项目名称:vc-community,代码行数:5,代码来源:Module.cs
示例16: DoImport
public void DoImport(System.IO.Stream inputStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var job = _container.Resolve<CoreExportImport>();
job.DoImport(inputStream, progressCallback);
}
开发者ID:n1njab0b,项目名称:vc-community,代码行数:5,代码来源:Module.cs
示例17: ImportPlatformEntriesInternal
private void ImportPlatformEntriesInternal(Package package, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var progressInfo = new ExportImportProgressInfo();
var platformEntriesPart = package.GetPart(_platformEntriesPartUri);
if (platformEntriesPart != null)
{
PlatformExportEntries platformEntries;
using (var stream = platformEntriesPart.GetStream())
{
platformEntries = stream.DeserializeJson<PlatformExportEntries>();
}
//Import security objects
if (manifest.HandleSecurity)
{
progressInfo.Description = String.Format("Import {0} users with roles...", platformEntries.Users.Count());
progressCallback(progressInfo);
//First need import roles
foreach (var role in platformEntries.Roles)
{
_roleManagementService.AddOrUpdateRole(role);
}
//Next create or update users
foreach (var user in platformEntries.Users)
{
if (_securityService.FindByIdAsync(user.Id, UserDetails.Reduced).Result != null)
{
_securityService.UpdateAsync(user);
}
else
{
_securityService.CreateAsync(user);
}
}
}
//Import dynamic properties
_dynamicPropertyService.SaveProperties(platformEntries.DynamicProperties.ToArray());
foreach (var propDicGroup in platformEntries.DynamicPropertyDictionaryItems.GroupBy(x => x.PropertyId))
{
_dynamicPropertyService.SaveDictionaryItems(propDicGroup.Key, propDicGroup.ToArray());
}
//Import modules settings
if (manifest.HandleSettings)
{
foreach (var module in manifest.Modules)
{
_settingsManager.SaveSettings(platformEntries.Settings.Where(x => x.ModuleId == module.Id).ToArray());
}
}
}
}
开发者ID:alexsandrocruz,项目名称:vc-community,代码行数:55,代码来源:PlatformExportImportManager.cs
示例18: ExportPlatformEntriesInternal
private void ExportPlatformEntriesInternal(Package package, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var progressInfo = new ExportImportProgressInfo();
var platformExportObj = new PlatformExportEntries();
if (manifest.HandleSecurity)
{
//Roles
platformExportObj.Roles = _roleManagementService.SearchRoles(new RoleSearchRequest { SkipCount = 0, TakeCount = int.MaxValue }).Roles;
//users
var usersResult = _securityService.SearchUsersAsync(new UserSearchRequest { TakeCount = int.MaxValue }).Result;
progressInfo.Description = String.Format("Security: {0} users exporting...", usersResult.Users.Count());
progressCallback(progressInfo);
foreach (var user in usersResult.Users)
{
platformExportObj.Users.Add(_securityService.FindByIdAsync(user.Id, UserDetails.Export).Result);
}
}
//Export setting for selected modules
if (manifest.HandleSettings)
{
progressInfo.Description = String.Format("Settings: selected modules settings exporting...");
progressCallback(progressInfo);
platformExportObj.Settings = manifest.Modules.SelectMany(x => _settingsManager.GetModuleSettings(x.Id)).ToList();
}
//Dynamic properties
var allTypes = _dynamicPropertyService.GetAvailableObjectTypeNames();
progressInfo.Description = String.Format("Dynamic properties: load properties...");
progressCallback(progressInfo);
platformExportObj.DynamicProperties = allTypes.SelectMany(x => _dynamicPropertyService.GetProperties(x)).ToList();
platformExportObj.DynamicPropertyDictionaryItems = platformExportObj.DynamicProperties.Where(x => x.IsDictionary).SelectMany(x => _dynamicPropertyService.GetDictionaryItems(x.Id)).ToList();
//Create part for platform entries
var platformEntiriesPart = package.CreatePart(_platformEntriesPartUri, System.Net.Mime.MediaTypeNames.Application.Octet, CompressionOption.Normal);
using (var partStream = platformEntiriesPart.GetStream())
{
platformExportObj.SerializeJson<PlatformExportEntries>(partStream);
}
}
开发者ID:alexsandrocruz,项目名称:vc-community,代码行数:45,代码来源:PlatformExportImportManager.cs
示例19: 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
注:本文中的VirtoCommerce.Platform.Core.ExportImport.PlatformExportManifest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论