本文整理汇总了C#中VirtoCommerce.Platform.Core.ExportImport.PlatformExportManifest类的典型用法代码示例。如果您正苦于以下问题:C# PlatformExportManifest类的具体用法?C# PlatformExportManifest怎么用?C# PlatformExportManifest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlatformExportManifest类属于VirtoCommerce.Platform.Core.ExportImport命名空间,在下文中一共展示了PlatformExportManifest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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();
}
}
}
示例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);
}
}
}
}
}
示例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());
}
}
}
示例9: DoExport
public void DoExport(Stream backupStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var backupObject = GetBackupObject(progressCallback, manifest.HandleBinaryData);
backupObject.SerializeJson(backupStream);
}
示例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);
}
}
示例11: DoImport
public void DoImport(Stream inputStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
//Nothing todo
//Is needed only for settings import
}
示例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;
}
示例13: DoExport
public void DoExport(Stream outStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var job = _container.Resolve<QuoteExportImport>();
job.DoExport(outStream, progressCallback);
}
示例14: DoImport
public void DoImport(Stream inputStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var exportJob = _container.Resolve<CatalogExportImport>();
exportJob.DoImport(inputStream, manifest, progressCallback);
}
示例15: DoExport
public void DoExport(System.IO.Stream outStream, PlatformExportManifest manifest, Action<ExportImportProgressInfo> progressCallback)
{
var exportJob = _container.Resolve<PricingExportImport>();
exportJob.DoExport(outStream, progressCallback);
}