protected override void Process() { try { foreach (Connector connector in base.Connectors.Where(x => x.ObsoleteProducts)) { if (connector.ObsoleteProducts) { log.DebugFormat("Start Process O items import for {0}", connector.Name); DateTime start = DateTime.Now; log.InfoFormat("Start process stock:{0}", start); AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); XDocument products = new XDocument(soap.GetOAssortment(connector.ConnectorID, false, "227782")); Processor process = new Processor(products, log, connector); process.ImportOItems(products, null); process.ImportStock();; } } } catch (Exception ex) { log.Error("Error import obsolete items", ex); } }
protected override void Process() { foreach (Connector connector in base.Connectors.Where(c => ((ConnectorType)c.ConnectorType).Has(ConnectorType.ShopAssortment) && c.ObsoleteProducts)) { log.DebugFormat("Start Process shop O import for {0}", connector.Name); DateTime start = DateTime.Now; try { using (AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient()) { var input = soap.GetOAssortment(connector.ConnectorID, true, null); if (input != null) { XDocument o_Products = XDocument.Parse(input); if (o_Products != null) { ImportOItems(o_Products, connector); //ImportOBarcodes(o_Products); } else { log.Info("Get O Assortment failed"); } } else { log.Info("Empty O product Feed"); } } } catch (Exception ex) { log.Fatal(ex); } log.DebugFormat("Finish Process shop O import for {0}", connector.Name); } }
protected override void Process() { using (var unit = GetUnitOfWork()) { var repoOrderResponses = unit.Scope.Repository <OrderResponseLine>(); var orderLedgerRepo = unit.Scope.Repository <OrderLedger>(); foreach (Connector connector in base.Connectors.Where(c => ((ConnectorType)c.ConnectorType).Has(ConnectorType.ShopAssortment))) { log.DebugFormat("Start Process shop Third Party import for {0}", connector.Name); DateTime start = DateTime.Now; try { using (AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient()) { var products = repoOrderResponses.GetAll(o => o.OrderLineID.HasValue && o.OrderLine.OrderLedgers.Max(x => x.Status) == (int)OrderLineStatus.PushProduct).Distinct().ToList(); foreach (var product in products) { try { if (product.OrderLine.DispatchedToVendorID.HasValue) { var vendorAss = product.OrderLine.Product.VendorAssortments.Where(x => x.VendorID == product.OrderLine.DispatchedToVendorID.Value || (x.Vendor.ParentVendorID.HasValue && x.Vendor.ParentVendorID.Value == product.OrderLine.DispatchedToVendorID.Value)).FirstOrDefault(); decimal unitcost = 0; if (vendorAss.VendorPrices.FirstOrDefault().CostPrice.HasValue) { unitcost = vendorAss.VendorPrices.FirstOrDefault().CostPrice.Value; } else if (vendorAss.VendorPrices.FirstOrDefault().Price.HasValue) { unitcost = vendorAss.VendorPrices.FirstOrDefault().Price.Value; } var input = soap.GetOAssortment(connector.ConnectorID, false, product.VendorItemNumber.Trim()); if (input != null) { XDocument o_Products = XDocument.Parse(input); if (o_Products != null && o_Products.Root.Elements("Product").Count() > 0) { ImportOItems(o_Products, connector, (decimal)(product.OrderLine.Price.HasValue ? (decimal)product.OrderLine.Price.Value : product.Price), unitcost); product.OrderLine.SetStatus(OrderLineStatus.ReadyToOrder, orderLedgerRepo); unit.Save(); } else { log.Info("Get Third Party product failed"); } } else { log.Info("Empty Third Party product Feed"); } } } catch (Exception ex) { log.Error(string.Format("Failed to insert product {0} to shop", product.VendorItemNumber.Trim()), ex); } } } } catch (Exception ex) { log.Fatal(ex); } log.DebugFormat("Finish Process shop Third Party product import for {0}", connector.Name); } } }
protected override void Process() { foreach (Connector connector in Connectors.Where(x => ((ConnectorType)x.ConnectorType).Has(ConnectorType.WebAssortment))) { log.DebugFormat("Start process push product for {0}", connector.Name); using (var unit = GetUnitOfWork()) { try { var _pushRepo = unit.Scope.Repository <Concentrator.Objects.Models.Products.PushProduct>(); DateTime start = DateTime.Now; log.DebugFormat("Start process products:{0}", start); AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); XDocument products = null; var pushProducts = _pushRepo.GetAll(x => !x.Processed && x.ConnectorID == connector.ConnectorID).ToList(); foreach (var product in pushProducts) { if (product.ProductID.HasValue) { products = new XDocument(soap.GetAssortment(connector.ConnectorID, product.ProductID.Value.ToString(), false)); } else { products = new XDocument(soap.GetOAssortment(connector.ConnectorID, false, product.CustomItemNumber)); } Processor process = new Processor(products, log, connector); process.ImportOItems(products, product.CustomItemNumber); product.Processed = true; unit.Save(); } } catch (Exception ex) { log.Error("Error push product", ex); } } log.DebugFormat("Finish push product import for {0}", connector.Name); } foreach (Connector connector in Connectors.Where(x => ((ConnectorType)x.ConnectorType).Has(ConnectorType.ShopAssortment))) { log.DebugFormat("Start process push product for {0}", connector.Name); using (var unit = GetUnitOfWork()) { try { var _pushRepo = unit.Scope.Repository <Concentrator.Objects.Models.Products.PushProduct>(); DateTime start = DateTime.Now; log.DebugFormat("Start process products:{0}", start); AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); XDocument products = null; var pushProducts = _pushRepo.GetAll(x => !x.Processed && x.ConnectorID == connector.ConnectorID).ToList(); foreach (var product in pushProducts) { // if (product.ProductID.HasValue) // products = new XDocument(soap.GetAssortment(connector.ConnectorID, product.ProductID.Value.ToString(), false)); //else // products = new XDocument(soap.GetOAssortment(connector.ConnectorID, false, product.CustomItemNumber)); ShopImportOProduct processor = new ShopImportOProduct(); processor.ImportOItems(products, connector); //Processor process = new Processor(products, log, connector); //process.ImportOItems(products, product.CustomItemNumber); product.Processed = true; unit.Save(); } } catch (Exception ex) { log.Error("Error push product", ex); } } log.DebugFormat("Finish push product import for {0}", connector.Name); } }