protected override void Process() { foreach (Connector connector in Connectors.Where(x => ((ConnectorType)x.ConnectorType).Has(ConnectorType.WebAssortment) && x.Selectors)) { #if DEBUG if (connector.ConnectorID != 1) { continue; } #endif using ( WebsiteDataContext context = new WebsiteDataContext( ConfigurationManager.ConnectionStrings[connector.Connection].ConnectionString)) { log.DebugFormat("Start Selector Product import for {0}", connector.Name); try { DateTime start = DateTime.Now; log.DebugFormat("Start Selector Product:{0}", start); AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); XDocument products; var selectorIDs = (from s in context.Selectors select s.SelectorID).ToList(); foreach (int selectorID in selectorIDs) { products = new XDocument(soap.GetSelectorProducts(connector.ConnectorID, selectorID)); Processor processor = new Processor(products, log, connector); log.Debug("Start import brands"); processor.ImportBrands(); log.Debug("Finished import brands"); log.Debug("Start import productgroups"); processor.ImportProductGroups(false); log.Debug("Finished import productgroups"); log.Debug("Start import Products"); processor.ImportSelectorProducts(); log.Debug("Finished import Products"); //log.Debug("Start import Attributes"); //processor.ProcessAttributes(soap, connector, false, null, false); //log.Debug("Finished import Attributes"); //processor.CleanUpProducts(); //processor.CleanUpProductGroupMapping(); } } catch (Exception ex) { log.Error("Error import Selector Products", ex); } log.DebugFormat("Finish Process Selector Product for {0}", connector.Name); } } }
protected override void Process() { log.Info("Selector import cycle started..."); try { foreach (Connector connector in base.Connectors.Where(c => ((ConnectorType)c.ConnectorType).Has(ConnectorType.WebAssortment) && c.Selectors)) { DateTime start = DateTime.Now; AssortmentServiceSoapClient contentClient = new AssortmentServiceSoapClient(); SelectorServiceSoapClient serviceClient = new SelectorServiceSoapClient(); using ( WebsiteDataContext context = new WebsiteDataContext( ConfigurationManager.ConnectionStrings[connector.Connection].ConnectionString)) { log.InfoFormat("Start selector import for connector {0}", connector.Name); var selectorIDs = (from s in context.Selectors select s.SelectorID).ToList(); foreach (int selectorID in selectorIDs) { var products = XDocument.Parse(contentClient.GetSelectorProducts(connector.ConnectorID, selectorID)); Processor processor = new Processor(products, log, connector); log.Debug("Start import brands"); processor.ImportBrands(); log.Debug("Finished import brands"); log.Debug("Start import productgroups"); processor.ImportProductGroups(false); log.Debug("Finished import productgroups"); log.Debug("Start import Products"); processor.ImportSelectorProducts(); log.Debug("Finished import Products"); log.Debug("Start import Attributes"); processor.processSelectorAttributes(connector); log.Debug("Finished import Attributes"); log.Debug("Start import images"); ProcessProductImages(connector, products); log.Debug("Finish import images"); //processor.CleanUpProducts(); // } try { log.InfoFormat("Starting import of related products"); ImportRelatedProducts(context, serviceClient, contentClient, connector); log.InfoFormat("Finished import of related products"); } catch (Exception e) { log.Error("Importing of related products for connector " + connector.Name + "failed ", e); } try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress, TimeSpan.FromMinutes(5))) { context.SubmitChanges(); scope.Complete(); } log.AuditSuccess("Finished selector export for connector " + connector.Name, "Selector export"); } catch (Exception e) { log.AuditFatal("There was an error inserting the selectors", e); } } } } catch (Exception e) { log.Fatal("Selector import cycle failed", e); } }