예제 #1
0
        protected override void Process()
        {
            _monitoring.Notify(Name, 0);

            log.InfoFormat("Start processing Product Price Update");

            var vendorIDsToProcess = VendorSettingsHelper.GetVendorIDsToExportToWehkamp(log);

            foreach (var vendorID in vendorIDsToProcess)
            {
                _monitoring.Notify(Name, vendorID);
                log.InfoFormat("Start processing Product Price Update for VendorID {0}", vendorID);

                var runDateTime = DateTime.Now;

                //Get all price updates that we need to export to Wehkamp
                var products = GetProductsWithChangedPricesData(vendorID);
                if (products == null || products.Count == 0)
                {
                    log.InfoFormat("There are no price updates for VendorID {0}", vendorID);
                    //Update last processed datetime for vendor
                    VendorSettingsHelper.SetLastPriceExportDateTime(vendorID, runDateTime);
                    continue;
                }

                log.InfoFormat("Processing {0} Product Price Updates records for VendorID {1}", products.Count, vendorID);

                //Add all products to the artikelInformatie file
                var priceChange = new prijsAanpassing {
                    aanpassing = new List <prijsAanpassingAanpassing>()
                };

                foreach (var product in products)
                {
                    priceChange.aanpassing.Add(CreateNewPrijsAanpassingItem(product));
                }

                //Save data to disk
                SavePriceChanges(vendorID, priceChange);

                //Process products which needs a price update file
                ProcessResendProductInformationToWehkampProducts(products);

                //Update last processed datetime for vendor
                VendorSettingsHelper.SetLastPriceExportDateTime(vendorID, runDateTime);

                log.InfoFormat("Finished processing Product Price Update for VendorID {0}", vendorID);
            } //end foreach (var vendorID in vendorIDsToProcess)

            log.InfoFormat("Finished processing Product Price Update");
            _monitoring.Notify(Name, 1);
        }