示例#1
0
        public void ProcessPriceUpdates(string productCode)
        {
            // get the necessary dependencies
            IWebPageEngine       pageEngine      = EngineLocator.CreateEngine <IWebPageEngine>();
            IProductParserEngine priceEngine     = EngineLocator.CreateEngine <IProductParserEngine>();
            IProductAccessor     productAccessor = AccessorLocator.CreateAccessor <IProductAccessor>();
            IEmailAccessor       emailAccessor   = AccessorLocator.CreateAccessor <IEmailAccessor>();

            // build the url
            string url = pageEngine.BuildUrl(productCode);
            // get the page contents
            string contents = pageEngine.GetWebPageContents(url);
            // get the stored product information
            var product = productAccessor.FindByCode(productCode);
            // get the current price
            decimal currentPrice = priceEngine.GetProductPrice(contents, productCode);

            // if the current price is different from the price threshold then send an email
            if (currentPrice > 0)
            {
                if (product.PriceThreshold != currentPrice)
                {
                    emailAccessor.SendPriceNotice(product, currentPrice);
                }
            }
        }
示例#2
0
        public void ProcessPriceUpdates(string productCode)
        {
            // build the url
            string url = _pageEngine.BuildUrl(productCode);
            // get the page contents
            string contents = _pageEngine.GetWebPageContents(url);
            // get the stored product information
            var product = _productAccessor.FindByCode(productCode);
            // get the current price
            decimal currentPrice = _priceEngine.GetProductPrice(contents, productCode);

            // if the current price is different from the price threshold then send an email
            if (currentPrice > 0)
            {
                if (product.PriceThreshold != currentPrice)
                {
                    _emailAccessor.SendPriceNotice(product, currentPrice);
                }
            }
        }