Пример #1
0
        /// <summary>
        /// Executes a task
        /// </summary>
        public void Execute()
        {
            var scheduleTaskService = EngineContext.Current.Resolve <IScheduleTaskService>();
            var name         = typeof(ParsePricesTask).FullName + ", Nop.Services";
            var scheduleTask = scheduleTaskService.GetTaskByType(name);
            var isNeed       = false;

            if (scheduleTask.LastSuccessUtc != null)
            {
                if (scheduleTask.LastSuccessUtc.Value.Date < DateTime.UtcNow.Date)
                {
                    isNeed = true;                     //daily update
                }
                else
                {
                    // int x = 0;
                    // Skip because today already was successfull update
                }
            }
            else
            {
                isNeed = true;                 // first time update
            }

            if (isNeed)
            {
                var log = EngineContext.Current.Resolve <ILogger>();
                log.Debug("Start ParsePricesTask...");
                _priceManagerService.ApplyPriceDownloadAll();
                _priceManagerService.ApplyImportAll();
                log.Debug("End ParsePricesTask.");
            }
        }
Пример #2
0
        public ActionResult ImportProductList()
        {
            mIsStopProducsImport = false;

            _logger.Debug("--- ImportProductList START...");

            var productsToImportTotalCount = _yandexMarketProductService.GetByCategory(categoryId: 0, isNotImportedOnly: true, isActiveOnly: true).TotalCount;
            var parserCategories           = _yandexMarketCategoryService.GetActive();

            _logger.Debug("--- Will be import categories: " + parserCategories.Count + ". Products: " + productsToImportTotalCount);


            var totalImportedCounter = 0;

            var allSpecAttrList = _specificationAttributeService.GetSpecificationAttributes();

            int currentCategoryIndex = 1;

            // цикл по активным категориям
            foreach (var currentParserCategory in parserCategories)
            {
                var records = _yandexMarketProductService.GetByCategory(currentParserCategory.Id, isNotImportedOnly: true);

                var categoryProductCounter = 1;

                _logger.Debug("--- Start Category (" + currentCategoryIndex + " from " + parserCategories.Count + ") " + currentParserCategory.Name + ". Will be imported products: " + records.TotalCount);
                foreach (var curYaProduct in records)
                {
                    CheckStopAction();

                    var isImported = ImportYaProduct(curYaProduct, currentParserCategory.ShopCategoryId, allSpecAttrList);


                    if (totalImportedCounter % 10 == 0)                     // через каждые 5 записей выводить в лог сообщение
                    {
                        _logger.Debug("... imported products in current category: " + categoryProductCounter + ", in general: " + totalImportedCounter + " from " + productsToImportTotalCount + "...");
                    }

                    if (isImported)
                    {
                        categoryProductCounter++;
                        totalImportedCounter++;
                    }
                }

                _logger.Debug("--- End Category imported " + currentParserCategory.Name + ". In general: " + totalImportedCounter + " from " + productsToImportTotalCount);

                currentCategoryIndex++;
            }

            _priceManagerService.ApplyImportAll();
            _logger.Debug("--- ImportProductList for End.");

            return(Content("Success"));
        }
Пример #3
0
        public ActionResult ApplyImportAll(OstatkiFileParserModel model)
        {
            if (model.IsForceDownloadingNewData)
            {
                _priceManagerService.ApplyPriceDownloadAll();
            }

            var msgResult = _priceManagerService.ApplyImportAll();

            return(Content(msgResult));
        }