void ConfigureCatalogSystem(PipelineInfo pipeInfo) { if (!catContextCreated) { CatalogSiteAgent siteAgent = new CatalogSiteAgent(); siteAgent.SiteName = SiteName; //Create the catalog cache options CacheConfiguration catCacheConfiguration = new CacheConfiguration(); catCacheConfiguration.SchemaCacheTimeout = catCacheConfiguration.ItemInformationCacheTimeout = catCacheConfiguration.ItemHierarchyCacheTimeout = catCacheConfiguration.ItemRelationshipsCacheTimeout = catCacheConfiguration.ItemAssociationsCacheTimeout = catCacheConfiguration.CatalogCollectionCacheTimeout = TimeSpan.FromMinutes(5); //Now create the CatalogContext with the cache configurations specified to setup the caching catContext = CommerceServer.Core.Catalog.CatalogContext.Create(siteAgent, catCacheConfiguration); catContextCreated = true; } pipeInfo["CatalogContext"] = catContext; }
public void ImportXML(CommerceServer.Core.Catalog.CatalogImportOptions options, System.IO.Stream xmlStream) { CatalogSiteAgent catalogSiteAgent = new CatalogSiteAgent(); catalogSiteAgent.SiteName = Configuration.CSSiteName; CatalogContext context = CatalogContext.Create(catalogSiteAgent); ImportProgress importProgress = context.ImportXml(options, xmlStream); try { while (importProgress.Status == CatalogOperationsStatus.InProgress) { System.Threading.Thread.Sleep(3000); importProgress.Refresh(); } } catch (Exception ex) { StringBuilder errors = new StringBuilder(); errors.AppendLine("CatalogInternalRepositoryImpl_ImportXML:"); if (importProgress != null && importProgress.Errors != null && importProgress.Errors.Count > 0) { foreach (CatalogError e in importProgress.Errors) { errors.AppendLine(String.Format("Line: {0} - Message: {1}", e.LineNumber, e.Message)); } } Exception newException = new Exception(errors.ToString(), ex); throw newException; } }