public ActionResult Configure()
        {
            var model = new YandexMarketParserModel();

            model.AvailableCategories = GetCategoriesForDDL();

            return(View("Nop.Plugin.Misc.YandexMarketParser.Views.YandexMarketParser.Configure", model));
        }
        public ActionResult Add(YandexMarketParserModel model)
        {
            var newItem = new YandexMarketCategoryRecord()
            {
                Name = model.AddCategoryName
            };

            _yandexMarketCategoryService.Insert(newItem);

            return(Json(new { Result = true }));
        }
        public ActionResult Add(YandexMarketParserModel model)
        {
            var newItem = new YandexMarketCategoryRecord()
            {
                Name           = model.AddParserCategoryName,
                Url            = model.AddParserCategoryUrl,
                ShopCategoryId = model.AddShopCategoryId,
                IsActive       = model.AddIsActive,
            };

            this._yandexMarketCategoryService.Insert(newItem);

            return(Json(new { Result = true }));
        }
Beispiel #4
0
        //[AdminAuthorize]
        //[ChildActionOnly]
        public ActionResult Configure()
        {
            var model = new YandexMarketParserModel();

            model.AvailableParserCategories = _yandexMarketCategoryService.GetCategoriesForDDL();
            model.AvailableShopCategories   =
                _shopCategoryService.GetAllCategories()
                .Select(x => new SelectListItem()
            {
                Selected = false, Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            return(View(model));
        }
        public ActionResult Configure(YandexMarketParserModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            if (model.IsTest)
            {
                model.ProductList = CreateTestProductList(model.CategoryId);
                _yandexMarketProductService.InsertList(model.ProductList);
            }
            else
            {
                var categoryName = _yandexMarketCategoryService.GetById(model.CategoryId).Name;
                var parser       = new Parser(categoryName, model.ParseNotMoreThen);
                model.ProductList = parser.Parse();
            }

            return(View("Nop.Plugin.Misc.YandexMarketParser.Views.YandexMarketParser.Configure", model));
        }
Beispiel #6
0
        public ActionResult Parse(YandexMarketParserModel model)
        {
            mIsStopProducsImport = false;

            _logger.Debug("--- ALL PARSE START...");

            int foundNewProductsTotal  = 0;
            var activeParserCategories = _yandexMarketCategoryService.GetActive();

            foreach (var currentCategory in activeParserCategories)
            {
                CheckStopAction();

                _logger.Debug("---  PARSE START FOR CATEGORY " + currentCategory.Name + "...");

                if (!this.ModelState.IsValid)
                {
                    throw new Exception("ModelState.IsNOTValid");
                }

                if (model.IsClearCategoryProductsBeforeParsing)
                {
                    _logger.Debug("Deleting old products...");
                    _yandexMarketProductService.DeleteByCategory(currentCategory.Id);
                }


                var categoryName   = currentCategory.Name;
                var parser         = BaseParser.Create(categoryName, currentCategory.Id, model.ParseNotMoreThen, currentCategory.Url, _logger, _yandexMarketProductService);
                var newProductList = parser.Parse(ref mIsStopProducsImport);

                foundNewProductsTotal += newProductList.Count;
                _logger.Debug("+++ PARSE CATEGORY " + currentCategory.Name + " DONE. Found new products: " + newProductList.Count);
            }            // end for

            _logger.Debug("Found new products total: " + foundNewProductsTotal);
            _logger.Debug("+++ ALL PARSING DONE.");
            return(Json(new { Result = true }));
        }